posthog-node 5.1.1 → 5.2.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/CHANGELOG.md +4 -0
- package/lib/edge/index.cjs +25 -8
- package/lib/edge/index.cjs.map +1 -1
- package/lib/edge/index.mjs +25 -8
- package/lib/edge/index.mjs.map +1 -1
- package/lib/index.d.ts +8 -1
- package/lib/node/index.cjs +25 -8
- package/lib/node/index.cjs.map +1 -1
- package/lib/node/index.mjs +25 -8
- package/lib/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -230,6 +230,12 @@ type SurveyAppearance = {
|
|
|
230
230
|
widgetColor?: string;
|
|
231
231
|
};
|
|
232
232
|
declare enum SurveyPosition {
|
|
233
|
+
TopLeft = "top_left",
|
|
234
|
+
TopCenter = "top_center",
|
|
235
|
+
TopRight = "top_right",
|
|
236
|
+
MiddleLeft = "middle_left",
|
|
237
|
+
MiddleCenter = "middle_center",
|
|
238
|
+
MiddleRight = "middle_right",
|
|
233
239
|
Left = "left",
|
|
234
240
|
Right = "right",
|
|
235
241
|
Center = "center"
|
|
@@ -818,7 +824,7 @@ declare class ErrorTracking {
|
|
|
818
824
|
private _exceptionAutocaptureEnabled;
|
|
819
825
|
static stackParser: StackParser;
|
|
820
826
|
static frameModifiers: StackFrameModifierFn[];
|
|
821
|
-
static
|
|
827
|
+
static buildEventMessage(error: unknown, hint: EventHint, distinctId?: string, additionalProperties?: Record<string | number, any>): Promise<EventMessage>;
|
|
822
828
|
constructor(client: PostHogBackendClient, options: PostHogOptions);
|
|
823
829
|
private startAutocaptureIfEnabled;
|
|
824
830
|
private onException;
|
|
@@ -906,6 +912,7 @@ declare abstract class PostHogBackendClient extends PostHogCoreStateless impleme
|
|
|
906
912
|
_shutdown(shutdownTimeoutMs?: number): Promise<void>;
|
|
907
913
|
private addLocalPersonAndGroupProperties;
|
|
908
914
|
captureException(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>): void;
|
|
915
|
+
captureExceptionImmediate(error: unknown, distinctId?: string, additionalProperties?: Record<string | number, any>): Promise<void>;
|
|
909
916
|
}
|
|
910
917
|
|
|
911
918
|
/**
|
package/lib/node/index.cjs
CHANGED
|
@@ -881,7 +881,7 @@ function applyChunkIds(frames, parser) {
|
|
|
881
881
|
|
|
882
882
|
const SHUTDOWN_TIMEOUT = 2000;
|
|
883
883
|
class ErrorTracking {
|
|
884
|
-
static async
|
|
884
|
+
static async buildEventMessage(error, hint, distinctId, additionalProperties) {
|
|
885
885
|
const properties = {
|
|
886
886
|
...additionalProperties
|
|
887
887
|
};
|
|
@@ -891,14 +891,14 @@ class ErrorTracking {
|
|
|
891
891
|
properties.$process_person_profile = false;
|
|
892
892
|
}
|
|
893
893
|
const exceptionProperties = await propertiesFromUnknownInput(this.stackParser, this.frameModifiers, error, hint);
|
|
894
|
-
|
|
894
|
+
return {
|
|
895
895
|
event: '$exception',
|
|
896
896
|
distinctId: distinctId || uuidv7(),
|
|
897
897
|
properties: {
|
|
898
898
|
...exceptionProperties,
|
|
899
899
|
...properties
|
|
900
900
|
}
|
|
901
|
-
}
|
|
901
|
+
};
|
|
902
902
|
}
|
|
903
903
|
constructor(client, options) {
|
|
904
904
|
this.client = client;
|
|
@@ -912,7 +912,9 @@ class ErrorTracking {
|
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
onException(exception, hint) {
|
|
915
|
-
ErrorTracking.
|
|
915
|
+
void ErrorTracking.buildEventMessage(exception, hint).then(msg => {
|
|
916
|
+
this.client.capture(msg);
|
|
917
|
+
});
|
|
916
918
|
}
|
|
917
919
|
async onFatalError() {
|
|
918
920
|
await this.client.shutdown(SHUTDOWN_TIMEOUT);
|
|
@@ -932,9 +934,9 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
932
934
|
};
|
|
933
935
|
// Given stateless nature of Node SDK we capture exceptions using personless processing
|
|
934
936
|
// when no user can be determined e.g. in the case of exception autocapture
|
|
935
|
-
ErrorTracking.
|
|
937
|
+
ErrorTracking.buildEventMessage(error, hint, uuidv7(), {
|
|
936
938
|
$process_person_profile: false
|
|
937
|
-
});
|
|
939
|
+
}).then(msg => _posthog.capture(msg));
|
|
938
940
|
next(error);
|
|
939
941
|
});
|
|
940
942
|
}
|
|
@@ -1340,7 +1342,7 @@ function snipLine(line, colno) {
|
|
|
1340
1342
|
return newLine;
|
|
1341
1343
|
}
|
|
1342
1344
|
|
|
1343
|
-
var version = "5.
|
|
1345
|
+
var version = "5.2.1";
|
|
1344
1346
|
|
|
1345
1347
|
var PostHogPersistedProperty;
|
|
1346
1348
|
(function (PostHogPersistedProperty) {
|
|
@@ -1378,6 +1380,12 @@ var Compression;
|
|
|
1378
1380
|
})(Compression || (Compression = {}));
|
|
1379
1381
|
var SurveyPosition;
|
|
1380
1382
|
(function (SurveyPosition) {
|
|
1383
|
+
SurveyPosition["TopLeft"] = "top_left";
|
|
1384
|
+
SurveyPosition["TopCenter"] = "top_center";
|
|
1385
|
+
SurveyPosition["TopRight"] = "top_right";
|
|
1386
|
+
SurveyPosition["MiddleLeft"] = "middle_left";
|
|
1387
|
+
SurveyPosition["MiddleCenter"] = "middle_center";
|
|
1388
|
+
SurveyPosition["MiddleRight"] = "middle_right";
|
|
1381
1389
|
SurveyPosition["Left"] = "left";
|
|
1382
1390
|
SurveyPosition["Right"] = "right";
|
|
1383
1391
|
SurveyPosition["Center"] = "center";
|
|
@@ -3684,9 +3692,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3684
3692
|
}
|
|
3685
3693
|
captureException(error, distinctId, additionalProperties) {
|
|
3686
3694
|
const syntheticException = new Error('PostHog syntheticException');
|
|
3687
|
-
ErrorTracking.
|
|
3695
|
+
ErrorTracking.buildEventMessage(error, {
|
|
3696
|
+
syntheticException
|
|
3697
|
+
}, distinctId, additionalProperties).then(msg => {
|
|
3698
|
+
this.capture(msg);
|
|
3699
|
+
});
|
|
3700
|
+
}
|
|
3701
|
+
async captureExceptionImmediate(error, distinctId, additionalProperties) {
|
|
3702
|
+
const syntheticException = new Error('PostHog syntheticException');
|
|
3703
|
+
const evtMsg = await ErrorTracking.buildEventMessage(error, {
|
|
3688
3704
|
syntheticException
|
|
3689
3705
|
}, distinctId, additionalProperties);
|
|
3706
|
+
return await this.captureImmediate(evtMsg);
|
|
3690
3707
|
}
|
|
3691
3708
|
}
|
|
3692
3709
|
|