posthog-js 1.85.2 → 1.85.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.
Files changed (49) hide show
  1. package/dist/array.full.js +1 -1
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +1 -1
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +1 -1
  6. package/dist/es.js.map +1 -1
  7. package/dist/exception-autocapture.js +2 -0
  8. package/dist/exception-autocapture.js.map +1 -0
  9. package/dist/module.d.ts +0 -32
  10. package/dist/module.js +1 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/recorder-v2.js.map +1 -1
  13. package/dist/recorder.js.map +1 -1
  14. package/dist/surveys.js.map +1 -1
  15. package/lib/package.json +1 -1
  16. package/lib/src/decide.js +23 -10
  17. package/lib/src/decide.js.map +1 -1
  18. package/lib/src/extensions/exception-autocapture/error-conversion.js.map +1 -0
  19. package/lib/src/extensions/{exceptions/exception-autocapture.d.ts → exception-autocapture/index.d.ts} +1 -1
  20. package/lib/src/extensions/{exceptions/exception-autocapture.js → exception-autocapture/index.js} +9 -36
  21. package/lib/src/extensions/exception-autocapture/index.js.map +1 -0
  22. package/lib/src/extensions/exception-autocapture/stack-trace.js.map +1 -0
  23. package/lib/src/extensions/exception-autocapture/type-checking.js.map +1 -0
  24. package/lib/src/extensions/replay/sessionrecording.d.ts +0 -1
  25. package/lib/src/extensions/replay/sessionrecording.js +0 -3
  26. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  27. package/lib/src/extensions/sentry-integration.js.map +1 -1
  28. package/lib/src/extensions/toolbar.js +19 -4
  29. package/lib/src/extensions/toolbar.js.map +1 -1
  30. package/lib/src/loader-exception-autocapture.d.ts +2 -0
  31. package/lib/src/loader-exception-autocapture.js +6 -0
  32. package/lib/src/loader-exception-autocapture.js.map +1 -0
  33. package/lib/src/posthog-core.d.ts +0 -3
  34. package/lib/src/posthog-core.js +0 -16
  35. package/lib/src/posthog-core.js.map +1 -1
  36. package/lib/src/utils.d.ts +1 -0
  37. package/lib/src/utils.js +8 -0
  38. package/lib/src/utils.js.map +1 -1
  39. package/package.json +1 -1
  40. package/lib/src/extensions/exceptions/error-conversion.js.map +0 -1
  41. package/lib/src/extensions/exceptions/exception-autocapture.js.map +0 -1
  42. package/lib/src/extensions/exceptions/stack-trace.js.map +0 -1
  43. package/lib/src/extensions/exceptions/type-checking.js.map +0 -1
  44. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.d.ts +0 -0
  45. /package/lib/src/extensions/{exceptions → exception-autocapture}/error-conversion.js +0 -0
  46. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.d.ts +0 -0
  47. /package/lib/src/extensions/{exceptions → exception-autocapture}/stack-trace.js +0 -0
  48. /package/lib/src/extensions/{exceptions → exception-autocapture}/type-checking.d.ts +0 -0
  49. /package/lib/src/extensions/{exceptions → exception-autocapture}/type-checking.js +0 -0
package/lib/src/decide.js CHANGED
@@ -10,7 +10,7 @@ var __values = (this && this.__values) || function(o) {
10
10
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
11
  };
12
12
  import { autocapture } from './autocapture';
13
- import { _base64Encode, loadScript, logger } from './utils';
13
+ import { _base64Encode, _isUndefined, loadScript, logger } from './utils';
14
14
  import { STORED_GROUP_PROPERTIES_KEY, STORED_PERSON_PROPERTIES_KEY } from './constants';
