posthog-js 1.158.0 → 1.158.2

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 (96) hide show
  1. package/dist/array.full.js +2 -2
  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/exception-autocapture.js.map +1 -1
  6. package/dist/lib/src/entrypoints/web-vitals.d.ts +4 -4
  7. package/dist/lib/src/extensions/replay/config.d.ts +1 -1
  8. package/dist/lib/src/extensions/replay/sessionrecording.d.ts +4 -0
  9. package/dist/lib/src/extensions/surveys.d.ts +2 -2
  10. package/dist/lib/src/utils/globals.d.ts +6 -6
  11. package/dist/lib/src/utils/logger.d.ts +1 -1
  12. package/dist/main.js +1 -1
  13. package/dist/main.js.map +1 -1
  14. package/dist/module.d.ts +4 -0
  15. package/dist/module.js +1 -1
  16. package/dist/module.js.map +1 -1
  17. package/dist/recorder-v2.js.map +1 -1
  18. package/dist/recorder.js.map +1 -1
  19. package/lib/package.json +14 -9
  20. package/lib/src/autocapture-utils.js.map +1 -1
  21. package/lib/src/autocapture.js.map +1 -1
  22. package/lib/src/consent.js +1 -1
  23. package/lib/src/consent.js.map +1 -1
  24. package/lib/src/decide.js.map +1 -1
  25. package/lib/src/entrypoints/exception-autocapture.js.map +1 -1
  26. package/lib/src/entrypoints/recorder.js +12 -12
  27. package/lib/src/entrypoints/recorder.js.map +1 -1
  28. package/lib/src/entrypoints/surveys.js.map +1 -1
  29. package/lib/src/entrypoints/tracing-headers.js.map +1 -1
  30. package/lib/src/entrypoints/web-vitals.d.ts +4 -4
  31. package/lib/src/extensions/exception-autocapture/error-conversion.js +2 -2
  32. package/lib/src/extensions/exception-autocapture/error-conversion.js.map +1 -1
  33. package/lib/src/extensions/exception-autocapture/index.js.map +1 -1
  34. package/lib/src/extensions/exception-autocapture/stack-trace.js.map +1 -1
  35. package/lib/src/extensions/exception-autocapture/type-checking.js +1 -1
  36. package/lib/src/extensions/exception-autocapture/type-checking.js.map +1 -1
  37. package/lib/src/extensions/rageclick.js.map +1 -1
  38. package/lib/src/extensions/replay/config.d.ts +1 -1
  39. package/lib/src/extensions/replay/config.js.map +1 -1
  40. package/lib/src/extensions/replay/external/denylist.js.map +1 -1
  41. package/lib/src/extensions/replay/mutation-rate-limiter.js.map +1 -1
  42. package/lib/src/extensions/replay/rrweb-plugins/patch.js.map +1 -1
  43. package/lib/src/extensions/replay/sessionrecording-utils.js.map +1 -1
  44. package/lib/src/extensions/replay/sessionrecording.d.ts +4 -0
  45. package/lib/src/extensions/replay/sessionrecording.js +22 -13
  46. package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
  47. package/lib/src/extensions/segment-integration.js.map +1 -1
  48. package/lib/src/extensions/sentry-integration.js.map +1 -1
  49. package/lib/src/extensions/surveys/action-matcher.js.map +1 -1
  50. package/lib/src/extensions/surveys/components/BottomSection.jsx.map +1 -1
  51. package/lib/src/extensions/surveys/components/ConfirmationMessage.jsx.map +1 -1
  52. package/lib/src/extensions/surveys/components/QuestionTypes.jsx.map +1 -1
  53. package/lib/src/extensions/surveys/hooks/useContrastingTextColor.js.map +1 -1
  54. package/lib/src/extensions/surveys/surveys-utils.jsx.map +1 -1
  55. package/lib/src/extensions/surveys.d.ts +2 -2
  56. package/lib/src/extensions/surveys.jsx.map +1 -1
  57. package/lib/src/extensions/toolbar.js +2 -2
  58. package/lib/src/extensions/toolbar.js.map +1 -1
  59. package/lib/src/extensions/tracing-headers.js.map +1 -1
  60. package/lib/src/extensions/web-vitals/index.js.map +1 -1
  61. package/lib/src/heatmaps.js.map +1 -1
  62. package/lib/src/page-view.js.map +1 -1
  63. package/lib/src/posthog-core.js +5 -5
  64. package/lib/src/posthog-core.js.map +1 -1
  65. package/lib/src/posthog-featureflags.js.map +1 -1
  66. package/lib/src/posthog-persistence.js.map +1 -1
  67. package/lib/src/posthog-surveys.js.map +1 -1
  68. package/lib/src/rate-limiter.js.map +1 -1
  69. package/lib/src/request-queue.js.map +1 -1
  70. package/lib/src/request.js +2 -2
  71. package/lib/src/request.js.map +1 -1
  72. package/lib/src/retry-queue.js.map +1 -1
  73. package/lib/src/scroll-manager.js.map +1 -1
  74. package/lib/src/session-props.js.map +1 -1
  75. package/lib/src/sessionid.js.map +1 -1
  76. package/lib/src/storage.js +10 -10
  77. package/lib/src/storage.js.map +1 -1
  78. package/lib/src/types.js.map +1 -1
  79. package/lib/src/utils/blocked-uas.js.map +1 -1
  80. package/lib/src/utils/event-utils.js +13 -13
  81. package/lib/src/utils/event-utils.js.map +1 -1
  82. package/lib/src/utils/globals.d.ts +6 -6
  83. package/lib/src/utils/index.js +3 -3
  84. package/lib/src/utils/index.js.map +1 -1
  85. package/lib/src/utils/logger.d.ts +1 -1
  86. package/lib/src/utils/logger.js.map +1 -1
  87. package/lib/src/utils/request-router.js +11 -2
  88. package/lib/src/utils/request-router.js.map +1 -1
  89. package/lib/src/utils/request-utils.js +1 -1
  90. package/lib/src/utils/request-utils.js.map +1 -1
  91. package/lib/src/utils/simple-event-emitter.js.map +1 -1
  92. package/lib/src/utils/survey-event-receiver.js.map +1 -1
  93. package/lib/src/utils/type-utils.js.map +1 -1
  94. package/lib/src/utils/user-agent-utils.js.map +1 -1
  95. package/lib/src/uuidv7.js.map +1 -1
  96. package/package.json +14 -9
