posthog-js 1.76.0 → 1.77.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/array.full.js +2 -2
  2. package/dist/array.full.js.map +1 -1
  3. package/dist/array.js +2 -2
  4. package/dist/array.js.map +1 -1
  5. package/dist/es.js +2 -2
  6. package/dist/es.js.map +1 -1
  7. package/dist/module.d.ts +38 -6
  8. package/dist/module.js +2 -2
  9. package/dist/module.js.map +1 -1
  10. package/lib/package.json +8 -6
  11. package/lib/src/autocapture-utils.d.ts +15 -0
  12. package/lib/src/autocapture-utils.js +303 -0
  13. package/lib/src/autocapture-utils.js.map +1 -0
  14. package/lib/src/autocapture.d.ts +27 -0
  15. package/lib/src/autocapture.js +290 -0
  16. package/lib/src/autocapture.js.map +1 -0
  17. package/lib/src/base-request-queue.d.ts +12 -0
  18. package/lib/src/base-request-queue.js +33 -0
  19. package/lib/src/base-request-queue.js.map +1 -0
  20. package/lib/src/compression.d.ts +3 -0
  21. package/lib/src/compression.js +35 -0
  22. package/lib/src/compression.js.map +1 -0
  23. package/lib/src/config.d.ts +5 -0
  24. package/lib/src/config.js +9 -0
  25. package/lib/src/config.js.map +1 -0
  26. package/lib/src/constants.d.ts +19 -0
  27. package/lib/src/constants.js +41 -0
  28. package/lib/src/constants.js.map +1 -0
  29. package/lib/src/decide.d.ts +8 -0
  30. package/lib/src/decide.js +118 -0
  31. package/lib/src/decide.js.map +1 -0
  32. package/lib/src/extensions/cloud.d.ts +1 -0
  33. package/lib/src/extensions/cloud.js +2 -0
  34. package/lib/src/extensions/cloud.js.map +1 -0
  35. package/lib/src/extensions/exceptions/error-conversion.d.ts +26 -0
  36. package/lib/src/extensions/exceptions/error-conversion.js +204 -0
  37. package/lib/src/extensions/exceptions/error-conversion.js.map +1 -0
  38. package/lib/src/extensions/exceptions/exception-autocapture.d.ts +24 -0
  39. package/lib/src/extensions/exceptions/exception-autocapture.js +164 -0
  40. package/lib/src/extensions/exceptions/exception-autocapture.js.map +1 -0
  41. package/lib/src/extensions/exceptions/stack-trace.d.ts +31 -0
  42. package/lib/src/extensions/exceptions/stack-trace.js +259 -0
  43. package/lib/src/extensions/exceptions/stack-trace.js.map +1 -0
  44. package/lib/src/extensions/exceptions/type-checking.d.ts +10 -0
  45. package/lib/src/extensions/exceptions/type-checking.js +43 -0
  46. package/lib/src/extensions/exceptions/type-checking.js.map +1 -0
  47. package/lib/src/extensions/rageclick.d.ts +10 -0
  48. package/lib/src/extensions/rageclick.js +33 -0
  49. package/lib/src/extensions/rageclick.js.map +1 -0
  50. package/lib/src/extensions/segment-integration.d.ts +44 -0
  51. package/lib/src/extensions/segment-integration.js +34 -0
  52. package/lib/src/extensions/segment-integration.js.map +1 -0
  53. package/lib/src/extensions/sentry-integration.d.ts +30 -0
  54. package/lib/src/extensions/sentry-integration.js +63 -0
  55. package/lib/src/extensions/sentry-integration.js.map +1 -0
  56. package/lib/src/extensions/sessionrecording-utils.d.ts +67 -0
  57. package/lib/src/extensions/sessionrecording-utils.js +192 -0
  58. package/lib/src/extensions/sessionrecording-utils.js.map +1 -0
  59. package/lib/src/extensions/sessionrecording.d.ts +45 -0
  60. package/lib/src/extensions/sessionrecording.js +430 -0
  61. package/lib/src/extensions/sessionrecording.js.map +1 -0
  62. package/lib/src/extensions/toolbar.d.ts +18 -0
  63. package/lib/src/extensions/toolbar.js +151 -0
  64. package/lib/src/extensions/toolbar.js.map +1 -0
  65. package/lib/src/extensions/web-performance.d.ts +20 -0
  66. package/lib/src/extensions/web-performance.js +245 -0
  67. package/lib/src/extensions/web-performance.js.map +1 -0
  68. package/lib/src/gdpr-utils.d.ts +80 -0
  69. package/lib/src/gdpr-utils.js +236 -0
  70. package/lib/src/gdpr-utils.js.map +1 -0
  71. package/lib/src/loader-globals-full.d.ts +1 -0
  72. package/lib/src/loader-globals-full.js +5 -0
  73. package/lib/src/loader-globals-full.js.map +1 -0
  74. package/lib/src/loader-globals.d.ts +1 -0
  75. package/lib/src/loader-globals.js +3 -0
  76. package/lib/src/loader-globals.js.map +1 -0
  77. package/lib/src/loader-module.d.ts +4 -0
  78. package/lib/src/loader-module.js +6 -0
  79. package/lib/src/loader-module.js.map +1 -0
  80. package/lib/src/loader-recorder-v2.d.ts +2 -0
  81. package/lib/src/loader-recorder-v2.js +15 -0
  82. package/lib/src/loader-recorder-v2.js.map +1 -0
  83. package/lib/src/loader-recorder.d.ts +2 -0
  84. package/lib/src/loader-recorder.js +15 -0
  85. package/lib/src/loader-recorder.js.map +1 -0
  86. package/lib/src/page-view.d.ts +38 -0
  87. package/lib/src/page-view.js +127 -0
  88. package/lib/src/page-view.js.map +1 -0
  89. package/lib/src/posthog-core.d.ts +701 -0
  90. package/lib/src/posthog-core.js +1916 -0
  91. package/lib/src/posthog-core.js.map +1 -0
  92. package/lib/src/posthog-featureflags.d.ts +70 -0
  93. package/lib/src/posthog-featureflags.js +438 -0
  94. package/lib/src/posthog-featureflags.js.map +1 -0
  95. package/lib/src/posthog-persistence.d.ts +57 -0
  96. package/lib/src/posthog-persistence.js +256 -0
  97. package/lib/src/posthog-persistence.js.map +1 -0
  98. package/lib/src/posthog-surveys.d.ts +57 -0
  99. package/lib/src/posthog-surveys.js +76 -0
  100. package/lib/src/posthog-surveys.js.map +1 -0
  101. package/lib/src/rate-limiter.d.ts +5 -0
  102. package/lib/src/rate-limiter.js +66 -0
  103. package/lib/src/rate-limiter.js.map +1 -0
  104. package/lib/src/request-queue.d.ts +10 -0
  105. package/lib/src/request-queue.js +146 -0
  106. package/lib/src/request-queue.js.map +1 -0
  107. package/lib/src/retry-queue.d.ts +28 -0
  108. package/lib/src/retry-queue.js +198 -0
  109. package/lib/src/retry-queue.js.map +1 -0
  110. package/lib/src/send-request.d.ts +6 -0
  111. package/lib/src/send-request.js +125 -0
  112. package/lib/src/send-request.js.map +1 -0
  113. package/lib/src/sessionid.d.ts +28 -0
  114. package/lib/src/sessionid.js +205 -0
  115. package/lib/src/sessionid.js.map +1 -0
  116. package/lib/src/storage.d.ts +7 -0
  117. package/lib/src/storage.js +291 -0
  118. package/lib/src/storage.js.map +1 -0
  119. package/lib/src/types.d.ts +294 -0
  120. package/lib/src/types.js +6 -0
  121. package/lib/src/types.js.map +1 -0
  122. package/lib/src/utils.d.ts +89 -0
  123. package/lib/src/utils.js +868 -0
  124. package/lib/src/utils.js.map +1 -0
  125. package/lib/src/uuidv7.d.ts +42 -0
  126. package/lib/src/uuidv7.js +228 -0
  127. package/lib/src/uuidv7.js.map +1 -0
  128. package/package.json +8 -6
  129. package/CHANGELOG.md +0 -1145
