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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Next
2
2
 
3
+ # 5.2.1 - 2025-07-07
4
+
5
+ 1. feat: add captureExceptionImmediate method on posthog client
6
+
3
7
  # 5.1.1 - 2025-06-16
4
8
 
5
9
  1. fix: Handle double-encoded JSON payloads from the remote config endpoint
@@ -877,7 +877,7 @@ function applyChunkIds(frames, parser) {
877
877
 
878
878
  const SHUTDOWN_TIMEOUT = 2000;
879
879
  class ErrorTracking {
880
- static async captureException(client, error, hint, distinctId, additionalProperties) {
880
+ static async buildEventMessage(error, hint, distinctId, additionalProperties) {
881
881
  const properties = {
882
882
  ...additionalProperties
883
883
  };
@@ -887,14 +887,14 @@ class ErrorTracking {
887
887
  properties.$process_person_profile = false;
888
888
  }
889
889
  const exceptionProperties = await propertiesFromUnknownInput(this.stackParser, this.frameModifiers, error, hint);
890
- client.capture({
890
+ return {
891
891
  event: '$exception',
892
892
  distinctId: distinctId || uuidv7(),
893
893
  properties: {
894
894
  ...exceptionProperties,
895
895
  ...properties
896
896
  }
897
- });
897
+ };
898
898
  }
899
899
  constructor(client, options) {
900
900
  this.client = client;
@@ -908,7 +908,9 @@ class ErrorTracking {
908
908
  }
909
909
  }
910
910
  onException(exception, hint) {
911
- ErrorTracking.captureException(this.client, exception, hint);
911
+ void ErrorTracking.buildEventMessage(exception, hint).then(msg => {
912
+ this.client.capture(msg);
913
+ });
912
914
  }
913
915
  async onFatalError() {
914
916
  await this.client.shutdown(SHUTDOWN_TIMEOUT);
@@ -928,14 +930,14 @@ function setupExpressErrorHandler(_posthog, app) {
928
930
  };
929
931
  // Given stateless nature of Node SDK we capture exceptions using personless processing
930
932
  // when no user can be determined e.g. in the case of exception autocapture
931
- ErrorTracking.captureException(_posthog, error, hint, uuidv7(), {
933
+ ErrorTracking.buildEventMessage(error, hint, uuidv7(), {
932
934
  $process_person_profile: false
933
- });
935
+ }).then(msg => _posthog.capture(msg));
934
936
  next(error);
935
937
  });
936
938
  }
937
939
 
938
- var version = "5.1.1";
940
+ var version = "5.2.1";
939
941
 
940
942
  var PostHogPersistedProperty;
941
943
  (function (PostHogPersistedProperty) {
@@ -973,6 +975,12 @@ var Compression;
973
975
  })(Compression || (Compression = {}));
974
976
  var SurveyPosition;
975
977
  (function (SurveyPosition) {
978
+ SurveyPosition["TopLeft"] = "top_left";
979
+ SurveyPosition["TopCenter"] = "top_center";
980
+ SurveyPosition["TopRight"] = "top_right";
981
+ SurveyPosition["MiddleLeft"] = "middle_left";
982
+ SurveyPosition["MiddleCenter"] = "middle_center";
983
+ SurveyPosition["MiddleRight"] = "middle_right";
976
984
  SurveyPosition["Left"] = "left";
977
985
  SurveyPosition["Right"] = "right";
978
986
  SurveyPosition["Center"] = "center";
@@ -3279,9 +3287,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
3279
3287
  }
3280
3288
  captureException(error, distinctId, additionalProperties) {
3281
3289
  const syntheticException = new Error('PostHog syntheticException');
3282
- ErrorTracking.captureException(this, error, {
3290
+ ErrorTracking.buildEventMessage(error, {
3291
+ syntheticException
3292
+ }, distinctId, additionalProperties).then(msg => {
3293
+ this.capture(msg);
3294
+ });
3295
+ }
3296
+ async captureExceptionImmediate(error, distinctId, additionalProperties) {
3297
+ const syntheticException = new Error('PostHog syntheticException');
3298
+ const evtMsg = await ErrorTracking.buildEventMessage(error, {
3283
3299
  syntheticException
3284
3300
  }, distinctId, additionalProperties);
3301
+ return await this.captureImmediate(evtMsg);
3285
3302
  }
3286
3303
  }
3287
3304