@posthog/core 1.19.0 → 1.20.1
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/dist/error-tracking/error-properties-builder.d.ts +2 -2
- package/dist/error-tracking/error-properties-builder.d.ts.map +1 -1
- package/dist/error-tracking/error-properties-builder.js +5 -4
- package/dist/error-tracking/error-properties-builder.mjs +5 -4
- package/dist/error-tracking/types.d.ts +2 -0
- package/dist/error-tracking/types.d.ts.map +1 -1
- package/dist/posthog-core-stateless.d.ts +9 -0
- package/dist/posthog-core-stateless.d.ts.map +1 -1
- package/dist/posthog-core-stateless.js +5 -3
- package/dist/posthog-core-stateless.mjs +5 -3
- package/dist/posthog-core.d.ts +1 -0
- package/dist/posthog-core.d.ts.map +1 -1
- package/dist/posthog-core.js +10 -3
- package/dist/posthog-core.mjs +11 -4
- package/dist/utils/string-utils.d.ts +11 -0
- package/dist/utils/string-utils.d.ts.map +1 -1
- package/dist/utils/string-utils.js +18 -0
- package/dist/utils/string-utils.mjs +16 -1
- package/package.json +1 -1
- package/src/error-tracking/error-properties-builder.coerce.spec.ts +2 -1
- package/src/error-tracking/error-properties-builder.parse.spec.ts +1 -1
- package/src/error-tracking/error-properties-builder.ts +5 -4
- package/src/error-tracking/types.ts +2 -0
- package/src/posthog-core-stateless.ts +17 -3
- package/src/posthog-core.ts +32 -3
- package/src/utils/string-utils.spec.ts +121 -0
- package/src/utils/string-utils.ts +40 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorProperties, StackFrameModifierFn, StackParser, ErrorTrackingCoercer, EventHint } from './types';
|
|
1
|
+
import { ErrorProperties, CoercingContext, StackFrameModifierFn, StackParser, ErrorTrackingCoercer, EventHint, Mechanism } from './types';
|
|
2
2
|
export declare class ErrorPropertiesBuilder {
|
|
3
3
|
private coercers;
|
|
4
4
|
private stackParser;
|
|
@@ -13,6 +13,6 @@ export declare class ErrorPropertiesBuilder {
|
|
|
13
13
|
private applyModifiers;
|
|
14
14
|
private convertToExceptionList;
|
|
15
15
|
private buildParsingContext;
|
|
16
|
-
|
|
16
|
+
buildCoercingContext(mechanism: Mechanism, hint: EventHint, depth?: number): CoercingContext;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=error-properties-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-properties-builder.d.ts","sourceRoot":"","sources":["../../src/error-tracking/error-properties-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,
|
|
1
|
+
{"version":3,"file":"error-properties-builder.d.ts","sourceRoot":"","sources":["../../src/error-tracking/error-properties-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAGf,eAAe,EAEf,oBAAoB,EACpB,WAAW,EACX,oBAAoB,EACpB,SAAS,EAGT,SAAS,EAGV,MAAM,SAAS,CAAA;AAIhB,qBAAa,sBAAsB;IAE/B,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;gBAFT,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE,EACrC,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,oBAAoB,EAAO;IAGhD,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,GAAE,SAAc,GAAG,eAAe;IAiBjE,YAAY,CAAC,aAAa,EAAE,eAAe,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;IASlH,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;YASP,cAAc;IAQ5B,OAAO,CAAC,sBAAsB;IA6B9B,OAAO,CAAC,mBAAmB;IAQpB,oBAAoB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,GAAE,MAAU,GAAG,eAAe;CAuBvG"}
|
|
@@ -43,7 +43,7 @@ class ErrorPropertiesBuilder {
|
|
|
43
43
|
};
|
|
44
44
|
const coercingContext = this.buildCoercingContext(mechanism, hint, 0);
|
|
45
45
|
const exceptionWithCause = coercingContext.apply(input);
|
|
46
|
-
const parsingContext = this.buildParsingContext();
|
|
46
|
+
const parsingContext = this.buildParsingContext(hint);
|
|
47
47
|
const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext);
|
|
48
48
|
const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism);
|
|
49
49
|
return {
|
|
@@ -67,7 +67,7 @@ class ErrorPropertiesBuilder {
|
|
|
67
67
|
let cause;
|
|
68
68
|
if (null != err.cause) cause = this.parseStacktrace(err.cause, ctx);
|
|
69
69
|
let stack;
|
|
70
|
-
if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ?
|
|
70
|
+
if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? ctx.skipFirstLines : 0), ctx.chunkIdMap);
|
|
71
71
|
return {
|
|
72
72
|
...err,
|
|
73
73
|
cause,
|
|
@@ -112,9 +112,10 @@ class ErrorPropertiesBuilder {
|
|
|
112
112
|
}));
|
|
113
113
|
return exceptionList;
|
|
114
114
|
}
|
|
115
|
-
buildParsingContext() {
|
|
115
|
+
buildParsingContext(hint) {
|
|
116
116
|
const context = {
|
|
117
|
-
chunkIdMap: (0, external_chunk_ids_js_namespaceObject.getFilenameToChunkIdMap)(this.stackParser)
|
|
117
|
+
chunkIdMap: (0, external_chunk_ids_js_namespaceObject.getFilenameToChunkIdMap)(this.stackParser),
|
|
118
|
+
skipFirstLines: hint.skipFirstLines ?? 1
|
|
118
119
|
};
|
|
119
120
|
return context;
|
|
120
121
|
}
|
|
@@ -15,7 +15,7 @@ class ErrorPropertiesBuilder {
|
|
|
15
15
|
};
|
|
16
16
|
const coercingContext = this.buildCoercingContext(mechanism, hint, 0);
|
|
17
17
|
const exceptionWithCause = coercingContext.apply(input);
|
|
18
|
-
const parsingContext = this.buildParsingContext();
|
|
18
|
+
const parsingContext = this.buildParsingContext(hint);
|
|
19
19
|
const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext);
|
|
20
20
|
const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism);
|
|
21
21
|
return {
|
|
@@ -39,7 +39,7 @@ class ErrorPropertiesBuilder {
|
|
|
39
39
|
let cause;
|
|
40
40
|
if (null != err.cause) cause = this.parseStacktrace(err.cause, ctx);
|
|
41
41
|
let stack;
|
|
42
|
-
if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ?
|
|
42
|
+
if ('' != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? ctx.skipFirstLines : 0), ctx.chunkIdMap);
|
|
43
43
|
return {
|
|
44
44
|
...err,
|
|
45
45
|
cause,
|
|
@@ -84,9 +84,10 @@ class ErrorPropertiesBuilder {
|
|
|
84
84
|
}));
|
|
85
85
|
return exceptionList;
|
|
86
86
|
}
|
|
87
|
-
buildParsingContext() {
|
|
87
|
+
buildParsingContext(hint) {
|
|
88
88
|
const context = {
|
|
89
|
-
chunkIdMap: getFilenameToChunkIdMap(this.stackParser)
|
|
89
|
+
chunkIdMap: getFilenameToChunkIdMap(this.stackParser),
|
|
90
|
+
skipFirstLines: hint.skipFirstLines ?? 1
|
|
90
91
|
};
|
|
91
92
|
return context;
|
|
92
93
|
}
|
|
@@ -10,6 +10,7 @@ export interface PolymorphicEvent {
|
|
|
10
10
|
export interface EventHint {
|
|
11
11
|
mechanism?: Partial<Mechanism>;
|
|
12
12
|
syntheticException?: Error | null;
|
|
13
|
+
skipFirstLines?: number;
|
|
13
14
|
}
|
|
14
15
|
export interface PreviouslyCapturedError {
|
|
15
16
|
__posthog_previously_captured_error?: boolean;
|
|
@@ -67,6 +68,7 @@ export interface CoercingContext extends EventHint {
|
|
|
67
68
|
export type ChunkIdMapType = Record<string, string>;
|
|
68
69
|
export interface ParsingContext {
|
|
69
70
|
chunkIdMap?: ChunkIdMapType;
|
|
71
|
+
skipFirstLines: number;
|
|
70
72
|
}
|
|
71
73
|
interface Coercer<T, U, C> {
|
|
72
74
|
match(input: unknown): input is T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/error-tracking/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKxC,eAAO,MAAM,cAAc,gEAAiE,CAAA;AAC5F,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAC9B,kBAAkB,CAAC,EAAE,KAAK,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/error-tracking/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKxC,eAAO,MAAM,cAAc,gEAAiE,CAAA;AAC5F,MAAM,CAAC,OAAO,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;I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ACvB;AAED,UAAU,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACvB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAAA;IACjC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;CAC5B;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,EAAE,eAAe,CAAC,CAAA;AAE5F,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB,KAAK,CAAC,EAAE,aAAa,CAAA;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD,KAAK,CAAC,EAAE,UAAU,EAAE,CAAA;IACpB,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB"}
|
|
@@ -143,6 +143,15 @@ export declare abstract class PostHogCoreStateless {
|
|
|
143
143
|
* @returns The transformed message, or null to drop it
|
|
144
144
|
*/
|
|
145
145
|
protected processBeforeEnqueue(message: PostHogEventProperties): PostHogEventProperties | null;
|
|
146
|
+
/**
|
|
147
|
+
* Hook that allows subclasses to wait for storage operations to complete.
|
|
148
|
+
* This is called after queue changes are persisted during flush to ensure
|
|
149
|
+
* data is safely written to storage before considering events as sent.
|
|
150
|
+
*
|
|
151
|
+
* Override this in implementations with async storage (e.g., React Native)
|
|
152
|
+
* to prevent duplicate events on app crash/restart scenarios.
|
|
153
|
+
*/
|
|
154
|
+
protected flushStorage(): Promise<void>;
|
|
146
155
|
protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
|
|
147
156
|
protected sendImmediate(type: string, _message: any, options?: PostHogCaptureOptions): Promise<void>;
|
|
148
157
|
protected prepareMessage(type: string, _message: any, options?: PostHogCaptureOptions): PostHogEventProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-core-stateless.d.ts","sourceRoot":"","sources":["../src/posthog-core-stateless.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAGnD,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAGhB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EAExB,MAAM,EACN,cAAc,EAEf,MAAM,SAAS,CAAA;AAChB,OAAO,EAOL,gBAAgB,EAIjB,MAAM,SAAS,CAAA;AAqChB,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,OAAO,QAAQ,GAAG,SAAS,KAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAC9C,CAAA;AAE7C,wBAAsB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAY3D;AAUD,oBAAY,mBAAmB;IAC7B,YAAY,kBAAkB;IAC9B,UAAU,eAAe;CAC1B;AAED,8BAAsB,oBAAoB;IAExC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAA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AI;cAsCrE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuD1G,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,sBAAsB;IA0B9G,OAAO,CAAC,eAAe;IAOvB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAMvB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB5B,SAAS,CAAC,gBAAgB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;YAazC,MAAM;YA4FN,cAAc;IAsDtB,SAAS,CAAC,iBAAiB,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDjE;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,QAAQ,CAAC,iBAAiB,GAAE,MAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAYjE"}
|
|
@@ -466,6 +466,7 @@ class PostHogCoreStateless {
|
|
|
466
466
|
processBeforeEnqueue(message) {
|
|
467
467
|
return message;
|
|
468
468
|
}
|
|
469
|
+
async flushStorage() {}
|
|
469
470
|
enqueue(type, _message, options) {
|
|
470
471
|
this.wrap(()=>{
|
|
471
472
|
if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
@@ -581,11 +582,12 @@ class PostHogCoreStateless {
|
|
|
581
582
|
while(queue.length > 0 && sentMessages.length < originalQueueLength){
|
|
582
583
|
const batchItems = queue.slice(0, this.maxBatchSize);
|
|
583
584
|
const batchMessages = batchItems.map((item)=>item.message);
|
|
584
|
-
const persistQueueChange = ()=>{
|
|
585
|
+
const persistQueueChange = async ()=>{
|
|
585
586
|
const refreshedQueue = this.getPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.Queue) || [];
|
|
586
587
|
const newQueue = refreshedQueue.slice(batchItems.length);
|
|
587
588
|
this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.Queue, newQueue);
|
|
588
589
|
queue = newQueue;
|
|
590
|
+
await this.flushStorage();
|
|
589
591
|
};
|
|
590
592
|
const data = {
|
|
591
593
|
api_key: this.apiKey,
|
|
@@ -621,11 +623,11 @@ class PostHogCoreStateless {
|
|
|
621
623
|
this._logger.warn(`Received 413 when sending batch of size ${batchMessages.length}, reducing batch size to ${this.maxBatchSize}`);
|
|
622
624
|
continue;
|
|
623
625
|
}
|
|
624
|
-
if (!(err instanceof PostHogFetchNetworkError)) persistQueueChange();
|
|
626
|
+
if (!(err instanceof PostHogFetchNetworkError)) await persistQueueChange();
|
|
625
627
|
this._events.emit('error', err);
|
|
626
628
|
throw err;
|
|
627
629
|
}
|
|
628
|
-
persistQueueChange();
|
|
630
|
+
await persistQueueChange();
|
|
629
631
|
sentMessages.push(...batchMessages);
|
|
630
632
|
}
|
|
631
633
|
this._events.emit('flush', sentMessages);
|
|
@@ -435,6 +435,7 @@ class PostHogCoreStateless {
|
|
|
435
435
|
processBeforeEnqueue(message) {
|
|
436
436
|
return message;
|
|
437
437
|
}
|
|
438
|
+
async flushStorage() {}
|
|
438
439
|
enqueue(type, _message, options) {
|
|
439
440
|
this.wrap(()=>{
|
|
440
441
|
if (this.optedOut) return void this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
@@ -550,11 +551,12 @@ class PostHogCoreStateless {
|
|
|
550
551
|
while(queue.length > 0 && sentMessages.length < originalQueueLength){
|
|
551
552
|
const batchItems = queue.slice(0, this.maxBatchSize);
|
|
552
553
|
const batchMessages = batchItems.map((item)=>item.message);
|
|
553
|
-
const persistQueueChange = ()=>{
|
|
554
|
+
const persistQueueChange = async ()=>{
|
|
554
555
|
const refreshedQueue = this.getPersistedProperty(PostHogPersistedProperty.Queue) || [];
|
|
555
556
|
const newQueue = refreshedQueue.slice(batchItems.length);
|
|
556
557
|
this.setPersistedProperty(PostHogPersistedProperty.Queue, newQueue);
|
|
557
558
|
queue = newQueue;
|
|
559
|
+
await this.flushStorage();
|
|
558
560
|
};
|
|
559
561
|
const data = {
|
|
560
562
|
api_key: this.apiKey,
|
|
@@ -590,11 +592,11 @@ class PostHogCoreStateless {
|
|
|
590
592
|
this._logger.warn(`Received 413 when sending batch of size ${batchMessages.length}, reducing batch size to ${this.maxBatchSize}`);
|
|
591
593
|
continue;
|
|
592
594
|
}
|
|
593
|
-
if (!(err instanceof PostHogFetchNetworkError)) persistQueueChange();
|
|
595
|
+
if (!(err instanceof PostHogFetchNetworkError)) await persistQueueChange();
|
|
594
596
|
this._events.emit('error', err);
|
|
595
597
|
throw err;
|
|
596
598
|
}
|
|
597
|
-
persistQueueChange();
|
|
599
|
+
await persistQueueChange();
|
|
598
600
|
sentMessages.push(...batchMessages);
|
|
599
601
|
}
|
|
600
602
|
this._events.emit('flush', sentMessages);
|
package/dist/posthog-core.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
10
10
|
private _sessionMaxLengthSeconds;
|
|
11
11
|
protected sessionProps: PostHogEventProperties;
|
|
12
12
|
protected _personProfiles: 'always' | 'identified_only' | 'never';
|
|
13
|
+
protected _cachedPersonProperties: string | null;
|
|
13
14
|
constructor(apiKey: string, options?: PostHogCoreOptions);
|
|
14
15
|
protected setupBootstrap(options?: Partial<PostHogCoreOptions>): void;
|
|
15
16
|
private clearProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-core.d.ts","sourceRoot":"","sources":["../src/posthog-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,mBAAmB,EACnB,gBAA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aceObject.Pos
|
|
|
39
39
|
...options,
|
|
40
40
|
disableGeoip: disableGeoipOption,
|
|
41
41
|
featureFlagsRequestTimeoutMs
|
|
42
|
-
}), this.flagCallReported = {}, this._sessionMaxLengthSeconds = 86400, this.sessionProps = {};
|
|
42
|
+
}), this.flagCallReported = {}, this._sessionMaxLengthSeconds = 86400, this.sessionProps = {}, this._cachedPersonProperties = null;
|
|
43
43
|
this.sendFeatureFlagEvent = options?.sendFeatureFlagEvent ?? true;
|
|
44
44
|
this._sessionExpirationTimeSeconds = options?.sessionExpirationTimeSeconds ?? 1800;
|
|
45
45
|
this._personProfiles = options?.personProfiles ?? 'identified_only';
|
|
@@ -94,6 +94,7 @@ class PostHogCore extends external_posthog_core_stateless_js_namespaceObject.Pos
|
|
|
94
94
|
...propertiesToKeep || []
|
|
95
95
|
];
|
|
96
96
|
this.clearProps();
|
|
97
|
+
this._cachedPersonProperties = null;
|
|
97
98
|
for (const key of Object.keys(external_types_js_namespaceObject.PostHogPersistedProperty))if (!allPropertiesToKeep.includes(external_types_js_namespaceObject.PostHogPersistedProperty[key])) this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty[key], null);
|
|
98
99
|
this.reloadFeatureFlags();
|
|
99
100
|
});
|
|
@@ -176,13 +177,16 @@ class PostHogCore extends external_posthog_core_stateless_js_namespaceObject.Pos
|
|
|
176
177
|
...(0, external_posthog_core_stateless_js_namespaceObject.maybeAdd)('$set', userProps),
|
|
177
178
|
...(0, external_posthog_core_stateless_js_namespaceObject.maybeAdd)('$set_once', userPropsOnce)
|
|
178
179
|
});
|
|
180
|
+
const userPropsObj = (0, index_js_namespaceObject.isObject)(userProps) ? userProps : void 0;
|
|
181
|
+
const userPropsOnceObj = (0, index_js_namespaceObject.isObject)(userPropsOnce) ? userPropsOnce : void 0;
|
|
179
182
|
if (distinctId !== previousDistinctId) {
|
|
180
183
|
this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.AnonymousId, previousDistinctId);
|
|
181
184
|
this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.DistinctId, distinctId);
|
|
182
185
|
this.setPersistedProperty(external_types_js_namespaceObject.PostHogPersistedProperty.PersonMode, 'identified');
|
|
183
186
|
this.reloadFeatureFlags();
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
super.identifyStateless(distinctId, allProperties, options);
|
|
188
|
+
this._cachedPersonProperties = (0, index_js_namespaceObject.getPersonPropertiesHash)(distinctId, userPropsObj, userPropsOnceObj);
|
|
189
|
+
} else if (userPropsObj || userPropsOnceObj) this.setPersonProperties(userPropsObj, userPropsOnceObj);
|
|
186
190
|
});
|
|
187
191
|
}
|
|
188
192
|
capture(event, properties, options) {
|
|
@@ -635,6 +639,8 @@ class PostHogCore extends external_posthog_core_stateless_js_namespaceObject.Pos
|
|
|
635
639
|
const isSetOnceEmpty = (0, index_js_namespaceObject.isNullish)(userPropertiesToSetOnce) || (0, index_js_namespaceObject.isEmptyObject)(userPropertiesToSetOnce);
|
|
636
640
|
if (isSetEmpty && isSetOnceEmpty) return;
|
|
637
641
|
if (!this._requirePersonProcessing('posthog.setPersonProperties')) return;
|
|
642
|
+
const hash = (0, index_js_namespaceObject.getPersonPropertiesHash)(this.getDistinctId(), userPropertiesToSet, userPropertiesToSetOnce);
|
|
643
|
+
if (this._cachedPersonProperties === hash) return void this._logger.info('A duplicate setPersonProperties call was made with the same properties. It has been ignored.');
|
|
638
644
|
const mergedProperties = {
|
|
639
645
|
...userPropertiesToSetOnce || {},
|
|
640
646
|
...userPropertiesToSet || {}
|
|
@@ -644,6 +650,7 @@ class PostHogCore extends external_posthog_core_stateless_js_namespaceObject.Pos
|
|
|
644
650
|
$set: userPropertiesToSet || {},
|
|
645
651
|
$set_once: userPropertiesToSetOnce || {}
|
|
646
652
|
});
|
|
653
|
+
this._cachedPersonProperties = hash;
|
|
647
654
|
});
|
|
648
655
|
}
|
|
649
656
|
processBeforeEnqueue(message) {
|
package/dist/posthog-core.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createFlagsResponseFromFlagsAndPayloads, getFeatureFlagValue, getFlagVa
|
|
|
2
2
|
import { Compression, FeatureFlagError, PostHogPersistedProperty } from "./types.mjs";
|
|
3
3
|
import { PostHogCoreStateless, QuotaLimitedFeature, maybeAdd } from "./posthog-core-stateless.mjs";
|
|
4
4
|
import { uuidv7 } from "./vendor/uuidv7.mjs";
|
|
5
|
-
import { isEmptyObject, isNullish, isPlainError } from "./utils/index.mjs";
|
|
5
|
+
import { getPersonPropertiesHash, isEmptyObject, isNullish, isObject, isPlainError } from "./utils/index.mjs";
|
|
6
6
|
class PostHogCore extends PostHogCoreStateless {
|
|
7
7
|
constructor(apiKey, options){
|
|
8
8
|
const disableGeoipOption = options?.disableGeoip ?? false;
|
|
@@ -11,7 +11,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
11
11
|
...options,
|
|
12
12
|
disableGeoip: disableGeoipOption,
|
|
13
13
|
featureFlagsRequestTimeoutMs
|
|
14
|
-
}), this.flagCallReported = {}, this._sessionMaxLengthSeconds = 86400, this.sessionProps = {};
|
|
14
|
+
}), this.flagCallReported = {}, this._sessionMaxLengthSeconds = 86400, this.sessionProps = {}, this._cachedPersonProperties = null;
|
|
15
15
|
this.sendFeatureFlagEvent = options?.sendFeatureFlagEvent ?? true;
|
|
16
16
|
this._sessionExpirationTimeSeconds = options?.sessionExpirationTimeSeconds ?? 1800;
|
|
17
17
|
this._personProfiles = options?.personProfiles ?? 'identified_only';
|
|
@@ -66,6 +66,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
66
66
|
...propertiesToKeep || []
|
|
67
67
|
];
|
|
68
68
|
this.clearProps();
|
|
69
|
+
this._cachedPersonProperties = null;
|
|
69
70
|
for (const key of Object.keys(PostHogPersistedProperty))if (!allPropertiesToKeep.includes(PostHogPersistedProperty[key])) this.setPersistedProperty(PostHogPersistedProperty[key], null);
|
|
70
71
|
this.reloadFeatureFlags();
|
|
71
72
|
});
|
|
@@ -148,13 +149,16 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
148
149
|
...maybeAdd('$set', userProps),
|
|
149
150
|
...maybeAdd('$set_once', userPropsOnce)
|
|
150
151
|
});
|
|
152
|
+
const userPropsObj = isObject(userProps) ? userProps : void 0;
|
|
153
|
+
const userPropsOnceObj = isObject(userPropsOnce) ? userPropsOnce : void 0;
|
|
151
154
|
if (distinctId !== previousDistinctId) {
|
|
152
155
|
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId);
|
|
153
156
|
this.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
|
|
154
157
|
this.setPersistedProperty(PostHogPersistedProperty.PersonMode, 'identified');
|
|
155
158
|
this.reloadFeatureFlags();
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
super.identifyStateless(distinctId, allProperties, options);
|
|
160
|
+
this._cachedPersonProperties = getPersonPropertiesHash(distinctId, userPropsObj, userPropsOnceObj);
|
|
161
|
+
} else if (userPropsObj || userPropsOnceObj) this.setPersonProperties(userPropsObj, userPropsOnceObj);
|
|
158
162
|
});
|
|
159
163
|
}
|
|
160
164
|
capture(event, properties, options) {
|
|
@@ -607,6 +611,8 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
607
611
|
const isSetOnceEmpty = isNullish(userPropertiesToSetOnce) || isEmptyObject(userPropertiesToSetOnce);
|
|
608
612
|
if (isSetEmpty && isSetOnceEmpty) return;
|
|
609
613
|
if (!this._requirePersonProcessing('posthog.setPersonProperties')) return;
|
|
614
|
+
const hash = getPersonPropertiesHash(this.getDistinctId(), userPropertiesToSet, userPropertiesToSetOnce);
|
|
615
|
+
if (this._cachedPersonProperties === hash) return void this._logger.info('A duplicate setPersonProperties call was made with the same properties. It has been ignored.');
|
|
610
616
|
const mergedProperties = {
|
|
611
617
|
...userPropertiesToSetOnce || {},
|
|
612
618
|
...userPropertiesToSet || {}
|
|
@@ -616,6 +622,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
616
622
|
$set: userPropertiesToSet || {},
|
|
617
623
|
$set_once: userPropertiesToSetOnce || {}
|
|
618
624
|
});
|
|
625
|
+
this._cachedPersonProperties = hash;
|
|
619
626
|
});
|
|
620
627
|
}
|
|
621
628
|
processBeforeEnqueue(message) {
|
|
@@ -1,6 +1,17 @@
|
|
|
1
|
+
import type { JsonType } from '../types';
|
|
1
2
|
export declare function includes(str: string, needle: string): boolean;
|
|
2
3
|
export declare function includes<T>(arr: T[], needle: T): boolean;
|
|
3
4
|
export declare const trim: (str: string) => string;
|
|
4
5
|
export declare const stripLeadingDollar: (s: string) => string;
|
|
5
6
|
export declare function isDistinctIdStringLike(value: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a hash string from distinct_id and person properties.
|
|
9
|
+
* Used to detect if person properties have changed to avoid duplicate $set events.
|
|
10
|
+
* Uses sorted keys to ensure consistent ordering regardless of object construction order.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPersonPropertiesHash(distinct_id: string, userPropertiesToSet?: {
|
|
13
|
+
[key: string]: JsonType;
|
|
14
|
+
}, userPropertiesToSetOnce?: {
|
|
15
|
+
[key: string]: JsonType;
|
|
16
|
+
}): string;
|
|
6
17
|
//# sourceMappingURL=string-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;AAC9D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAA;AAKzD,eAAO,MAAM,IAAI,GAAa,KAAK,MAAM,KAAG,MAM3C,CAAA;AAID,eAAO,MAAM,kBAAkB,GAAa,GAAG,MAAM,KAAG,MAEvD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D"}
|
|
1
|
+
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAA;AAC9D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAA;AAKzD,eAAO,MAAM,IAAI,GAAa,KAAK,MAAM,KAAG,MAM3C,CAAA;AAID,eAAO,MAAM,kBAAkB,GAAa,GAAG,MAAM,KAAG,MAEvD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE7D;AAuBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,mBAAmB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,EACjD,uBAAuB,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,GACpD,MAAM,CAMR"}
|
|
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getPersonPropertiesHash: ()=>getPersonPropertiesHash,
|
|
27
28
|
includes: ()=>includes,
|
|
28
29
|
isDistinctIdStringLike: ()=>isDistinctIdStringLike,
|
|
29
30
|
stripLeadingDollar: ()=>stripLeadingDollar,
|
|
@@ -44,11 +45,28 @@ function isDistinctIdStringLike(value) {
|
|
|
44
45
|
'distinctid'
|
|
45
46
|
].includes(value.toLowerCase());
|
|
46
47
|
}
|
|
48
|
+
function deepSortKeys(value) {
|
|
49
|
+
if (null === value || 'object' != typeof value) return value;
|
|
50
|
+
if (Array.isArray(value)) return value.map(deepSortKeys);
|
|
51
|
+
return Object.keys(value).sort().reduce((acc, key)=>{
|
|
52
|
+
acc[key] = deepSortKeys(value[key]);
|
|
53
|
+
return acc;
|
|
54
|
+
}, {});
|
|
55
|
+
}
|
|
56
|
+
function getPersonPropertiesHash(distinct_id, userPropertiesToSet, userPropertiesToSetOnce) {
|
|
57
|
+
return JSON.stringify({
|
|
58
|
+
distinct_id,
|
|
59
|
+
userPropertiesToSet: userPropertiesToSet ? deepSortKeys(userPropertiesToSet) : void 0,
|
|
60
|
+
userPropertiesToSetOnce: userPropertiesToSetOnce ? deepSortKeys(userPropertiesToSetOnce) : void 0
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
exports.getPersonPropertiesHash = __webpack_exports__.getPersonPropertiesHash;
|
|
47
64
|
exports.includes = __webpack_exports__.includes;
|
|
48
65
|
exports.isDistinctIdStringLike = __webpack_exports__.isDistinctIdStringLike;
|
|
49
66
|
exports.stripLeadingDollar = __webpack_exports__.stripLeadingDollar;
|
|
50
67
|
exports.trim = __webpack_exports__.trim;
|
|
51
68
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
69
|
+
"getPersonPropertiesHash",
|
|
52
70
|
"includes",
|
|
53
71
|
"isDistinctIdStringLike",
|
|
54
72
|
"stripLeadingDollar",
|
|
@@ -13,4 +13,19 @@ function isDistinctIdStringLike(value) {
|
|
|
13
13
|
'distinctid'
|
|
14
14
|
].includes(value.toLowerCase());
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
function deepSortKeys(value) {
|
|
17
|
+
if (null === value || 'object' != typeof value) return value;
|
|
18
|
+
if (Array.isArray(value)) return value.map(deepSortKeys);
|
|
19
|
+
return Object.keys(value).sort().reduce((acc, key)=>{
|
|
20
|
+
acc[key] = deepSortKeys(value[key]);
|
|
21
|
+
return acc;
|
|
22
|
+
}, {});
|
|
23
|
+
}
|
|
24
|
+
function getPersonPropertiesHash(distinct_id, userPropertiesToSet, userPropertiesToSetOnce) {
|
|
25
|
+
return JSON.stringify({
|
|
26
|
+
distinct_id,
|
|
27
|
+
userPropertiesToSet: userPropertiesToSet ? deepSortKeys(userPropertiesToSet) : void 0,
|
|
28
|
+
userPropertiesToSetOnce: userPropertiesToSetOnce ? deepSortKeys(userPropertiesToSetOnce) : void 0
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { getPersonPropertiesHash, includes, isDistinctIdStringLike, stripLeadingDollar, trim };
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import { DOMExceptionCoercer, ErrorEventCoercer, ErrorCoercer, ObjectCoercer, St
|
|
|
2
2
|
import { PrimitiveCoercer } from './coercers/primitive-coercer'
|
|
3
3
|
import { PromiseRejectionEventCoercer } from './coercers/promise-rejection-event'
|
|
4
4
|
import { ErrorPropertiesBuilder } from './error-properties-builder'
|
|
5
|
+
import { createStackParser } from './parsers'
|
|
5
6
|
import { ExceptionLike } from './types'
|
|
6
7
|
|
|
7
8
|
describe('ErrorPropertiesBuilder', () => {
|
|
@@ -24,7 +25,7 @@ describe('ErrorPropertiesBuilder', () => {
|
|
|
24
25
|
new StringCoercer(),
|
|
25
26
|
new PrimitiveCoercer(),
|
|
26
27
|
],
|
|
27
|
-
|
|
28
|
+
createStackParser('web:javascript'),
|
|
28
29
|
[]
|
|
29
30
|
)
|
|
30
31
|
|
|
@@ -11,7 +11,7 @@ describe('ErrorPropertiesBuilder', () => {
|
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
function parseStack(error: Error): StackFrame[] | undefined {
|
|
14
|
-
const ctx = {}
|
|
14
|
+
const ctx = { skipFirstLines: 1 }
|
|
15
15
|
//@ts-expect-error: testing private method
|
|
16
16
|
const exception = errorPropertiesBuilder.parseStacktrace(
|
|
17
17
|
{
|
|
@@ -34,7 +34,7 @@ export class ErrorPropertiesBuilder {
|
|
|
34
34
|
}
|
|
35
35
|
const coercingContext: CoercingContext = this.buildCoercingContext(mechanism, hint, 0)
|
|
36
36
|
const exceptionWithCause = coercingContext.apply(input)
|
|
37
|
-
const parsingContext: ParsingContext = this.buildParsingContext()
|
|
37
|
+
const parsingContext: ParsingContext = this.buildParsingContext(hint)
|
|
38
38
|
const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext)
|
|
39
39
|
const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism)
|
|
40
40
|
return {
|
|
@@ -68,7 +68,7 @@ export class ErrorPropertiesBuilder {
|
|
|
68
68
|
}
|
|
69
69
|
let stack: StackFrame[] | undefined = undefined
|
|
70
70
|
if (err.stack != '' && err.stack != null) {
|
|
71
|
-
stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ?
|
|
71
|
+
stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? ctx.skipFirstLines : 0), ctx.chunkIdMap)
|
|
72
72
|
}
|
|
73
73
|
return { ...err, cause, stack }
|
|
74
74
|
}
|
|
@@ -128,14 +128,15 @@ export class ErrorPropertiesBuilder {
|
|
|
128
128
|
return exceptionList
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
private buildParsingContext(): ParsingContext {
|
|
131
|
+
private buildParsingContext(hint: EventHint): ParsingContext {
|
|
132
132
|
const context = {
|
|
133
133
|
chunkIdMap: getFilenameToChunkIdMap(this.stackParser),
|
|
134
|
+
skipFirstLines: hint.skipFirstLines ?? 1,
|
|
134
135
|
} as ParsingContext
|
|
135
136
|
return context
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
public buildCoercingContext(mechanism: Mechanism, hint: EventHint, depth: number = 0): CoercingContext {
|
|
139
140
|
const coerce = (input: unknown, depth: number) => {
|
|
140
141
|
if (depth <= MAX_CAUSE_RECURSION) {
|
|
141
142
|
const ctx = this.buildCoercingContext(mechanism, hint, depth)
|
|
@@ -19,6 +19,7 @@ export interface PolymorphicEvent {
|
|
|
19
19
|
export interface EventHint {
|
|
20
20
|
mechanism?: Partial<Mechanism>
|
|
21
21
|
syntheticException?: Error | null
|
|
22
|
+
skipFirstLines?: number
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export interface PreviouslyCapturedError {
|
|
@@ -86,6 +87,7 @@ export type ChunkIdMapType = Record<string, string>
|
|
|
86
87
|
|
|
87
88
|
export interface ParsingContext {
|
|
88
89
|
chunkIdMap?: ChunkIdMapType
|
|
90
|
+
skipFirstLines: number
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
interface Coercer<T, U, C> {
|
|
@@ -862,6 +862,18 @@ export abstract class PostHogCoreStateless {
|
|
|
862
862
|
return message
|
|
863
863
|
}
|
|
864
864
|
|
|
865
|
+
/**
|
|
866
|
+
* Hook that allows subclasses to wait for storage operations to complete.
|
|
867
|
+
* This is called after queue changes are persisted during flush to ensure
|
|
868
|
+
* data is safely written to storage before considering events as sent.
|
|
869
|
+
*
|
|
870
|
+
* Override this in implementations with async storage (e.g., React Native)
|
|
871
|
+
* to prevent duplicate events on app crash/restart scenarios.
|
|
872
|
+
*/
|
|
873
|
+
protected async flushStorage(): Promise<void> {
|
|
874
|
+
// Default: no-op for sync storage implementations
|
|
875
|
+
}
|
|
876
|
+
|
|
865
877
|
protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void {
|
|
866
878
|
this.wrap(() => {
|
|
867
879
|
if (this.optedOut) {
|
|
@@ -1078,11 +1090,13 @@ export abstract class PostHogCoreStateless {
|
|
|
1078
1090
|
const batchItems = queue.slice(0, this.maxBatchSize)
|
|
1079
1091
|
const batchMessages = batchItems.map((item) => item.message)
|
|
1080
1092
|
|
|
1081
|
-
const persistQueueChange = (): void => {
|
|
1093
|
+
const persistQueueChange = async (): Promise<void> => {
|
|
1082
1094
|
const refreshedQueue = this.getPersistedProperty<PostHogQueueItem[]>(PostHogPersistedProperty.Queue) || []
|
|
1083
1095
|
const newQueue = refreshedQueue.slice(batchItems.length)
|
|
1084
1096
|
this.setPersistedProperty<PostHogQueueItem[]>(PostHogPersistedProperty.Queue, newQueue)
|
|
1085
1097
|
queue = newQueue
|
|
1098
|
+
// Wait for storage to complete to prevent duplicate events on app crash
|
|
1099
|
+
await this.flushStorage()
|
|
1086
1100
|
}
|
|
1087
1101
|
|
|
1088
1102
|
const data: Record<string, any> = {
|
|
@@ -1137,14 +1151,14 @@ export abstract class PostHogCoreStateless {
|
|
|
1137
1151
|
// depending on the error type, eg a malformed JSON or broken queue, it'll always return an error
|
|
1138
1152
|
// and this will be an endless loop, in this case, if the error isn't a network issue, we always remove the items from the queue
|
|
1139
1153
|
if (!(err instanceof PostHogFetchNetworkError)) {
|
|
1140
|
-
persistQueueChange()
|
|
1154
|
+
await persistQueueChange()
|
|
1141
1155
|
}
|
|
1142
1156
|
this._events.emit('error', err)
|
|
1143
1157
|
|
|
1144
1158
|
throw err
|
|
1145
1159
|
}
|
|
1146
1160
|
|
|
1147
|
-
persistQueueChange()
|
|
1161
|
+
await persistQueueChange()
|
|
1148
1162
|
|
|
1149
1163
|
sentMessages.push(...batchMessages)
|
|
1150
1164
|
}
|
package/src/posthog-core.ts
CHANGED
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
import { Compression, FeatureFlagError, PostHogPersistedProperty } from './types'
|
|
31
31
|
import { maybeAdd, PostHogCoreStateless, QuotaLimitedFeature } from './posthog-core-stateless'
|
|
32
32
|
import { uuidv7 } from './vendor/uuidv7'
|
|
33
|
-
import { isEmptyObject, isNullish, isPlainError } from './utils'
|
|
33
|
+
import { isEmptyObject, isNullish, isPlainError, getPersonPropertiesHash, isObject } from './utils'
|
|
34
34
|
|
|
35
35
|
export abstract class PostHogCore extends PostHogCoreStateless {
|
|
36
36
|
// options
|
|
@@ -47,6 +47,9 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
47
47
|
// person profiles
|
|
48
48
|
protected _personProfiles: 'always' | 'identified_only' | 'never'
|
|
49
49
|
|
|
50
|
+
// cache for person properties to avoid duplicate $set events
|
|
51
|
+
protected _cachedPersonProperties: string | null = null
|
|
52
|
+
|
|
50
53
|
constructor(apiKey: string, options?: PostHogCoreOptions) {
|
|
51
54
|
// Default for stateful mode is to not disable geoip. Only override if explicitly set
|
|
52
55
|
const disableGeoipOption = options?.disableGeoip ?? false
|
|
@@ -130,6 +133,9 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
130
133
|
// clean up props
|
|
131
134
|
this.clearProps()
|
|
132
135
|
|
|
136
|
+
// clear cached person properties
|
|
137
|
+
this._cachedPersonProperties = null
|
|
138
|
+
|
|
133
139
|
for (const key of <(keyof typeof PostHogPersistedProperty)[]>Object.keys(PostHogPersistedProperty)) {
|
|
134
140
|
if (!allPropertiesToKeep.includes(PostHogPersistedProperty[key])) {
|
|
135
141
|
this.setPersistedProperty((PostHogPersistedProperty as any)[key], null)
|
|
@@ -294,6 +300,10 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
294
300
|
...maybeAdd('$set_once', userPropsOnce),
|
|
295
301
|
})
|
|
296
302
|
|
|
303
|
+
// Safely cast userProps and userPropsOnce to object types for hash and setPersonProperties
|
|
304
|
+
const userPropsObj = isObject(userProps) ? (userProps as { [key: string]: JsonType }) : undefined
|
|
305
|
+
const userPropsOnceObj = isObject(userPropsOnce) ? (userPropsOnce as { [key: string]: JsonType }) : undefined
|
|
306
|
+
|
|
297
307
|
if (distinctId !== previousDistinctId) {
|
|
298
308
|
// We keep the AnonymousId to be used by flags calls and identify to link the previousId
|
|
299
309
|
this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId)
|
|
@@ -301,9 +311,16 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
301
311
|
// Mark the user as identified
|
|
302
312
|
this.setPersistedProperty(PostHogPersistedProperty.PersonMode, 'identified')
|
|
303
313
|
this.reloadFeatureFlags()
|
|
304
|
-
}
|
|
305
314
|
|
|
306
|
-
|
|
315
|
+
super.identifyStateless(distinctId, allProperties, options)
|
|
316
|
+
|
|
317
|
+
// Update the cached person properties hash
|
|
318
|
+
this._cachedPersonProperties = getPersonPropertiesHash(distinctId, userPropsObj, userPropsOnceObj)
|
|
319
|
+
} else if (userPropsObj || userPropsOnceObj) {
|
|
320
|
+
// If the distinct_id is not changing, but we have user properties to set, we can check if they have changed
|
|
321
|
+
// and if so, send a $set event
|
|
322
|
+
this.setPersonProperties(userPropsObj, userPropsOnceObj)
|
|
323
|
+
}
|
|
307
324
|
})
|
|
308
325
|
}
|
|
309
326
|
|
|
@@ -1218,12 +1235,24 @@ export abstract class PostHogCore extends PostHogCoreStateless {
|
|
|
1218
1235
|
return
|
|
1219
1236
|
}
|
|
1220
1237
|
|
|
1238
|
+
const hash = getPersonPropertiesHash(this.getDistinctId(), userPropertiesToSet, userPropertiesToSetOnce)
|
|
1239
|
+
|
|
1240
|
+
// If exactly this $set call has been sent before, don't send it again - determine based on hash of properties
|
|
1241
|
+
if (this._cachedPersonProperties === hash) {
|
|
1242
|
+
this._logger.info(
|
|
1243
|
+
'A duplicate setPersonProperties call was made with the same properties. It has been ignored.'
|
|
1244
|
+
)
|
|
1245
|
+
return
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1221
1248
|
// Update person properties for feature flags evaluation
|
|
1222
1249
|
// Merge setOnce first, then set to allow overwriting
|
|
1223
1250
|
const mergedProperties = { ...(userPropertiesToSetOnce || {}), ...(userPropertiesToSet || {}) }
|
|
1224
1251
|
this.setPersonPropertiesForFlags(mergedProperties, reloadFeatureFlags)
|
|
1225
1252
|
|
|
1226
1253
|
this.capture('$set', { $set: userPropertiesToSet || {}, $set_once: userPropertiesToSetOnce || {} })
|
|
1254
|
+
|
|
1255
|
+
this._cachedPersonProperties = hash
|
|
1227
1256
|
})
|
|
1228
1257
|
}
|
|
1229
1258
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getPersonPropertiesHash } from './string-utils'
|
|
2
|
+
|
|
3
|
+
describe('string-utils', () => {
|
|
4
|
+
describe('getPersonPropertiesHash', () => {
|
|
5
|
+
it('should return consistent hash regardless of top-level key order', () => {
|
|
6
|
+
const hash1 = getPersonPropertiesHash('user-1', { b: 'value-b', a: 'value-a' })
|
|
7
|
+
const hash2 = getPersonPropertiesHash('user-1', { a: 'value-a', b: 'value-b' })
|
|
8
|
+
expect(hash1).toBe(hash2)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('should return consistent hash regardless of nested object key order', () => {
|
|
12
|
+
const hash1 = getPersonPropertiesHash('user-1', {
|
|
13
|
+
nested: { z: 1, a: 2 },
|
|
14
|
+
})
|
|
15
|
+
const hash2 = getPersonPropertiesHash('user-1', {
|
|
16
|
+
nested: { a: 2, z: 1 },
|
|
17
|
+
})
|
|
18
|
+
expect(hash1).toBe(hash2)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should return consistent hash for deeply nested objects', () => {
|
|
22
|
+
const hash1 = getPersonPropertiesHash('user-1', {
|
|
23
|
+
level1: {
|
|
24
|
+
level2: {
|
|
25
|
+
level3: { c: 3, a: 1, b: 2 },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
const hash2 = getPersonPropertiesHash('user-1', {
|
|
30
|
+
level1: {
|
|
31
|
+
level2: {
|
|
32
|
+
level3: { a: 1, b: 2, c: 3 },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
})
|
|
36
|
+
expect(hash1).toBe(hash2)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
it('should handle arrays with nested objects', () => {
|
|
40
|
+
const hash1 = getPersonPropertiesHash('user-1', {
|
|
41
|
+
items: [
|
|
42
|
+
{ z: 1, a: 2 },
|
|
43
|
+
{ y: 3, b: 4 },
|
|
44
|
+
],
|
|
45
|
+
})
|
|
46
|
+
const hash2 = getPersonPropertiesHash('user-1', {
|
|
47
|
+
items: [
|
|
48
|
+
{ a: 2, z: 1 },
|
|
49
|
+
{ b: 4, y: 3 },
|
|
50
|
+
],
|
|
51
|
+
})
|
|
52
|
+
expect(hash1).toBe(hash2)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('should preserve array order (not sort array elements)', () => {
|
|
56
|
+
const hash1 = getPersonPropertiesHash('user-1', {
|
|
57
|
+
items: [1, 2, 3],
|
|
58
|
+
})
|
|
59
|
+
const hash2 = getPersonPropertiesHash('user-1', {
|
|
60
|
+
items: [3, 2, 1],
|
|
61
|
+
})
|
|
62
|
+
expect(hash1).not.toBe(hash2)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should handle null values', () => {
|
|
66
|
+
const hash1 = getPersonPropertiesHash('user-1', { a: null, b: 'value' })
|
|
67
|
+
const hash2 = getPersonPropertiesHash('user-1', { b: 'value', a: null })
|
|
68
|
+
expect(hash1).toBe(hash2)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('should handle primitive values', () => {
|
|
72
|
+
const hash1 = getPersonPropertiesHash('user-1', {
|
|
73
|
+
str: 'string',
|
|
74
|
+
num: 42,
|
|
75
|
+
bool: true,
|
|
76
|
+
nil: null,
|
|
77
|
+
})
|
|
78
|
+
const hash2 = getPersonPropertiesHash('user-1', {
|
|
79
|
+
nil: null,
|
|
80
|
+
bool: true,
|
|
81
|
+
num: 42,
|
|
82
|
+
str: 'string',
|
|
83
|
+
})
|
|
84
|
+
expect(hash1).toBe(hash2)
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('should handle userPropertiesToSetOnce with nested objects', () => {
|
|
88
|
+
const hash1 = getPersonPropertiesHash('user-1', undefined, {
|
|
89
|
+
nested: { z: 1, a: 2 },
|
|
90
|
+
})
|
|
91
|
+
const hash2 = getPersonPropertiesHash('user-1', undefined, {
|
|
92
|
+
nested: { a: 2, z: 1 },
|
|
93
|
+
})
|
|
94
|
+
expect(hash1).toBe(hash2)
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
it('should handle both userPropertiesToSet and userPropertiesToSetOnce', () => {
|
|
98
|
+
const hash1 = getPersonPropertiesHash('user-1', { nested: { z: 1, a: 2 } }, { other: { y: 3, b: 4 } })
|
|
99
|
+
const hash2 = getPersonPropertiesHash('user-1', { nested: { a: 2, z: 1 } }, { other: { b: 4, y: 3 } })
|
|
100
|
+
expect(hash1).toBe(hash2)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it('should return different hash for different distinct_id', () => {
|
|
104
|
+
const hash1 = getPersonPropertiesHash('user-1', { a: 1 })
|
|
105
|
+
const hash2 = getPersonPropertiesHash('user-2', { a: 1 })
|
|
106
|
+
expect(hash1).not.toBe(hash2)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('should return different hash for different property values', () => {
|
|
110
|
+
const hash1 = getPersonPropertiesHash('user-1', { a: 1 })
|
|
111
|
+
const hash2 = getPersonPropertiesHash('user-1', { a: 2 })
|
|
112
|
+
expect(hash1).not.toBe(hash2)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('should handle undefined properties', () => {
|
|
116
|
+
const hash1 = getPersonPropertiesHash('user-1')
|
|
117
|
+
const hash2 = getPersonPropertiesHash('user-1', undefined, undefined)
|
|
118
|
+
expect(hash1).toBe(hash2)
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
})
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { JsonType } from '../types'
|
|
2
|
+
|
|
1
3
|
export function includes(str: string, needle: string): boolean
|
|
2
4
|
export function includes<T>(arr: T[], needle: T): boolean
|
|
3
5
|
export function includes(str: unknown[] | string, needle: unknown): boolean {
|
|
@@ -21,3 +23,41 @@ export const stripLeadingDollar = function (s: string): string {
|
|
|
21
23
|
export function isDistinctIdStringLike(value: string): boolean {
|
|
22
24
|
return ['distinct_id', 'distinctid'].includes(value.toLowerCase())
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Recursively sorts all keys in an object and its nested objects/arrays.
|
|
29
|
+
* Used to ensure deterministic JSON serialization regardless of object construction order.
|
|
30
|
+
*/
|
|
31
|
+
function deepSortKeys(value: JsonType): JsonType {
|
|
32
|
+
if (value === null || typeof value !== 'object') {
|
|
33
|
+
return value
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Array.isArray(value)) {
|
|
37
|
+
return value.map(deepSortKeys)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return Object.keys(value)
|
|
41
|
+
.sort()
|
|
42
|
+
.reduce((acc: { [key: string]: JsonType }, key) => {
|
|
43
|
+
acc[key] = deepSortKeys(value[key])
|
|
44
|
+
return acc
|
|
45
|
+
}, {})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates a hash string from distinct_id and person properties.
|
|
50
|
+
* Used to detect if person properties have changed to avoid duplicate $set events.
|
|
51
|
+
* Uses sorted keys to ensure consistent ordering regardless of object construction order.
|
|
52
|
+
*/
|
|
53
|
+
export function getPersonPropertiesHash(
|
|
54
|
+
distinct_id: string,
|
|
55
|
+
userPropertiesToSet?: { [key: string]: JsonType },
|
|
56
|
+
userPropertiesToSetOnce?: { [key: string]: JsonType }
|
|
57
|
+
): string {
|
|
58
|
+
return JSON.stringify({
|
|
59
|
+
distinct_id,
|
|
60
|
+
userPropertiesToSet: userPropertiesToSet ? deepSortKeys(userPropertiesToSet) : undefined,
|
|
61
|
+
userPropertiesToSetOnce: userPropertiesToSetOnce ? deepSortKeys(userPropertiesToSetOnce) : undefined,
|
|
62
|
+
})
|
|
63
|
+
}
|