@@ -0,0 +1,259 @@
1
+ // copied and adapted from https://github.com/getsentry/sentry-javascript/blob/41fef4b10f3a644179b77985f00f8696c908539f/packages/browser/src/stack-parsers.ts
2
+ // 💖open source
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __read = (this && this.__read) || function (o, n) {
15
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
16
+ if (!m) return o;
17
+ var i = m.call(o), r, ar = [], e;
18
+ try {
19
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
20
+ }
21
+ catch (error) { e = { error: error }; }
22
+ finally {
23
+ try {
24
+ if (r && !r.done && (m = i["return"])) m.call(i);
25
+ }
26
+ finally { if (e) throw e.error; }
27
+ }
28
+ return ar;
29
+ };
30
+ var __values = (this && this.__values) || function(o) {
31
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
32
+ if (m) return m.call(o);
33
+ if (o && typeof o.length === "number") return {
34
+ next: function () {
35
+ if (o && i >= o.length) o = void 0;
36
+ return { value: o && o[i++], done: !o };
37
+ }
38
+ };
39
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
40
+ };
41
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
42
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43
+ if (ar || !(i in from)) {
44
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
45
+ ar[i] = from[i];
46
+ }
47
+ }
48
+ return to.concat(ar || Array.prototype.slice.call(from));
49
+ };
50
+ // This was originally forked from https://github.com/csnover/TraceKit, and was largely
51
+ // re-written as part of raven - js.
52
+ //
53
+ // This code was later copied to the JavaScript mono - repo and further modified and
54
+ // refactored over the years.
55
+ // Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors.
56
+ //
57
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this
58
+ // software and associated documentation files(the 'Software'), to deal in the Software
59
+ // without restriction, including without limitation the rights to use, copy, modify,
60
+ // merge, publish, distribute, sublicense, and / or sell copies of the Software, and to
61
+ // permit persons to whom the Software is furnished to do so, subject to the following
62
+ // conditions:
63
+ //
64
+ // The above copyright notice and this permission notice shall be included in all copies
65
+ // or substantial portions of the Software.
66
+ //
67
+ // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
68
+ // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
69
+ // PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
70
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
71
+ // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
72
+ // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
+ var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
74
+ var STACKTRACE_FRAME_LIMIT = 50;
75
+ var UNKNOWN_FUNCTION = '?';
76
+ var OPERA10_PRIORITY = 10;
77
+ var OPERA11_PRIORITY = 20;
78
+ var CHROME_PRIORITY = 30;
79
+ var WINJS_PRIORITY = 40;
80
+ var GECKO_PRIORITY = 50;
81
+ function createFrame(filename, func, lineno, colno) {
82
+ var frame = {
83
+ filename: filename,
84
+ function: func,
85
+ in_app: true, // All browser frames are considered in_app
86
+ };
87
+ if (lineno !== undefined) {
88
+ frame.lineno = lineno;
89
+ }
90
+ if (colno !== undefined) {
91
+ frame.colno = colno;
92
+ }
93
+ return frame;
94
+ }
95
+ // Chromium based browsers: Chrome, Brave, new Opera, new Edge
96
+ var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
97
+ var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
98
+ var chrome = function (line) {
99
+ var parts = chromeRegex.exec(line);
100
+ if (parts) {
101
+ var isEval = parts[2] && parts[2].indexOf('eval') === 0; // start of line
102
+ if (isEval) {
103
+ var subMatch = chromeEvalRegex.exec(parts[2]);
104
+ if (subMatch) {
105
+ // throw out eval line/column and use top-most line/column number
106
+ parts[2] = subMatch[1]; // url
107
+ parts[3] = subMatch[2]; // line
108
+ parts[4] = subMatch[3]; // column
109
+ }
110
+ }
111
+ // Kamil: One more hack won't hurt us right? Understanding and adding more rules on top of these regexps right now
112
+ // would be way too time consuming. (TODO: Rewrite whole RegExp to be more readable)
113
+ var _a = __read(extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]), 2), func = _a[0], filename = _a[1];
114
+ return createFrame(filename, func, parts[3] ? +parts[3] : undefined, parts[4] ? +parts[4] : undefined);
115
+ }
116
+ return;
117
+ };
118
+ export var chromeStackLineParser = [CHROME_PRIORITY, chrome];
119
+ // gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
120
+ // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
121
+ // We need this specific case for now because we want no other regex to match.
122
+ var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
123
+ var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
124
+ var gecko = function (line) {
125
+ var _a;
126
+ var parts = geckoREgex.exec(line);
127
+ if (parts) {
128
+ var isEval = parts[3] && parts[3].indexOf(' > eval') > -1;
129
+ if (isEval) {
130
+ var subMatch = geckoEvalRegex.exec(parts[3]);
131
+ if (subMatch) {
132
+ // throw out eval line/column and use top-most line number
133
+ parts[1] = parts[1] || 'eval';
134
+ parts[3] = subMatch[1];
135
+ parts[4] = subMatch[2];
136
+ parts[5] = ''; // no column when eval
137
+ }
138
+ }
139
+ var filename = parts[3];
140
+ var func = parts[1] || UNKNOWN_FUNCTION;
141
+ _a = __read(extractSafariExtensionDetails(func, filename), 2), func = _a[0], filename = _a[1];
142
+ return createFrame(filename, func, parts[4] ? +parts[4] : undefined, parts[5] ? +parts[5] : undefined);
143
+ }
144
+ return;
145
+ };
146
+ export var geckoStackLineParser = [GECKO_PRIORITY, gecko];
147
+ var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
148
+ var winjs = function (line) {
149
+ var parts = winjsRegex.exec(line);
150
+ return parts
151
+ ? createFrame(parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : undefined)
152
+ : undefined;
153
+ };
154
+ export var winjsStackLineParser = [WINJS_PRIORITY, winjs];
155
+ var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
156
+ var opera10 = function (line) {
157
+ var parts = opera10Regex.exec(line);
158
+ return parts ? createFrame(parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : undefined;
159
+ };
160
+ export var opera10StackLineParser = [OPERA10_PRIORITY, opera10];
161
+ var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
162
+ var opera11 = function (line) {
163
+ var parts = opera11Regex.exec(line);
164
+ return parts ? createFrame(parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : undefined;
165
+ };
166
+ export var opera11StackLineParser = [OPERA11_PRIORITY, opera11];
167
+ export var defaultStackLineParsers = [chromeStackLineParser, geckoStackLineParser, winjsStackLineParser];
168
+ export function reverse(stack) {
169
+ if (!stack.length) {
170
+ return [];
171
+ }
172
+ var localStack = stack.slice(0, STACKTRACE_FRAME_LIMIT);
173
+ localStack.reverse();
174
+ return localStack.map(function (frame) { return (__assign(__assign({}, frame), { filename: frame.filename || localStack[localStack.length - 1].filename, function: frame.function || '?' })); });
175
+ }
176
+ export function createStackParser() {
177
+ var parsers = [];
178
+ for (var _i = 0; _i < arguments.length; _i++) {
179
+ parsers[_i] = arguments[_i];
180
+ }
181
+ var sortedParsers = parsers.sort(function (a, b) { return a[0] - b[0]; }).map(function (p) { return p[1]; });
182
+ return function (stack, skipFirst) {
183
+ var e_1, _a;
184
+ if (skipFirst === void 0) { skipFirst = 0; }
185
+ var frames = [];
186
+ var lines = stack.split('\n');
187
+ for (var i = skipFirst; i < lines.length; i++) {
188
+ var line = lines[i];
189
+ // Ignore lines over 1kb as they are unlikely to be stack frames.
190
+ // Many of the regular expressions use backtracking which results in run time that increases exponentially with
191
+ // input size. Huge strings can result in hangs/Denial of Service:
192
+ // https://github.com/getsentry/sentry-javascript/issues/2286
193
+ if (line.length > 1024) {
194
+ continue;
195
+ }
196
+ // https://github.com/getsentry/sentry-javascript/issues/5459
197
+ // Remove webpack (error: *) wrappers
198
+ var cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, '$1') : line;
199
+ // https://github.com/getsentry/sentry-javascript/issues/7813
200
+ // Skip Error: lines
201
+ if (cleanedLine.match(/\S*Error: /)) {
202
+ continue;
203
+ }
204
+ try {
205
+ for (var sortedParsers_1 = (e_1 = void 0, __values(sortedParsers)), sortedParsers_1_1 = sortedParsers_1.next(); !sortedParsers_1_1.done; sortedParsers_1_1 = sortedParsers_1.next()) {
206
+ var parser = sortedParsers_1_1.value;
207
+ var frame = parser(cleanedLine);
208
+ if (frame) {
209
+ frames.push(frame);
210
+ break;
211
+ }
212
+ }
213
+ }
214
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
215
+ finally {
216
+ try {
217
+ if (sortedParsers_1_1 && !sortedParsers_1_1.done && (_a = sortedParsers_1.return)) _a.call(sortedParsers_1);
218
+ }
219
+ finally { if (e_1) throw e_1.error; }
220
+ }
221
+ if (frames.length >= STACKTRACE_FRAME_LIMIT) {
222
+ break;
223
+ }
224
+ }
225
+ return reverse(frames);
226
+ };
227
+ }
228
+ export var defaultStackParser = createStackParser.apply(void 0, __spreadArray([], __read(defaultStackLineParsers), false));
229
+ /**
230
+ * Safari web extensions, starting version unknown, can produce "frames-only" stacktraces.
231
+ * What it means, is that instead of format like:
232
+ *
233
+ * Error: wat
234
+ * at function@url:row:col
235
+ * at function@url:row:col
236
+ * at function@url:row:col
237
+ *
238
+ * it produces something like:
239
+ *
240
+ * function@url:row:col
241
+ * function@url:row:col
242
+ * function@url:row:col
243
+ *
244
+ * Because of that, it won't be captured by `chrome` RegExp and will fall into `Gecko` branch.
245
+ * This function is extracted so that we can use it in both places without duplicating the logic.
246
+ * Unfortunately "just" changing RegExp is too complicated now and making it pass all tests
247
+ * and fix this case seems like an impossible, or at least way too time-consuming task.
248
+ */
249
+ var extractSafariExtensionDetails = function (func, filename) {
250
+ var isSafariExtension = func.indexOf('safari-extension') !== -1;
251
+ var isSafariWebExtension = func.indexOf('safari-web-extension') !== -1;
252
+ return isSafariExtension || isSafariWebExtension
253
+ ? [
254
+ func.indexOf('@') !== -1 ? func.split('@')[0] : UNKNOWN_FUNCTION,
255
+ isSafariExtension ? "safari-extension:".concat(filename) : "safari-web-extension:".concat(filename),
256
+ ]
257
+ : [func, filename];
258
+ };
259
+ //# sourceMappingURL=stack-trace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack-trace.js","sourceRoot":"","sources":["../../../../src/extensions/exceptions/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,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,UAAA;QACR,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI,EAAE,2CAA2C;KAC5D,CAAA;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AAA,uEAAE;oBAA/B,IAAM,MAAM,0BAAA;oBACb,IAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;oBAEjC,IAAI,KAAK,EAAE;wBACP,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;wBAClB,MAAK;qBACR;iBACJ;;;;;;;;;YAED,IAAI,MAAM,CAAC,MAAM,IAAI,sBAAsB,EAAE;gBACzC,MAAK;aACR;SACJ;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC,CAAA;AACL,CAAC;AAED,MAAM,CAAC,IAAM,kBAAkB,GAAG,iBAAiB,wCAAI,uBAAuB,UAAC,CAAA;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,IAAM,6BAA6B,GAAG,UAAC,IAAY,EAAE,QAAgB;IACjE,IAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAA;IACjE,IAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAA;IAExE,OAAO,iBAAiB,IAAI,oBAAoB;QAC5C,CAAC,CAAC;YACI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB;YAChE,iBAAiB,CAAC,CAAC,CAAC,2BAAoB,QAAQ,CAAE,CAAC,CAAC,CAAC,+BAAwB,QAAQ,CAAE;SAC1F;QACH,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC1B,CAAC,CAAA","sourcesContent":["// copied and adapted from https://github.com/getsentry/sentry-javascript/blob/41fef4b10f3a644179b77985f00f8696c908539f/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\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 (lineno !== undefined) {\n frame.lineno = lineno\n }\n\n if (colno !== undefined) {\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,10 @@
1
+ export declare function isEvent(candidate: unknown): candidate is Event;
2
+ export declare function isPlainObject(candidate: unknown): candidate is Record<string, unknown>;
3
+ export declare function isInstanceOf(candidate: unknown, base: any): boolean;
4
+ export declare function isPrimitive(candidate: unknown): candidate is number | string | boolean | bigint | symbol | null | undefined;
5
+ export declare function isError(candidate: unknown): candidate is Error;
6
+ export declare function isErrorEvent(event: string | Error | Event): event is ErrorEvent;
7
+ export declare function isErrorWithStack(candidate: unknown): candidate is Error;
8
+ export declare function isBuiltin(candidate: unknown, className: string): boolean;
9
+ export declare function isDOMException(candidate: unknown): boolean;
10
+ export declare function isDOMError(candidate: unknown): boolean;
@@ -0,0 +1,43 @@
1
+ export function isEvent(candidate) {
2
+ return typeof Event !== 'undefined' && isInstanceOf(candidate, Event);
3
+ }
4
+ export function isPlainObject(candidate) {
5
+ return isBuiltin(candidate, 'Object');
6
+ }
7
+ export function isInstanceOf(candidate, base) {
8
+ try {
9
+ return candidate instanceof base;
10
+ }
11
+ catch (_e) {
12
+ return false;
13
+ }
14
+ }
15
+ export function isPrimitive(candidate) {
16
+ return candidate === null || (typeof candidate !== 'object' && typeof candidate !== 'function');
17
+ }
18
+ export function isError(candidate) {
19
+ switch (Object.prototype.toString.call(candidate)) {
20
+ case '[object Error]':
21
+ case '[object Exception]':
22
+ case '[object DOMException]':
23
+ return true;
24
+ default:
25
+ return isInstanceOf(candidate, Error);
26
+ }
27
+ }
28
+ export function isErrorEvent(event) {
29
+ return isBuiltin(event, 'ErrorEvent');
30
+ }
31
+ export function isErrorWithStack(candidate) {
32
+ return 'stack' in candidate;
33
+ }
34
+ export function isBuiltin(candidate, className) {
35
+ return Object.prototype.toString.call(candidate) === "[object ".concat(className, "]");
36
+ }
37
+ export function isDOMException(candidate) {
38
+ return isBuiltin(candidate, 'DOMException');
39
+ }
40
+ export function isDOMError(candidate) {
41
+ return isBuiltin(candidate, 'DOMError');
42
+ }
43
+ //# sourceMappingURL=type-checking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-checking.js","sourceRoot":"","sources":["../../../../src/extensions/exceptions/type-checking.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,SAAkB;IACtC,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;AACzE,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,SAAS,KAAK,IAAI,IAAI,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,UAAU,CAAC,CAAA;AACnG,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":["export function isEvent(candidate: unknown): candidate is Event {\n return typeof Event !== 'undefined' && 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 candidate === null || (typeof candidate !== 'object' && typeof candidate !== 'function')\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"]}
@@ -0,0 +1,10 @@
1
+ export default class RageClick {
2
+ clicks: {
3
+ x: number;
4
+ y: number;
5
+ timestamp: number;
6
+ }[];
7
+ enabled: boolean;
8
+ constructor(enabled: boolean);
9
+ isRageClick(x: number, y: number, timestamp: number): boolean;
10
+ }
@@ -0,0 +1,33 @@
1
+ // Naive rage click implementation: If mouse has not moved than RAGE_CLICK_THRESHOLD_PX
2
+ // over RAGE_CLICK_CLICK_COUNT clicks with max RAGE_CLICK_TIMEOUT_MS between clicks, it's
3
+ // counted as a rage click
4
+ var RAGE_CLICK_THRESHOLD_PX = 30;
5
+ var RAGE_CLICK_TIMEOUT_MS = 1000;
6
+ var RAGE_CLICK_CLICK_COUNT = 3;
7
+ var RageClick = /** @class */ (function () {
8
+ function RageClick(enabled) {
9
+ this.clicks = [];
10
+ this.enabled = enabled;
11
+ }
12
+ RageClick.prototype.isRageClick = function (x, y, timestamp) {
13
+ if (!this.enabled) {
14
+ return false;
15
+ }
16
+ var lastClick = this.clicks[this.clicks.length - 1];
17
+ if (lastClick &&
18
+ Math.abs(x - lastClick.x) + Math.abs(y - lastClick.y) < RAGE_CLICK_THRESHOLD_PX &&
19
+ timestamp - lastClick.timestamp < RAGE_CLICK_TIMEOUT_MS) {
20
+ this.clicks.push({ x: x, y: y, timestamp: timestamp });
21
+ if (this.clicks.length === RAGE_CLICK_CLICK_COUNT) {
22
+ return true;
23
+ }
24
+ }
25
+ else {
26
+ this.clicks = [{ x: x, y: y, timestamp: timestamp }];
27
+ }
28
+ return false;
29
+ };
30
+ return RageClick;
31
+ }());
32
+ export default RageClick;
33
+ //# sourceMappingURL=rageclick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rageclick.js","sourceRoot":"","sources":["../../../src/extensions/rageclick.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,yFAAyF;AACzF,0BAA0B;AAE1B,IAAM,uBAAuB,GAAG,EAAE,CAAA;AAClC,IAAM,qBAAqB,GAAG,IAAI,CAAA;AAClC,IAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC;IAII,mBAAY,OAAgB;QACxB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED,+BAAW,GAAX,UAAY,CAAS,EAAE,CAAS,EAAE,SAAiB;QAC/C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,OAAO,KAAK,CAAA;SACf;QAED,IAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACrD,IACI,SAAS;YACT,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,uBAAuB;YAC/E,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,qBAAqB,EACzD;YACE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,SAAS,WAAA,EAAE,CAAC,CAAA;YAErC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,sBAAsB,EAAE;gBAC/C,OAAO,IAAI,CAAA;aACd;SACJ;aAAM;YACH,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,GAAA,EAAE,CAAC,GAAA,EAAE,SAAS,WAAA,EAAE,CAAC,CAAA;SACtC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;IACL,gBAAC;AAAD,CAAC,AA/BD,IA+BC","sourcesContent":["// Naive rage click implementation: If mouse has not moved than RAGE_CLICK_THRESHOLD_PX\n// over RAGE_CLICK_CLICK_COUNT clicks with max RAGE_CLICK_TIMEOUT_MS between clicks, it's\n// counted as a rage click\n\nconst RAGE_CLICK_THRESHOLD_PX = 30\nconst RAGE_CLICK_TIMEOUT_MS = 1000\nconst RAGE_CLICK_CLICK_COUNT = 3\n\nexport default class RageClick {\n clicks: { x: number; y: number; timestamp: number }[]\n enabled: boolean\n\n constructor(enabled: boolean) {\n this.clicks = []\n this.enabled = enabled\n }\n\n isRageClick(x: number, y: number, timestamp: number): boolean {\n if (!this.enabled) {\n return false\n }\n\n const lastClick = this.clicks[this.clicks.length - 1]\n if (\n lastClick &&\n Math.abs(x - lastClick.x) + Math.abs(y - lastClick.y) < RAGE_CLICK_THRESHOLD_PX &&\n timestamp - lastClick.timestamp < RAGE_CLICK_TIMEOUT_MS\n ) {\n this.clicks.push({ x, y, timestamp })\n\n if (this.clicks.length === RAGE_CLICK_CLICK_COUNT) {\n return true\n }\n } else {\n this.clicks = [{ x, y, timestamp }]\n }\n\n return false\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Extend Segment with extra PostHog JS functionality. Required for things like Recordings and feature flags to work correctly.
3
+ *
4
+ * ### Usage
5
+ *
6
+ * ```js
7
+ * // After your standard segment anyalytics install
8
+ * analytics.load("GOEDfA21zZTtR7clsBuDvmBKAtAdZ6Np");
9
+ *
10
+ * analytics.ready(() => {
11
+ * posthog.init('<posthog-api-key>', {
12
+ * capture_pageview: false,
13
+ * segment: window.analytics, // NOTE: Be sure to use window.analytics here!
14
+ * });
15
+ * window.analytics.page();
16
+ * })
17
+ * ```
18
+ */
19
+ import { PostHog } from '../posthog-core';
20
+ interface SegmentPluginContext {
21
+ event: {
22
+ event: string;
23
+ userId?: string;
24
+ anonymousId?: string;
25
+ properties: any;
26
+ };
27
+ }
28
+ interface SegmentPlugin {
29
+ name: string;
30
+ version: string;
31
+ type: 'enrichment';
32
+ isLoaded: () => boolean;
33
+ load: (ctx: SegmentPluginContext, instance: any, config?: any) => Promise<unknown>;
34
+ unload?: (ctx: SegmentPluginContext, instance: any) => Promise<unknown> | unknown;
35
+ ready?: () => Promise<unknown>;
36
+ track?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
37
+ identify?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
38
+ page?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
39
+ group?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
40
+ alias?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
41
+ screen?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext;
42
+ }
43
+ export declare const createSegmentIntegration: (posthog: PostHog) => SegmentPlugin;
44
+ export {};
@@ -0,0 +1,34 @@
1
+ export var createSegmentIntegration = function (posthog) {
2
+ if (!Promise || !Promise.resolve) {
3
+ console.warn('This browser does not have Promise support, and can not use the segment integration');
4
+ }
5
+ var enrichEvent = function (ctx, eventName) {
6
+ if (!ctx.event.userId && ctx.event.anonymousId !== posthog.get_distinct_id()) {
7
+ // This is our only way of detecting that segment's analytics.reset() has been called so we also call it
8
+ posthog.reset();
9
+ }
10
+ if (ctx.event.userId && ctx.event.userId !== posthog.get_distinct_id()) {
11
+ posthog.register({
12
+ distinct_id: ctx.event.userId,
13
+ });
14
+ posthog.reloadFeatureFlags();
15
+ }
16
+ var additionalProperties = posthog._calculate_event_properties(eventName, ctx.event.properties);
17
+ ctx.event.properties = Object.assign({}, additionalProperties, ctx.event.properties);
18
+ return ctx;
19
+ };
20
+ return {
21
+ name: 'PostHog JS',
22
+ type: 'enrichment',
23
+ version: '1.0.0',
24
+ isLoaded: function () { return true; },
25
+ // check and early return above
26
+ // eslint-disable-next-line compat/compat
27
+ load: function () { return Promise.resolve(); },
28
+ track: function (ctx) { return enrichEvent(ctx, ctx.event.event); },
29
+ page: function (ctx) { return enrichEvent(ctx, '$pageview'); },
30
+ identify: function (ctx) { return enrichEvent(ctx, '$identify'); },
31
+ screen: function (ctx) { return enrichEvent(ctx, '$screen'); },
32
+ };
33
+ };
34
+ //# sourceMappingURL=segment-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment-integration.js","sourceRoot":"","sources":["../../../src/extensions/segment-integration.ts"],"names":[],"mappings":"AA8CA,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,OAAgB;IACrD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QAC9B,OAAO,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAA;KACtG;IAED,IAAM,WAAW,GAAG,UAAC,GAAyB,EAAE,SAAiB;QAC7D,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,OAAO,CAAC,eAAe,EAAE,EAAE;YAC1E,wGAAwG;YACxG,OAAO,CAAC,KAAK,EAAE,CAAA;SAClB;QACD,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,eAAe,EAAE,EAAE;YACpE,OAAO,CAAC,QAAQ,CAAC;gBACb,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM;aAChC,CAAC,CAAA;YACF,OAAO,CAAC,kBAAkB,EAAE,CAAA;SAC/B;QAED,IAAM,oBAAoB,GAAG,OAAO,CAAC,2BAA2B,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACjG,GAAG,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,oBAAoB,EAAE,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACpF,OAAO,GAAG,CAAA;IACd,CAAC,CAAA;IAED,OAAO;QACH,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;QACpB,+BAA+B;QAC/B,yCAAyC;QACzC,IAAI,EAAE,cAAM,OAAA,OAAO,CAAC,OAAO,EAAE,EAAjB,CAAiB;QAC7B,KAAK,EAAE,UAAC,GAAG,IAAK,OAAA,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAjC,CAAiC;QACjD,IAAI,EAAE,UAAC,GAAG,IAAK,OAAA,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,EAA7B,CAA6B;QAC5C,QAAQ,EAAE,UAAC,GAAG,IAAK,OAAA,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,EAA7B,CAA6B;QAChD,MAAM,EAAE,UAAC,GAAG,IAAK,OAAA,WAAW,CAAC,GAAG,EAAE,SAAS,CAAC,EAA3B,CAA2B;KAC/C,CAAA;AACL,CAAC,CAAA","sourcesContent":["/**\n * Extend Segment with extra PostHog JS functionality. Required for things like Recordings and feature flags to work correctly.\n *\n * ### Usage\n *\n * ```js\n * // After your standard segment anyalytics install\n * analytics.load(\"GOEDfA21zZTtR7clsBuDvmBKAtAdZ6Np\");\n *\n * analytics.ready(() => {\n * posthog.init('<posthog-api-key>', {\n * capture_pageview: false,\n * segment: window.analytics, // NOTE: Be sure to use window.analytics here!\n * });\n * window.analytics.page();\n * })\n * ```\n */\nimport { PostHog } from '../posthog-core'\n\n// Loosely based on https://github.com/segmentio/analytics-next/blob/master/packages/core/src/plugins/index.ts\ninterface SegmentPluginContext {\n event: {\n event: string\n userId?: string\n anonymousId?: string\n properties: any\n }\n}\n\ninterface SegmentPlugin {\n name: string\n version: string\n type: 'enrichment'\n isLoaded: () => boolean\n load: (ctx: SegmentPluginContext, instance: any, config?: any) => Promise<unknown>\n unload?: (ctx: SegmentPluginContext, instance: any) => Promise<unknown> | unknown\n ready?: () => Promise<unknown>\n track?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n identify?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n page?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n group?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n alias?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n screen?: (ctx: SegmentPluginContext) => Promise<SegmentPluginContext> | SegmentPluginContext\n}\n\nexport const createSegmentIntegration = (posthog: PostHog): SegmentPlugin => {\n if (!Promise || !Promise.resolve) {\n console.warn('This browser does not have Promise support, and can not use the segment integration')\n }\n\n const enrichEvent = (ctx: SegmentPluginContext, eventName: string) => {\n if (!ctx.event.userId && ctx.event.anonymousId !== posthog.get_distinct_id()) {\n // This is our only way of detecting that segment's analytics.reset() has been called so we also call it\n posthog.reset()\n }\n if (ctx.event.userId && ctx.event.userId !== posthog.get_distinct_id()) {\n posthog.register({\n distinct_id: ctx.event.userId,\n })\n posthog.reloadFeatureFlags()\n }\n\n const additionalProperties = posthog._calculate_event_properties(eventName, ctx.event.properties)\n ctx.event.properties = Object.assign({}, additionalProperties, ctx.event.properties)\n return ctx\n }\n\n return {\n name: 'PostHog JS',\n type: 'enrichment',\n version: '1.0.0',\n isLoaded: () => true,\n // check and early return above\n // eslint-disable-next-line compat/compat\n load: () => Promise.resolve(),\n track: (ctx) => enrichEvent(ctx, ctx.event.event),\n page: (ctx) => enrichEvent(ctx, '$pageview'),\n identify: (ctx) => enrichEvent(ctx, '$identify'),\n screen: (ctx) => enrichEvent(ctx, '$screen'),\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog
3
+ *
4
+ * ### Usage
5
+ *
6
+ * Sentry.init({
7
+ * dsn: 'https://example',
8
+ * integrations: [
9
+ * new posthog.SentryIntegration(posthog)
10
+ * ]
11
+ * })
12
+ *
13
+ * @param {Object} [posthog] The posthog object
14
+ * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry
15
+ * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
16
+ * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
17
+ */
18
+ import { PostHog } from '../posthog-core';
19
+ declare type _SentryEventProcessor = any;
20
+ declare type _SentryHub = any;
21
+ interface _SentryIntegration {
22
+ name: string;
23
+ setupOnce(addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub): void;
24
+ }
25
+ export declare class SentryIntegration implements _SentryIntegration {
26
+ name: string;
27
+ setupOnce: (addGlobalEventProcessor: (callback: _SentryEventProcessor) => void, getCurrentHub: () => _SentryHub) => void;
28
+ constructor(_posthog: PostHog, organization?: string, projectId?: number, prefix?: string);
29
+ }
30
+ export {};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Integrate Sentry with PostHog. This will add a direct link to the person in Sentry, and an $exception event in PostHog
3
+ *
4
+ * ### Usage
5
+ *
6
+ * Sentry.init({
7
+ * dsn: 'https://example',
8
+ * integrations: [
9
+ * new posthog.SentryIntegration(posthog)
10
+ * ]
11
+ * })
12
+ *
13
+ * @param {Object} [posthog] The posthog object
14
+ * @param {string} [organization] Optional: The Sentry organization, used to send a direct link from PostHog to Sentry
15
+ * @param {Number} [projectId] Optional: The Sentry project id, used to send a direct link from PostHog to Sentry
16
+ * @param {string} [prefix] Optional: Url of a self-hosted sentry instance (default: https://sentry.io/organizations/)
17
+ */
18
+ var SentryIntegration = /** @class */ (function () {
19
+ function SentryIntegration(_posthog, organization, projectId, prefix) {
20
+ // setupOnce gets called by Sentry when it intializes the plugin
21
+ this.name = 'posthog-js';
22
+ this.setupOnce = function (addGlobalEventProcessor) {
23
+ addGlobalEventProcessor(function (event) {
24
+ var _a, _b, _c, _d, _e;
25
+ if (event.level !== 'error' || !_posthog.__loaded)
26
+ return event;
27
+ if (!event.tags)
28
+ event.tags = {};
29
+ var host = _posthog.config.ui_host || _posthog.config.api_host;
30
+ event.tags['PostHog Person URL'] = host + '/person/' + _posthog.get_distinct_id();
31
+ if (_posthog.sessionRecordingStarted()) {
32
+ event.tags['PostHog Recording URL'] = _posthog.get_session_replay_url({ withTimestamp: true });
33
+ }
34
+ var exceptions = ((_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) || [];
35
+ var data = {
36
+ // PostHog Exception Properties,
37
+ $exception_message: (_b = exceptions[0]) === null || _b === void 0 ? void 0 : _b.value,
38
+ $exception_type: (_c = exceptions[0]) === null || _c === void 0 ? void 0 : _c.type,
39
+ $exception_personURL: host + '/person/' + _posthog.get_distinct_id(),
40
+ // Sentry Exception Properties
41
+ $sentry_event_id: event.event_id,
42
+ $sentry_exception: event.exception,
43
+ $sentry_exception_message: (_d = exceptions[0]) === null || _d === void 0 ? void 0 : _d.value,
44
+ $sentry_exception_type: (_e = exceptions[0]) === null || _e === void 0 ? void 0 : _e.type,
45
+ $sentry_tags: event.tags,
46
+ };
47
+ if (organization && projectId)
48
+ data['$sentry_url'] =
49
+ (prefix || 'https://sentry.io/organizations/') +
50
+ organization +
51
+ '/issues/?project=' +
52
+ projectId +
53
+ '&query=' +
54
+ event.event_id;
55
+ _posthog.capture('$exception', data);
56
+ return event;
57
+ });
58
+ };
59
+ }
60
+ return SentryIntegration;
61
+ }());
62
+ export { SentryIntegration };
63
+ //# sourceMappingURL=sentry-integration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentry-integration.js","sourceRoot":"","sources":["../../../src/extensions/sentry-integration.ts"],"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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"]}