@od-oneapp/analytics 2026.2.1701 → 2026.2.2301-canary
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/{ai-YMnynb-t.mjs → ai-Co8hBoEj.mjs} +2 -2
- package/{ai-YMnynb-t.mjs.map → ai-Co8hBoEj.mjs.map} +1 -1
- package/{client-D339NFJS.mjs → client-B8gfgflr.mjs} +1 -1
- package/{client-D339NFJS.mjs.map → client-B8gfgflr.mjs.map} +1 -1
- package/{client-CeOLjbac.mjs → client-C35AzV71.mjs} +21 -6
- package/client-C35AzV71.mjs.map +1 -0
- package/{client-CcFTauAh.mjs → client-DDehaDSz.mjs} +1 -1
- package/{client-CcFTauAh.mjs.map → client-DDehaDSz.mjs.map} +1 -1
- package/{client-CTzJVFU5.mjs → client-DK8twEdp.mjs} +2 -2
- package/{client-CTzJVFU5.mjs.map → client-DK8twEdp.mjs.map} +1 -1
- package/client-next.d.mts +7 -7
- package/client-next.d.mts.map +1 -1
- package/client-next.mjs +1615 -31
- package/client-next.mjs.map +1 -1
- package/client.d.mts +9 -9
- package/client.mjs +8 -116
- package/client.mjs.map +1 -1
- package/{config-P6P5adJg.mjs → config-6Mwe7b2O.mjs} +1 -1
- package/{config-P6P5adJg.mjs.map → config-6Mwe7b2O.mjs.map} +1 -1
- package/{config-DPS6bSYo.d.mts → config-Ciu7O6n1.d.mts} +2 -2
- package/{config-DPS6bSYo.d.mts.map → config-Ciu7O6n1.d.mts.map} +1 -1
- package/{console-8bND3mMU.mjs → console-BpU88FNF.mjs} +2 -2
- package/console-BpU88FNF.mjs.map +1 -0
- package/core-DBLE5iTF.mjs +95 -0
- package/core-DBLE5iTF.mjs.map +1 -0
- package/{ecommerce-Cgu4wlux.mjs → ecommerce-DGG1FbiH.mjs} +2 -2
- package/{ecommerce-Cgu4wlux.mjs.map → ecommerce-DGG1FbiH.mjs.map} +1 -1
- package/{emitters-DldkVSPp.d.mts → emitters-BDSsleo_.d.mts} +2 -2
- package/{emitters-DldkVSPp.d.mts.map → emitters-BDSsleo_.d.mts.map} +1 -1
- package/{emitters-6-nKo8i-.mjs → emitters-BvEelkxS.mjs} +1 -1
- package/{emitters-6-nKo8i-.mjs.map → emitters-BvEelkxS.mjs.map} +1 -1
- package/{index-jPzXRn52.d.mts → index-BWhDEs8u.d.mts} +3 -3
- package/{index-jPzXRn52.d.mts.map → index-BWhDEs8u.d.mts.map} +1 -1
- package/{index-BkIWe--N.d.mts → index-Cp-N57Zb.d.mts} +2 -2
- package/{index-BkIWe--N.d.mts.map → index-Cp-N57Zb.d.mts.map} +1 -1
- package/{index-BfNWgfa5.d.mts → index-DTvdqV7H.d.mts} +14 -2
- package/{index-BfNWgfa5.d.mts.map → index-DTvdqV7H.d.mts.map} +1 -1
- package/{manager-DvRRjza6.d.mts → manager-OJpSKwqb.d.mts} +3 -2
- package/manager-OJpSKwqb.d.mts.map +1 -0
- package/module-DVAU7zKb.mjs +5850 -0
- package/module-DVAU7zKb.mjs.map +1 -0
- package/package.json +42 -37
- package/{posthog-bootstrap-DWxFrxlt.d.mts → posthog-bootstrap-Bu1BfhVv.d.mts} +3 -3
- package/{posthog-bootstrap-DWxFrxlt.d.mts.map → posthog-bootstrap-Bu1BfhVv.d.mts.map} +1 -1
- package/{posthog-bootstrap-CYfIy_WS.mjs → posthog-bootstrap-DkPdn-hA.mjs} +81 -46
- package/posthog-bootstrap-DkPdn-hA.mjs.map +1 -0
- package/providers-http-client.d.mts +1 -1
- package/providers-http-client.d.mts.map +1 -1
- package/providers-http-client.mjs +35 -7
- package/providers-http-client.mjs.map +1 -1
- package/providers-http-server.d.mts +1 -1
- package/providers-http-server.d.mts.map +1 -1
- package/providers-http-server.mjs +19 -3
- package/providers-http-server.mjs.map +1 -1
- package/providers-http.d.mts +9 -1
- package/providers-http.d.mts.map +1 -1
- package/server-edge.d.mts +3 -3
- package/server-edge.mjs +4 -4
- package/server-edge.mjs.map +1 -1
- package/server-next.d.mts +9 -9
- package/server-next.mjs +5 -5
- package/server.d.mts +9 -9
- package/server.mjs +5 -5
- package/{service-Duqnlppl.mjs → service-NuHnv30x.mjs} +51 -119
- package/service-NuHnv30x.mjs.map +1 -0
- package/shared.d.mts +4 -4
- package/shared.mjs +3 -3
- package/{types-CBvxUEaF.d.mts → types-DEcTnnFe.d.mts} +1 -1
- package/{types-CBvxUEaF.d.mts.map → types-DEcTnnFe.d.mts.map} +1 -1
- package/{types-BxBnNQ0V.d.mts → types-cMMfHIpi.d.mts} +1 -1
- package/{types-BxBnNQ0V.d.mts.map → types-cMMfHIpi.d.mts.map} +1 -1
- package/types.d.mts +3 -3
- package/{vercel-types-lwakUfoI.d.mts → vercel-types-oM7Sn385.d.mts} +1 -1
- package/{vercel-types-lwakUfoI.d.mts.map → vercel-types-oM7Sn385.d.mts.map} +1 -1
- package/client-CeOLjbac.mjs.map +0 -1
- package/console-8bND3mMU.mjs.map +0 -1
- package/manager-DvRRjza6.d.mts.map +0 -1
- package/posthog-bootstrap-CYfIy_WS.mjs.map +0 -1
- package/service-Duqnlppl.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,75 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@od-oneapp/analytics",
|
|
3
|
-
"version": "2026.2.
|
|
3
|
+
"version": "2026.2.2301-canary",
|
|
4
4
|
"description": "Multi-provider analytics package with type-safe event tracking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
8
8
|
"./client": {
|
|
9
|
+
"types": "./client.d.mts",
|
|
9
10
|
"import": "./client.mjs",
|
|
10
|
-
"
|
|
11
|
+
"default": "./client.mjs"
|
|
11
12
|
},
|
|
12
13
|
"./server": {
|
|
14
|
+
"types": "./server.d.mts",
|
|
13
15
|
"import": "./server.mjs",
|
|
14
|
-
"
|
|
16
|
+
"default": "./server.mjs"
|
|
15
17
|
},
|
|
16
18
|
"./client/next": {
|
|
19
|
+
"types": "./client-next.d.mts",
|
|
17
20
|
"import": "./client-next.mjs",
|
|
18
|
-
"
|
|
21
|
+
"default": "./client-next.mjs"
|
|
19
22
|
},
|
|
20
23
|
"./server/next": {
|
|
24
|
+
"types": "./server-next.d.mts",
|
|
21
25
|
"import": "./server-next.mjs",
|
|
22
|
-
"
|
|
26
|
+
"default": "./server-next.mjs"
|
|
23
27
|
},
|
|
24
28
|
"./server/edge": {
|
|
29
|
+
"types": "./server-edge.d.mts",
|
|
25
30
|
"import": "./server-edge.mjs",
|
|
26
|
-
"
|
|
31
|
+
"default": "./server-edge.mjs"
|
|
27
32
|
},
|
|
28
33
|
"./shared": {
|
|
34
|
+
"types": "./shared.d.mts",
|
|
29
35
|
"import": "./shared.mjs",
|
|
30
|
-
"
|
|
36
|
+
"default": "./shared.mjs"
|
|
31
37
|
},
|
|
32
38
|
"./types": {
|
|
39
|
+
"types": "./types.d.mts",
|
|
33
40
|
"import": "./types.mjs",
|
|
34
|
-
"
|
|
41
|
+
"default": "./types.mjs"
|
|
35
42
|
},
|
|
36
43
|
"./providers/http": {
|
|
44
|
+
"types": "./providers-http.d.mts",
|
|
37
45
|
"import": "./providers-http.mjs",
|
|
38
|
-
"
|
|
46
|
+
"default": "./providers-http.mjs"
|
|
39
47
|
},
|
|
40
48
|
"./providers/http/client": {
|
|
49
|
+
"types": "./providers-http-client.d.mts",
|
|
41
50
|
"import": "./providers-http-client.mjs",
|
|
42
|
-
"
|
|
51
|
+
"default": "./providers-http-client.mjs"
|
|
43
52
|
},
|
|
44
53
|
"./providers/http/server": {
|
|
54
|
+
"types": "./providers-http-server.d.mts",
|
|
45
55
|
"import": "./providers-http-server.mjs",
|
|
46
|
-
"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"posthog-js": "^1.301.2",
|
|
51
|
-
"posthog-node": "^5.24.15",
|
|
52
|
-
"@segment/analytics-node": "^2.3.0",
|
|
53
|
-
"@vercel/analytics": "^1.6.1",
|
|
54
|
-
"@t3-oss/env-core": "^0.13.10",
|
|
55
|
-
"@od-oneapp/observability": "2026.2.1701",
|
|
56
|
-
"@od-oneapp/shared": "2026.2.1701"
|
|
57
|
-
},
|
|
58
|
-
"optionalDependencies": {
|
|
59
|
-
"@segment/analytics-next": "^1.81.1",
|
|
60
|
-
"@flags-sdk/edge-config": "^0.1.2",
|
|
61
|
-
"@flags-sdk/openfeature": "^0.1.2",
|
|
62
|
-
"@vercel/analytics": "^1.6.1",
|
|
63
|
-
"@vercel/blob": "^2.2.0"
|
|
64
|
-
},
|
|
65
|
-
"peerDependencies": {
|
|
66
|
-
"next": ">=14.0.0",
|
|
67
|
-
"react": ">=18.0.0",
|
|
68
|
-
"zod": ">=3.23.0"
|
|
69
|
-
},
|
|
70
|
-
"peerDependenciesMeta": {
|
|
71
|
-
"next": {
|
|
72
|
-
"optional": true
|
|
56
|
+
"default": "./providers-http-server.mjs"
|
|
73
57
|
}
|
|
74
58
|
},
|
|
75
59
|
"repository": {
|
|
@@ -137,5 +121,26 @@
|
|
|
137
121
|
"engines": {
|
|
138
122
|
"node": ">=22.0.0",
|
|
139
123
|
"pnpm": ">=10.28.2"
|
|
124
|
+
},
|
|
125
|
+
"dependencies": {
|
|
126
|
+
"@od-oneapp/integration-posthog": "canary",
|
|
127
|
+
"@od-oneapp/integration-segment": "canary",
|
|
128
|
+
"@od-oneapp/integration-vercel": "canary",
|
|
129
|
+
"@od-oneapp/observability": "canary",
|
|
130
|
+
"@od-oneapp/shared": "canary",
|
|
131
|
+
"@t3-oss/env-core": "^0.13.10",
|
|
132
|
+
"next": "16.1.6",
|
|
133
|
+
"posthog-node": "^5.24.15",
|
|
134
|
+
"react": "^19.2.4",
|
|
135
|
+
"zod": "4.3.6"
|
|
136
|
+
},
|
|
137
|
+
"peerDependencies": {
|
|
138
|
+
"next": "16.1.6",
|
|
139
|
+
"react": "^19.2.4"
|
|
140
|
+
},
|
|
141
|
+
"peerDependenciesMeta": {
|
|
142
|
+
"next": {
|
|
143
|
+
"optional": true
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as EmitterPagePayload, D as EmitterTrackPayload, b as EmitterIdentifyPayload, g as EmitterContext, p as EmitterAliasPayload, v as EmitterGroupPayload, w as EmitterPayload } from "./types-
|
|
2
|
-
import { s as BootstrapData } from "./vercel-types-
|
|
1
|
+
import { C as EmitterPagePayload, D as EmitterTrackPayload, b as EmitterIdentifyPayload, g as EmitterContext, p as EmitterAliasPayload, v as EmitterGroupPayload, w as EmitterPayload } from "./types-cMMfHIpi.mjs";
|
|
2
|
+
import { s as BootstrapData } from "./vercel-types-oM7Sn385.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/shared/emitters/helpers.d.ts
|
|
5
5
|
declare class ContextBuilder {
|
|
@@ -78,4 +78,4 @@ declare function createBootstrapData(distinctId: string): BootstrapData;
|
|
|
78
78
|
declare function createMinimalBootstrapData(distinctId?: string): BootstrapData;
|
|
79
79
|
//#endregion
|
|
80
80
|
export { ContextBuilder as a, createAnonymousSession as c, isGroupPayload as d, isIdentifyPayload as f, withUTM as g, withMetadata as h, getDistinctIdFromCookies as i, createUserSession as l, isTrackPayload as m, createMinimalBootstrapData as n, EventBatch as o, isPagePayload as p, generateDistinctId as r, PayloadBuilder as s, createBootstrapData as t, isAliasPayload as u };
|
|
81
|
-
//# sourceMappingURL=posthog-bootstrap-
|
|
81
|
+
//# sourceMappingURL=posthog-bootstrap-Bu1BfhVv.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-bootstrap-
|
|
1
|
+
{"version":3,"file":"posthog-bootstrap-Bu1BfhVv.d.mts","names":[],"sources":["../src/shared/emitters/helpers.ts","../src/shared/utils/posthog-bootstrap.ts"],"mappings":";;;;cAuDa,cAAA;EAAA,QACH,OAAA;cAEI,cAAA,GAAiB,OAAA,CAAQ,cAAA;EAMrC,OAAA,CAAQ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as identify, t as alias } from "./emitters-BvEelkxS.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/shared/utils/rate-limit.ts
|
|
5
5
|
/**
|
|
@@ -253,7 +253,10 @@ const XSS_PATTERNS = {
|
|
|
253
253
|
* ```
|
|
254
254
|
*/
|
|
255
255
|
function containsPII(value) {
|
|
256
|
-
return Object.values(PII_PATTERNS).some((pattern) =>
|
|
256
|
+
return Object.values(PII_PATTERNS).some((pattern) => {
|
|
257
|
+
pattern.lastIndex = 0;
|
|
258
|
+
return pattern.test(value);
|
|
259
|
+
});
|
|
257
260
|
}
|
|
258
261
|
/**
|
|
259
262
|
* Redact PII from a string.
|
|
@@ -272,7 +275,10 @@ function containsPII(value) {
|
|
|
272
275
|
*/
|
|
273
276
|
function redactPII(value) {
|
|
274
277
|
let redacted = value;
|
|
275
|
-
for (const [type, pattern] of Object.entries(PII_PATTERNS))
|
|
278
|
+
for (const [type, pattern] of Object.entries(PII_PATTERNS)) {
|
|
279
|
+
pattern.lastIndex = 0;
|
|
280
|
+
redacted = redacted.replace(pattern, `[REDACTED_${type.toUpperCase()}]`);
|
|
281
|
+
}
|
|
276
282
|
return redacted;
|
|
277
283
|
}
|
|
278
284
|
/**
|
|
@@ -488,6 +494,7 @@ function sanitizeProperties(properties, options = {}) {
|
|
|
488
494
|
* - Non-empty string
|
|
489
495
|
* - Not exceeding 255 characters
|
|
490
496
|
* - No XSS patterns
|
|
497
|
+
* - Only alphanumeric characters, spaces, dots, underscores, and hyphens
|
|
491
498
|
*
|
|
492
499
|
* @param {string} event - Event name to validate
|
|
493
500
|
* @returns {{ valid: boolean; reason?: string }} Validation result with reason if invalid
|
|
@@ -513,10 +520,17 @@ function validateEventName(event) {
|
|
|
513
520
|
valid: false,
|
|
514
521
|
reason: "Event name cannot exceed 255 characters"
|
|
515
522
|
};
|
|
516
|
-
if (Object.values(XSS_PATTERNS).some((pattern) =>
|
|
523
|
+
if (Object.values(XSS_PATTERNS).some((pattern) => {
|
|
524
|
+
pattern.lastIndex = 0;
|
|
525
|
+
return pattern.test(event);
|
|
526
|
+
})) return {
|
|
517
527
|
valid: false,
|
|
518
528
|
reason: "Event name contains potentially malicious content"
|
|
519
529
|
};
|
|
530
|
+
if (!/^[\s\w.-]+$/.test(event)) return {
|
|
531
|
+
valid: false,
|
|
532
|
+
reason: "Event name can only contain alphanumeric characters, spaces, dots, underscores, and hyphens"
|
|
533
|
+
};
|
|
520
534
|
return { valid: true };
|
|
521
535
|
}
|
|
522
536
|
|
|
@@ -714,14 +728,24 @@ var AnalyticsManager = class {
|
|
|
714
728
|
getContext() {
|
|
715
729
|
return { ...this.context };
|
|
716
730
|
}
|
|
731
|
+
/**
|
|
732
|
+
* Build per-call context without mutating global manager state.
|
|
733
|
+
*/
|
|
734
|
+
mergeCallContext(options, extraContext) {
|
|
735
|
+
return {
|
|
736
|
+
...this.context,
|
|
737
|
+
...options?.context ?? {},
|
|
738
|
+
...extraContext ?? {}
|
|
739
|
+
};
|
|
740
|
+
}
|
|
717
741
|
async track(eventOrPayload, properties, options) {
|
|
718
742
|
if (typeof eventOrPayload === "object") {
|
|
719
743
|
const payload = eventOrPayload;
|
|
720
744
|
return this.track(payload.event, payload.properties, {
|
|
721
745
|
...options,
|
|
722
746
|
context: {
|
|
723
|
-
...
|
|
724
|
-
...payload.context
|
|
747
|
+
...options?.context ?? {},
|
|
748
|
+
...payload.context ?? {}
|
|
725
749
|
}
|
|
726
750
|
});
|
|
727
751
|
}
|
|
@@ -748,9 +772,10 @@ var AnalyticsManager = class {
|
|
|
748
772
|
stripHTML: true,
|
|
749
773
|
allowDangerousKeys: false
|
|
750
774
|
});
|
|
751
|
-
const targetProviders = this.getTargetProviders(options);
|
|
775
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
776
|
+
const callContext = this.mergeCallContext(options);
|
|
752
777
|
const enhancedProperties = {
|
|
753
|
-
...
|
|
778
|
+
...callContext,
|
|
754
779
|
...sanitized.data
|
|
755
780
|
};
|
|
756
781
|
const promises = [...targetProviders.entries()].map(async ([name, provider]) => {
|
|
@@ -764,7 +789,7 @@ var AnalyticsManager = class {
|
|
|
764
789
|
return;
|
|
765
790
|
}
|
|
766
791
|
try {
|
|
767
|
-
await provider.track(event, enhancedProperties,
|
|
792
|
+
await provider.track(event, enhancedProperties, callContext);
|
|
768
793
|
const metrics = this.providerMetrics.get(name);
|
|
769
794
|
if (metrics) {
|
|
770
795
|
metrics.callCount++;
|
|
@@ -790,8 +815,8 @@ var AnalyticsManager = class {
|
|
|
790
815
|
return this.identify(payload.userId, payload.traits, {
|
|
791
816
|
...options,
|
|
792
817
|
context: {
|
|
793
|
-
...
|
|
794
|
-
...payload.context
|
|
818
|
+
...options?.context ?? {},
|
|
819
|
+
...payload.context ?? {}
|
|
795
820
|
}
|
|
796
821
|
});
|
|
797
822
|
}
|
|
@@ -809,11 +834,11 @@ var AnalyticsManager = class {
|
|
|
809
834
|
stripHTML: true,
|
|
810
835
|
allowDangerousKeys: false
|
|
811
836
|
});
|
|
812
|
-
this.
|
|
837
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
838
|
+
const callContext = this.mergeCallContext(options, {
|
|
813
839
|
userId,
|
|
814
840
|
...sanitized.data
|
|
815
841
|
});
|
|
816
|
-
const targetProviders = this.getTargetProviders(options);
|
|
817
842
|
const enhancedTraits = { ...sanitized.data };
|
|
818
843
|
const promises = [...targetProviders.entries()].map(async ([name, provider]) => {
|
|
819
844
|
if (provider.identify) {
|
|
@@ -829,7 +854,7 @@ var AnalyticsManager = class {
|
|
|
829
854
|
try {
|
|
830
855
|
await provider.identify(userId, enhancedTraits, {
|
|
831
856
|
...options,
|
|
832
|
-
context:
|
|
857
|
+
context: callContext
|
|
833
858
|
});
|
|
834
859
|
const metrics = this.providerMetrics.get(name);
|
|
835
860
|
if (metrics) {
|
|
@@ -857,8 +882,8 @@ var AnalyticsManager = class {
|
|
|
857
882
|
return this.page(payload.name, payload.properties, {
|
|
858
883
|
...options,
|
|
859
884
|
context: {
|
|
860
|
-
...
|
|
861
|
-
...payload.context
|
|
885
|
+
...options?.context ?? {},
|
|
886
|
+
...payload.context ?? {}
|
|
862
887
|
}
|
|
863
888
|
});
|
|
864
889
|
}
|
|
@@ -876,7 +901,8 @@ var AnalyticsManager = class {
|
|
|
876
901
|
stripHTML: true,
|
|
877
902
|
allowDangerousKeys: false
|
|
878
903
|
});
|
|
879
|
-
const targetProviders = this.getTargetProviders(options);
|
|
904
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
905
|
+
const callContext = this.mergeCallContext(options);
|
|
880
906
|
const enhancedProperties = { ...sanitized.data };
|
|
881
907
|
const promises = [...targetProviders.entries()].map(async ([providerName, provider]) => {
|
|
882
908
|
if (provider.page) {
|
|
@@ -892,7 +918,7 @@ var AnalyticsManager = class {
|
|
|
892
918
|
try {
|
|
893
919
|
await provider.page(name ?? "", enhancedProperties, {
|
|
894
920
|
...options,
|
|
895
|
-
context:
|
|
921
|
+
context: callContext
|
|
896
922
|
});
|
|
897
923
|
const metrics = this.providerMetrics.get(providerName);
|
|
898
924
|
if (metrics) {
|
|
@@ -920,8 +946,8 @@ var AnalyticsManager = class {
|
|
|
920
946
|
return this.screen(payload.name, payload.properties, {
|
|
921
947
|
...options,
|
|
922
948
|
context: {
|
|
923
|
-
...
|
|
924
|
-
...payload.context
|
|
949
|
+
...options?.context ?? {},
|
|
950
|
+
...payload.context ?? {}
|
|
925
951
|
}
|
|
926
952
|
});
|
|
927
953
|
}
|
|
@@ -939,7 +965,8 @@ var AnalyticsManager = class {
|
|
|
939
965
|
stripHTML: true,
|
|
940
966
|
allowDangerousKeys: false
|
|
941
967
|
});
|
|
942
|
-
const targetProviders = this.getTargetProviders(options);
|
|
968
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
969
|
+
const callContext = this.mergeCallContext(options);
|
|
943
970
|
const enhancedProperties = { ...sanitized.data };
|
|
944
971
|
const promises = [...targetProviders.entries()].map(async ([providerName, provider]) => {
|
|
945
972
|
if (provider.screen) {
|
|
@@ -955,7 +982,7 @@ var AnalyticsManager = class {
|
|
|
955
982
|
try {
|
|
956
983
|
await provider.screen(name ?? "", enhancedProperties, {
|
|
957
984
|
...options,
|
|
958
|
-
context:
|
|
985
|
+
context: callContext
|
|
959
986
|
});
|
|
960
987
|
const metrics = this.providerMetrics.get(providerName);
|
|
961
988
|
if (metrics) {
|
|
@@ -983,8 +1010,8 @@ var AnalyticsManager = class {
|
|
|
983
1010
|
return this.group(payload.groupId, payload.traits, {
|
|
984
1011
|
...options,
|
|
985
1012
|
context: {
|
|
986
|
-
...
|
|
987
|
-
...payload.context
|
|
1013
|
+
...options?.context ?? {},
|
|
1014
|
+
...payload.context ?? {}
|
|
988
1015
|
}
|
|
989
1016
|
});
|
|
990
1017
|
}
|
|
@@ -1002,11 +1029,11 @@ var AnalyticsManager = class {
|
|
|
1002
1029
|
stripHTML: true,
|
|
1003
1030
|
allowDangerousKeys: false
|
|
1004
1031
|
});
|
|
1005
|
-
this.
|
|
1032
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
1033
|
+
const callContext = this.mergeCallContext(options, {
|
|
1006
1034
|
organizationId: groupId,
|
|
1007
1035
|
...sanitized.data
|
|
1008
1036
|
});
|
|
1009
|
-
const targetProviders = this.getTargetProviders(options);
|
|
1010
1037
|
const enhancedTraits = { ...sanitized.data };
|
|
1011
1038
|
const promises = [...targetProviders.entries()].map(async ([providerName, provider]) => {
|
|
1012
1039
|
if (provider.group) {
|
|
@@ -1022,7 +1049,7 @@ var AnalyticsManager = class {
|
|
|
1022
1049
|
try {
|
|
1023
1050
|
await provider.group(groupId, enhancedTraits, {
|
|
1024
1051
|
...options,
|
|
1025
|
-
context:
|
|
1052
|
+
context: callContext
|
|
1026
1053
|
});
|
|
1027
1054
|
const metrics = this.providerMetrics.get(providerName);
|
|
1028
1055
|
if (metrics) {
|
|
@@ -1050,8 +1077,8 @@ var AnalyticsManager = class {
|
|
|
1050
1077
|
return this.alias(payload.userId, payload.previousId, {
|
|
1051
1078
|
...options,
|
|
1052
1079
|
context: {
|
|
1053
|
-
...
|
|
1054
|
-
...payload.context
|
|
1080
|
+
...options?.context ?? {},
|
|
1081
|
+
...payload.context ?? {}
|
|
1055
1082
|
}
|
|
1056
1083
|
});
|
|
1057
1084
|
}
|
|
@@ -1066,7 +1093,9 @@ var AnalyticsManager = class {
|
|
|
1066
1093
|
});
|
|
1067
1094
|
return;
|
|
1068
1095
|
}
|
|
1069
|
-
const
|
|
1096
|
+
const targetProviders = await this.getTargetProviders(options);
|
|
1097
|
+
const callContext = this.mergeCallContext(options, { userId });
|
|
1098
|
+
const promises = [...targetProviders.entries()].map(async ([providerName, provider]) => {
|
|
1070
1099
|
if (provider.alias) {
|
|
1071
1100
|
if (!await this.rateLimiter.tryAcquire()) {
|
|
1072
1101
|
if (this.config.debug && this.config.onInfo) this.config.onInfo(`Rate limit exceeded for provider ${providerName}`);
|
|
@@ -1079,7 +1108,7 @@ var AnalyticsManager = class {
|
|
|
1079
1108
|
return;
|
|
1080
1109
|
}
|
|
1081
1110
|
try {
|
|
1082
|
-
await provider.alias(userId, prevId,
|
|
1111
|
+
await provider.alias(userId, prevId, callContext);
|
|
1083
1112
|
const metrics = this.providerMetrics.get(providerName);
|
|
1084
1113
|
if (metrics) {
|
|
1085
1114
|
metrics.callCount++;
|
|
@@ -1210,18 +1239,21 @@ var AnalyticsManager = class {
|
|
|
1210
1239
|
*/
|
|
1211
1240
|
async emitBatch(payloads, options) {
|
|
1212
1241
|
const batchStartTime = process.hrtime.bigint();
|
|
1213
|
-
const concurrency = options?.concurrency ?? 10;
|
|
1242
|
+
const concurrency = Math.max(1, options?.concurrency ?? 10);
|
|
1214
1243
|
if (payloads.length === 0) return;
|
|
1215
|
-
const
|
|
1216
|
-
const
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1244
|
+
const workQueue = [...payloads.map((p) => structuredClone(p))];
|
|
1245
|
+
const workerCount = Math.min(concurrency, workQueue.length);
|
|
1246
|
+
const runWorker = async (failFast) => {
|
|
1247
|
+
while (workQueue.length > 0) {
|
|
1248
|
+
const payload = workQueue.shift();
|
|
1249
|
+
if (!payload) return;
|
|
1250
|
+
if (failFast) await this.emit(payload, options?.timeout !== void 0 ? { timeout: options.timeout } : void 0);
|
|
1251
|
+
else try {
|
|
1252
|
+
await this.emit(payload, options?.timeout !== void 0 ? { timeout: options.timeout } : void 0);
|
|
1253
|
+
} catch {}
|
|
1254
|
+
}
|
|
1222
1255
|
};
|
|
1223
|
-
|
|
1224
|
-
await Promise.all(chunkPromises);
|
|
1256
|
+
await Promise.all(Array.from({ length: workerCount }, () => runWorker(options?.failFast === true)));
|
|
1225
1257
|
if (this.config.debug && this.config.onInfo) {
|
|
1226
1258
|
const batchTime = Number(process.hrtime.bigint() - batchStartTime) / 1e6;
|
|
1227
1259
|
this.config.onInfo(`Batch of ${payloads.length} events processed in ${batchTime.toFixed(2)}ms (concurrency: ${concurrency})`);
|
|
@@ -1243,19 +1275,22 @@ var AnalyticsManager = class {
|
|
|
1243
1275
|
/**
|
|
1244
1276
|
* Get target providers based on tracking options
|
|
1245
1277
|
*/
|
|
1246
|
-
getTargetProviders(options) {
|
|
1278
|
+
async getTargetProviders(options) {
|
|
1247
1279
|
let targetProviders = new Map(this.providers);
|
|
1248
1280
|
if (options) {
|
|
1249
1281
|
if (options.providers && Object.hasOwn(options, "providers")) for (const [name, config] of Object.entries(options.providers)) {
|
|
1250
1282
|
const factory = this.availableProviders[name];
|
|
1251
1283
|
if (factory) try {
|
|
1284
|
+
const providerInitStart = typeof process.hrtime?.bigint === "function" ? process.hrtime.bigint() : BigInt(Date.now() * 1e6);
|
|
1252
1285
|
const provider = factory(config);
|
|
1286
|
+
await provider.initialize(config);
|
|
1253
1287
|
targetProviders.set(name, provider);
|
|
1288
|
+
const now = typeof process.hrtime?.bigint === "function" ? process.hrtime.bigint() : BigInt(Date.now() * 1e6);
|
|
1254
1289
|
this.providerMetrics.set(name, {
|
|
1255
|
-
initTime:
|
|
1290
|
+
initTime: now - providerInitStart,
|
|
1256
1291
|
callCount: 0,
|
|
1257
1292
|
errorCount: 0,
|
|
1258
|
-
lastUsed:
|
|
1293
|
+
lastUsed: now
|
|
1259
1294
|
});
|
|
1260
1295
|
} catch (error) {
|
|
1261
1296
|
if (this.config.onError) this.config.onError(error, {
|
|
@@ -1766,4 +1801,4 @@ function createMinimalBootstrapData(distinctId) {
|
|
|
1766
1801
|
|
|
1767
1802
|
//#endregion
|
|
1768
1803
|
export { AnalyticsManager as _, ContextBuilder as a, validateEventName as b, createAnonymousSession as c, isGroupPayload as d, isIdentifyPayload as f, withUTM as g, withMetadata as h, getDistinctIdFromCookies as i, createUserSession as l, isTrackPayload as m, createMinimalBootstrapData as n, EventBatch as o, isPagePayload as p, generateDistinctId as r, PayloadBuilder as s, createBootstrapData as t, isAliasPayload as u, createAnalyticsManager as v, sanitizeProperties as y };
|
|
1769
|
-
//# sourceMappingURL=posthog-bootstrap-
|
|
1804
|
+
//# sourceMappingURL=posthog-bootstrap-DkPdn-hA.mjs.map
|