Skip to content

Commit 7500fbe

Browse files
committed
Improves PostHog error tracking on sandbox page
Updates error tracking logic to use the imported `posthog` instance instead of relying on `window.posthog`. This ensures that the PostHog instance is correctly referenced, improving the reliability of error tracking on the sandbox page.
1 parent 5a9f5d5 commit 7500fbe

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/views/sandbox-view/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
import ProductIcon from '@components/product-icon'
3434
import { PRODUCT_DATA_MAP } from 'data/product-data-map'
3535
import { SidebarProps } from '@components/sidebar'
36+
import posthog from 'posthog-js'
3637

3738
interface SandboxPageProps {
3839
product: (typeof PRODUCT_DATA_MAP)[keyof typeof PRODUCT_DATA_MAP]
@@ -50,8 +51,8 @@ const trackSandboxPageError = (
5051
context?: Record<string, unknown>
5152
) => {
5253
// Track error in PostHog for production monitoring
53-
if (typeof window !== 'undefined' && window.posthog?.capture) {
54-
window.posthog.capture('sandbox_page_error', {
54+
if (typeof window !== 'undefined' && posthog?.capture) {
55+
posthog.capture('sandbox_page_error', {
5556
error_type: errorType,
5657
error_message: errorMessage,
5758
timestamp: new Date().toISOString(),

0 commit comments

Comments
 (0)