posthog-node 5.39.0 → 5.39.2
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/client.d.ts +3 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +78 -17
- package/dist/client.mjs +78 -17
- package/dist/extensions/error-tracking/index.js +1 -1
- package/dist/extensions/error-tracking/index.mjs +1 -1
- package/dist/extensions/express.js +1 -3
- package/dist/extensions/express.mjs +1 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.mjs +1 -1
- package/package.json +2 -2
- package/src/client.ts +109 -19
- package/src/extensions/error-tracking/index.ts +1 -1
- package/src/extensions/express.ts +1 -1
- package/src/version.ts +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -218,7 +218,8 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
218
218
|
*/
|
|
219
219
|
debug(enabled?: boolean): void;
|
|
220
220
|
private _warnIfInvalidCapture;
|
|
221
|
-
private
|
|
221
|
+
private _sendPreparedEvent;
|
|
222
|
+
_capturePreparedEvent(props: EventMessage, immediate: boolean): Promise<void>;
|
|
222
223
|
/**
|
|
223
224
|
* Capture an event manually.
|
|
224
225
|
*
|
|
@@ -1094,6 +1095,7 @@ export declare abstract class PostHogBackendClient extends PostHogCoreStateless
|
|
|
1094
1095
|
properties: PostHogEventProperties;
|
|
1095
1096
|
options: PostHogCaptureOptions;
|
|
1096
1097
|
}>;
|
|
1098
|
+
private _prepareEventMessage;
|
|
1097
1099
|
private _runBeforeSend;
|
|
1098
1100
|
}
|
|
1099
1101
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,gBAAgB,EAGhB,QAAQ,EACR,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EAC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,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAc5C,2BAA2B;IAqCzC,OAAO,CAAC,0BAA0B;YA+BpB,uBAAuB;IAuErC,OAAO,CAAC,gCAAgC;IAqBxC,OAAO,CAAC,kCAAkC;IAe1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACH,gBAAgB,CACd,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,IAAI,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,EAC3B,KAAK,CAAC,EAAE,sBAAsB,GAC7B,IAAI;IAeP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,yBAAyB,CAC7B,KAAK,EAAE,OAAO,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACnD,KAAK,CAAC,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAeH,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC7D,UAAU,EAAE,MAAM,CAAA;QAClB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,sBAAsB,CAAA;QAClC,OAAO,EAAE,qBAAqB,CAAA;KAC/B,CAAC;YAIY,oBAAoB;IA8IlC,OAAO,CAAC,cAAc;CAuBvB"}
|
package/dist/client.js
CHANGED
|
@@ -128,7 +128,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
128
128
|
this.scheduleDebouncedFlush();
|
|
129
129
|
}
|
|
130
130
|
async flush() {
|
|
131
|
-
const flushPromise =
|
|
131
|
+
const flushPromise = this.flushWithPendingPromises();
|
|
132
132
|
const waitUntil = this.options.waitUntil;
|
|
133
133
|
if (waitUntil && !this._waitUntilCycle) try {
|
|
134
134
|
waitUntil(flushPromise.catch(()=>{}));
|
|
@@ -176,7 +176,7 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
176
176
|
async resolveWaitUntilFlush() {
|
|
177
177
|
const resolve = this._consumeWaitUntilCycle();
|
|
178
178
|
try {
|
|
179
|
-
await
|
|
179
|
+
await this.flushWithPendingPromises();
|
|
180
180
|
} catch {} finally{
|
|
181
181
|
resolve?.();
|
|
182
182
|
}
|
|
@@ -215,18 +215,29 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
215
215
|
if ('string' == typeof props) this._logger.warn(stringArgumentWarning);
|
|
216
216
|
if ('$exception' === props.event && !props._originatedFromCaptureException) this._logger.warn(exceptionCaptureWarning);
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
return this.addPendingPromise(this.
|
|
218
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions) {
|
|
219
|
+
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options })=>{
|
|
220
220
|
const captureOptions = {
|
|
221
221
|
timestamp: options.timestamp,
|
|
222
222
|
disableGeoip: options.disableGeoip,
|
|
223
223
|
uuid: options.uuid
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
const message = {
|
|
226
|
+
distinctId,
|
|
227
|
+
event,
|
|
228
|
+
properties: {
|
|
229
|
+
...properties,
|
|
230
|
+
...this.getCommonEventProperties()
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
return immediate ? this.sendImmediate(type, message, captureOptions) : this.enqueue(type, message, captureOptions);
|
|
226
234
|
}).catch((err)=>{
|
|
227
235
|
if (err) console.error(err);
|
|
228
236
|
}));
|
|
229
237
|
}
|
|
238
|
+
_capturePreparedEvent(props, immediate) {
|
|
239
|
+
return this._sendPreparedEvent('capture', props, immediate);
|
|
240
|
+
}
|
|
230
241
|
capture(props) {
|
|
231
242
|
this._warnIfInvalidCapture(props, 'Called capture() with a string as the first argument when an object was expected.', "Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
|
|
232
243
|
this._capturePreparedEvent(props, false);
|
|
@@ -244,8 +255,13 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
244
255
|
$set_once: setOnceProps,
|
|
245
256
|
$anon_distinct_id: $anon_distinct_id ?? void 0
|
|
246
257
|
};
|
|
247
|
-
|
|
258
|
+
this._sendPreparedEvent('identify', {
|
|
259
|
+
distinctId,
|
|
260
|
+
event: '$identify',
|
|
261
|
+
properties: eventProperties,
|
|
248
262
|
disableGeoip
|
|
263
|
+
}, false, {
|
|
264
|
+
includeContextProperties: false
|
|
249
265
|
});
|
|
250
266
|
}
|
|
251
267
|
async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
|
|
@@ -257,8 +273,13 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
257
273
|
$set_once: setOnceProps,
|
|
258
274
|
$anon_distinct_id: $anon_distinct_id ?? void 0
|
|
259
275
|
};
|
|
260
|
-
await
|
|
276
|
+
await this._sendPreparedEvent('identify', {
|
|
277
|
+
distinctId,
|
|
278
|
+
event: '$identify',
|
|
279
|
+
properties: eventProperties,
|
|
261
280
|
disableGeoip
|
|
281
|
+
}, true, {
|
|
282
|
+
includeContextProperties: false
|
|
262
283
|
});
|
|
263
284
|
}
|
|
264
285
|
setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
|
|
@@ -284,13 +305,29 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
284
305
|
});
|
|
285
306
|
}
|
|
286
307
|
alias(data) {
|
|
287
|
-
|
|
308
|
+
this._sendPreparedEvent('alias', {
|
|
309
|
+
distinctId: data.distinctId,
|
|
310
|
+
event: '$create_alias',
|
|
311
|
+
properties: {
|
|
312
|
+
distinct_id: data.distinctId,
|
|
313
|
+
alias: data.alias
|
|
314
|
+
},
|
|
288
315
|
disableGeoip: data.disableGeoip
|
|
316
|
+
}, false, {
|
|
317
|
+
includeContextProperties: false
|
|
289
318
|
});
|
|
290
319
|
}
|
|
291
320
|
async aliasImmediate(data) {
|
|
292
|
-
await
|
|
321
|
+
await this._sendPreparedEvent('alias', {
|
|
322
|
+
distinctId: data.distinctId,
|
|
323
|
+
event: '$create_alias',
|
|
324
|
+
properties: {
|
|
325
|
+
distinct_id: data.distinctId,
|
|
326
|
+
alias: data.alias
|
|
327
|
+
},
|
|
293
328
|
disableGeoip: data.disableGeoip
|
|
329
|
+
}, true, {
|
|
330
|
+
includeContextProperties: false
|
|
294
331
|
});
|
|
295
332
|
}
|
|
296
333
|
isLocalEvaluationReady() {
|
|
@@ -696,14 +733,32 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
696
733
|
return this._featureFlagEvaluationsHost;
|
|
697
734
|
}
|
|
698
735
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
699
|
-
|
|
736
|
+
this._sendPreparedEvent('capture', {
|
|
737
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
738
|
+
event: '$groupidentify',
|
|
739
|
+
properties: {
|
|
740
|
+
$group_type: groupType,
|
|
741
|
+
$group_key: groupKey,
|
|
742
|
+
$group_set: properties || {}
|
|
743
|
+
},
|
|
700
744
|
disableGeoip
|
|
701
|
-
},
|
|
745
|
+
}, false, {
|
|
746
|
+
includeContextProperties: false
|
|
747
|
+
});
|
|
702
748
|
}
|
|
703
749
|
async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
704
|
-
await
|
|
750
|
+
await this._sendPreparedEvent('capture', {
|
|
751
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
752
|
+
event: '$groupidentify',
|
|
753
|
+
properties: {
|
|
754
|
+
$group_type: groupType,
|
|
755
|
+
$group_key: groupKey,
|
|
756
|
+
$group_set: properties || {}
|
|
757
|
+
},
|
|
705
758
|
disableGeoip
|
|
706
|
-
},
|
|
759
|
+
}, true, {
|
|
760
|
+
includeContextProperties: false
|
|
761
|
+
});
|
|
707
762
|
}
|
|
708
763
|
async reloadFeatureFlags() {
|
|
709
764
|
await this.featureFlagsPoller?.loadFeatureFlags(true);
|
|
@@ -883,11 +938,11 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
883
938
|
const syntheticException = new Error('PostHog syntheticException');
|
|
884
939
|
this.addPendingPromise(index_js_default().buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
885
940
|
syntheticException
|
|
886
|
-
}, distinctId, additionalProperties).then((msg)=>this.
|
|
941
|
+
}, distinctId, additionalProperties).then((msg)=>this._capturePreparedEvent({
|
|
887
942
|
...msg,
|
|
888
943
|
uuid,
|
|
889
944
|
flags
|
|
890
|
-
})));
|
|
945
|
+
}, false)));
|
|
891
946
|
}
|
|
892
947
|
}
|
|
893
948
|
async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
|
|
@@ -902,19 +957,25 @@ class PostHogBackendClient extends core_namespaceObject.PostHogCoreStateless {
|
|
|
902
957
|
}
|
|
903
958
|
}
|
|
904
959
|
async prepareEventMessage(props) {
|
|
960
|
+
return this._prepareEventMessage(props);
|
|
961
|
+
}
|
|
962
|
+
async _prepareEventMessage(props, options = {}) {
|
|
905
963
|
const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
906
964
|
const contextData = this.context?.get();
|
|
965
|
+
const includeContextProperties = options.includeContextProperties ?? true;
|
|
907
966
|
let mergedDistinctId = distinctId || contextData?.distinctId;
|
|
908
|
-
const mergedProperties = {
|
|
967
|
+
const mergedProperties = includeContextProperties ? {
|
|
909
968
|
...this.props,
|
|
910
969
|
...contextData?.properties || {},
|
|
911
970
|
...properties || {}
|
|
971
|
+
} : {
|
|
972
|
+
...properties || {}
|
|
912
973
|
};
|
|
913
974
|
if (!mergedDistinctId) {
|
|
914
975
|
mergedDistinctId = (0, core_namespaceObject.uuidv7)();
|
|
915
976
|
mergedProperties.$process_person_profile = false;
|
|
916
977
|
}
|
|
917
|
-
if (contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
|
|
978
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
|
|
918
979
|
const eventMessage = this._runBeforeSend({
|
|
919
980
|
distinctId: mergedDistinctId,
|
|
920
981
|
event,
|
package/dist/client.mjs
CHANGED
|
@@ -89,7 +89,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
89
89
|
this.scheduleDebouncedFlush();
|
|
90
90
|
}
|
|
91
91
|
async flush() {
|
|
92
|
-
const flushPromise =
|
|
92
|
+
const flushPromise = this.flushWithPendingPromises();
|
|
93
93
|
const waitUntil = this.options.waitUntil;
|
|
94
94
|
if (waitUntil && !this._waitUntilCycle) try {
|
|
95
95
|
waitUntil(flushPromise.catch(()=>{}));
|
|
@@ -137,7 +137,7 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
137
137
|
async resolveWaitUntilFlush() {
|
|
138
138
|
const resolve = this._consumeWaitUntilCycle();
|
|
139
139
|
try {
|
|
140
|
-
await
|
|
140
|
+
await this.flushWithPendingPromises();
|
|
141
141
|
} catch {} finally{
|
|
142
142
|
resolve?.();
|
|
143
143
|
}
|
|
@@ -176,18 +176,29 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
176
176
|
if ('string' == typeof props) this._logger.warn(stringArgumentWarning);
|
|
177
177
|
if ('$exception' === props.event && !props._originatedFromCaptureException) this._logger.warn(exceptionCaptureWarning);
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
return this.addPendingPromise(this.
|
|
179
|
+
_sendPreparedEvent(type, props, immediate, prepareOptions) {
|
|
180
|
+
return this.addPendingPromise(this._prepareEventMessage(props, prepareOptions).then(({ distinctId, event, properties, options })=>{
|
|
181
181
|
const captureOptions = {
|
|
182
182
|
timestamp: options.timestamp,
|
|
183
183
|
disableGeoip: options.disableGeoip,
|
|
184
184
|
uuid: options.uuid
|
|
185
185
|
};
|
|
186
|
-
|
|
186
|
+
const message = {
|
|
187
|
+
distinctId,
|
|
188
|
+
event,
|
|
189
|
+
properties: {
|
|
190
|
+
...properties,
|
|
191
|
+
...this.getCommonEventProperties()
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
return immediate ? this.sendImmediate(type, message, captureOptions) : this.enqueue(type, message, captureOptions);
|
|
187
195
|
}).catch((err)=>{
|
|
188
196
|
if (err) console.error(err);
|
|
189
197
|
}));
|
|
190
198
|
}
|
|
199
|
+
_capturePreparedEvent(props, immediate) {
|
|
200
|
+
return this._sendPreparedEvent('capture', props, immediate);
|
|
201
|
+
}
|
|
191
202
|
capture(props) {
|
|
192
203
|
this._warnIfInvalidCapture(props, 'Called capture() with a string as the first argument when an object was expected.', "Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically.");
|
|
193
204
|
this._capturePreparedEvent(props, false);
|
|
@@ -205,8 +216,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
205
216
|
$set_once: setOnceProps,
|
|
206
217
|
$anon_distinct_id: $anon_distinct_id ?? void 0
|
|
207
218
|
};
|
|
208
|
-
|
|
219
|
+
this._sendPreparedEvent('identify', {
|
|
220
|
+
distinctId,
|
|
221
|
+
event: '$identify',
|
|
222
|
+
properties: eventProperties,
|
|
209
223
|
disableGeoip
|
|
224
|
+
}, false, {
|
|
225
|
+
includeContextProperties: false
|
|
210
226
|
});
|
|
211
227
|
}
|
|
212
228
|
async identifyImmediate({ distinctId, properties = {}, disableGeoip }) {
|
|
@@ -218,8 +234,13 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
218
234
|
$set_once: setOnceProps,
|
|
219
235
|
$anon_distinct_id: $anon_distinct_id ?? void 0
|
|
220
236
|
};
|
|
221
|
-
await
|
|
237
|
+
await this._sendPreparedEvent('identify', {
|
|
238
|
+
distinctId,
|
|
239
|
+
event: '$identify',
|
|
240
|
+
properties: eventProperties,
|
|
222
241
|
disableGeoip
|
|
242
|
+
}, true, {
|
|
243
|
+
includeContextProperties: false
|
|
223
244
|
});
|
|
224
245
|
}
|
|
225
246
|
setPersonProperties({ distinctId, properties = {}, propertiesOnce = {} }) {
|
|
@@ -245,13 +266,29 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
245
266
|
});
|
|
246
267
|
}
|
|
247
268
|
alias(data) {
|
|
248
|
-
|
|
269
|
+
this._sendPreparedEvent('alias', {
|
|
270
|
+
distinctId: data.distinctId,
|
|
271
|
+
event: '$create_alias',
|
|
272
|
+
properties: {
|
|
273
|
+
distinct_id: data.distinctId,
|
|
274
|
+
alias: data.alias
|
|
275
|
+
},
|
|
249
276
|
disableGeoip: data.disableGeoip
|
|
277
|
+
}, false, {
|
|
278
|
+
includeContextProperties: false
|
|
250
279
|
});
|
|
251
280
|
}
|
|
252
281
|
async aliasImmediate(data) {
|
|
253
|
-
await
|
|
282
|
+
await this._sendPreparedEvent('alias', {
|
|
283
|
+
distinctId: data.distinctId,
|
|
284
|
+
event: '$create_alias',
|
|
285
|
+
properties: {
|
|
286
|
+
distinct_id: data.distinctId,
|
|
287
|
+
alias: data.alias
|
|
288
|
+
},
|
|
254
289
|
disableGeoip: data.disableGeoip
|
|
290
|
+
}, true, {
|
|
291
|
+
includeContextProperties: false
|
|
255
292
|
});
|
|
256
293
|
}
|
|
257
294
|
isLocalEvaluationReady() {
|
|
@@ -657,14 +694,32 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
657
694
|
return this._featureFlagEvaluationsHost;
|
|
658
695
|
}
|
|
659
696
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
660
|
-
|
|
697
|
+
this._sendPreparedEvent('capture', {
|
|
698
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
699
|
+
event: '$groupidentify',
|
|
700
|
+
properties: {
|
|
701
|
+
$group_type: groupType,
|
|
702
|
+
$group_key: groupKey,
|
|
703
|
+
$group_set: properties || {}
|
|
704
|
+
},
|
|
661
705
|
disableGeoip
|
|
662
|
-
},
|
|
706
|
+
}, false, {
|
|
707
|
+
includeContextProperties: false
|
|
708
|
+
});
|
|
663
709
|
}
|
|
664
710
|
async groupIdentifyImmediate({ groupType, groupKey, properties, distinctId, disableGeoip }) {
|
|
665
|
-
await
|
|
711
|
+
await this._sendPreparedEvent('capture', {
|
|
712
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
713
|
+
event: '$groupidentify',
|
|
714
|
+
properties: {
|
|
715
|
+
$group_type: groupType,
|
|
716
|
+
$group_key: groupKey,
|
|
717
|
+
$group_set: properties || {}
|
|
718
|
+
},
|
|
666
719
|
disableGeoip
|
|
667
|
-
},
|
|
720
|
+
}, true, {
|
|
721
|
+
includeContextProperties: false
|
|
722
|
+
});
|
|
668
723
|
}
|
|
669
724
|
async reloadFeatureFlags() {
|
|
670
725
|
await this.featureFlagsPoller?.loadFeatureFlags(true);
|
|
@@ -844,11 +899,11 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
844
899
|
const syntheticException = new Error('PostHog syntheticException');
|
|
845
900
|
this.addPendingPromise(error_tracking.buildEventMessage(this.getErrorPropertiesBuilder(), error, {
|
|
846
901
|
syntheticException
|
|
847
|
-
}, distinctId, additionalProperties).then((msg)=>this.
|
|
902
|
+
}, distinctId, additionalProperties).then((msg)=>this._capturePreparedEvent({
|
|
848
903
|
...msg,
|
|
849
904
|
uuid,
|
|
850
905
|
flags
|
|
851
|
-
})));
|
|
906
|
+
}, false)));
|
|
852
907
|
}
|
|
853
908
|
}
|
|
854
909
|
async captureExceptionImmediate(error, distinctId, additionalProperties, flags) {
|
|
@@ -863,19 +918,25 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
863
918
|
}
|
|
864
919
|
}
|
|
865
920
|
async prepareEventMessage(props) {
|
|
921
|
+
return this._prepareEventMessage(props);
|
|
922
|
+
}
|
|
923
|
+
async _prepareEventMessage(props, options = {}) {
|
|
866
924
|
const { distinctId, event, properties, groups, flags, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
867
925
|
const contextData = this.context?.get();
|
|
926
|
+
const includeContextProperties = options.includeContextProperties ?? true;
|
|
868
927
|
let mergedDistinctId = distinctId || contextData?.distinctId;
|
|
869
|
-
const mergedProperties = {
|
|
928
|
+
const mergedProperties = includeContextProperties ? {
|
|
870
929
|
...this.props,
|
|
871
930
|
...contextData?.properties || {},
|
|
872
931
|
...properties || {}
|
|
932
|
+
} : {
|
|
933
|
+
...properties || {}
|
|
873
934
|
};
|
|
874
935
|
if (!mergedDistinctId) {
|
|
875
936
|
mergedDistinctId = uuidv7();
|
|
876
937
|
mergedProperties.$process_person_profile = false;
|
|
877
938
|
}
|
|
878
|
-
if (contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
|
|
939
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id) mergedProperties.$session_id = contextData.sessionId;
|
|
879
940
|
const eventMessage = this._runBeforeSend({
|
|
880
941
|
distinctId: mergedDistinctId,
|
|
881
942
|
event,
|
|
@@ -77,7 +77,7 @@ class ErrorTracking {
|
|
|
77
77
|
if (isRateLimited) return void this._logger.info('Skipping exception capture because of client rate limiting.', {
|
|
78
78
|
exception: exceptionType
|
|
79
79
|
});
|
|
80
|
-
return this.client.
|
|
80
|
+
return this.client._capturePreparedEvent(eventMessage, false);
|
|
81
81
|
}
|
|
82
82
|
})());
|
|
83
83
|
}
|
|
@@ -49,7 +49,7 @@ class ErrorTracking {
|
|
|
49
49
|
if (isRateLimited) return void this._logger.info('Skipping exception capture because of client rate limiting.', {
|
|
50
50
|
exception: exceptionType
|
|
51
51
|
});
|
|
52
|
-
return this.client.
|
|
52
|
+
return this.client._capturePreparedEvent(eventMessage, false);
|
|
53
53
|
}
|
|
54
54
|
})());
|
|
55
55
|
}
|
|
@@ -97,9 +97,7 @@ function posthogErrorHandler(posthog) {
|
|
|
97
97
|
...contextData.properties || {},
|
|
98
98
|
$response_status_code: res.statusCode
|
|
99
99
|
};
|
|
100
|
-
posthog.addPendingPromise(index_js_default().buildEventMessage(posthog.getErrorPropertiesBuilder(), error, hint, contextData.distinctId, additionalProperties).then((msg)=>
|
|
101
|
-
posthog.capture(msg);
|
|
102
|
-
}));
|
|
100
|
+
posthog.addPendingPromise(index_js_default().buildEventMessage(posthog.getErrorPropertiesBuilder(), error, hint, contextData.distinctId, additionalProperties).then((msg)=>posthog._capturePreparedEvent(msg, false)));
|
|
103
101
|
next(error);
|
|
104
102
|
};
|
|
105
103
|
}
|
|
@@ -58,9 +58,7 @@ function posthogErrorHandler(posthog) {
|
|
|
58
58
|
...contextData.properties || {},
|
|
59
59
|
$response_status_code: res.statusCode
|
|
60
60
|
};
|
|
61
|
-
posthog.addPendingPromise(error_tracking.buildEventMessage(posthog.getErrorPropertiesBuilder(), error, hint, contextData.distinctId, additionalProperties).then((msg)=>
|
|
62
|
-
posthog.capture(msg);
|
|
63
|
-
}));
|
|
61
|
+
posthog.addPendingPromise(error_tracking.buildEventMessage(posthog.getErrorPropertiesBuilder(), error, hint, contextData.distinctId, additionalProperties).then((msg)=>posthog._capturePreparedEvent(msg, false)));
|
|
64
62
|
next(error);
|
|
65
63
|
};
|
|
66
64
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "5.39.
|
|
1
|
+
export declare const version = "5.39.2";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
version: ()=>version
|
|
28
28
|
});
|
|
29
|
-
const version = '5.39.
|
|
29
|
+
const version = '5.39.2';
|
|
30
30
|
exports.version = __webpack_exports__.version;
|
|
31
31
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
32
|
"version"
|
package/dist/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = '5.39.
|
|
1
|
+
const version = '5.39.2';
|
|
2
2
|
export { version };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "posthog-node",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.2",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"module": "dist/entrypoints/index.node.mjs",
|
|
29
29
|
"types": "dist/entrypoints/index.node.d.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@posthog/core": "^1.39.
|
|
31
|
+
"@posthog/core": "^1.39.3"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@edge-runtime/jest-environment": "^4.0.0",
|
package/src/client.ts
CHANGED
|
@@ -240,7 +240,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
override async flush(): Promise<void> {
|
|
243
|
-
const flushPromise =
|
|
243
|
+
const flushPromise = this.flushWithPendingPromises()
|
|
244
244
|
const waitUntil = this.options.waitUntil
|
|
245
245
|
// Only register when no debounce promise is already keeping runtime alive
|
|
246
246
|
if (waitUntil && !this._waitUntilCycle) {
|
|
@@ -313,7 +313,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
313
313
|
private async resolveWaitUntilFlush(): Promise<void> {
|
|
314
314
|
const resolve = this._consumeWaitUntilCycle()
|
|
315
315
|
try {
|
|
316
|
-
await
|
|
316
|
+
await this.flushWithPendingPromises()
|
|
317
317
|
} catch {
|
|
318
318
|
// Flush errors are already logged by flush() internals
|
|
319
319
|
} finally {
|
|
@@ -532,18 +532,31 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
-
private
|
|
535
|
+
private _sendPreparedEvent(
|
|
536
|
+
type: string,
|
|
537
|
+
props: EventMessage,
|
|
538
|
+
immediate: boolean,
|
|
539
|
+
prepareOptions?: { includeContextProperties?: boolean }
|
|
540
|
+
): Promise<void> {
|
|
536
541
|
return this.addPendingPromise(
|
|
537
|
-
this.
|
|
542
|
+
this._prepareEventMessage(props, prepareOptions)
|
|
538
543
|
.then(({ distinctId, event, properties, options }) => {
|
|
539
544
|
const captureOptions: PostHogCaptureOptions = {
|
|
540
545
|
timestamp: options.timestamp,
|
|
541
546
|
disableGeoip: options.disableGeoip,
|
|
542
547
|
uuid: options.uuid,
|
|
543
548
|
}
|
|
549
|
+
const message = {
|
|
550
|
+
distinctId,
|
|
551
|
+
event,
|
|
552
|
+
properties: {
|
|
553
|
+
...properties,
|
|
554
|
+
...this.getCommonEventProperties(),
|
|
555
|
+
},
|
|
556
|
+
}
|
|
544
557
|
return immediate
|
|
545
|
-
?
|
|
546
|
-
:
|
|
558
|
+
? this.sendImmediate(type, message, captureOptions)
|
|
559
|
+
: this.enqueue(type, message, captureOptions)
|
|
547
560
|
})
|
|
548
561
|
.catch((err) => {
|
|
549
562
|
if (err) {
|
|
@@ -553,6 +566,10 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
553
566
|
)
|
|
554
567
|
}
|
|
555
568
|
|
|
569
|
+
_capturePreparedEvent(props: EventMessage, immediate: boolean): Promise<void> {
|
|
570
|
+
return this._sendPreparedEvent('capture', props, immediate)
|
|
571
|
+
}
|
|
572
|
+
|
|
556
573
|
/**
|
|
557
574
|
* Capture an event manually.
|
|
558
575
|
*
|
|
@@ -676,7 +693,12 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
676
693
|
$set_once: setOnceProps,
|
|
677
694
|
$anon_distinct_id: $anon_distinct_id ?? undefined,
|
|
678
695
|
}
|
|
679
|
-
|
|
696
|
+
this._sendPreparedEvent(
|
|
697
|
+
'identify',
|
|
698
|
+
{ distinctId, event: '$identify', properties: eventProperties, disableGeoip },
|
|
699
|
+
false,
|
|
700
|
+
{ includeContextProperties: false }
|
|
701
|
+
)
|
|
680
702
|
}
|
|
681
703
|
|
|
682
704
|
/**
|
|
@@ -710,7 +732,12 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
710
732
|
$set_once: setOnceProps,
|
|
711
733
|
$anon_distinct_id: $anon_distinct_id ?? undefined,
|
|
712
734
|
}
|
|
713
|
-
await
|
|
735
|
+
await this._sendPreparedEvent(
|
|
736
|
+
'identify',
|
|
737
|
+
{ distinctId, event: '$identify', properties: eventProperties, disableGeoip },
|
|
738
|
+
true,
|
|
739
|
+
{ includeContextProperties: false }
|
|
740
|
+
)
|
|
714
741
|
}
|
|
715
742
|
|
|
716
743
|
/**
|
|
@@ -790,7 +817,17 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
790
817
|
* @param data - The alias data containing distinctId and alias
|
|
791
818
|
*/
|
|
792
819
|
alias(data: { distinctId: string; alias: string; disableGeoip?: boolean }): void {
|
|
793
|
-
|
|
820
|
+
this._sendPreparedEvent(
|
|
821
|
+
'alias',
|
|
822
|
+
{
|
|
823
|
+
distinctId: data.distinctId,
|
|
824
|
+
event: '$create_alias',
|
|
825
|
+
properties: { distinct_id: data.distinctId, alias: data.alias },
|
|
826
|
+
disableGeoip: data.disableGeoip,
|
|
827
|
+
},
|
|
828
|
+
false,
|
|
829
|
+
{ includeContextProperties: false }
|
|
830
|
+
)
|
|
794
831
|
}
|
|
795
832
|
|
|
796
833
|
/**
|
|
@@ -811,7 +848,17 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
811
848
|
* @returns Promise that resolves when the alias is processed
|
|
812
849
|
*/
|
|
813
850
|
async aliasImmediate(data: { distinctId: string; alias: string; disableGeoip?: boolean }): Promise<void> {
|
|
814
|
-
await
|
|
851
|
+
await this._sendPreparedEvent(
|
|
852
|
+
'alias',
|
|
853
|
+
{
|
|
854
|
+
distinctId: data.distinctId,
|
|
855
|
+
event: '$create_alias',
|
|
856
|
+
properties: { distinct_id: data.distinctId, alias: data.alias },
|
|
857
|
+
disableGeoip: data.disableGeoip,
|
|
858
|
+
},
|
|
859
|
+
true,
|
|
860
|
+
{ includeContextProperties: false }
|
|
861
|
+
)
|
|
815
862
|
}
|
|
816
863
|
|
|
817
864
|
/**
|
|
@@ -1965,7 +2012,21 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
1965
2012
|
* @param data - The group identify data
|
|
1966
2013
|
*/
|
|
1967
2014
|
groupIdentify({ groupType, groupKey, properties, distinctId, disableGeoip }: GroupIdentifyMessage): void {
|
|
1968
|
-
|
|
2015
|
+
this._sendPreparedEvent(
|
|
2016
|
+
'capture',
|
|
2017
|
+
{
|
|
2018
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
2019
|
+
event: '$groupidentify',
|
|
2020
|
+
properties: {
|
|
2021
|
+
$group_type: groupType,
|
|
2022
|
+
$group_key: groupKey,
|
|
2023
|
+
$group_set: properties || {},
|
|
2024
|
+
},
|
|
2025
|
+
disableGeoip,
|
|
2026
|
+
},
|
|
2027
|
+
false,
|
|
2028
|
+
{ includeContextProperties: false }
|
|
2029
|
+
)
|
|
1969
2030
|
}
|
|
1970
2031
|
|
|
1971
2032
|
/**
|
|
@@ -1997,7 +2058,21 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
1997
2058
|
distinctId,
|
|
1998
2059
|
disableGeoip,
|
|
1999
2060
|
}: GroupIdentifyMessage): Promise<void> {
|
|
2000
|
-
await
|
|
2061
|
+
await this._sendPreparedEvent(
|
|
2062
|
+
'capture',
|
|
2063
|
+
{
|
|
2064
|
+
distinctId: distinctId || `$${groupType}_${groupKey}`,
|
|
2065
|
+
event: '$groupidentify',
|
|
2066
|
+
properties: {
|
|
2067
|
+
$group_type: groupType,
|
|
2068
|
+
$group_key: groupKey,
|
|
2069
|
+
$group_set: properties || {},
|
|
2070
|
+
},
|
|
2071
|
+
disableGeoip,
|
|
2072
|
+
},
|
|
2073
|
+
true,
|
|
2074
|
+
{ includeContextProperties: false }
|
|
2075
|
+
)
|
|
2001
2076
|
}
|
|
2002
2077
|
|
|
2003
2078
|
/**
|
|
@@ -2465,7 +2540,7 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2465
2540
|
{ syntheticException },
|
|
2466
2541
|
distinctId,
|
|
2467
2542
|
additionalProperties
|
|
2468
|
-
).then((msg) => this.
|
|
2543
|
+
).then((msg) => this._capturePreparedEvent({ ...msg, uuid, flags }, false))
|
|
2469
2544
|
)
|
|
2470
2545
|
}
|
|
2471
2546
|
}
|
|
@@ -2531,6 +2606,18 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2531
2606
|
event: string
|
|
2532
2607
|
properties: PostHogEventProperties
|
|
2533
2608
|
options: PostHogCaptureOptions
|
|
2609
|
+
}> {
|
|
2610
|
+
return this._prepareEventMessage(props)
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2613
|
+
private async _prepareEventMessage(
|
|
2614
|
+
props: EventMessage,
|
|
2615
|
+
options: { includeContextProperties?: boolean } = {}
|
|
2616
|
+
): Promise<{
|
|
2617
|
+
distinctId: string
|
|
2618
|
+
event: string
|
|
2619
|
+
properties: PostHogEventProperties
|
|
2620
|
+
options: PostHogCaptureOptions
|
|
2534
2621
|
}> {
|
|
2535
2622
|
const {
|
|
2536
2623
|
distinctId,
|
|
@@ -2545,21 +2632,24 @@ export abstract class PostHogBackendClient extends PostHogCoreStateless implemen
|
|
|
2545
2632
|
}: EventMessage = props
|
|
2546
2633
|
|
|
2547
2634
|
const contextData = this.context?.get()
|
|
2635
|
+
const includeContextProperties = options.includeContextProperties ?? true
|
|
2548
2636
|
|
|
2549
2637
|
let mergedDistinctId = distinctId || contextData?.distinctId
|
|
2550
2638
|
|
|
2551
|
-
const mergedProperties =
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2639
|
+
const mergedProperties = includeContextProperties
|
|
2640
|
+
? {
|
|
2641
|
+
...this.props,
|
|
2642
|
+
...(contextData?.properties || {}),
|
|
2643
|
+
...(properties || {}),
|
|
2644
|
+
}
|
|
2645
|
+
: { ...(properties || {}) }
|
|
2556
2646
|
|
|
2557
2647
|
if (!mergedDistinctId) {
|
|
2558
2648
|
mergedDistinctId = uuidv7()
|
|
2559
2649
|
mergedProperties.$process_person_profile = false
|
|
2560
2650
|
}
|
|
2561
2651
|
|
|
2562
|
-
if (contextData?.sessionId && !mergedProperties.$session_id) {
|
|
2652
|
+
if (includeContextProperties && contextData?.sessionId && !mergedProperties.$session_id) {
|
|
2563
2653
|
mergedProperties.$session_id = contextData.sessionId
|
|
2564
2654
|
}
|
|
2565
2655
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.39.
|
|
1
|
+
export const version = '5.39.2'
|