fix(analytics): the Track API payload field is 'name', not 'event'

Second half of the envelope fix: ITrackPayload is {name, properties, profileId} — sending
'event' is rejected with 400 "payload/name Invalid input: expected string", which the
module swallows by design. Verified against packages/validation/src/track.validation.ts
and the SDK's track(name, properties) signature.
This commit is contained in:
ZCode
2026-09-21 09:16:21 +00:00
parent 34290b9371
commit d69ec7f7a9
+3 -1
View File
@@ -39,7 +39,9 @@ async def track(event: str, properties: dict[str, Any] | None = None, profile_id
return
# OpenPanel's Track API takes {type, payload:{…}} (same envelope the browser SDK
# sends) — a flat body is rejected with 400, which this module swallows by design.
inner: dict[str, Any] = {"event": event, "properties": properties or {}}
# The payload field is "name" (ITrackPayload in packages/validation) — "event" is
# rejected with a 400 that this module swallows.
inner: dict[str, Any] = {"name": event, "properties": properties or {}}
if profile_id:
inner["profileId"] = profile_id
body = {"type": "track", "payload": inner}