15
15
  var Decide = /** @class */ (function () {
16
16
  function Decide(instance) {
@@ -39,7 +39,7 @@ var Decide = /** @class */ (function () {
39
39
  Decide.prototype.parseDecideResponse = function (response) {
40
40
  var e_1, _a, e_2, _b;
41
41
  var _this = this;
42
- var _c, _d, _e;
42
+ var _c, _d;
43
43
  this.instance.featureFlags.setReloadingPaused(false);
44
44
  // :TRICKY: Reload - start another request if queued!
45
45
  this.instance.featureFlags._startReloadTimer();
@@ -58,7 +58,6 @@ var Decide = /** @class */ (function () {
58
58
  (_c = this.instance.sessionRecording) === null || _c === void 0 ? void 0 : _c.afterDecideResponse(response);
59
59
  autocapture.afterDecideResponse(response, this.instance);
60
60
  (_d = this.instance.webPerformance) === null || _d === void 0 ? void 0 : _d.afterDecideResponse(response);
61
- (_e = this.instance.exceptionAutocapture) === null || _e === void 0 ? void 0 : _e.afterDecideResponse(response);
62
61
  if (!this.instance.config.advanced_disable_feature_flags_on_first_load) {
63
62
  this.instance.featureFlags.receivedFeatureFlags(response);
64
63
  }
@@ -66,21 +65,20 @@ var Decide = /** @class */ (function () {
66
65
  if (response['supportedCompression'] && !this.instance.config.disable_compression) {
67
66
  var compression = {};
68
67
  try {
69
- for (var _f = __values(response['supportedCompression']), _g = _f.next(); !_g.done; _g = _f.next()) {
70
- var method = _g.value;
68
+ for (var _e = __values(response['supportedCompression']), _f = _e.next(); !_f.done; _f = _e.next()) {
69
+ var method = _f.value;
71
70
  compression[method] = true;
72
71
  }
73
72
  }
74
73
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
75
74
  finally {
76
75
  try {
77
- if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
76
+ if (_f && !_f.done && (_a = _e.return)) _a.call(_e);
78
77
  }
79
78
  finally { if (e_1) throw e_1.error; }
80
79
  }
81
80
  this.instance['compression'] = compression;
82
81
  }
83
- // Check if recorder.js is already loaded
84
82
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
85
83
  // @ts-ignore
86
84
  var surveysGenerator = window === null || window === void 0 ? void 0 : window.extendPostHogWithSurveys;
@@ -94,6 +92,21 @@ var Decide = /** @class */ (function () {
94
92
  window.extendPostHogWithSurveys(_this.instance);
95
93
  });
96
94
  }
95
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
96
+ // @ts-ignore
97
+ var exceptionAutoCaptureAddedToWindow = window === null || window === void 0 ? void 0 : window.extendPostHogWithExceptionAutoCapture;
98
+ if (response['autocaptureExceptions'] &&
99
+ !!response['autocaptureExceptions'] &&
100
+ _isUndefined(exceptionAutoCaptureAddedToWindow)) {
101
+ loadScript(this.instance.config.api_host + "/static/exception-autocapture.js", function (err) {
102
+ if (err) {
103
+ return logger.error("Could not load exception autocapture script", err);
104
+ }
105
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
106
+ // @ts-ignore
107
+ window.extendPostHogWithExceptionAutocapture(_this.instance, response);
108
+ });
109
+ }
97
110
  if (response['siteApps']) {
98
111
  if (this.instance.config.opt_in_site_apps) {
99
112
  var apiHost = this.instance.config.api_host;
@@ -111,15 +124,15 @@ var Decide = /** @class */ (function () {
111
124
  };
112
125
  var this_1 = this;
113
126
  try {
114
- for (var _h = __values(response['siteApps']), _j = _h.next(); !_j.done; _j = _h.next()) {
115
- var _k = _j.value, id = _k.id, url = _k.url;
127
+ for (var _g = __values(response['siteApps']), _h = _g.next(); !_h.done; _h = _g.next()) {
128
+ var _j = _h.value, id = _j.id, url = _j.url;
116
129
  _loop_1(id, url);
117
130
  }
118
131
  }
119
132
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
120
133
  finally {
121
134
  try {
122
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
135
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
123
136
  }
124
137
  finally { if (e_2) throw e_2.error; }
125
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"decide.js","sourceRoot":"","sources":["../../src/decide.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAG3D,OAAO,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAA;AAEvF;IAGI,gBAAY,QAAiB;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,qFAAqF;QACrF,IAAI,CAAC,QAAQ,CAAC,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,4BAA4B,EAAE,CAAA;IACrF,CAAC;IAED,qBAAI,GAAJ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AAG,CAAC,CAAA;yBACjF;oBACL,CAAC,CAAC,CAAA;;;;oBAZN,KAA0B,IAAA,KAAA,SAAA,QAAQ,CAAC,UAAU,CAAC,CAAA,gBAAA;wBAAnC,IAAA,aAAW,EAAT,EAAE,QAAA,EAAE,GAAG,SAAA;gCAAP,EAAE,EAAE,GAAG;qBAanB;;;;;;;;;aACJ;iBAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;gBACxC,MAAM,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAA;aACnG;SACJ;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AA7GD,IA6GC","sourcesContent":["import { autocapture } from './autocapture'\nimport { _base64Encode, loadScript, logger } from './utils'\nimport { PostHog } from './posthog-core'\nimport { Compression, DecideResponse } from './types'\nimport { STORED_GROUP_PROPERTIES_KEY, STORED_PERSON_PROPERTIES_KEY } from './constants'\n\nexport class Decide {\n instance: PostHog\n\n constructor(instance: PostHog) {\n this.instance = instance\n // don't need to wait for `decide` to return if flags were provided on initialisation\n this.instance.decideEndpointWasHit = this.instance._hasBootstrappedFeatureFlags()\n }\n\n call(): void {\n /*\n Calls /decide endpoint to fetch options for autocapture, session recording, feature flags & compression.\n */\n const json_data = JSON.stringify({\n token: this.instance.config.token,\n distinct_id: this.instance.get_distinct_id(),\n groups: this.instance.getGroups(),\n person_properties: this.instance.get_property(STORED_PERSON_PROPERTIES_KEY),\n group_properties: this.instance.get_property(STORED_GROUP_PROPERTIES_KEY),\n disable_flags:\n this.instance.config.advanced_disable_feature_flags ||\n this.instance.config.advanced_disable_feature_flags_on_first_load ||\n undefined,\n })\n\n const encoded_data = _base64Encode(json_data)\n this.instance._send_request(\n `${this.instance.config.api_host}/decide/?v=3`,\n { data: encoded_data, verbose: true },\n { method: 'POST' },\n (response) => this.parseDecideResponse(response as DecideResponse)\n )\n }\n\n parseDecideResponse(response: DecideResponse): void {\n this.instance.featureFlags.setReloadingPaused(false)\n // :TRICKY: Reload - start another request if queued!\n this.instance.featureFlags._startReloadTimer()\n\n if (response?.status === 0) {\n logger.error('Failed to fetch feature flags from PostHog.')\n return\n }\n if (!(document && document.body)) {\n logger.info('document not ready yet, trying again in 500 milliseconds...')\n setTimeout(() => {\n this.parseDecideResponse(response)\n }, 500)\n return\n }\n\n this.instance.toolbar.afterDecideResponse(response)\n this.instance.sessionRecording?.afterDecideResponse(response)\n autocapture.afterDecideResponse(response, this.instance)\n this.instance.webPerformance?.afterDecideResponse(response)\n this.instance.exceptionAutocapture?.afterDecideResponse(response)\n\n if (!this.instance.config.advanced_disable_feature_flags_on_first_load) {\n this.instance.featureFlags.receivedFeatureFlags(response)\n }\n\n this.instance['compression'] = {}\n if (response['supportedCompression'] && !this.instance.config.disable_compression) {\n const compression: Partial<Record<Compression, boolean>> = {}\n for (const method of response['supportedCompression']) {\n compression[method] = true\n }\n this.instance['compression'] = compression\n }\n\n // Check if recorder.js is already loaded\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const surveysGenerator = window?.extendPostHogWithSurveys\n\n if (response['surveys'] && !surveysGenerator) {\n loadScript(this.instance.config.api_host + `/static/surveys.js`, (err) => {\n if (err) {\n return logger.error(`Could not load surveys script`, err)\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.extendPostHogWithSurveys(this.instance)\n })\n }\n\n if (response['siteApps']) {\n if (this.instance.config.opt_in_site_apps) {\n const apiHost = this.instance.config.api_host\n for (const { id, url } of response['siteApps']) {\n const scriptUrl = [\n apiHost,\n apiHost[apiHost.length - 1] === '/' && url[0] === '/' ? url.substring(1) : url,\n ].join('')\n\n ;(window as any)[`__$$ph_site_app_${id}`] = this.instance\n\n loadScript(scriptUrl, (err) => {\n if (err) {\n logger.error(`Error while initializing PostHog app with config id ${id}`, err)\n }\n })\n }\n } else if (response['siteApps'].length > 0) {\n logger.error('PostHog site apps are disabled. Enable the \"opt_in_site_apps\" config to proceed.')\n }\n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,GAAG,CAAC,EAAE;gBACxC,MAAM,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAA;aACnG;SACJ;IACL,CAAC;IACL,aAAC;AAAD,CAAC,AA9HD,IA8HC","sourcesContent":["import { autocapture } from './autocapture'\nimport { _base64Encode, _isUndefined, loadScript, logger } from './utils'\nimport { PostHog } from './posthog-core'\nimport { Compression, DecideResponse } from './types'\nimport { STORED_GROUP_PROPERTIES_KEY, STORED_PERSON_PROPERTIES_KEY } from './constants'\n\nexport class Decide {\n instance: PostHog\n\n constructor(instance: PostHog) {\n this.instance = instance\n // don't need to wait for `decide` to return if flags were provided on initialisation\n this.instance.decideEndpointWasHit = this.instance._hasBootstrappedFeatureFlags()\n }\n\n call(): void {\n /*\n Calls /decide endpoint to fetch options for autocapture, session recording, feature flags & compression.\n */\n const json_data = JSON.stringify({\n token: this.instance.config.token,\n distinct_id: this.instance.get_distinct_id(),\n groups: this.instance.getGroups(),\n person_properties: this.instance.get_property(STORED_PERSON_PROPERTIES_KEY),\n group_properties: this.instance.get_property(STORED_GROUP_PROPERTIES_KEY),\n disable_flags:\n this.instance.config.advanced_disable_feature_flags ||\n this.instance.config.advanced_disable_feature_flags_on_first_load ||\n undefined,\n })\n\n const encoded_data = _base64Encode(json_data)\n this.instance._send_request(\n `${this.instance.config.api_host}/decide/?v=3`,\n { data: encoded_data, verbose: true },\n { method: 'POST' },\n (response) => this.parseDecideResponse(response as DecideResponse)\n )\n }\n\n parseDecideResponse(response: DecideResponse): void {\n this.instance.featureFlags.setReloadingPaused(false)\n // :TRICKY: Reload - start another request if queued!\n this.instance.featureFlags._startReloadTimer()\n\n if (response?.status === 0) {\n logger.error('Failed to fetch feature flags from PostHog.')\n return\n }\n if (!(document && document.body)) {\n logger.info('document not ready yet, trying again in 500 milliseconds...')\n setTimeout(() => {\n this.parseDecideResponse(response)\n }, 500)\n return\n }\n\n this.instance.toolbar.afterDecideResponse(response)\n this.instance.sessionRecording?.afterDecideResponse(response)\n autocapture.afterDecideResponse(response, this.instance)\n this.instance.webPerformance?.afterDecideResponse(response)\n\n if (!this.instance.config.advanced_disable_feature_flags_on_first_load) {\n this.instance.featureFlags.receivedFeatureFlags(response)\n }\n\n this.instance['compression'] = {}\n if (response['supportedCompression'] && !this.instance.config.disable_compression) {\n const compression: Partial<Record<Compression, boolean>> = {}\n for (const method of response['supportedCompression']) {\n compression[method] = true\n }\n this.instance['compression'] = compression\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const surveysGenerator = window?.extendPostHogWithSurveys\n\n if (response['surveys'] && !surveysGenerator) {\n loadScript(this.instance.config.api_host + `/static/surveys.js`, (err) => {\n if (err) {\n return logger.error(`Could not load surveys script`, err)\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.extendPostHogWithSurveys(this.instance)\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const exceptionAutoCaptureAddedToWindow = window?.extendPostHogWithExceptionAutoCapture\n if (\n response['autocaptureExceptions'] &&\n !!response['autocaptureExceptions'] &&\n _isUndefined(exceptionAutoCaptureAddedToWindow)\n ) {\n loadScript(this.instance.config.api_host + `/static/exception-autocapture.js`, (err) => {\n if (err) {\n return logger.error(`Could not load exception autocapture script`, err)\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n window.extendPostHogWithExceptionAutocapture(this.instance, response)\n })\n }\n\n if (response['siteApps']) {\n if (this.instance.config.opt_in_site_apps) {\n const apiHost = this.instance.config.api_host\n for (const { id, url } of response['siteApps']) {\n const scriptUrl = [\n apiHost,\n apiHost[apiHost.length - 1] === '/' && url[0] === '/' ? url.substring(1) : url,\n ].join('')\n\n ;(window as any)[`__$$ph_site_app_${id}`] = this.instance\n\n loadScript(scriptUrl, (err) => {\n if (err) {\n logger.error(`Error while initializing PostHog app with config id ${id}`, err)\n }\n })\n }\n } else if (response['siteApps'].length > 0) {\n logger.error('PostHog site apps are disabled. Enable the \"opt_in_site_apps\" config to proceed.')\n }\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-conversion.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/error-conversion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,UAAU,EACV,cAAc,EACd,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,OAAO,EACP,aAAa,EACb,WAAW,GACd,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,kBAAkB,EAAc,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEhE;;GAEG;AAEH,IAAM,mBAAmB,GACrB,0GAA0G,CAAA;AAuB9G,IAAM,mBAAmB,GAAG,6BAA6B,CAAA;AAEzD,SAAS,UAAU,CAAC,EAAoC;IACpD,IAAI,EAAE,EAAE;QACJ,IAAI,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE;YAC3B,OAAO,EAAE,CAAC,WAAW,CAAA;SACxB;QAED,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;YACtC,OAAO,CAAC,CAAA;SACX;KACJ;IAED,OAAO,CAAC,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAyD;IACtF,iEAAiE;IACjE,4DAA4D;IAC5D,mCAAmC;IACnC,IAAM,UAAU,GAAG,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,CAAA;IAElD,IAAM,OAAO,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IAE9B,IAAI;QACA,OAAO,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;KACjD;IAAC,OAAO,CAAC,EAAE;QACR,WAAW;KACd;IAED,OAAO,EAAE,CAAA;AACb,CAAC;AAED,SAAS,wBAAwB,C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AClB,4EAA4E;QAC5E,eAAe,EAAE,CAAC,eAAe,CAAC,eAAe,GAAG,oBAAoB,CAAC,EACzE,kBAAkB,EAAE,CAAC,eAAe,CAAC,kBAAkB;YACnD,eAAe,CAAC,kBAAkB,IAAK,EAAU,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IACjF;AACL,CAAC","sourcesContent":["import {\n isDOMError,\n isDOMException,\n isError,\n isErrorEvent,\n isErrorWithStack,\n isEvent,\n isPlainObject,\n isPrimitive,\n} from './type-checking'\nimport { defaultStackParser, StackFrame } from './stack-trace'\nimport { _isNumber, _isString, _isUndefined } from '../../utils'\n\n/**\n * based on the very wonderful MIT licensed Sentry SDK\n */\n\nconst ERROR_TYPES_PATTERN =\n /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined\n]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_source?: string\n $exception_lineno?: number\n $exception_colno?: number\n $exception_DOMException_code?: string\n $exception_is_synthetic?: boolean\n $exception_stack_trace_raw?: string\n $exception_handled?: boolean\n $exception_personURL?: string\n}\n\nconst reactMinifiedRegexp = /Minified React error #\\d+;/i\n\nfunction getPopSize(ex: Error & { framesToPop?: number }): number {\n if (ex) {\n if (_isNumber(ex.framesToPop)) {\n return ex.framesToPop\n }\n\n if (reactMinifiedRegexp.test(ex.message)) {\n return 1\n }\n }\n\n return 0\n}\n\nexport function parseStackFrames(ex: Error & { framesToPop?: number; stacktrace?: string }): StackFrame[] {\n // Access and store the stacktrace property before doing ANYTHING\n // else to it because Opera is not very good at providing it\n // reliably in other circumstances.\n const stacktrace = ex.stacktrace || ex.stack || ''\n\n const popSize = getPopSize(ex)\n\n try {\n return defaultStackParser(stacktrace, popSize)\n } catch (e) {\n // no-empty\n }\n\n return []\n}\n\nfunction errorPropertiesFromError(error: Error): ErrorProperties {\n const frames = parseStackFrames(error)\n\n return {\n $exception_type: error.name,\n $exception_message: error.message,\n $exception_stack_trace_raw: JSON.stringify(frames),\n }\n}\n\nfunction errorPropertiesFromString(candidate: string): ErrorProperties {\n return {\n $exception_type: 'Error',\n $exception_message: candidate,\n }\n}\n\n/**\n * Given any captured exception, extract its keys and create a sorted\n * and truncated list that will be used inside the event message.\n * eg. `Non-error exception captured with keys: foo, bar, baz`\n */\nfunction extractExceptionKeysForMessage(exception: Record<string, unknown>, maxLength = 40): string {\n const keys = Object.keys(exception)\n keys.sort()\n\n if (!keys.length) {\n return '[object has no keys]'\n }\n\n for (let i = keys.length; i > 0; i--) {\n const serialized = keys.slice(0, i).join(', ')\n if (serialized.length > maxLength) {\n continue\n }\n if (i === keys.length) {\n return serialized\n }\n return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`\n }\n\n return ''\n}\n\nfunction errorPropertiesFromObject(candidate: Record<string, unknown>): ErrorProperties {\n return {\n $exception_type: isEvent(candidate) ? candidate.constructor.name : 'Error',\n $exception_message: `Non-Error ${'exception'} captured with keys: ${extractExceptionKeysForMessage(candidate)}`,\n }\n}\n\nexport function errorToProperties([event, source, lineno, colno, error]: ErrorEventArgs): ErrorProperties {\n // exception type and message are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message'> & {\n $exception_type?: string\n $exception_message?: string\n } = {}\n\n if (_isUndefined(error) && _isString(event)) {\n let name = 'Error'\n let message = event\n const groups = event.match(ERROR_TYPES_PATTERN)\n if (groups) {\n name = groups[1]\n message = groups[2]\n }\n errorProperties = {\n $exception_type: name,\n $exception_message: message,\n }\n }\n\n const candidate = error || event\n\n if (isDOMError(candidate) || isDOMException(candidate)) {\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMError\n // https://developer.mozilla.org/en-US/docs/Web/API/DOMException\n\n const domException = candidate as unknown as DOMException\n\n if (isErrorWithStack(candidate)) {\n errorProperties = errorPropertiesFromError(candidate as Error)\n } else {\n const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException')\n const message = domException.message ? `${name}: ${domException.message}` : name\n errorProperties = errorPropertiesFromString(message)\n errorProperties.$exception_type = isDOMError(domException) ? 'DOMError' : 'DOMException'\n errorProperties.$exception_message = errorProperties.$exception_message || message\n }\n if ('code' in domException) {\n errorProperties['$exception_DOMException_code'] = `${domException.code}`\n }\n } else if (isErrorEvent(candidate as ErrorEvent) && (candidate as ErrorEvent).error) {\n errorProperties = errorPropertiesFromError((candidate as ErrorEvent).error as Error)\n } else if (isError(candidate)) {\n errorProperties = errorPropertiesFromError(candidate)\n } else if (isPlainObject(candidate) || isEvent(candidate)) {\n // group these by using the keys available on the object\n const objectException = candidate as Record<string, unknown>\n errorProperties = errorPropertiesFromObject(objectException)\n errorProperties.$exception_is_synthetic = true\n } else {\n // If none of previous checks were valid, then it must be a string\n errorProperties.$exception_type = errorProperties.$exception_type || 'Error'\n errorProperties.$exception_message = errorProperties.$exception_message || candidate\n errorProperties.$exception_is_synthetic = true\n }\n\n return {\n ...errorProperties,\n // now we make sure the mandatory fields that were made optional are present\n $exception_type: errorProperties.$exception_type || 'UnknownErrorType',\n $exception_message: errorProperties.$exception_message || '',\n ...(source\n ? {\n $exception_source: source, // TODO get this from URL if not present\n }\n : {}),\n ...(lineno ? { $exception_lineno: lineno } : {}),\n ...(colno ? { $exception_colno: colno } : {}),\n }\n}\n\nexport function unhandledRejectionToProperties([ev]: [ev: PromiseRejectionEvent]): ErrorProperties {\n // dig the object of the rejection out of known event types\n let error: unknown = ev\n try {\n // PromiseRejectionEvents store the object of the rejection under 'reason'\n // see https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent\n if ('reason' in ev) {\n error = ev.reason\n }\n // something, somewhere, (likely a browser extension) effectively casts PromiseRejectionEvents\n // to CustomEvents, moving the `promise` and `reason` attributes of the PRE into\n // the CustomEvent's `detail` attribute, since they're not part of CustomEvent's spec\n // see https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent and\n // https://github.com/getsentry/sentry-javascript/issues/2380\n else if ('detail' in ev && 'reason' in (ev as any).detail) {\n error = (ev as any).detail.reason\n }\n } catch (_oO) {\n // no-empty\n }\n\n // exception type and message are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message'> & {\n $exception_type?: string\n $exception_message?: string\n } = {}\n if (isPrimitive(error)) {\n errorProperties = {\n $exception_message: `Non-Error promise rejection captured with value: ${String(error)}`,\n }\n } else {\n errorProperties = errorToProperties([error as string | Event])\n }\n errorProperties.$exception_handled = false\n\n return {\n ...errorProperties,\n // now we make sure the mandatory fields that were made optional are present\n $exception_type: (errorProperties.$exception_type = 'UnhandledRejection'),\n $exception_message: (errorProperties.$exception_message =\n errorProperties.$exception_message || (ev as any).reason || String(error)),\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { PostHog } from '../../posthog-core';
2
2
  import { DecideResponse, Properties } from '../../types';
3
3
  import { ErrorEventArgs } from './error-conversion';
4
+ export declare const extendPostHog: (instance: PostHog, response: DecideResponse) => ExceptionObserver;
4
5
  export declare class ExceptionObserver {
5
6
  instance: PostHog;
6
7
  remoteEnabled: boolean | undefined;
@@ -8,7 +9,6 @@ export declare class ExceptionObserver {
8
9
  private originalOnUnhandledRejectionHandler;
9
10
  private errorsToIgnore;
10
11
  constructor(instance: PostHog);
11
- private debugLog;
12
12
  startCapturing(): void;
13
13
  stopCapturing(): void;
14
14
  isCapturing(): boolean;
@@ -9,35 +9,15 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __read = (this && this.__read) || function (o, n) {
13
- var m = typeof Symbol === "function" && o[Symbol.iterator];
14
- if (!m) return o;
15
- var i = m.call(o), r, ar = [], e;
16
- try {
17
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
- }
19
- catch (error) { e = { error: error }; }
20
- finally {
21
- try {
22
- if (r && !r.done && (m = i["return"])) m.call(i);
23
- }
24
- finally { if (e) throw e.error; }
25
- }
26
- return ar;
27
- };
28
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
- if (ar || !(i in from)) {
31
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
- ar[i] = from[i];
33
- }
34
- }
35
- return to.concat(ar || Array.prototype.slice.call(from));
36
- };
37
- import { _isArray, _isUndefined, logger, window } from '../../utils';
12
+ import { _isArray, _isObject, _isUndefined, logger, window } from '../../utils';
38
13
  import { errorToProperties, unhandledRejectionToProperties } from './error-conversion';
39
14
  import { isPrimitive } from './type-checking';
40
15
  var EXCEPTION_INGESTION_ENDPOINT = '/e/';
16
+ export var extendPostHog = function (instance, response) {
17
+ var exceptionObserver = new ExceptionObserver(instance);
18
+ exceptionObserver.afterDecideResponse(response);
19
+ return exceptionObserver;
20
+ };
41
21
  var ExceptionObserver = /** @class */ (function () {
42
22
  function ExceptionObserver(instance) {
43
23
  this.originalOnErrorHandler = undefined;
@@ -45,13 +25,6 @@ var ExceptionObserver = /** @class */ (function () {
45
25
  this.errorsToIgnore = [];
46
26
  this.instance = instance;
47
27
  }
48
- ExceptionObserver.prototype.debugLog = function () {
49
- var args = [];
50
- for (var _i = 0; _i < arguments.length; _i++) {
51
- args[_i] = arguments[_i];
52
- }
53
- logger.info.apply(logger, __spreadArray(['[ExceptionObserver]'], __read(args), false));
54
- };
55
28
  ExceptionObserver.prototype.startCapturing = function () {
56
29
  var _a;
57
30
  if (!this.isEnabled() || ((_a = window.onerror) === null || _a === void 0 ? void 0 : _a.__POSTHOG_INSTRUMENTED__)) {
@@ -127,13 +100,13 @@ var ExceptionObserver = /** @class */ (function () {
127
100
  }
128
101
  if (this.isEnabled()) {
129
102
  this.startCapturing();
130
- this.debugLog('Remote config for exception autocapture is enabled, starting', autocaptureExceptionsResponse);
103
+ logger.info('[Exception Capture] Remote config for exception autocapture is enabled, starting with config: ', _isObject(autocaptureExceptionsResponse) ? autocaptureExceptionsResponse : {});
131
104
  }
132
105
  };
133
106
  ExceptionObserver.prototype.captureException = function (args, properties) {
134
107
  var errorProperties = errorToProperties(args);
135
108
  if (this.errorsToIgnore.some(function (regex) { return regex.test(errorProperties.$exception_message || ''); })) {
136
- this.debugLog('Ignoring exception based on remote config', errorProperties);
109
+ logger.info('[Exception Capture] Ignoring exception based on remote config', errorProperties);
137
110
  return;
138
111
  }
139
112
  var propertiesToSend = __assign(__assign({}, properties), errorProperties);
@@ -156,4 +129,4 @@ var ExceptionObserver = /** @class */ (function () {
156
129
  return ExceptionObserver;
157
130
  }());
158
131
  export { ExceptionObserver };
159
- //# sourceMappingURL=exception-autocapture.js.map
132
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAG/E,OAAO,EAAmC,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAA;AACvH,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAE7C,IAAM,4BAA4B,GAAG,KAAK,CAAA;AAE1C,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,QAAiB,EAAE,QAAwB;IACrE,IAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAA;IACzD,iBAAiB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAC/C,OAAO,iBAAiB,CAAA;AAC5B,CAAC,CAAA;AAED;IAQI,2BAAY,QAAiB;QALrB,2BAAsB,GAAgD,SAAS,CAAA;QAC/E,wCAAmC,GAA6D,SAAS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AQ,EAAE,4BAA4B;YACtC,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,gBAAgB;SAC9B,CAAC,CAAA;IACN,CAAC;IACL,wBAAC;AAAD,CAAC,AAjID,IAiIC","sourcesContent":["import { _isArray, _isObject, _isUndefined, logger, window } from '../../utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, Properties } from '../../types'\nimport { ErrorEventArgs, ErrorProperties, errorToProperties, unhandledRejectionToProperties } from './error-conversion'\nimport { isPrimitive } from './type-checking'\n\nconst EXCEPTION_INGESTION_ENDPOINT = '/e/'\n\nexport const extendPostHog = (instance: PostHog, response: DecideResponse) => {\n const exceptionObserver = new ExceptionObserver(instance)\n exceptionObserver.afterDecideResponse(response)\n return exceptionObserver\n}\n\nexport class ExceptionObserver {\n instance: PostHog\n remoteEnabled: boolean | undefined\n private originalOnErrorHandler: typeof window['onerror'] | null | undefined = undefined\n private originalOnUnhandledRejectionHandler: typeof window['onunhandledrejection'] | null | undefined = undefined\n\n private errorsToIgnore: RegExp[] = []\n\n constructor(instance: PostHog) {\n this.instance = instance\n }\n\n startCapturing() {\n if (!this.isEnabled() || (window.onerror as any)?.__POSTHOG_INSTRUMENTED__) {\n return\n }\n\n try {\n this.originalOnErrorHandler = window.onerror\n\n window.onerror = function (this: ExceptionObserver, ...args: ErrorEventArgs): boolean {\n this.captureException(args)\n\n if (this.originalOnErrorHandler) {\n // eslint-disable-next-line prefer-rest-params\n return this.originalOnErrorHandler.apply(this, args)\n }\n\n return false\n }.bind(this)\n ;(window.onerror as any).__POSTHOG_INSTRUMENTED__ = true\n\n this.originalOnUnhandledRejectionHandler = window.onunhandledrejection\n\n window.onunhandledrejection = function (\n this: ExceptionObserver,\n ...args: [ev: PromiseRejectionEvent]\n ): boolean {\n const errorProperties: ErrorProperties = unhandledRejectionToProperties(args)\n this.sendExceptionEvent(errorProperties)\n\n if (this.originalOnUnhandledRejectionHandler) {\n // eslint-disable-next-line prefer-rest-params\n return this.originalOnUnhandledRejectionHandler.apply(window, args)\n }\n\n return true\n }.bind(this)\n ;(window.onunhandledrejection as any).__POSTHOG_INSTRUMENTED__ = true\n } catch (e) {\n logger.error('PostHog failed to start exception autocapture', e)\n this.stopCapturing()\n }\n }\n\n stopCapturing() {\n if (!_isUndefined(this.originalOnErrorHandler)) {\n window.onerror = this.originalOnErrorHandler\n this.originalOnErrorHandler = null\n }\n delete (window.onerror as any)?.__POSTHOG_INSTRUMENTED__\n\n if (!_isUndefined(this.originalOnUnhandledRejectionHandler)) {\n window.onunhandledrejection = this.originalOnUnhandledRejectionHandler\n this.originalOnUnhandledRejectionHandler = null\n }\n delete (window.onunhandledrejection as any)?.__POSTHOG_INSTRUMENTED__\n }\n\n isCapturing() {\n return !!(window.onerror as any)?.__POSTHOG_INSTRUMENTED__\n }\n\n isEnabled() {\n return this.remoteEnabled ?? false\n }\n\n afterDecideResponse(response: DecideResponse) {\n const autocaptureExceptionsResponse = response.autocaptureExceptions\n this.remoteEnabled = !!autocaptureExceptionsResponse || false\n if (\n !isPrimitive(autocaptureExceptionsResponse) &&\n 'errors_to_ignore' in autocaptureExceptionsResponse &&\n _isArray(autocaptureExceptionsResponse.errors_to_ignore)\n ) {\n const dropRules = autocaptureExceptionsResponse.errors_to_ignore\n\n this.errorsToIgnore = dropRules.map((rule) => {\n return new RegExp(rule)\n })\n }\n\n if (this.isEnabled()) {\n this.startCapturing()\n logger.info(\n '[Exception Capture] Remote config for exception autocapture is enabled, starting with config: ',\n _isObject(autocaptureExceptionsResponse) ? autocaptureExceptionsResponse : {}\n )\n }\n }\n\n captureException(args: ErrorEventArgs, properties?: Properties) {\n const errorProperties = errorToProperties(args)\n\n if (this.errorsToIgnore.some((regex) => regex.test(errorProperties.$exception_message || ''))) {\n logger.info('[Exception Capture] Ignoring exception based on remote config', errorProperties)\n return\n }\n\n const propertiesToSend = { ...properties, ...errorProperties }\n\n const posthogHost = this.instance.config.ui_host || this.instance.config.api_host\n errorProperties.$exception_personURL = posthogHost + '/person/' + this.instance.get_distinct_id()\n\n this.sendExceptionEvent(propertiesToSend)\n }\n\n /**\n * :TRICKY: Make sure we batch these requests\n */\n sendExceptionEvent(properties: { [key: string]: any }) {\n this.instance.capture('$exception', properties, {\n transport: 'XHR',\n method: 'POST',\n endpoint: EXCEPTION_INGESTION_ENDPOINT,\n _noTruncate: true,\n _batchKey: 'exceptionEvent',\n })\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-trace.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/stack-trace.ts"],"names":[],"mappings":"AAAA,6JAA6J;AAC7J,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhB,uFAAuF;AACvF,oCAAoC;AACpC,EAAE;AACF,oFAAoF;AACpF,6BAA6B;AAE7B,0FAA0F;AAC1F,EAAE;AACF,uFAAuF;AACvF,uFAAuF;AACvF,qFAAqF;AACrF,uFAAuF;AACvF,sFAAsF;AACtF,cAAc;AACd,EAAE;AACF,wFAAwF;AACxF,2CAA2C;AAC3C,EAAE;AACF,sFAAsF;AACtF,gFAAgF;AAChF,oFAAoF;AACpF,uFAAuF;AACvF,uFAAuF;AACvF,gDAAgD;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,IAAM,oBAAoB,GAAG,iBAAiB,CAAA;AAC9C,IAAM,sBAAsB,GAAG,EAAE,CAAA;AAEjC,IAAM,gBAAgB,GAAG,GAAG,CAAA;AAE5B,IAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,IAAM,gBAAgB,GAAG,EAAE,CAAA;AAC3B,IAAM,eAAe,GAAG,EAAE,CAAA;AAC1B,IAAM,cAAc,GAAG,EAAE,CAAA;AACzB,IAAM,cAAc,GAAG,EAAE,CAAA;AAoBzB,SAAS,WAAW,CAAC,QAAgB,EAAE,IAAY,EAAE,MAAe,EAAE,KAAc;IAChF,IAAM,KAAK,GAAe;QACtB,QAAQ,UA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644179b77985f00f8696c908539f/packages/browser/src/stack-parsers.ts\n// 💖open source\n\n// This was originally forked from https://github.com/csnover/TraceKit, and was largely\n// re-written as part of raven - js.\n//\n// This code was later copied to the JavaScript mono - repo and further modified and\n// refactored over the years.\n\n// Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy of this\n// software and associated documentation files(the 'Software'), to deal in the Software\n// without restriction, including without limitation the rights to use, copy, modify,\n// merge, publish, distribute, sublicense, and / or sell copies of the Software, and to\n// permit persons to whom the Software is furnished to do so, subject to the following\n// conditions:\n//\n// The above copyright notice and this permission notice shall be included in all copies\n// or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n// PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF\n// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE\n// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nimport { _isUndefined } from '../../utils'\n\nconst WEBPACK_ERROR_REGEXP = /\\(error: (.*)\\)/\nconst STACKTRACE_FRAME_LIMIT = 50\n\nconst UNKNOWN_FUNCTION = '?'\n\nconst OPERA10_PRIORITY = 10\nconst OPERA11_PRIORITY = 20\nconst CHROME_PRIORITY = 30\nconst WINJS_PRIORITY = 40\nconst GECKO_PRIORITY = 50\n\nexport interface StackFrame {\n filename?: string\n function?: string\n module?: string\n platform?: string\n lineno?: number\n colno?: number\n abs_path?: string\n context_line?: string\n pre_context?: string[]\n post_context?: string[]\n in_app?: boolean\n instruction_addr?: string\n addr_mode?: string\n vars?: { [key: string]: any }\n debug_id?: string\n}\n\nfunction createFrame(filename: string, func: string, lineno?: number, colno?: number): StackFrame {\n const frame: StackFrame = {\n filename,\n function: func,\n in_app: true, // All browser frames are considered in_app\n }\n\n if (!_isUndefined(lineno)) {\n frame.lineno = lineno\n }\n\n if (!_isUndefined(colno)) {\n frame.colno = colno\n }\n\n return frame\n}\n\nexport type StackParser = (stack: string, skipFirst?: number) => StackFrame[]\nexport type StackLineParserFn = (line: string) => StackFrame | undefined\nexport type StackLineParser = [number, StackLineParserFn]\n\n// Chromium based browsers: Chrome, Brave, new Opera, new Edge\nconst chromeRegex =\n /^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i\nconst chromeEvalRegex = /\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/\n\nconst chrome: StackLineParserFn = (line) => {\n const parts = chromeRegex.exec(line)\n\n if (parts) {\n const isEval = parts[2] && parts[2].indexOf('eval') === 0 // start of line\n\n if (isEval) {\n const subMatch = chromeEvalRegex.exec(parts[2])\n\n if (subMatch) {\n // throw out eval line/column and use top-most line/column number\n parts[2] = subMatch[1] // url\n parts[3] = subMatch[2] // line\n parts[4] = subMatch[3] // column\n }\n }\n\n // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now\n // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)\n const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2])\n\n return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined)\n }\n\n return\n}\n\nexport const chromeStackLineParser: StackLineParser = [CHROME_PRIORITY, chrome]\n\n// gecko regex: `(?:bundle|\\d+\\.js)`: `bundle` is for react native, `\\d+\\.js` also but specifically for ram bundles because it\n// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js\n// We need this specific case for now because we want no other regex to match.\nconst geckoREgex =\n /^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i\nconst geckoEvalRegex = /(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i\n\nconst gecko: StackLineParserFn = (line) => {\n const parts = geckoREgex.exec(line)\n\n if (parts) {\n const isEval = parts[3] && parts[3].indexOf(' > eval') > -1\n if (isEval) {\n const subMatch = geckoEvalRegex.exec(parts[3])\n\n if (subMatch) {\n // throw out eval line/column and use top-most line number\n parts[1] = parts[1] || 'eval'\n parts[3] = subMatch[1]\n parts[4] = subMatch[2]\n parts[5] = '' // no column when eval\n }\n }\n\n let filename = parts[3]\n let func = parts[1] || UNKNOWN_FUNCTION\n ;[func, filename] = extractSafariExtensionDetails(func, filename)\n\n return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined)\n }\n\n return\n}\n\nexport const geckoStackLineParser: StackLineParser = [GECKO_PRIORITY, gecko]\n\nconst winjsRegex = /^\\s*at (?:((?:\\[object object\\])?.+) )?\\(?((?:[-a-z]+):.*?):(\\d+)(?::(\\d+))?\\)?\\s*$/i\n\nconst winjs: StackLineParserFn = (line) => {\n const parts = winjsRegex.exec(line)\n\n return parts\n ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)\n : undefined\n}\n\nexport const winjsStackLineParser: StackLineParser = [WINJS_PRIORITY, winjs]\n\nconst opera10Regex = / line (\\d+).*script (?:in )?(\\S+)(?:: in function (\\S+))?$/i\n\nconst opera10: StackLineParserFn = (line) => {\n const parts = opera10Regex.exec(line)\n return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined\n}\n\nexport const opera10StackLineParser: StackLineParser = [OPERA10_PRIORITY, opera10]\n\nconst opera11Regex = / line (\\d+), column (\\d+)\\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\\(.*\\))? in (.*):\\s*$/i\n\nconst opera11: StackLineParserFn = (line) => {\n const parts = opera11Regex.exec(line)\n return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined\n}\n\nexport const opera11StackLineParser: StackLineParser = [OPERA11_PRIORITY, opera11]\n\nexport const defaultStackLineParsers = [chromeStackLineParser, geckoStackLineParser, winjsStackLineParser]\n\nexport function reverse(stack: ReadonlyArray<StackFrame>): StackFrame[] {\n if (!stack.length) {\n return []\n }\n\n const localStack = stack.slice(0, STACKTRACE_FRAME_LIMIT)\n\n localStack.reverse()\n\n return localStack.map((frame) => ({\n ...frame,\n filename: frame.filename || localStack[localStack.length - 1].filename,\n function: frame.function || '?',\n }))\n}\n\nexport function createStackParser(...parsers: StackLineParser[]): StackParser {\n const sortedParsers = parsers.sort((a, b) => a[0] - b[0]).map((p) => p[1])\n\n return (stack: string, skipFirst = 0): StackFrame[] => {\n const frames: StackFrame[] = []\n const lines = stack.split('\\n')\n\n for (let i = skipFirst; i < lines.length; i++) {\n const line = lines[i]\n // Ignore lines over 1kb as they are unlikely to be stack frames.\n // Many of the regular expressions use backtracking which results in run time that increases exponentially with\n // input size. Huge strings can result in hangs/Denial of Service:\n // https://github.com/getsentry/sentry-javascript/issues/2286\n if (line.length > 1024) {\n continue\n }\n\n // https://github.com/getsentry/sentry-javascript/issues/5459\n // Remove webpack (error: *) wrappers\n const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line\n\n // https://github.com/getsentry/sentry-javascript/issues/7813\n // Skip Error: lines\n if (cleanedLine.match(/\\S*Error: /)) {\n continue\n }\n\n for (const parser of sortedParsers) {\n const frame = parser(cleanedLine)\n\n if (frame) {\n frames.push(frame)\n break\n }\n }\n\n if (frames.length >= STACKTRACE_FRAME_LIMIT) {\n break\n }\n }\n\n return reverse(frames)\n }\n}\n\nexport const defaultStackParser = createStackParser(...defaultStackLineParsers)\n\n/**\n * Safari web extensions, starting version unknown, can produce \"frames-only\" stacktraces.\n * What it means, is that instead of format like:\n *\n * Error: wat\n * at function@url:row:col\n * at function@url:row:col\n * at function@url:row:col\n *\n * it produces something like:\n *\n * function@url:row:col\n * function@url:row:col\n * function@url:row:col\n *\n * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.\n * This function is extracted so that we can use it in both places without duplicating the logic.\n * Unfortunately \"just\" changing RegExp is too complicated now and making it pass all tests\n * and fix this case seems like an impossible, or at least way too time-consuming task.\n */\nconst extractSafariExtensionDetails = (func: string, filename: string): [string, string] => {\n const isSafariExtension = func.indexOf('safari-extension') !== -1\n const isSafariWebExtension = func.indexOf('safari-web-extension') !== -1\n\n return isSafariExtension || isSafariWebExtension\n ? [\n func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,\n isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`,\n ]\n : [func, filename]\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checking.js","sourceRoot":"","sources":["../../../../src/extensions/exception-autocapture/type-checking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE3E,MAAM,UAAU,OAAO,CAAC,SAAkB;IACtC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AACjE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAAkB;IAC5C,OAAO,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAkB,EAAE,IAAS;IACtD,IAAI;QACA,OAAO,SAAS,YAAY,IAAI,CAAA;KACnC;IAAC,OAAO,EAAE,EAAE;QACT,OAAO,KAAK,CAAA;KACf;AACL,CAAC;AAED,MAAM,UAAU,WAAW,CACvB,SAAkB;IAElB,OAAO,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAA;AACnF,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,SAAkB;IACtC,QAAQ,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAC/C,KAAK,gBAAgB,CAAC;QACtB,KAAK,oBAAoB,CAAC;QAC1B,KAAK,uBAAuB;YACxB,OAAO,IAAI,CAAA;QACf;YACI,OAAO,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;KAC5C;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAA6B;IACtD,OAAO,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,SAAkB;IAC/C,OAAO,OAAO,IAAK,SAAmB,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,SAAkB,EAAE,SAAiB;IAC3D,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,kBAAW,SAAS,MAAG,CAAA;AAChF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAkB;IAC7C,OAAO,SAAS,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,SAAkB;IACzC,OAAO,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { _isFunction, _isNull, _isObject, _isUndefined } from '../../utils'\n\nexport function isEvent(candidate: unknown): candidate is Event {\n return !_isUndefined(Event) && isInstanceOf(candidate, Event)\n}\n\nexport function isPlainObject(candidate: unknown): candidate is Record<string, unknown> {\n return isBuiltin(candidate, 'Object')\n}\n\nexport function isInstanceOf(candidate: unknown, base: any): boolean {\n try {\n return candidate instanceof base\n } catch (_e) {\n return false\n }\n}\n\nexport function isPrimitive(\n candidate: unknown\n): candidate is number | string | boolean | bigint | symbol | null | undefined {\n return _isNull(candidate) || (!_isObject(candidate) && !_isFunction(candidate))\n}\n\nexport function isError(candidate: unknown): candidate is Error {\n switch (Object.prototype.toString.call(candidate)) {\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n return true\n default:\n return isInstanceOf(candidate, Error)\n }\n}\n\nexport function isErrorEvent(event: string | Error | Event): event is ErrorEvent {\n return isBuiltin(event, 'ErrorEvent')\n}\n\nexport function isErrorWithStack(candidate: unknown): candidate is Error {\n return 'stack' in (candidate as Error)\n}\n\nexport function isBuiltin(candidate: unknown, className: string): boolean {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`\n}\n\nexport function isDOMException(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMException')\n}\n\nexport function isDOMError(candidate: unknown): boolean {\n return isBuiltin(candidate, 'DOMError')\n}\n"]}
@@ -2,7 +2,6 @@ import { PostHog } from '../../posthog-core';
2
2
  import { DecideResponse } from '../../types';
3
3
  import { type eventWithTime } from '@rrweb/types';
4
4
  export declare const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS: number;
5
- export declare const TEN_MINUTES_IN_MS: number;
6
5
  export declare const RECORDING_MAX_EVENT_SIZE: number;
7
6
  export declare const RECORDING_BUFFER_TIMEOUT = 2000;
8
7
  export declare const SESSION_RECORDING_BATCH_KEY = "recordings";
@@ -43,7 +43,6 @@ import Config from '../../config';
43
43
  import { _isBoolean, _isNull, _isNumber, _isObject, _isString, _isUndefined, _timestamp, loadScript, logger, } from '../../utils';
44
44
  var BASE_ENDPOINT = '/s/';
45
45
  export var RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
46
- export var TEN_MINUTES_IN_MS = 10 * 60 * 1000;
47
46
  export var RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9; // ~1mb (with some wiggle room)
48
47
  export var RECORDING_BUFFER_TIMEOUT = 2000; // 2 seconds
49
48
  export var SESSION_RECORDING_BATCH_KEY = 'recordings';
@@ -412,8 +411,6 @@ var SessionRecording = /** @class */ (function () {
412
411
  collectFonts: false,
413
412
  inlineStylesheet: true,
414
413
  recordCrossOriginIframes: false,
415
- //take a full snapshot after every N ms
416
- checkoutEveryNms: TEN_MINUTES_IN_MS,
417
414
  };
418
415
  // We switched from loading all of rrweb to just the record part, but
419
416
  // keep backwards compatibility if someone hasn't upgraded PostHog
@@ -1 +1 @@
1
- {"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EACH,yCAAyC,EACzC,qCAAqC,EACrC,4BAA4B,EAC5B,8CAA8C,GACjD,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACH,wBAAwB,EACxB,+BAA+B,EAC/B,eAAe,EACf,mBAAmB,EAGnB,wBAAwB,GAC3B,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,SAAS,EAA4C,MAAM,cAAc,CAAA;AAClF,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EACH,UAAU,EACV,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,MAAM,GACT,MAAM,aAAa,CAAA;AAEpB,IAAM,aAAa,GAAG,KAAK,CAAA;AAE3B,MAAM,CAAC,IAAM,kCAAkC,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,YAAY;AAC5E,MAAM,CAAC,IAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAC/C,MAAM,CAAC,IAAM,wBAAwB,GAAG,IAAI,GAAG,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ESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE,\n} from '../../constants'\nimport {\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, NetworkRequest, Properties } from '../../types'\nimport { EventType, type eventWithTime, type listenerHandler } from '@rrweb/types'\nimport Config from '../../config'\nimport {\n _isBoolean,\n _isNull,\n _isNumber,\n _isObject,\n _isString,\n _isUndefined,\n _timestamp,\n loadScript,\n logger,\n} from '../../utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 // 5 minutes\nexport const TEN_MINUTES_IN_MS = 10 * 60 * 1000\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\ninterface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string | null\n windowId: string | null\n}\n\nexport class SessionRecording {\n private _linkedFlagSeen: boolean = false\n private instance: PostHog\n private _endpoint: string\n private windowId: string | null\n private sessionId: string | null\n private _lastActivityTimestamp: number = Date.now()\n private flushBufferTimer?: any\n private buffer?: SnapshotBuffer\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private rrwebRecord: rrwebRecord | undefined\n private isIdle = false\n private _linkedFlag: string | null = null\n private _sampleRate: number | null = null\n private _minimumDuration: number | null = null\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n logger.error('Session recording started without valid sessionManager')\n throw new Error('Session recording started without valid sessionManager. This is a bug.')\n }\n\n return this.instance.sessionManager\n }\n\n private get isSampled(): boolean | null {\n if (_isNumber(this._sampleRate)) {\n return this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n } else {\n return null\n }\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshot = this.buffer?.data[this.buffer?.data.length - 1]\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshot ? mostRecentSnapshot.timestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get recordingVersion() {\n const recordingVersion_server_side = this.instance.get_property(SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE)\n const recordingVersion_client_side = this.instance.config.session_recording?.recorderVersion\n return recordingVersion_client_side || recordingVersion_server_side || 'v1'\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (_isString(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (_isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(instance: PostHog) {\n this.instance = instance\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n window.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n\n if (!this.instance.sessionManager) {\n logger.error('Session recording started without valid sessionManager')\n throw new Error('Session recording started without valid sessionManager. This is a bug.')\n }\n\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n this.windowId = windowId\n this.sessionId = sessionId\n\n this.buffer = this.clearBuffer()\n }\n\n startRecordingIfEnabled() {\n if (this.isRecordingEnabled) {\n this.startCaptureAndTrySendingQueuedSnapshots()\n } else {\n this.stopRecording()\n this.clearBuffer()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n if (!_isNumber(this._sampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n if (sessionIdChanged || !_isBoolean(storedIsSampled)) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < this._sampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample) {\n logger.warn(\n `[SessionSampling] Sample rate (${this._sampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n if (this.instance.persistence) {\n this.instance.persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE]: response.sessionRecording?.recorderVersion,\n })\n }\n\n const receivedSampleRate = response.sessionRecording?.sampleRate\n this._sampleRate =\n _isUndefined(receivedSampleRate) || _isNull(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n this._minimumDuration = _isUndefined(receivedMinimumDuration) ? null : receivedMinimumDuration\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n if (_isNumber(this._sampleRate)) {\n this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n\n if (_isString(this._linkedFlag)) {\n const linkedFlag = this._linkedFlag\n this.instance.onFeatureFlags((flags) => {\n this._linkedFlagSeen = flags.includes(linkedFlag)\n })\n }\n\n this.receivedDecide = true\n this.startRecordingIfEnabled()\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: _timestamp(),\n })\n }\n\n private startCaptureAndTrySendingQueuedSnapshots() {\n this._startCapture()\n }\n\n private _startCapture() {\n if (_isUndefined(Object.assign)) {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n if (this._captureStarted || this.instance.config.disable_session_recording) {\n return\n }\n\n this._captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n this.sessionManager.checkAndGetSessionAndWindowId()\n\n const recorderJS = this.recordingVersion === 'v2' ? 'recorder-v2.js' : 'recorder.js'\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported) or matches the requested recorder version, don't load script. Otherwise, remotely import\n // recorder.js from cdn since it hasn't been loaded.\n if (this.instance.__loaded_recorder_version !== this.recordingVersion) {\n loadScript(this.instance.config.api_host + `/static/${recorderJS}?v=${Config.LIB_VERSION}`, (err) => {\n if (err) {\n return logger.error(`Could not load ${recorderJS}`, err)\n }\n\n this._onScriptLoaded()\n })\n } else {\n this._onScriptLoaded()\n }\n }\n\n private _isInteractiveEvent(event: eventWithTime) {\n return event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE && ACTIVE_SOURCES.indexOf(event.data?.source) !== -1\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this._isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this._lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n }\n }\n\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ignored previous mutations\n this.isIdle = false\n this._tryTakeFullSnapshot()\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = this.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (\n [FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (windowIdChanged || sessionIdChanged)\n ) {\n this._tryTakeFullSnapshot()\n }\n }\n\n private _tryTakeFullSnapshot(): boolean {\n // TODO this should ignore based on emit?\n if (!this._captureStarted) {\n return false\n }\n try {\n this.rrwebRecord?.takeFullSnapshot()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet, so we can't take a full snapshot.\n logger.error('Error taking full snapshot.', e)\n return false\n }\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n //take a full snapshot after every N ms\n checkoutEveryNms: TEN_MINUTES_IN_MS,\n }\n // We switched from loading all of rrweb to just the record part, but\n // keep backwards compatibility if someone hasn't upgraded PostHog\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.rrwebRecord = window.rrweb ? window.rrweb.record : window.rrwebRecord\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.info(message, {\n node: node,\n })\n\n this.log('[PostHog Recorder] ' + message, 'warn')\n },\n })\n\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins:\n (window as any).rrwebConsoleRecord && this.isConsoleLogCaptureEnabled\n ? [(window as any).rrwebConsoleRecord.getRecordConsolePlugin()]\n : [],\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = this._maskUrl(window.location.href)\n if (!href) {\n return\n }\n this.rrwebRecord?.addCustomEvent('$pageview', { href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n if (!rawEvent || !_isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n if (!href) {\n return\n }\n rawEvent.data.href = href\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n const size = JSON.stringify(event).length\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n this._updateWindowAndSessionIds(event)\n\n if (this.isIdle) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): SnapshotBuffer {\n this.buffer = undefined\n\n return {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n }\n\n // the intention is a buffer that (currently) is used only after a decide response enables session recording\n // it is called ever X seconds using the flushBufferTimer so that we don't have to wait for the buffer to fill up\n // when it is called on a timer it assumes that it can definitely flush\n // it is flushed when the session id changes or the size of the buffered data gets too great (1mb by default)\n // first change: if the recording is in buffering mode,\n // flush buffer simply resets the timer and returns the existing flush buffer\n private _flushBuffer() {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this._minimumDuration\n const sessionDuration = this.sessionDuration\n const isBelowMinimumDuration =\n _isNumber(minimumDuration) && _isNumber(sessionDuration) && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n return this.buffer || this.clearBuffer()\n }\n\n if (this.buffer && this.buffer.data.length !== 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n\n return this.clearBuffer()\n } else {\n return this.buffer || this.clearBuffer()\n }\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n !this.buffer ||\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this.buffer = this._flushBuffer()\n }\n\n this.buffer.size += properties.$snapshot_bytes\n this.buffer.data.push(properties.$snapshot_data)\n\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n transport: 'XHR',\n method: 'POST',\n endpoint: this._endpoint,\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _metrics: {\n rrweb_full_snapshot: properties.$snapshot_data.type === FULL_SNAPSHOT_EVENT_TYPE,\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"sessionrecording.js","sourceRoot":"","sources":["../../../../src/extensions/replay/sessionrecording.ts"],"names":[],"mappings":";;;;;;;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AAA;YACvB,CAAC,EAAE,wBAAwB,CAAC,CAAA;SAC/B;IACL,CAAC;IAEO,2CAAgB,GAAxB,UAAyB,UAAsB;QAC3C,oGAAoG;QACpG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE;YAC3C,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,WAAW,EAAE,IAAI;YACjB,SAAS,EAAE,2BAA2B;YACtC,QAAQ,EAAE;gBACN,mBAAmB,EAAE,UAAU,CAAC,cAAc,CAAC,IAAI,KAAK,wBAAwB;aACnF;SACJ,CAAC,CAAA;IACN,CAAC;IACL,uBAAC;AAAD,CAAC,AAnjBD,IAmjBC","sourcesContent":["import {\n CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_ENABLED_SERVER_SIDE,\n SESSION_RECORDING_IS_SAMPLED,\n SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE,\n} from '../../constants'\nimport {\n FULL_SNAPSHOT_EVENT_TYPE,\n INCREMENTAL_SNAPSHOT_EVENT_TYPE,\n META_EVENT_TYPE,\n MutationRateLimiter,\n recordOptions,\n rrwebRecord,\n truncateLargeConsoleLogs,\n} from './sessionrecording-utils'\nimport { PostHog } from '../../posthog-core'\nimport { DecideResponse, NetworkRequest, Properties } from '../../types'\nimport { EventType, type eventWithTime, type listenerHandler } from '@rrweb/types'\nimport Config from '../../config'\nimport {\n _isBoolean,\n _isNull,\n _isNumber,\n _isObject,\n _isString,\n _isUndefined,\n _timestamp,\n loadScript,\n logger,\n} from '../../utils'\n\nconst BASE_ENDPOINT = '/s/'\n\nexport const RECORDING_IDLE_ACTIVITY_TIMEOUT_MS = 5 * 60 * 1000 // 5 minutes\nexport const RECORDING_MAX_EVENT_SIZE = 1024 * 1024 * 0.9 // ~1mb (with some wiggle room)\nexport const RECORDING_BUFFER_TIMEOUT = 2000 // 2 seconds\nexport const SESSION_RECORDING_BATCH_KEY = 'recordings'\n\n// NOTE: Importing this type is problematic as we can't safely bundle it to a TS definition so, instead we redefine.\n// import type { record } from 'rrweb2/typings'\n// import type { recordOptions } from 'rrweb/typings/types'\n\n// Copied from rrweb typings to avoid import\nenum IncrementalSource {\n Mutation = 0,\n MouseMove = 1,\n MouseInteraction = 2,\n Scroll = 3,\n ViewportResize = 4,\n Input = 5,\n TouchMove = 6,\n MediaInteraction = 7,\n StyleSheetRule = 8,\n CanvasMutation = 9,\n Font = 10,\n Log = 11,\n Drag = 12,\n StyleDeclaration = 13,\n Selection = 14,\n AdoptedStyleSheet = 15,\n}\n\nconst ACTIVE_SOURCES = [\n IncrementalSource.MouseMove,\n IncrementalSource.MouseInteraction,\n IncrementalSource.Scroll,\n IncrementalSource.ViewportResize,\n IncrementalSource.Input,\n IncrementalSource.TouchMove,\n IncrementalSource.MediaInteraction,\n IncrementalSource.Drag,\n]\n\n/**\n * Session recording starts in buffering mode while waiting for decide response\n * Once the response is received it might be disabled, active or sampled\n * When sampled that means a sample rate is set and the last time the session id was rotated\n * the sample rate determined this session should be sent to the server.\n */\ntype SessionRecordingStatus = 'disabled' | 'sampled' | 'active' | 'buffering'\n\ninterface SnapshotBuffer {\n size: number\n data: any[]\n sessionId: string | null\n windowId: string | null\n}\n\nexport class SessionRecording {\n private _linkedFlagSeen: boolean = false\n private instance: PostHog\n private _endpoint: string\n private windowId: string | null\n private sessionId: string | null\n private _lastActivityTimestamp: number = Date.now()\n private flushBufferTimer?: any\n private buffer?: SnapshotBuffer\n private mutationRateLimiter?: MutationRateLimiter\n private _captureStarted: boolean\n private stopRrweb: listenerHandler | undefined\n private receivedDecide: boolean\n private rrwebRecord: rrwebRecord | undefined\n private isIdle = false\n private _linkedFlag: string | null = null\n private _sampleRate: number | null = null\n private _minimumDuration: number | null = null\n\n public get started(): boolean {\n // TODO could we use status instead of _captureStarted?\n return this._captureStarted\n }\n\n private get sessionManager() {\n if (!this.instance.sessionManager) {\n logger.error('Session recording started without valid sessionManager')\n throw new Error('Session recording started without valid sessionManager. This is a bug.')\n }\n\n return this.instance.sessionManager\n }\n\n private get isSampled(): boolean | null {\n if (_isNumber(this._sampleRate)) {\n return this.instance.get_property(SESSION_RECORDING_IS_SAMPLED)\n } else {\n return null\n }\n }\n\n private get sessionDuration(): number | null {\n const mostRecentSnapshot = this.buffer?.data[this.buffer?.data.length - 1]\n const { sessionStartTimestamp } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n return mostRecentSnapshot ? mostRecentSnapshot.timestamp - sessionStartTimestamp : null\n }\n\n private get isRecordingEnabled() {\n const enabled_server_side = !!this.instance.get_property(SESSION_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = !this.instance.config.disable_session_recording\n return enabled_server_side && enabled_client_side\n }\n\n private get isConsoleLogCaptureEnabled() {\n const enabled_server_side = !!this.instance.get_property(CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE)\n const enabled_client_side = this.instance.config.enable_recording_console_log\n return enabled_client_side ?? enabled_server_side\n }\n\n private get recordingVersion() {\n const recordingVersion_server_side = this.instance.get_property(SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE)\n const recordingVersion_client_side = this.instance.config.session_recording?.recorderVersion\n return recordingVersion_client_side || recordingVersion_server_side || 'v1'\n }\n\n /**\n * defaults to buffering mode until a decide response is received\n * once a decide response is received status can be disabled, active or sampled\n */\n private get status(): SessionRecordingStatus {\n if (!this.receivedDecide) {\n return 'buffering'\n }\n\n if (!this.isRecordingEnabled) {\n return 'disabled'\n }\n\n if (_isString(this._linkedFlag) && !this._linkedFlagSeen) {\n return 'buffering'\n }\n\n if (_isBoolean(this.isSampled)) {\n return this.isSampled ? 'sampled' : 'disabled'\n } else {\n return 'active'\n }\n }\n\n constructor(instance: PostHog) {\n this.instance = instance\n this._captureStarted = false\n this._endpoint = BASE_ENDPOINT\n this.stopRrweb = undefined\n this.receivedDecide = false\n\n window.addEventListener('beforeunload', () => {\n this._flushBuffer()\n })\n\n if (!this.instance.sessionManager) {\n logger.error('Session recording started without valid sessionManager')\n throw new Error('Session recording started without valid sessionManager. This is a bug.')\n }\n\n const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId(true)\n this.windowId = windowId\n this.sessionId = sessionId\n\n this.buffer = this.clearBuffer()\n }\n\n startRecordingIfEnabled() {\n if (this.isRecordingEnabled) {\n this.startCaptureAndTrySendingQueuedSnapshots()\n } else {\n this.stopRecording()\n this.clearBuffer()\n }\n }\n\n stopRecording() {\n if (this._captureStarted && this.stopRrweb) {\n this.stopRrweb()\n this.stopRrweb = undefined\n this._captureStarted = false\n }\n }\n\n private makeSamplingDecision(sessionId: string): void {\n const sessionIdChanged = this.sessionId !== sessionId\n\n if (!_isNumber(this._sampleRate)) {\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: null,\n })\n return\n }\n\n const storedIsSampled = this.isSampled\n\n /**\n * if we get this far then we should make a sampling decision.\n * When the session id changes or there is no stored sampling decision for this session id\n * then we should make a new decision.\n *\n * Otherwise, we should use the stored decision.\n */\n let shouldSample: boolean\n if (sessionIdChanged || !_isBoolean(storedIsSampled)) {\n const randomNumber = Math.random()\n shouldSample = randomNumber < this._sampleRate\n } else {\n shouldSample = storedIsSampled\n }\n\n if (!shouldSample) {\n logger.warn(\n `[SessionSampling] Sample rate (${this._sampleRate}) has determined that this sessionId (${sessionId}) will not be sent to the server.`\n )\n }\n\n this.instance.persistence?.register({\n [SESSION_RECORDING_IS_SAMPLED]: shouldSample,\n })\n }\n\n afterDecideResponse(response: DecideResponse) {\n if (this.instance.persistence) {\n this.instance.persistence.register({\n [SESSION_RECORDING_ENABLED_SERVER_SIDE]: !!response['sessionRecording'],\n [CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE]: response.sessionRecording?.consoleLogRecordingEnabled,\n [SESSION_RECORDING_RECORDER_VERSION_SERVER_SIDE]: response.sessionRecording?.recorderVersion,\n })\n }\n\n const receivedSampleRate = response.sessionRecording?.sampleRate\n this._sampleRate =\n _isUndefined(receivedSampleRate) || _isNull(receivedSampleRate) ? null : parseFloat(receivedSampleRate)\n\n const receivedMinimumDuration = response.sessionRecording?.minimumDurationMilliseconds\n this._minimumDuration = _isUndefined(receivedMinimumDuration) ? null : receivedMinimumDuration\n\n this._linkedFlag = response.sessionRecording?.linkedFlag || null\n\n if (response.sessionRecording?.endpoint) {\n this._endpoint = response.sessionRecording?.endpoint\n }\n\n if (_isNumber(this._sampleRate)) {\n this.sessionManager.onSessionId((sessionId) => {\n this.makeSamplingDecision(sessionId)\n })\n }\n\n if (_isString(this._linkedFlag)) {\n const linkedFlag = this._linkedFlag\n this.instance.onFeatureFlags((flags) => {\n this._linkedFlagSeen = flags.includes(linkedFlag)\n })\n }\n\n this.receivedDecide = true\n this.startRecordingIfEnabled()\n }\n\n log(message: string, level: 'log' | 'warn' | 'error' = 'log') {\n this.instance.sessionRecording?.onRRwebEmit({\n type: 6,\n data: {\n plugin: 'rrweb/console@1',\n payload: {\n level,\n trace: [],\n // Even though it is a string we stringify it as that's what rrweb expects\n payload: [JSON.stringify(message)],\n },\n },\n timestamp: _timestamp(),\n })\n }\n\n private startCaptureAndTrySendingQueuedSnapshots() {\n this._startCapture()\n }\n\n private _startCapture() {\n if (_isUndefined(Object.assign)) {\n // According to the rrweb docs, rrweb is not supported on IE11 and below:\n // \"rrweb does not support IE11 and below because it uses the MutationObserver API which was supported by these browsers.\"\n // https://github.com/rrweb-io/rrweb/blob/master/guide.md#compatibility-note\n //\n // However, MutationObserver does exist on IE11, it just doesn't work well and does not detect all changes.\n // Instead, when we load \"recorder.js\", the first JS error is about \"Object.assign\" being undefined.\n // Thus instead of MutationObserver, we look for this function and block recording if it's undefined.\n return\n }\n\n // We do not switch recorder versions midway through a recording.\n if (this._captureStarted || this.instance.config.disable_session_recording) {\n return\n }\n\n this._captureStarted = true\n // We want to ensure the sessionManager is reset if necessary on load of the recorder\n this.sessionManager.checkAndGetSessionAndWindowId()\n\n const recorderJS = this.recordingVersion === 'v2' ? 'recorder-v2.js' : 'recorder.js'\n\n // If recorder.js is already loaded (if array.full.js snippet is used or posthog-js/dist/recorder is\n // imported) or matches the requested recorder version, don't load script. Otherwise, remotely import\n // recorder.js from cdn since it hasn't been loaded.\n if (this.instance.__loaded_recorder_version !== this.recordingVersion) {\n loadScript(this.instance.config.api_host + `/static/${recorderJS}?v=${Config.LIB_VERSION}`, (err) => {\n if (err) {\n return logger.error(`Could not load ${recorderJS}`, err)\n }\n\n this._onScriptLoaded()\n })\n } else {\n this._onScriptLoaded()\n }\n }\n\n private _isInteractiveEvent(event: eventWithTime) {\n return event.type === INCREMENTAL_SNAPSHOT_EVENT_TYPE && ACTIVE_SOURCES.indexOf(event.data?.source) !== -1\n }\n\n private _updateWindowAndSessionIds(event: eventWithTime) {\n // Some recording events are triggered by non-user events (e.g. \"X minutes ago\" text updating on the screen).\n // We don't want to extend the session or trigger a new session in these cases. These events are designated by event\n // type -> incremental update, and source -> mutation.\n\n const isUserInteraction = this._isInteractiveEvent(event)\n\n if (!isUserInteraction && !this.isIdle) {\n // We check if the lastActivityTimestamp is old enough to go idle\n if (event.timestamp - this._lastActivityTimestamp > RECORDING_IDLE_ACTIVITY_TIMEOUT_MS) {\n this.isIdle = true\n }\n }\n\n if (isUserInteraction) {\n this._lastActivityTimestamp = event.timestamp\n if (this.isIdle) {\n // Remove the idle state if set and trigger a full snapshot as we will have ignored previous mutations\n this.isIdle = false\n this._tryTakeFullSnapshot()\n }\n }\n\n if (this.isIdle) {\n return\n }\n\n // We only want to extend the session if it is an interactive event.\n const { windowId, sessionId } = this.sessionManager.checkAndGetSessionAndWindowId(\n !isUserInteraction,\n event.timestamp\n )\n\n const sessionIdChanged = this.sessionId !== sessionId\n const windowIdChanged = this.windowId !== windowId\n this.windowId = windowId\n this.sessionId = sessionId\n\n if (\n [FULL_SNAPSHOT_EVENT_TYPE, META_EVENT_TYPE].indexOf(event.type) === -1 &&\n (windowIdChanged || sessionIdChanged)\n ) {\n this._tryTakeFullSnapshot()\n }\n }\n\n private _tryTakeFullSnapshot(): boolean {\n // TODO this should ignore based on emit?\n if (!this._captureStarted) {\n return false\n }\n try {\n this.rrwebRecord?.takeFullSnapshot()\n return true\n } catch (e) {\n // Sometimes a race can occur where the recorder is not fully started yet, so we can't take a full snapshot.\n logger.error('Error taking full snapshot.', e)\n return false\n }\n }\n\n private _onScriptLoaded() {\n // rrweb config info: https://github.com/rrweb-io/rrweb/blob/7d5d0033258d6c29599fb08412202d9a2c7b9413/src/record/index.ts#L28\n const sessionRecordingOptions: recordOptions<eventWithTime> = {\n // select set of rrweb config options we expose to our users\n // see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n blockClass: 'ph-no-capture',\n blockSelector: undefined,\n ignoreClass: 'ph-ignore-input',\n maskTextClass: 'ph-mask',\n maskTextSelector: undefined,\n maskTextFn: undefined,\n maskAllInputs: true,\n maskInputOptions: {},\n maskInputFn: undefined,\n slimDOMOptions: {},\n collectFonts: false,\n inlineStylesheet: true,\n recordCrossOriginIframes: false,\n }\n // We switched from loading all of rrweb to just the record part, but\n // keep backwards compatibility if someone hasn't upgraded PostHog\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.rrwebRecord = window.rrweb ? window.rrweb.record : window.rrwebRecord\n\n // only allows user to set our allow-listed options\n const userSessionRecordingOptions = this.instance.config.session_recording\n for (const [key, value] of Object.entries(userSessionRecordingOptions || {})) {\n if (key in sessionRecordingOptions) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n sessionRecordingOptions[key] = value\n }\n }\n\n if (!this.rrwebRecord) {\n logger.error(\n 'onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.'\n )\n return\n }\n\n this.mutationRateLimiter =\n this.mutationRateLimiter ??\n new MutationRateLimiter(this.rrwebRecord, {\n onBlockedNode: (id, node) => {\n const message = `Too many mutations on node '${id}'. Rate limiting. This could be due to SVG animations or something similar`\n logger.info(message, {\n node: node,\n })\n\n this.log('[PostHog Recorder] ' + message, 'warn')\n },\n })\n\n this.stopRrweb = this.rrwebRecord({\n emit: (event) => {\n this.onRRwebEmit(event)\n },\n plugins:\n (window as any).rrwebConsoleRecord && this.isConsoleLogCaptureEnabled\n ? [(window as any).rrwebConsoleRecord.getRecordConsolePlugin()]\n : [],\n ...sessionRecordingOptions,\n })\n\n // :TRICKY: rrweb does not capture navigation within SPA-s, so hook into our $pageview events to get access to all events.\n // Dropping the initial event is fine (it's always captured by rrweb).\n this.instance._addCaptureHook((eventName) => {\n // If anything could go wrong here it has the potential to block the main loop,\n // so we catch all errors.\n try {\n if (eventName === '$pageview') {\n const href = this._maskUrl(window.location.href)\n if (!href) {\n return\n }\n this.rrwebRecord?.addCustomEvent('$pageview', { href })\n }\n } catch (e) {\n logger.error('Could not add $pageview to rrweb session', e)\n }\n })\n\n // We reset the last activity timestamp, resetting the idle timer\n this._lastActivityTimestamp = Date.now()\n this.isIdle = false\n }\n\n onRRwebEmit(rawEvent: eventWithTime) {\n if (!rawEvent || !_isObject(rawEvent)) {\n return\n }\n\n if (rawEvent.type === EventType.Meta) {\n const href = this._maskUrl(rawEvent.data.href)\n if (!href) {\n return\n }\n rawEvent.data.href = href\n }\n\n const throttledEvent = this.mutationRateLimiter\n ? this.mutationRateLimiter.throttleMutations(rawEvent)\n : rawEvent\n\n if (!throttledEvent) {\n return\n }\n\n // TODO: Re-add ensureMaxMessageSize once we are confident in it\n const event = truncateLargeConsoleLogs(throttledEvent)\n const size = JSON.stringify(event).length\n\n const properties = {\n $snapshot_bytes: size,\n $snapshot_data: event,\n $session_id: this.sessionId,\n $window_id: this.windowId,\n }\n\n this._updateWindowAndSessionIds(event)\n\n if (this.isIdle) {\n // When in an idle state we keep recording, but don't capture the events\n return\n }\n\n if (this.status !== 'disabled') {\n this._captureSnapshotBuffered(properties)\n } else {\n this.clearBuffer()\n }\n }\n\n private _maskUrl(url: string): string | undefined {\n const userSessionRecordingOptions = this.instance.config.session_recording\n\n if (userSessionRecordingOptions.maskNetworkRequestFn) {\n let networkRequest: NetworkRequest | null | undefined = {\n url,\n }\n\n networkRequest = userSessionRecordingOptions.maskNetworkRequestFn(networkRequest)\n\n return networkRequest?.url\n }\n\n return url\n }\n\n private clearBuffer(): SnapshotBuffer {\n this.buffer = undefined\n\n return {\n size: 0,\n data: [],\n sessionId: this.sessionId,\n windowId: this.windowId,\n }\n }\n\n // the intention is a buffer that (currently) is used only after a decide response enables session recording\n // it is called ever X seconds using the flushBufferTimer so that we don't have to wait for the buffer to fill up\n // when it is called on a timer it assumes that it can definitely flush\n // it is flushed when the session id changes or the size of the buffered data gets too great (1mb by default)\n // first change: if the recording is in buffering mode,\n // flush buffer simply resets the timer and returns the existing flush buffer\n private _flushBuffer() {\n if (this.flushBufferTimer) {\n clearTimeout(this.flushBufferTimer)\n this.flushBufferTimer = undefined\n }\n\n const minimumDuration = this._minimumDuration\n const sessionDuration = this.sessionDuration\n const isBelowMinimumDuration =\n _isNumber(minimumDuration) && _isNumber(sessionDuration) && sessionDuration < minimumDuration\n\n if (this.status === 'buffering' || isBelowMinimumDuration) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n return this.buffer || this.clearBuffer()\n }\n\n if (this.buffer && this.buffer.data.length !== 0) {\n this._captureSnapshot({\n $snapshot_bytes: this.buffer.size,\n $snapshot_data: this.buffer.data,\n $session_id: this.buffer.sessionId,\n $window_id: this.buffer.windowId,\n })\n\n return this.clearBuffer()\n } else {\n return this.buffer || this.clearBuffer()\n }\n }\n\n private _captureSnapshotBuffered(properties: Properties) {\n const additionalBytes = 2 + (this.buffer?.data.length || 0) // 2 bytes for the array brackets and 1 byte for each comma\n if (\n !this.buffer ||\n this.buffer.size + properties.$snapshot_bytes + additionalBytes > RECORDING_MAX_EVENT_SIZE ||\n this.buffer.sessionId !== this.sessionId\n ) {\n this.buffer = this._flushBuffer()\n }\n\n this.buffer.size += properties.$snapshot_bytes\n this.buffer.data.push(properties.$snapshot_data)\n\n if (!this.flushBufferTimer) {\n this.flushBufferTimer = setTimeout(() => {\n this._flushBuffer()\n }, RECORDING_BUFFER_TIMEOUT)\n }\n }\n\n private _captureSnapshot(properties: Properties) {\n // :TRICKY: Make sure we batch these requests, use a custom endpoint and don't truncate the strings.\n this.instance.capture('$snapshot', properties, {\n transport: 'XHR',\n method: 'POST',\n endpoint: this._endpoint,\n _noTruncate: true,\n _batchKey: SESSION_RECORDING_BATCH_KEY,\n _metrics: {\n rrweb_full_snapshot: properties.$snapshot_data.type === FULL_SNAPSHOT_EVENT_TYPE,\n },\n })\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmCH;IAQI,2BAAY,QAAiB,EAAE,YAAqB,EAAE,SAAkB,EAAE,MAAe;QACrF,gEAAgE;QAChE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,UAAU,uBAAkE;YACzF,uBAAuB,CAAC,UAAC,KAAmB;;gBACxC,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBAC/D,IAAI,CAAC,KAAK,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAA;gBAEhC,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;gBAChE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAA;gBACjF,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE;oBACpC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;iBACjG;gBAED,IAAM,UAAU,GAAG,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,EAAE,CAAA;gBAEhD,IAAM,IAAI,GAAgD;oBACtD,gCAAgC;oBAChC,kBAAkB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBACxC,eAAe,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBACpC,oBAAoB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE;oBACpE,8BAA8B;oBAC9B,gBAAgB,EAAE,KAAK,CAAC,QAAQ;oBAChC,iBAAiB,EAAE,KAAK,CAAC,SAAS;oBAClC,yBAAyB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBAC/C,sBAAsB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBAC3C,YAAY,EAAE,KAAK,CAAC,IAAI;iBAC3B,CAAA;gBAED,IAAI,YAAY,IAAI,SAAS;oBACzB,IAAI,CAAC,aAAa,CAAC;wBACf,CAAC,MAAM,IAAI,kCAAkC,CAAC;4BAC9C,YAAY;4BACZ,mBAAmB;4BACnB,SAAS;4BACT,SAAS;4BACT,KAAK,CAAC,QAAQ,CAAA;gBACtB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;gBACpC,OAAO,KAAK,CAAA;YAChB,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAlDD,IAkDC","sourcesContent":["/**\n * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog\n *\n * ### Usage\n *\n * Sentry.init({\n * dsn: 'https://example',\n * integrations: [\n * new posthog.SentryIntegration(posthog)\n * ]\n * })\n *\n * @param {Object} [posthog] The posthog object\n * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry\n * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry\n * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)\n */\n\nimport { PostHog } from '../posthog-core'\nimport { ErrorProperties } from './exceptions/error-conversion'\n\n// NOTE - we can't import from @sentry/types because it changes frequently and causes clashes\n// We only use a small subset of the types, so we can just define the integration overall and use any for the rest\n\n// import {\n// Event as _SentryEvent,\n// EventProcessor as _SentryEventProcessor,\n// Hub as _SentryHub,\n// Integration as _SentryIntegration,\n// } from '@sentry/types'\n\n// Uncomment the above and comment the below to get type checking for development\n\ntype _SentryEvent = any\ntype _SentryEventProcessor = any\ntype _SentryHub = any\n\ninterface _SentryIntegration {\n name: string\n setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void\n}\n\ninterface SentryExceptionProperties {\n $sentry_event_id: any\n $sentry_exception: any\n $sentry_exception_message: any\n $sentry_exception_type: any\n $sentry_tags: any\n $sentry_url?: string\n}\n\nexport class SentryIntegration implements _SentryIntegration {\n name: string\n\n setupOnce: (\n addGlobalEventProcessor: (callback: _SentryEventProcessor) => void,\n getCurrentHub: () => _SentryHub\n ) => void\n\n constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string) {\n // setupOnce gets called by Sentry when it intializes the plugin\n this.name = 'posthog-js'\n this.setupOnce = function (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void) {\n addGlobalEventProcessor((event: _SentryEvent) => {\n if (event.level !== 'error' || !_posthog.__loaded) return event\n if (!event.tags) event.tags = {}\n\n const host = _posthog.config.ui_host || _posthog.config.api_host\n event.tags['PostHog Person URL'] = host + '/person/' + _posthog.get_distinct_id()\n if (_posthog.sessionRecordingStarted()) {\n event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true })\n }\n\n const exceptions = event.exception?.values || []\n\n const data: SentryExceptionProperties & ErrorProperties = {\n // PostHog Exception Properties,\n $exception_message: exceptions[0]?.value,\n $exception_type: exceptions[0]?.type,\n $exception_personURL: host + '/person/' + _posthog.get_distinct_id(),\n // Sentry Exception Properties\n $sentry_event_id: event.event_id,\n $sentry_exception: event.exception,\n $sentry_exception_message: exceptions[0]?.value,\n $sentry_exception_type: exceptions[0]?.type,\n $sentry_tags: event.tags,\n }\n\n if (organization && projectId)\n data['$sentry_url'] =\n (prefix || 'https://sentry.io/organizations/') +\n organization +\n '/issues/?project=' +\n projectId +\n '&query=' +\n event.event_id\n _posthog.capture('$exception', data)\n return event\n })\n }\n }\n}\n"]}
1
+ {"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAkCH;IAQI,2BAAY,QAAiB,EAAE,YAAqB,EAAE,SAAkB,EAAE,MAAe;QACrF,gEAAgE;QAChE,IAAI,CAAC,IAAI,GAAG,YAAY,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,UAAU,uBAAkE;YACzF,uBAAuB,CAAC,UAAC,KAAmB;;gBACxC,IAAI,KAAK,CAAC,KAAK,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAAE,OAAO,KAAK,CAAA;gBAC/D,IAAI,CAAC,KAAK,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,EAAE,CAAA;gBAEhC,IAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;gBAChE,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAA;gBACjF,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE;oBACpC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;iBACjG;gBAED,IAAM,UAAU,GAAG,CAAA,MAAA,KAAK,CAAC,SAAS,0CAAE,MAAM,KAAI,EAAE,CAAA;gBAEhD,IAAM,IAAI,GAMN;oBACA,gCAAgC;oBAChC,kBAAkB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBACxC,eAAe,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBACpC,oBAAoB,EAAE,IAAI,GAAG,UAAU,GAAG,QAAQ,CAAC,eAAe,EAAE;oBACpE,8BAA8B;oBAC9B,gBAAgB,EAAE,KAAK,CAAC,QAAQ;oBAChC,iBAAiB,EAAE,KAAK,CAAC,SAAS;oBAClC,yBAAyB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,KAAK;oBAC/C,sBAAsB,EAAE,MAAA,UAAU,CAAC,CAAC,CAAC,0CAAE,IAAI;oBAC3C,YAAY,EAAE,KAAK,CAAC,IAAI;iBAC3B,CAAA;gBAED,IAAI,YAAY,IAAI,SAAS;oBACzB,IAAI,CAAC,aAAa,CAAC;wBACf,CAAC,MAAM,IAAI,kCAAkC,CAAC;4BAC9C,YAAY;4BACZ,mBAAmB;4BACnB,SAAS;4BACT,SAAS;4BACT,KAAK,CAAC,QAAQ,CAAA;gBACtB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;gBACpC,OAAO,KAAK,CAAA;YAChB,CAAC,CAAC,CAAA;QACN,CAAC,CAAA;IACL,CAAC;IACL,wBAAC;AAAD,CAAC,AAxDD,IAwDC","sourcesContent":["/**\n * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog\n *\n * ### Usage\n *\n * Sentry.init({\n * dsn: 'https://example',\n * integrations: [\n * new posthog.SentryIntegration(posthog)\n * ]\n * })\n *\n * @param {Object} [posthog] The posthog object\n * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry\n * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry\n * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)\n */\n\nimport { PostHog } from '../posthog-core'\n\n// NOTE - we can't import from @sentry/types because it changes frequently and causes clashes\n// We only use a small subset of the types, so we can just define the integration overall and use any for the rest\n\n// import {\n// Event as _SentryEvent,\n// EventProcessor as _SentryEventProcessor,\n// Hub as _SentryHub,\n// Integration as _SentryIntegration,\n// } from '@sentry/types'\n\n// Uncomment the above and comment the below to get type checking for development\n\ntype _SentryEvent = any\ntype _SentryEventProcessor = any\ntype _SentryHub = any\n\ninterface _SentryIntegration {\n name: string\n setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void\n}\n\ninterface SentryExceptionProperties {\n $sentry_event_id: any\n $sentry_exception: any\n $sentry_exception_message: any\n $sentry_exception_type: any\n $sentry_tags: any\n $sentry_url?: string\n}\n\nexport class SentryIntegration implements _SentryIntegration {\n name: string\n\n setupOnce: (\n addGlobalEventProcessor: (callback: _SentryEventProcessor) => void,\n getCurrentHub: () => _SentryHub\n ) => void\n\n constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string) {\n // setupOnce gets called by Sentry when it intializes the plugin\n this.name = 'posthog-js'\n this.setupOnce = function (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void) {\n addGlobalEventProcessor((event: _SentryEvent) => {\n if (event.level !== 'error' || !_posthog.__loaded) return event\n if (!event.tags) event.tags = {}\n\n const host = _posthog.config.ui_host || _posthog.config.api_host\n event.tags['PostHog Person URL'] = host + '/person/' + _posthog.get_distinct_id()\n if (_posthog.sessionRecordingStarted()) {\n event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true })\n }\n\n const exceptions = event.exception?.values || []\n\n const data: SentryExceptionProperties & {\n // two properties added to match any exception auto-capture\n // added manually to avoid any dependency on the lazily loaded content\n $exception_message: any\n $exception_type: any\n $exception_personURL: string\n } = {\n // PostHog Exception Properties,\n $exception_message: exceptions[0]?.value,\n $exception_type: exceptions[0]?.type,\n $exception_personURL: host + '/person/' + _posthog.get_distinct_id(),\n // Sentry Exception Properties\n $sentry_event_id: event.event_id,\n $sentry_exception: event.exception,\n $sentry_exception_message: exceptions[0]?.value,\n $sentry_exception_type: exceptions[0]?.type,\n $sentry_tags: event.tags,\n }\n\n if (organization && projectId)\n data['$sentry_url'] =\n (prefix || 'https://sentry.io/organizations/') +\n organization +\n '/issues/?project=' +\n projectId +\n '&query=' +\n event.event_id\n _posthog.capture('$exception', data)\n return event\n })\n }\n }\n}\n"]}