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.
@@ -859,7 +859,7 @@ function applyChunkIds(frames, parser) {
859
859
 
860
860
  const SHUTDOWN_TIMEOUT = 2000;
861
861
  class ErrorTracking {
862
- static async captureException(client, error, hint, distinctId, additionalProperties) {
862
+ static async buildEventMessage(error, hint, distinctId, additionalProperties) {
863
863
  const properties = {
864
864
  ...additionalProperties
865
865
  };
@@ -869,14 +869,14 @@ class ErrorTracking {
869
869
  properties.$process_person_profile = false;
870
870
  }
871
871
  const exceptionProperties = await propertiesFromUnknownInput(this.stackParser, this.frameModifiers, error, hint);
872
- client.capture({
872
+ return {
873
873
  event: '$exception',
874
874
  distinctId: distinctId || uuidv7(),
875
875
  properties: {
876
876
  ...exceptionProperties,
877
877
  ...properties
878
878
  }
879
- });
879
+ };
880
880
  }
881
881
  constructor(client, options) {
882
882
  this.client = client;
@@ -890,7 +890,9 @@ class ErrorTracking {
890
890
  }
891
891
  }
892
892
  onException(exception, hint) {
893
- ErrorTracking.captureException(this.client, exception, hint);
893
+ void ErrorTracking.buildEventMessage(exception, hint).then(msg => {
894
+ this.client.capture(msg);
895
+ });
894
896
  }
895
897
  async onFatalError() {
896
898
  await this.client.shutdown(SHUTDOWN_TIMEOUT);
@@ -910,9 +912,9 @@ function setupExpressErrorHandler(_posthog, app) {
910
912
  };
911
913
  // Given stateless nature of Node SDK we capture exceptions using personless processing
912
914
  // when no user can be determined e.g. in the case of exception autocapture
913
- ErrorTracking.captureException(_posthog, error, hint, uuidv7(), {
915
+ ErrorTracking.buildEventMessage(error, hint, uuidv7(), {
914
916
  $process_person_profile: false
915
- });
917
+ }).then(msg => _posthog.capture(msg));
916
918
  next(error);
917
919
  });
918
920
  }
@@ -1318,7 +1320,7 @@ function snipLine(line, colno) {
1318
1320
  return newLine;
1319
1321
  }
1320
1322
 
1321
- var version = "5.1.1";
1323
+ var version = "5.2.1";
1322
1324
 
1323
1325
  var PostHogPersistedProperty;
1324
1326
  (function (PostHogPersistedProperty) {
@@ -1356,6 +1358,12 @@ var Compression;
1356
1358
  })(Compression || (Compression = {}));
1357
1359
  var SurveyPosition;
1358
1360
  (function (SurveyPosition) {
1361
+ SurveyPosition["TopLeft"] = "top_left";
1362
+ SurveyPosition["TopCenter"] = "top_center";
1363
+ SurveyPosition["TopRight"] = "top_right";
1364
+ SurveyPosition["MiddleLeft"] = "middle_left";
1365
+ SurveyPosition["MiddleCenter"] = "middle_center";
1366
+ SurveyPosition["MiddleRight"] = "middle_right";
1359
1367
  SurveyPosition["Left"] = "left";
1360
1368
  SurveyPosition["Right"] = "right";
1361
1369
  SurveyPosition["Center"] = "center";
@@ -3662,9 +3670,18 @@ class PostHogBackendClient extends PostHogCoreStateless {
3662
3670
  }
3663
3671
  captureException(error, distinctId, additionalProperties) {
3664
3672
  const syntheticException = new Error('PostHog syntheticException');
3665
- ErrorTracking.captureException(this, error, {
3673
+ ErrorTracking.buildEventMessage(error, {
3674
+ syntheticException
3675
+ }, distinctId, additionalProperties).then(msg => {
3676
+ this.capture(msg);
3677
+ });
3678
+ }
3679
+ async captureExceptionImmediate(error, distinctId, additionalProperties) {
3680
+ const syntheticException = new Error('PostHog syntheticException');
3681
+ const evtMsg = await ErrorTracking.buildEventMessage(error, {
3666
3682
  syntheticException
3667
3683
  }, distinctId, additionalProperties);
3684
+ return await this.captureImmediate(evtMsg);
3668
3685
  }
3669
3686
  }
3670
3687