{"record":{"id":"5d902688146145dd","repo":"medusajs/medusa","slug":"error-tracking-event-for-data-event-error-me","errorCode":null,"errorMessage":"Error tracking event for ${data.event}: ${error.message}","messagePattern":"Error tracking event for (.+?): (.+?)","errorType":"exception","errorClass":"MedusaError","httpStatus":500,"severity":"error","filePath":"packages/modules/analytics/src/services/analytics-service.ts","lineNumber":33,"sourceCode":"  constructor({ analyticsProviderService }: InjectedDependencies) {\n    this.analyticsProviderService_ = analyticsProviderService\n  }\n\n  __hooks = {\n    onApplicationShutdown: async () => {\n      await this.analyticsProviderService_.shutdown()\n    },\n  }\n\n  getProvider() {\n    return this.analyticsProviderService_\n  }\n\n  async track(data: TrackAnalyticsEventDTO): Promise<void> {\n    try {\n      await this.analyticsProviderService_.track(data)\n    } catch (error) {\n      throw new MedusaError(\n        MedusaError.Types.UNEXPECTED_STATE,\n        `Error tracking event for ${data.event}: ${error.message}`\n      )\n    }\n  }\n\n  async identify(data: IdentifyAnalyticsEventDTO): Promise<void> {\n    try {\n      await this.analyticsProviderService_.identify(data)\n    } catch (error) {\n      throw new MedusaError(\n        MedusaError.Types.UNEXPECTED_STATE,\n        `Error identifying event for ${\n          \"group\" in data ? data.group.id : data.actor_id\n        }: ${error.message}`\n      )\n    }\n  }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/analytics/src/services/analytics-service.ts#L15-L51","documentation":"Thrown by the analytics module's track() when the configured analytics provider's track() call fails; the underlying provider error message is wrapped in a MedusaError of type UNEXPECTED_STATE. The module itself is a thin wrapper around a pluggable analytics provider, so this always indicates a provider-side failure (network, auth, payload).","triggerScenarios":"Any workflow/step or internal call invoking analyticsModuleService.track(...) while the analytics provider (e.g. a third-party tracking API) errors — invalid credentials, unreachable endpoint, malformed event payload, or rate limiting.","commonSituations":"Analytics provider API key rotated/expired and not updated in module options; network egress blocked from the server; provider schema change rejecting the event payload.","solutions":["Inspect the appended error.message to identify the provider failure (auth, network, payload)","Verify the analytics provider credentials/config passed to the AnalyticsModule in medusa-config","If the failure is transient (rate limit/network), retry or make tracking non-fatal in your workflow","Check that the event payload matches the provider's expected schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await analyticsService.track({ event: 'order_placed', ... })\n} catch (e) {\n  if (e.type === 'unexpected_state' && /^Error tracking event/.test(e.message)) {\n    logger.warn(`analytics track failed: ${e.message}`) // non-fatal\n    return\n  }\n  throw e\n}","preventionTips":["Treat analytics as non-fatal: wrap track calls so tracking outages don't break commerce flows","Monitor provider credential expiry and provider status pages","Validate event payloads against the provider schema in dev/test environments"],"tags":["analytics","provider","third-party","wrapper"],"backgroundTag":"provider-call-failed","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}