posthog-node 5.8.3 → 5.8.4

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.
@@ -25,13 +25,15 @@ import { PostHogCoreStateless, getFeatureFlagValue, safeSetTimeout as safeSetTim
25
25
  * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
26
26
  * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
27
27
  * @param {SeverityLevel[] | '*'} [severityAllowList] Optional: send events matching the provided levels. Use '*' to send all events (default: ['error'])
28
+ * @param {boolean} [sendExceptionsToPostHog] Optional: capture exceptions as events in PostHog (default: true)
28
29
  */
29
30
  const NAME = 'posthog-node';
30
31
  function createEventProcessor(_posthog, {
31
32
  organization,
32
33
  projectId,
33
34
  prefix,
34
- severityAllowList = ['error']
35
+ severityAllowList = ['error'],
36
+ sendExceptionsToPostHog = true
35
37
  } = {}) {
36
38
  return event => {
37
39
  const shouldProcessLevel = severityAllowList === '*' || severityAllowList.includes(event.level);
@@ -81,11 +83,13 @@ function createEventProcessor(_posthog, {
81
83
  if (organization && projectId) {
82
84
  properties['$sentry_url'] = (prefix || 'https://sentry.io/organizations/') + organization + '/issues/?project=' + projectId + '&query=' + event.event_id;
83
85
  }
84
- _posthog.capture({
85
- event: '$exception',
86
- distinctId: userId,
87
- properties
88
- });
86
+ if (sendExceptionsToPostHog) {
87
+ _posthog.capture({
88
+ event: '$exception',
89
+ distinctId: userId,
90
+ properties
91
+ });
92
+ }
89
93
  return event;
90
94
  };
91
95
  }
@@ -101,7 +105,7 @@ function sentryIntegration(_posthog, options) {
101
105
  }
102
106
  // V7 integration - class based
103
107
  class PostHogSentryIntegration {
104
- constructor(_posthog, organization, prefix, severityAllowList) {
108
+ constructor(_posthog, organization, prefix, severityAllowList, sendExceptionsToPostHog) {
105
109
  this.name = NAME;
106
110
  // setupOnce gets called by Sentry when it intializes the plugin
107
111
  this.name = NAME;
@@ -111,7 +115,8 @@ class PostHogSentryIntegration {
111
115
  organization,
112
116
  projectId,
113
117
  prefix,
114
- severityAllowList
118
+ severityAllowList,
119
+ sendExceptionsToPostHog: sendExceptionsToPostHog ?? true
115
120
  }));
116
121
  };
117
122
  }
@@ -1184,7 +1189,7 @@ function snipLine(line, colno) {
1184
1189
  return newLine;
1185
1190
  }
1186
1191
 
1187
- var version = "5.8.3";
1192
+ var version = "5.8.4";
1188
1193
 
1189
1194
  /**
1190
1195
  * A lazy value that is only computed when needed. Inspired by C#'s Lazy<T> class.