Moved 'region' from payload.data to payload root, align with backend contract
All checks were successful
armco-org/analytics/pipeline/head This commit looks good

This commit is contained in:
2025-12-22 00:29:20 +05:30
parent 59a0aed4a7
commit 8ca9dead46
3 changed files with 6 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@armco/analytics",
"version": "0.3.2",
"version": "0.3.3",
"description": "Universal Analytics Library for Browser and Node.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View File

@@ -33,7 +33,7 @@ import {
getTimestamp,
deepMerge,
} from "../utils/helpers";
import { ensureRegion } from "../utils/region";
import { getRegionFallback } from "../utils/region";
import { resolveEndpoint, detectEnvironment } from "../utils/config-loader";
import type { EndpointConfig } from "./types";
@@ -317,12 +317,13 @@ export class Analytics implements IAnalytics {
return;
}
// Create base event with region enrichment
// Create base event with region at top level
const event: TrackingEvent<T> = {
eventType,
timestamp: getTimestamp(),
eventId: uuidv4(),
data: ensureRegion(sanitizeEventData(data || {})) as T,
region: getRegionFallback(),
data: sanitizeEventData(data || {}) as T,
};
// Process through plugins

View File

@@ -43,6 +43,7 @@ export interface TrackingEvent<T extends EventData = EventData> {
eventId: string;
sessionId?: string;
userId?: string;
region?: string;
data: T;
}