Update event payload

This commit is contained in:
Eric Bailey
2026-01-21 18:02:25 -06:00
parent a55f380ac0
commit f9ae0f01eb
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -76,6 +76,9 @@ function createLogger(
const Context = createContext<AnalyticsBaseContextType>({
logger: createLogger(Logger.Context.Default, {}),
metric: (event, payload, metadata) => {
if (metadata && '__meta' in metadata) {
delete metadata.__meta
}
metrics.track(event, payload, metadata)
},
metadata: {
@@ -115,8 +118,7 @@ export function AnalyticsContext({
metadata?: MergeableMetadata
}) {
if (metadata) {
// @ts-ignore
if (metadata.__meta !== true) {
if (!('__meta' in metadata)) {
throw new Error(
'Use the useMeta() helper when passing metadata to AnalyticsContext',
)
+1 -1
View File
@@ -74,7 +74,7 @@ export class MetricsClient<M extends Record<string, any>> {
})
try {
const body = JSON.stringify(events)
const body = JSON.stringify({events})
if (env.IS_WEB && 'navigator' in globalThis && navigator.sendBeacon) {
navigator.sendBeacon(
TRACKING_ENDPOINT,