{"record":{"id":"0f341afd442e3c74","repo":"tinyhumansai/openhuman","slug":"analytics-trackevent-failed","errorCode":null,"errorMessage":"[analytics] trackEvent failed","messagePattern":"\\[analytics\\] trackEvent failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/services/analytics.ts","lineNumber":400,"sourceCode":"      ...properties,\n    });\n  }\n  if (opInitialized) {\n    void sendOpenPanelTrack('screen_view', { ...properties, __title: currentDocumentTitle() });\n  }\n}\n\n/**\n * Send a privacy-limited feature-engagement event to all initialized providers.\n *\n * Event names must appear in `ALLOWED_EVENTS`. Calls with unlisted names\n * are dropped and a console warning is emitted.\n */\nexport function trackEvent(eventName: string, params?: AnalyticsParams): void {\n  try {\n    trackEventUnsafe(eventName, params);\n  } catch (error) {\n    console.warn('[analytics] trackEvent failed', {\n      eventName,\n      error: error instanceof Error ? error.name : typeof error,\n    });\n  }\n}\n\n/** Typed, best-effort facade for successful domain outcomes. */\nexport function trackAnalyticsEvent(eventName: AnalyticsEventName, params?: AnalyticsParams): void {\n  trackEvent(eventName, params);\n}\n\nfunction trackEventUnsafe(eventName: string, params?: AnalyticsParams): void {\n  if (!ALLOWED_EVENTS.has(eventName)) {\n    console.warn(\n      `[analytics] trackEvent dropped — '${eventName}' is not in ALLOWED_EVENTS allowlist`\n    );\n    return;\n  }","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/app/src/services/analytics.ts#L382-L418","documentation":"Safety net around trackEventUnsafe inside trackEvent: the public event API wraps its provider fan-out (GA dataLayer push, OpenPanel send) so that a throw from any provider — unlisted event name path, serialization issue, or gtag absence — cannot propagate into feature code. The catch warns with the event name and error; the event is dropped, not queued.","triggerScenarios":"Thrown at app/src/services/analytics.ts:400 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the logged eventName against ALLOWED_EVENTS — unlisted names are the usual cause","Fix the failing provider specifically (GA init vs OpenPanel) using the logged error","Keep the wrapper: analytics must never break feature flows"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}