@@ -1 +1 @@
1
- {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/type-utils.ts","../src/extensions/exception-autocapture/type-checking.ts","../src/extensions/exception-autocapture/stack-trace.ts","../src/types.ts","../src/extensions/exception-autocapture/error-conversion.ts","../src/utils/globals.ts","../src/utils/logger.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\nexport const isUint8Array = function (x: unknown): x is Uint8Array {\n return toString.call(x) === '[object Uint8Array]'\n}\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = function (f: any): f is (...args: any[]) => any {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof f === 'function'\n}\n// Underscore Addons\nexport const isObject = function (x: unknown): x is Record<string, any> {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = function (x: unknown): x is Record<string, any> {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = function (x: unknown): x is undefined {\n return x === void 0\n}\n\nexport const isString = function (x: unknown): x is string {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = function (x: unknown): boolean {\n return isString(x) && x.trim().length === 0\n}\n\nexport const isNull = function (x: unknown): x is null {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = function (x: unknown): x is null | undefined {\n return isUndefined(x) || isNull(x)\n}\n\nexport const isDate = function (x: unknown): x is Date {\n // eslint-disable-next-line posthog-js/no-direct-date-check\n return toString.call(x) == '[object Date]'\n}\nexport const isNumber = function (x: unknown): x is number {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = function (x: unknown): x is boolean {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n","import { isFunction, isNull, isObject, isUndefined } from '../../utils/type-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","// 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\nimport { isUndefined } from '../../utils/type-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","import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'\nimport { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * if the allowlist has button then we allow the capture when the button or the svg is the click target\n * but not if either of the divs are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport interface PerformanceCaptureConfig {\n /** works with session replay to use the browser's native performance observer to capture performance metrics */\n network_timing?: boolean\n /** works as a passenger event to use chrome's web vitals library to wrap fetch and capture web vitals */\n web_vitals?: boolean\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n * if not set this defaults to 15 minutes\n */\n __web_vitals_max_value?: number\n}\n\nexport interface HeatmapConfig {\n /*\n * how often to send batched data in $$heatmap_data events\n * if set to 0 or not set, sends using the default interval of 1 second\n * */\n flush_interval_milliseconds: number\n}\n\nexport interface PostHogConfig {\n api_host: string\n /** @deprecated - This property is no longer supported */\n api_method?: string\n api_transport?: 'XHR' | 'fetch'\n ui_host: string | null\n token: string\n autocapture: boolean | AutocaptureConfig\n rageclick: boolean\n cross_subdomain_cookie: boolean\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n persistence_name: string\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n loaded: (posthog_instance: PostHog) => void\n store_google: boolean\n custom_campaign_params: string[]\n // a list of strings to be tested against navigator.userAgent to determine if the source is a bot\n // this is **added to** the default list of bots that we check\n // defaults to the empty array\n custom_blocked_useragents: string[]\n save_referrer: boolean\n verbose: boolean\n capture_pageview: boolean\n capture_pageleave: boolean | 'if_capture_pageview'\n debug: boolean\n cookie_expiration: number\n upgrade: boolean\n disable_session_recording: boolean\n disable_persistence: boolean\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n disable_surveys: boolean\n /** If set, posthog-js will never load external scripts such as those needed for Session Replay or Surveys. */\n disable_external_dependency_loading?: boolean\n enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n /** Starts the SDK in an opted out state requiring opt_in_capturing() to be called before events will b captured */\n opt_out_capturing_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n /** If set to true this will disable persistence if the user is opted out of capturing. @default false */\n opt_out_persistence_by_default?: boolean\n /** Opt out of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: boolean\n\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean | PerformanceCaptureConfig\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: SegmentAnalytics\n __preview_send_client_session_params?: boolean\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n capture_heatmaps?: boolean | HeatmapConfig\n disable_scroll_properties?: boolean\n // Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n scroll_root_selector?: string | string[]\n\n /** You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting. There are three options:\n * - `person_profiles: 'always'` _(default)_ - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /** Client side rate limiting */\n rate_limiting?: {\n /** The average number of events per second that should be permitted (defaults to 10) */\n events_per_second?: number\n /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */\n events_burst_limit?: number\n }\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n // ADVANCED: while a user is active we take a full snapshot of the browser every interval. For very few sites playback performance might be better with different interval. Set to 0 to disable\n full_snapshot_interval_millis?: number\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n skip_client_rate_limiting?: boolean /** if set skips the client side rate limiting */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n analytics?: {\n endpoint?: string\n }\n elementsChainAsString?: boolean\n // this is currently in development and may have breaking changes without a major version bump\n autocaptureExceptions?:\n | boolean\n | {\n endpoint?: string\n }\n sessionRecording?: {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n heatmaps?: boolean\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\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\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = typeof severityLevels[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\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\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n","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'\n\nimport { isEmptyString, isNumber, isString, isUndefined } from '../../utils/type-utils'\nimport { ErrorEventArgs, ErrorProperties, SeverityLevel, severityLevels } from '../../types'\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\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 $exception_level: 'error',\n }\n}\n\nfunction errorPropertiesFromString(candidate: string): ErrorProperties {\n return {\n $exception_type: 'Error',\n $exception_message: candidate,\n $exception_level: 'error',\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 isSeverityLevel(x: unknown): x is SeverityLevel {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x as SeverityLevel) >= 0\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 $exception_level: isSeverityLevel(candidate.level) ? candidate.level : 'error',\n }\n}\n\nexport function errorToProperties([event, source, lineno, colno, error]: ErrorEventArgs): ErrorProperties {\n // some properties are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message' | '$exception_level'> & {\n $exception_type?: string\n $exception_message?: string\n $exception_level?: 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 $exception_level: isSeverityLevel(errorProperties.$exception_level)\n ? errorProperties.$exception_level\n : 'error',\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 // some properties are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message' | '$exception_level'> & {\n $exception_type?: string\n $exception_message?: string\n $exception_level?: 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 $exception_level: isSeverityLevel(errorProperties.$exception_level)\n ? errorProperties.$exception_level\n : 'error',\n }\n}\n","/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: Window & typeof globalThis & Record<string, any> = win ?? ({} as any)\n\nexport { win as window }\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nconst LOGGER_PREFIX = '[PostHog.js]'\nexport const logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(LOGGER_PREFIX, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(LOGGER_PREFIX, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n}\n","import { errorToProperties, unhandledRejectionToProperties } from '../extensions/exception-autocapture/error-conversion'\nimport { window } from '../utils/globals'\nimport { ErrorEventArgs, Properties } from '../types'\nimport { logger } from '../utils/logger'\n\nconst wrapOnError = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onerror')\n }\n const originalOnError = win.onerror\n\n win.onerror = function (...args: ErrorEventArgs): boolean {\n const errorProperties = errorToProperties(args)\n captureFn(errorProperties)\n return originalOnError?.(...args) ?? false\n }\n win.onerror.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onerror?.__POSTHOG_INSTRUMENTED__\n win.onerror = originalOnError\n }\n}\n\nconst wrapUnhandledRejection = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onUnhandledRejection')\n }\n\n const originalOnUnhandledRejection = win.onunhandledrejection\n\n win.onunhandledrejection = function (...args: [ev: PromiseRejectionEvent]): boolean {\n const errorProperties = unhandledRejectionToProperties(args)\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, args) ?? false\n }\n win.onunhandledrejection.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onunhandledrejection?.__POSTHOG_INSTRUMENTED__\n win.onunhandledrejection = originalOnUnhandledRejection\n }\n}\n\nconst posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n}\n\nif (window) {\n ;(window as any).posthogErrorWrappingFunctions = posthogErrorWrappingFunctions\n}\n\nexport default posthogErrorWrappingFunctions\n"],"names":["nativeIsArray","Array","isArray","toString","Object","prototype","obj","call","isFunction","f","isObject","x","isUndefined","isString","isEmptyString","trim","length","isNull","isNumber","isEvent","candidate","Event","isInstanceOf","base","_e","isBuiltin","className","concat","isDOMError","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","UNKNOWN_FUNCTION","createFrame","filename","func","lineno","colno","frame","function","in_app","chromeRegex","chromeEvalRegex","geckoREgex","geckoEvalRegex","winjsRegex","Compression","defaultStackParser","_len","arguments","parsers","_key","sortedParsers","sort","a","b","map","p","stack","skipFirst","undefined","frames","lines","split","i","line","cleanedLine","test","replace","match","_step","_iterator","_createForOfIteratorHelper","s","n","done","parser","value","push","err","e","localStack","slice","reverse","_objectSpread","apply","parts","exec","indexOf","subMatch","_extractSafariExtensi2","_slicedToArray","extractSafariExtensionDetails","_extractSafariExtensi4","isSafariExtension","isSafariWebExtension","severityLevels","ERROR_TYPES_PATTERN","reactMinifiedRegexp","parseStackFrames","ex","stacktrace","popSize","framesToPop","message","getPopSize","errorPropertiesFromError","error","$exception_type","name","$exception_message","$exception_stack_trace_raw","JSON","stringify","$exception_level","extractExceptionKeysForMessage","exception","maxLength","keys","serialized","join","isSeverityLevel","errorToProperties","_ref","_ref2","event","source","errorProperties","groups","isDOMException","domException","isErrorWithStack","errorPropertiesFromString","code","isErrorEvent","Error","isError","isPlainObject","constructor","level","errorPropertiesFromObject","$exception_is_synthetic","$exception_source","$exception_lineno","$exception_colno","unhandledRejectionToProperties","_ref3","ev","reason","detail","_oO","String","$exception_handled","win","window","global","globalThis","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","LOGGER_PREFIX","logger","_log","console","consoleLog","args","info","_len2","_key2","warn","_len3","_key3","_len4","_key4","critical","_console","_len5","_key5","uninitializedWarning","methodName","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","_originalOnUnhandledR","_win$onunhandledrejec"],"mappings":"wxEACA,IAAMA,EAAgBC,MAAMC,QAGtBC,EAFWC,OAAOC,UAEEF,SAEbD,EACTF,GACA,SAAUM,GACN,MAA8B,mBAAvBH,EAASI,KAAKD,EACzB,EAOSE,EAAa,SAAUC,GAEhC,MAAoB,mBAANA,CAClB,EAEaC,EAAW,SAAUC,GAE9B,OAAOA,IAAMP,OAAOO,KAAOT,EAAQS,EACvC,EAYaC,EAAc,SAAUD,GACjC,YAAa,IAANA,CACX,EAEaE,EAAW,SAAUF,GAE9B,MAA2B,mBAApBR,EAASI,KAAKI,EACzB,EAEaG,EAAgB,SAAUH,GACnC,OAAOE,EAASF,IAA0B,IAApBA,EAAEI,OAAOC,MACnC,EAEaC,EAAS,SAAUN,GAE5B,OAAa,OAANA,CACX,EAcaO,EAAW,SAAUP,GAE9B,MAA2B,mBAApBR,EAASI,KAAKI,EACzB,ECpEO,SAASQ,EAAQC,GACpB,OAAQR,EAAYS,QAAUC,EAAaF,EAAWC,MAC1D,CAMO,SAASC,EAAaF,EAAoBG,GAC7C,IACI,OAAOH,aAAqBG,CAC/B,CAAC,MAAOC,GACL,OAAO,CACX,CACJ,CA2BO,SAASC,EAAUL,EAAoBM,GAC1C,OAAOtB,OAAOC,UAAUF,SAASI,KAAKa,KAAU,WAAAO,OAAgBD,EAAY,IAChF,CAMO,SAASE,EAAWR,GACvB,OAAOK,EAAUL,EAAW,WAChC,CCvBA,IAAMS,EAAuB,kBACvBC,EAAyB,GAEzBC,EAAmB,IA0BzB,SAASC,EAAYC,EAAkBC,EAAcC,EAAiBC,GAClE,IAAMC,EAAoB,CACtBJ,SAAAA,EACAK,SAAUJ,EACVK,QAAQ,GAWZ,OARK3B,EAAYuB,KACbE,EAAMF,OAASA,GAGdvB,EAAYwB,KACbC,EAAMD,MAAQA,GAGXC,CACX,CAOA,IAAMG,EACF,6IACEC,EAAkB,gCAkClBC,E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,UAAK0B,IAAAA,GAAAA,GAEzD3C,EAAI0C,qBAAqBJ,0BAA2B,EAE7C,WAAM,IAAAM,EACsBA,QAA/BA,EAAO5C,EAAI0C,4BAAX,IAA+BE,UAAxBA,EAA0BN,yBACjCtC,EAAI0C,qBAAuBD,EAEnC,GAOIxC,IACEA,EAAe+B,8BAAgCA"}
1
+ {"version":3,"file":"exception-autocapture.js","sources":["../src/utils/type-utils.ts","../src/extensions/exception-autocapture/type-checking.ts","../src/extensions/exception-autocapture/stack-trace.ts","../src/types.ts","../src/extensions/exception-autocapture/error-conversion.ts","../src/utils/globals.ts","../src/utils/logger.ts","../src/entrypoints/exception-autocapture.ts"],"sourcesContent":["// eslint-disable-next-line posthog-js/no-direct-array-check\nconst nativeIsArray = Array.isArray\nconst ObjProto = Object.prototype\nexport const hasOwnProperty = ObjProto.hasOwnProperty\nconst toString = ObjProto.toString\n\nexport const isArray =\n nativeIsArray ||\n function (obj: any): obj is any[] {\n return toString.call(obj) === '[object Array]'\n }\nexport const isUint8Array = function (x: unknown): x is Uint8Array {\n return toString.call(x) === '[object Uint8Array]'\n}\n// from a comment on http://dbj.org/dbj/?p=286\n// fails on only one very rare and deliberate custom object:\n// let bomb = { toString : undefined, valueOf: function(o) { return \"function BOMBA!\"; }};\nexport const isFunction = function (f: any): f is (...args: any[]) => any {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof f === 'function'\n}\n// Underscore Addons\nexport const isObject = function (x: unknown): x is Record<string, any> {\n // eslint-disable-next-line posthog-js/no-direct-object-check\n return x === Object(x) && !isArray(x)\n}\nexport const isEmptyObject = function (x: unknown): x is Record<string, any> {\n if (isObject(x)) {\n for (const key in x) {\n if (hasOwnProperty.call(x, key)) {\n return false\n }\n }\n return true\n }\n return false\n}\nexport const isUndefined = function (x: unknown): x is undefined {\n return x === void 0\n}\n\nexport const isString = function (x: unknown): x is string {\n // eslint-disable-next-line posthog-js/no-direct-string-check\n return toString.call(x) == '[object String]'\n}\n\nexport const isEmptyString = function (x: unknown): boolean {\n return isString(x) && x.trim().length === 0\n}\n\nexport const isNull = function (x: unknown): x is null {\n // eslint-disable-next-line posthog-js/no-direct-null-check\n return x === null\n}\n\n/*\n sometimes you want to check if something is null or undefined\n that's what this is for\n */\nexport const isNullish = function (x: unknown): x is null | undefined {\n return isUndefined(x) || isNull(x)\n}\n\nexport const isDate = function (x: unknown): x is Date {\n // eslint-disable-next-line posthog-js/no-direct-date-check\n return toString.call(x) == '[object Date]'\n}\nexport const isNumber = function (x: unknown): x is number {\n // eslint-disable-next-line posthog-js/no-direct-number-check\n return toString.call(x) == '[object Number]'\n}\nexport const isBoolean = function (x: unknown): x is boolean {\n // eslint-disable-next-line posthog-js/no-direct-boolean-check\n return toString.call(x) === '[object Boolean]'\n}\n\nexport const isDocument = (x: unknown): x is Document => {\n // eslint-disable-next-line posthog-js/no-direct-document-check\n return x instanceof Document\n}\n\nexport const isFormData = (x: unknown): x is FormData => {\n // eslint-disable-next-line posthog-js/no-direct-form-data-check\n return x instanceof FormData\n}\n\nexport const isFile = (x: unknown): x is File => {\n // eslint-disable-next-line posthog-js/no-direct-file-check\n return x instanceof File\n}\n","import { isFunction, isNull, isObject, isUndefined } from '../../utils/type-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 {\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","// 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\nimport { isUndefined } from '../../utils/type-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","import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'\nimport { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * if the allowlist has button then we allow the capture when the button or the svg is the click target\n * but not if either of the divs are detected as the click target\n */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\n * we consider the tree of elements from the root to the target element of the click event\n * so for the tree div > div > button > svg\n * and allow list config `['[id]']`\n * we will capture the click if the click-target or its parents has any id\n */\n css_selector_allowlist?: string[]\n\n /**\n * Exclude certain element attributes from autocapture\n * E.g. ['aria-label'] or [data-attr-pii]\n */\n element_attribute_ignorelist?: string[]\n\n capture_copied_text?: boolean\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport interface PerformanceCaptureConfig {\n /** works with session replay to use the browser's native performance observer to capture performance metrics */\n network_timing?: boolean\n /** works as a passenger event to use chrome's web vitals library to wrap fetch and capture web vitals */\n web_vitals?: boolean\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n * if not set this defaults to 15 minutes\n */\n __web_vitals_max_value?: number\n}\n\nexport interface HeatmapConfig {\n /*\n * how often to send batched data in $$heatmap_data events\n * if set to 0 or not set, sends using the default interval of 1 second\n * */\n flush_interval_milliseconds: number\n}\n\nexport interface PostHogConfig {\n api_host: string\n /** @deprecated - This property is no longer supported */\n api_method?: string\n api_transport?: 'XHR' | 'fetch'\n ui_host: string | null\n token: string\n autocapture: boolean | AutocaptureConfig\n rageclick: boolean\n cross_subdomain_cookie: boolean\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n persistence_name: string\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n loaded: (posthog_instance: PostHog) => void\n store_google: boolean\n custom_campaign_params: string[]\n // a list of strings to be tested against navigator.userAgent to determine if the source is a bot\n // this is **added to** the default list of bots that we check\n // defaults to the empty array\n custom_blocked_useragents: string[]\n save_referrer: boolean\n verbose: boolean\n capture_pageview: boolean\n capture_pageleave: boolean | 'if_capture_pageview'\n debug: boolean\n cookie_expiration: number\n upgrade: boolean\n disable_session_recording: boolean\n disable_persistence: boolean\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n disable_surveys: boolean\n /** If set, posthog-js will never load external scripts such as those needed for Session Replay or Surveys. */\n disable_external_dependency_loading?: boolean\n enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n /** Starts the SDK in an opted out state requiring opt_in_capturing() to be called before events will b captured */\n opt_out_capturing_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n /** If set to true this will disable persistence if the user is opted out of capturing. @default false */\n opt_out_persistence_by_default?: boolean\n /** Opt out of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: boolean\n\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean | PerformanceCaptureConfig\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: SegmentAnalytics\n __preview_send_client_session_params?: boolean\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n capture_heatmaps?: boolean | HeatmapConfig\n disable_scroll_properties?: boolean\n // Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n scroll_root_selector?: string | string[]\n\n /** You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting. There are three options:\n * - `person_profiles: 'always'` _(default)_ - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` - we will only process persons when you call `posthog.identify`, `posthog.alias`, `posthog.setPersonProperties`, `posthog.group`, `posthog.setPersonPropertiesForFlags` or `posthog.setGroupPropertiesForFlags` Anonymous users won't get person profiles.\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /** Client side rate limiting */\n rate_limiting?: {\n /** The average number of events per second that should be permitted (defaults to 10) */\n events_per_second?: number\n /** How many events can be captured in a burst. This defaults to 10 times the events_per_second count */\n events_burst_limit?: number\n }\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * whether to wrap fetch and add tracing headers to the request\n * */\n __add_tracing_headers?: boolean\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n // ADVANCED: while a user is active we take a full snapshot of the browser every interval. For very few sites playback performance might be better with different interval. Set to 0 to disable\n full_snapshot_interval_millis?: number\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n skip_client_rate_limiting?: boolean /** if set skips the client side rate limiting */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n analytics?: {\n endpoint?: string\n }\n elementsChainAsString?: boolean\n // this is currently in development and may have breaking changes without a major version bump\n autocaptureExceptions?:\n | boolean\n | {\n endpoint?: string\n }\n sessionRecording?: {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n heatmaps?: boolean\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport interface PersistentStore {\n is_supported: () => boolean\n error: (error: any) => void\n parse: (name: string) => any\n get: (name: string) => any\n set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\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\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = typeof severityLevels[number]\n\nexport interface ErrorProperties {\n $exception_type: string\n $exception_message: string\n $exception_level: SeverityLevel\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\nexport interface ErrorConversions {\n errorToProperties: (args: ErrorEventArgs) => ErrorProperties\n unhandledRejectionToProperties: (args: [ev: PromiseRejectionEvent]) => ErrorProperties\n}\n","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'\n\nimport { isEmptyString, isNumber, isString, isUndefined } from '../../utils/type-utils'\nimport { ErrorEventArgs, ErrorProperties, SeverityLevel, severityLevels } from '../../types'\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\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 {\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 $exception_level: 'error',\n }\n}\n\nfunction errorPropertiesFromString(candidate: string): ErrorProperties {\n return {\n $exception_type: 'Error',\n $exception_message: candidate,\n $exception_level: 'error',\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 isSeverityLevel(x: unknown): x is SeverityLevel {\n return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x as SeverityLevel) >= 0\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 $exception_level: isSeverityLevel(candidate.level) ? candidate.level : 'error',\n }\n}\n\nexport function errorToProperties([event, source, lineno, colno, error]: ErrorEventArgs): ErrorProperties {\n // some properties are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message' | '$exception_level'> & {\n $exception_type?: string\n $exception_message?: string\n $exception_level?: 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 $exception_level: isSeverityLevel(errorProperties.$exception_level)\n ? errorProperties.$exception_level\n : 'error',\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 {\n // no-empty\n }\n\n // some properties are not optional but, it's useful to start off without them enforced\n let errorProperties: Omit<ErrorProperties, '$exception_type' | '$exception_message' | '$exception_level'> & {\n $exception_type?: string\n $exception_message?: string\n $exception_level?: 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 $exception_level: isSeverityLevel(errorProperties.$exception_level)\n ? errorProperties.$exception_level\n : 'error',\n }\n}\n","/*\n * Global helpers to protect access to browser globals in a way that is safer for different targets\n * like DOM, SSR, Web workers etc.\n *\n * NOTE: Typically we want the \"window\" but globalThis works for both the typical browser context as\n * well as other contexts such as the web worker context. Window is still exported for any bits that explicitly require it.\n * If in doubt - export the global you need from this file and use that as an optional value. This way the code path is forced\n * to handle the case where the global is not available.\n */\n\n// eslint-disable-next-line no-restricted-globals\nconst win: (Window & typeof globalThis) | undefined = typeof window !== 'undefined' ? window : undefined\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\nexport const ArrayProto = Array.prototype\nexport const nativeForEach = ArrayProto.forEach\nexport const nativeIndexOf = ArrayProto.indexOf\n\nexport const navigator = global?.navigator\nexport const document = global?.document\nexport const location = global?.location\nexport const fetch = global?.fetch\nexport const XMLHttpRequest =\n global?.XMLHttpRequest && 'withCredentials' in new global.XMLHttpRequest() ? global.XMLHttpRequest : undefined\nexport const AbortController = global?.AbortController\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: Window & typeof globalThis & Record<string, any> = win ?? ({} as any)\n\nexport { win as window }\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nconst LOGGER_PREFIX = '[PostHog.js]'\nexport const logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => {\n if (\n window &&\n (Config.DEBUG || assignableWindow.POSTHOG_DEBUG) &&\n !isUndefined(window.console) &&\n window.console\n ) {\n const consoleLog =\n '__rrweb_original__' in window.console[level]\n ? (window.console[level] as any)['__rrweb_original__']\n : window.console[level]\n\n // eslint-disable-next-line no-console\n consoleLog(LOGGER_PREFIX, ...args)\n }\n },\n\n info: (...args: any[]) => {\n logger._log('log', ...args)\n },\n\n warn: (...args: any[]) => {\n logger._log('warn', ...args)\n },\n\n error: (...args: any[]) => {\n logger._log('error', ...args)\n },\n\n critical: (...args: any[]) => {\n // Critical errors are always logged to the console\n // eslint-disable-next-line no-console\n console.error(LOGGER_PREFIX, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n}\n","import { errorToProperties, unhandledRejectionToProperties } from '../extensions/exception-autocapture/error-conversion'\nimport { window } from '../utils/globals'\nimport { ErrorEventArgs, Properties } from '../types'\nimport { logger } from '../utils/logger'\n\nconst wrapOnError = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onerror')\n }\n const originalOnError = win.onerror\n\n win.onerror = function (...args: ErrorEventArgs): boolean {\n const errorProperties = errorToProperties(args)\n captureFn(errorProperties)\n return originalOnError?.(...args) ?? false\n }\n win.onerror.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onerror?.__POSTHOG_INSTRUMENTED__\n win.onerror = originalOnError\n }\n}\n\nconst wrapUnhandledRejection = (captureFn: (props: Properties) => void) => {\n const win = window as any\n if (!win) {\n logger.info('window not available, cannot wrap onUnhandledRejection')\n }\n\n const originalOnUnhandledRejection = win.onunhandledrejection\n\n win.onunhandledrejection = function (...args: [ev: PromiseRejectionEvent]): boolean {\n const errorProperties = unhandledRejectionToProperties(args)\n captureFn(errorProperties)\n return originalOnUnhandledRejection?.apply(win, args) ?? false\n }\n win.onunhandledrejection.__POSTHOG_INSTRUMENTED__ = true\n\n return () => {\n delete win.onunhandledrejection?.__POSTHOG_INSTRUMENTED__\n win.onunhandledrejection = originalOnUnhandledRejection\n }\n}\n\nconst posthogErrorWrappingFunctions = {\n wrapOnError,\n wrapUnhandledRejection,\n}\n\nif (window) {\n ;(window as any).posthogErrorWrappingFunctions = posthogErrorWrappingFunctions\n}\n\nexport default posthogErrorWrappingFunctions\n"],"names":["nativeIsArray","Array","isArray","toString","Object","prototype","obj","call","isFunction","f","isObject","x","isUndefined","isString","isEmptyString","trim","length","isNull","isNumber","isEvent","candidate","Event","isInstanceOf","base","_unused","isBuiltin","className","concat","isDOMError","WEBPACK_ERROR_REGEXP","STACKTRACE_FRAME_LIMIT","UNKNOWN_FUNCTION","createFrame","filename","func","lineno","colno","frame","function","in_app","chromeRegex","chromeEvalRegex","geckoREgex","geckoEvalRegex","winjsRegex","Compression","defaultStackParser","_len","arguments","parsers","_key","sortedParsers","sort","a","b","map","p","stack","skipFirst","undefined","frames","lines","split","i","line","cleanedLine","test","replace","match","_step","_iterator","_createForOfIteratorHelper","s","n","done","parser","value","push","err","e","localStack","slice","reverse","_objectSpread","apply","parts","exec","indexOf","subMatch","_extractSafariExtensi2","_slicedToArray","extractSafariExtensionDetails","_extractSafariExtensi4","isSafariExtension","isSafariWebExtension","severityLevels","ERROR_TYPES_PATTERN","reactMinifiedRegexp","parseStackFrames","ex","stacktrace","popSize","framesToPop","message","getPopSize","errorPropertiesFromError","error","$exception_type","name","$exception_message","$exception_stack_trace_raw","JSON","stringify","$exception_level","extractExceptionKeysForMessage","exception","maxLength","keys","serialized","join","isSeverityLevel","errorToProperties","_ref","_ref2","event","source","errorProperties","groups","isDOMException","domException","isErrorWithStack","errorPropertiesFromString","code","isErrorEvent","Error","isError","isPlainObject","constructor","level","errorPropertiesFromObject","$exception_is_synthetic","$exception_source","$exception_lineno","$exception_colno","unhandledRejectionToProperties","_ref3","ev","reason","detail","_unused2","String","$exception_handled","win","window","global","globalThis","navigator","document","location","fetch","XMLHttpRequest","AbortController","userAgent","assignableWindow","LOGGER_PREFIX","logger","_log","console","consoleLog","args","info","_len2","_key2","warn","_len3","_key3","_len4","_key4","critical","_console","_len5","_key5","uninitializedWarning","methodName","posthogErrorWrappingFunctions","wrapOnError","captureFn","originalOnError","onerror","_originalOnError","__POSTHOG_INSTRUMENTED__","_win$onerror","wrapUnhandledRejection","originalOnUnhandledRejection","onunhandledrejection","_originalOnUnhandledR","_win$onunhandledrejec"],"mappings":"wxEACA,IAAMA,EAAgBC,MAAMC,QAGtBC,EAFWC,OAAOC,UAEEF,SAEbD,EACTF,GACA,SAAUM,GACN,MAA8B,mBAAvBH,EAASI,KAAKD,EACzB,EAOSE,EAAa,SAAUC,GAEhC,MAAoB,mBAANA,CAClB,EAEaC,EAAW,SAAUC,GAE9B,OAAOA,IAAMP,OAAOO,KAAOT,EAAQS,EACvC,EAYaC,EAAc,SAAUD,GACjC,YAAa,IAANA,CACX,EAEaE,EAAW,SAAUF,GAE9B,MAA2B,mBAApBR,EAASI,KAAKI,EACzB,EAEaG,EAAgB,SAAUH,GACnC,OAAOE,EAASF,IAA0B,IAApBA,EAAEI,OAAOC,MACnC,EAEaC,EAAS,SAAUN,GAE5B,OAAa,OAANA,CACX,EAcaO,EAAW,SAAUP,GAE9B,MAA2B,mBAApBR,EAASI,KAAKI,EACzB,ECpEO,SAASQ,EAAQC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AAA,EAAevG,WAAA,EAAMqF,UAAKoB,IAAAA,GAAAA,GAErCrC,EAAIoC,QAAQE,0BAA2B,EAEhC,WAAM,IAAAC,EACSA,QAAlBA,EAAOvC,EAAIoC,eAAX,IAAkBG,UAAXA,EAAaD,yBACpBtC,EAAIoC,QAAUD,EAEtB,EAyBIK,uBAvB2B,SAACN,GAC5B,IAAMlC,EAAMC,EACPD,GACDa,EAAOK,KAAK,0DAGhB,IAAMuB,EAA+BzC,EAAI0C,qBASzC,OAPA1C,EAAI0C,qBAAuB,WAAyD,IAAA,IAAAC,EAAAxB,EAAA3H,UAAAhC,OAA5CyJ,EAAIxK,IAAAA,MAAA0K,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,IAAJH,EAAIG,GAAA5H,UAAA4H,GACxC,IAAM9C,EAAkBkB,EAA+ByB,GAEvD,OADAiB,EAAU5D,GAC2C,QAArDqE,EAAOF,aAA4B,EAA5BA,EAA8B7G,MAAMoE,EAAKiB,UAAK0B,IAAAA,GAAAA,GAEzD3C,EAAI0C,qBAAqBJ,0BAA2B,EAE7C,WAAM,IAAAM,EACsBA,QAA/BA,EAAO5C,EAAI0C,4BAAX,IAA+BE,UAAxBA,EAA0BN,yBACjCtC,EAAI0C,qBAAuBD,EAEnC,GAOIxC,IACEA,EAAe+B,8BAAgCA"}
@@ -1,7 +1,7 @@
1
1
  declare const postHogWebVitalsCallbacks: {
2
- onLCP: (onReport: (metric: import("web-vitals").LCPMetric) => void, opts?: import("web-vitals").ReportOpts | undefined) => void;
3
- onCLS: (onReport: (metric: import("web-vitals").CLSMetric) => void, opts?: import("web-vitals").ReportOpts | undefined) => void;
4
- onFCP: (onReport: (metric: import("web-vitals").FCPMetric) => void, opts?: import("web-vitals").ReportOpts | undefined) => void;
5
- onINP: (onReport: (metric: import("web-vitals").INPMetric) => void, opts?: import("web-vitals").ReportOpts | undefined) => void;
2
+ onLCP: (onReport: (metric: import("web-vitals").LCPMetric) => void, opts?: import("web-vitals").ReportOpts) => void;
3
+ onCLS: (onReport: (metric: import("web-vitals").CLSMetric) => void, opts?: import("web-vitals").ReportOpts) => void;
4
+ onFCP: (onReport: (metric: import("web-vitals").FCPMetric) => void, opts?: import("web-vitals").ReportOpts) => void;
5
+ onINP: (onReport: (metric: import("web-vitals").INPMetric) => void, opts?: import("web-vitals").ReportOpts) => void;
6
6
  };
7
7
  export default postHogWebVitalsCallbacks;
@@ -6,4 +6,4 @@ export declare const defaultNetworkOptions: Required<NetworkRecordOptions>;
6
6
  * we _never_ want to record that header by accident
7
7
  * if someone complains then we'll add an opt-in to let them override it
8
8
  */
9
- export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, 'recordHeaders' | 'recordBody' | 'recordPerformance' | 'payloadHostDenyList'>) => NetworkRecordOptions;
9
+ export declare const buildNetworkRequestOptions: (instanceConfig: PostHogConfig, remoteNetworkOptions: Pick<NetworkRecordOptions, "recordHeaders" | "recordBody" | "recordPerformance" | "payloadHostDenyList">) => NetworkRecordOptions;
@@ -48,6 +48,10 @@ export declare class SessionRecording {
48
48
  */
49
49
  private get status();
50
50
  constructor(instance: PostHog);
51
+ private _onBeforeUnload;
52
+ private _onOffline;
53
+ private _onOnline;
54
+ private _onVisibilityChange;
51
55
  startIfEnabledOrStop(): void;
52
56
  stopRecording(): void;
53
57
  private makeSamplingDecision;
@@ -40,12 +40,12 @@ export declare const renderSurveysPreview: ({ survey, parentElement, previewPage
40
40
  survey: Survey;
41
41
  parentElement: HTMLElement;
42
42
  previewPageIndex: number;
43
- forceDisableHtml?: boolean | undefined;
43
+ forceDisableHtml?: boolean;
44
44
  }) => void;
45
45
  export declare const renderFeedbackWidgetPreview: ({ survey, root, forceDisableHtml, }: {
46
46
  survey: Survey;
47
47
  root: HTMLElement;
48
- forceDisableHtml?: boolean | undefined;
48
+ forceDisableHtml?: boolean;
49
49
  }) => void;
50
50
  export declare function generateSurveys(posthog: PostHog): SurveyManager | undefined;
51
51
  export declare function usePopupVisibility(survey: Survey, posthog: PostHog | undefined, millisecondDelay: number, isPreviewMode: boolean, removeSurveyFromFocus: (id: string) => void): {
@@ -1,7 +1,7 @@
1
1
  declare const win: (Window & typeof globalThis) | undefined;
2
2
  export declare const ArrayProto: any[];
3
3
  export declare const nativeForEach: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
4
- export declare const nativeIndexOf: (searchElement: any, fromIndex?: number | undefined) => number;
4
+ export declare const nativeIndexOf: (searchElement: any, fromIndex?: number) => number;
5
5
  export declare const navigator: Navigator | undefined;
6
6
  export declare const document: Document | undefined;
7
7
  export declare const location: Location | undefined;
@@ -9,11 +9,11 @@ export declare const fetch: typeof globalThis.fetch | undefined;
9
9
  export declare const XMLHttpRequest: {
10
10
  new (): XMLHttpRequest;
11
11
  prototype: XMLHttpRequest;
12
- readonly DONE: number;
13
- readonly HEADERS_RECEIVED: number;
14
- readonly LOADING: number;
15
- readonly OPENED: number;
16
- readonly UNSENT: number;
12
+ readonly UNSENT: 0;
13
+ readonly OPENED: 1;
14
+ readonly HEADERS_RECEIVED: 2;
15
+ readonly LOADING: 3;
16
+ readonly DONE: 4;
17
17
  } | undefined;
18
18
  export declare const AbortController: {
19
19
  new (): AbortController;
@@ -1,5 +1,5 @@
1
1
  export declare const logger: {
2
- _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void;
2
+ _log: (level: "log" | "warn" | "error", ...args: any[]) => void;
3
3
  info: (...args: any[]) => void;
4
4
  warn: (...args: any[]) => void;
5
5
  error: (...args: any[]) => void;