{"record":{"id":"ff62d047485d03f2","repo":"medusajs/medusa","slug":"actor-or-group-is-required-when-identifying-an-ent","errorCode":null,"errorMessage":"Actor or group is required when identifying an entity with Posthog","messagePattern":"Actor or group is required when identifying an entity with Posthog","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/modules/providers/analytics-posthog/src/services/posthog-analytics.ts","lineNumber":80,"sourceCode":"        : undefined,\n    })\n  }\n\n  async identify(data: ProviderIdentifyAnalyticsEventDTO): Promise<void> {\n    if (\"group\" in data) {\n      this.client_.groupIdentify({\n        groupKey: data.group.id!,\n        groupType: data.group.type!,\n        properties: data.properties,\n        distinctId: data.actor_id,\n      })\n    } else if (data.actor_id) {\n      this.client_.identify({\n        distinctId: data.actor_id,\n        properties: data.properties,\n      })\n    } else {\n      throw new Error(\n        \"Actor or group is required when identifying an entity with Posthog\"\n      )\n    }\n  }\n\n  async shutdown() {\n    await this.client_.shutdown()\n  }\n}\n","sourceCodeStart":62,"sourceCodeEnd":90,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/modules/providers/analytics-posthog/src/services/posthog-analytics.ts#L62-L90","documentation":"The Posthog provider's `identify` method must know what to identify: either a group (id+type) or an actor (distinct id). With neither present it throws because there is nothing to attach the properties to.","triggerScenarios":"Calling `identify({ properties: {...} })` with no group and no actor_id, typically when the payload is built conditionally and both branches were skipped.","commonSituations":"Calling identify for a system/background entity, or a DTO assembled from optional request context where both ids are undefined.","solutions":["Pass actor_id for user identification: `identify({ actor_id: userId, properties })`","For group identification pass a full group `{ id, type }`","Skip the identify call when neither id is available"],"exampleFix":"// before\nawait analytics.identify({ properties: { plan: 'pro' } })\n// after\nawait analytics.identify({ actor_id: userId, properties: { plan: 'pro' } })","handlingStrategy":"validation","validationCode":"if (!data.actor_id && !data.group?.id) {\n  logger.warn('identify skipped: no actor or group')\n  return\n}","typeGuard":"const isIdentifiable = (d: ProviderIdentifyAnalyticsEventDTO): boolean => Boolean(d.actor_id || d.group?.id)","tryCatchPattern":"try { await provider.identify(dto) } catch (e) { logger.warn(`analytics identify failed: ${e.message}`) }","preventionTips":["Resolve the actor id before calling identify","Skip identify when the user context is absent rather than sending an empty payload"],"tags":["posthog","analytics","validation"],"backgroundTag":"required-field-missing","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}