@deriv-com/analytics
Version:
Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.
1 lines • 1.27 MB
Source Map (JSON)
{"version":3,"sources":["../node_modules/posthog-js/src/utils/globals.ts","../node_modules/posthog-js/src/config.ts","../node_modules/core/dist/gzip.mjs","../node_modules/core/dist/utils/bot-detection.mjs","../node_modules/core/dist/types.mjs","../node_modules/core/dist/utils/string-utils.mjs","../node_modules/core/dist/utils/type-utils.mjs","../node_modules/core/dist/utils/number-utils.mjs","../node_modules/core/dist/utils/bucketed-rate-limiter.mjs","../node_modules/core/dist/utils/user-agent-utils.mjs","../node_modules/core/dist/error-tracking/chunk-ids.mjs","../node_modules/core/dist/utils/index.mjs","../node_modules/core/dist/logs/logs-utils.mjs","../node_modules/core/dist/error-tracking/error-properties-builder.mjs","../node_modules/core/dist/error-tracking/parsers/base.mjs","../node_modules/core/dist/error-tracking/parsers/safari.mjs","../node_modules/core/dist/error-tracking/parsers/chrome.mjs","../node_modules/core/dist/error-tracking/parsers/gecko.mjs","../node_modules/core/dist/error-tracking/parsers/index.mjs","../node_modules/core/dist/error-tracking/coercers/dom-exception-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/error-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/error-event-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/string-coercer.mjs","../node_modules/core/dist/error-tracking/types.mjs","../node_modules/core/dist/error-tracking/coercers/utils.mjs","../node_modules/core/dist/error-tracking/coercers/object-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/event-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/primitive-coercer.mjs","../node_modules/core/dist/error-tracking/coercers/promise-rejection-event.mjs","../node_modules/core/dist/error-tracking/exception-steps.mjs","../node_modules/posthog-js/src/utils/logger.ts","../node_modules/posthog-js/src/entrypoints/external-scripts-loader.ts","../node_modules/posthog-js/src/constants.ts","../node_modules/posthog-js/src/utils/index.ts","../node_modules/posthog-js/src/uuidv7.ts","../node_modules/posthog-js/src/storage.ts","../node_modules/posthog-js/src/consent.ts","../node_modules/posthog-js/src/extensions/dead-clicks-autocapture.ts","../node_modules/posthog-js/src/extensions/segment-integration.ts","../node_modules/posthog-js/src/extensions/sentry-integration.ts","../node_modules/posthog-js/src/page-view.ts","../node_modules/posthog-js/src/persistence-key-transforms.ts","../node_modules/posthog-js/src/persistence-key-policy.ts","../node_modules/posthog-js/src/utils/request-utils.ts","../node_modules/posthog-js/src/utils/event-utils.ts","../node_modules/posthog-js/src/posthog-persistence.ts","../node_modules/posthog-js/src/posthog-surveys-types.ts","../node_modules/posthog-js/src/posthog-product-tours-types.ts","../node_modules/posthog-js/src/rate-limiter.ts","../node_modules/posthog-js/src/remote-config.ts","../node_modules/posthog-js/src/types.ts","../node_modules/.pnpm/fflate@0.4.8/node_modules/fflate/esm/browser.js","../node_modules/posthog-js/src/request.ts","../node_modules/posthog-js/src/utils/encode-utils.ts","../node_modules/posthog-js/src/request-queue.ts","../node_modules/posthog-js/src/retry-queue.ts","../node_modules/posthog-js/src/scroll-manager.ts","../node_modules/posthog-js/src/session-props.ts","../node_modules/posthog-js/src/utils/simple-event-emitter.ts","../node_modules/posthog-js/src/sessionid.ts","../node_modules/posthog-js/src/utils/blocked-uas.ts","../node_modules/posthog-js/src/utils/regex-utils.ts","../node_modules/posthog-js/src/utils/property-utils.ts","../node_modules/posthog-js/src/utils/request-router.ts","../node_modules/posthog-js/src/utils/survey-utils.ts","../node_modules/posthog-js/src/extensions/external-integration.ts","../node_modules/posthog-js/src/posthog-core.ts","../node_modules/core/dist/surveys/events.mjs","../node_modules/posthog-js/src/utils/element-utils.ts","../node_modules/posthog-js/src/autocapture-utils.ts","../node_modules/posthog-js/src/extensions/rageclick.ts","../node_modules/posthog-js/src/autocapture.ts","../node_modules/posthog-js/src/extensions/exception-autocapture/index.ts","../node_modules/posthog-js/src/extensions/replay/rrweb-plugins/patch.ts","../node_modules/posthog-js/src/extensions/tracing-headers.ts","../node_modules/posthog-js/src/extensions/web-vitals/index.ts","../node_modules/posthog-js/src/extensions/replay/external/triggerMatching.ts","../node_modules/posthog-js/src/extensions/replay/external/recording-strategies.ts","../node_modules/posthog-js/src/extensions/replay/external/lazy-loaded-session-recorder.ts","../node_modules/posthog-js/src/extensions/replay/session-recording.ts","../node_modules/posthog-js/src/heatmaps.ts","../node_modules/posthog-js/src/posthog-product-tours.ts","../node_modules/posthog-js/src/site-apps.ts","../node_modules/posthog-js/src/utils/elements-chain-utils.ts","../node_modules/posthog-js/src/extensions/surveys/action-matcher.ts","../node_modules/posthog-js/src/utils/event-receiver.ts","../node_modules/posthog-js/src/utils/survey-event-receiver.ts","../node_modules/posthog-js/src/posthog-surveys.ts","../node_modules/posthog-js/src/extensions/toolbar.ts","../node_modules/posthog-js/src/posthog-featureflags.ts","../node_modules/posthog-js/src/posthog-exceptions.ts","../node_modules/posthog-js/src/web-experiments.ts","../node_modules/posthog-js/src/extensions/conversations/posthog-conversations.ts","../node_modules/posthog-js/src/extensions/extension-bundles.ts","../node_modules/posthog-js/src/extensions/history-autocapture.ts","../node_modules/posthog-js/src/posthog-logs.ts","../node_modules/posthog-js/src/entrypoints/default-extensions.ts","../node_modules/posthog-js/src/entrypoints/module.no-external.es.ts","../src/providers/posthog.ts"],"sourcesContent":["import type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ExternalIntegrationKind,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n SessionStartReason,\n} from '../types'\nimport type {\n ConversationsRemoteConfig,\n GetMessagesResponse,\n GetTicketsOptions,\n GetTicketsResponse,\n MarkAsReadResponse,\n RestoreFromTokenResponse,\n RequestRestoreLinkResponse,\n SendMessageResponse,\n UserProvidedTraits,\n} from '../posthog-conversations-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SessionRecordingStatus, TriggerType } from '../extensions/replay/external/triggerMatching'\nimport { eventWithTime } from '../extensions/replay/types/rrweb-types'\nimport { ErrorTracking } from '@posthog/core'\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\nexport type AssignableWindow = Window &\n typeof globalThis & {\n /*\n * Main PostHog instance\n */\n posthog: any\n\n /*\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n */\n __PosthogExtensions__?: PostHogExtensions\n\n /**\n * When loading remote config, we assign it to this global configuration\n * for ease of sharing it with the rest of the SDK\n */\n _POSTHOG_REMOTE_CONFIG?: Record<\n string,\n {\n config: RemoteConfig\n siteApps: SiteAppLoader[]\n }\n >\n\n /**\n * If this is set on the window, our logger will log to the console\n * for ease of debugging. Used for testing purposes only.\n *\n * @see {Config.DEBUG} from config.ts\n */\n POSTHOG_DEBUG: any\n\n // Exposed by the browser\n doNotTrack: any\n\n // See entrypoints/customizations.full.ts\n posthogCustomizations: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/exception-autocapture.ts\n *\n * @deprecated use `__PosthogExtensions__.errorWrappingFunctions` instead\n */\n posthogErrorWrappingFunctions: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrweb` instead\n */\n rrweb: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.rrwebConsoleRecord` instead\n */\n rrwebConsoleRecord: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/posthog-recorder.ts\n *\n * @deprecated use `__PosthogExtensions__.getRecordNetworkPlugin` instead\n */\n getRecordNetworkPlugin: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/web-vitals.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogWebVitalsCallbacks` instead\n */\n postHogWebVitalsCallbacks: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/tracing-headers.ts\n *\n * @deprecated use `__PosthogExtensions__.postHogTracingHeadersPatchFns` instead\n */\n postHogTracingHeadersPatchFns: any\n\n /**\n * This is a legacy way to expose these functions, but we still need to support it for backwards compatibility\n * Can be removed once we drop support for 1.161.1\n *\n * See entrypoints/surveys.ts\n *\n * @deprecated use `__PosthogExtensions__.generateSurveys` instead\n */\n extendPostHogWithSurveys: any\n\n /*\n * These are used to handle our toolbar state.\n * @see {Toolbar} from extensions/toolbar.ts\n */\n ph_load_toolbar: any\n ph_load_editor: any\n ph_toolbar_state: any\n } & Record<`__$$ph_site_app_${string}`, any>\n\n/**\n * This is our contract between (potentially) lazily loaded extensions and the SDK\n * changes to this interface can be breaking changes for users of the SDK\n */\n\nexport type ExternalExtensionKind = 'intercom-integration' | 'crisp-chat-integration'\n\nexport type PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'web-vitals-with-attribution'\n | 'recorder'\n | 'lazy-recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'logs'\n | 'conversations'\n | 'product-tours'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n | ExternalExtensionKind\n\nexport interface LazyLoadedSessionRecordingInterface {\n start: (startReason?: SessionStartReason) => void\n stop: () => void\n discard: () => void\n sessionId: string\n status: SessionRecordingStatus\n onRRwebEmit: (rawEvent: eventWithTime) => void\n log: (message: string, level: 'log' | 'warn' | 'error') => void\n sdkDebugProperties: Properties\n overrideLinkedFlag: () => void\n overrideSampling: () => void\n overrideTrigger: (triggerType: TriggerType) => void\n isStarted: boolean\n tryAddCustomEvent(tag: string, payload: any): boolean\n}\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\n}\n\nexport interface LazyLoadedConversationsInterface {\n // Widget control\n show: () => void\n hide: () => void\n isVisible: () => boolean\n\n // Lifecycle\n reset: () => void\n\n // Identity verification\n setIdentity: () => void\n clearIdentity: () => void\n\n // API methods\n sendMessage: (message: string, userTraits?: UserProvidedTraits, newTicket?: boolean) => Promise<SendMessageResponse>\n getMessages: (ticketId?: string, after?: string) => Promise<GetMessagesResponse>\n markAsRead: (ticketId?: string) => Promise<MarkAsReadResponse>\n getTickets: (options?: GetTicketsOptions) => Promise<GetTicketsResponse>\n requestRestoreLink: (email: string) => Promise<RequestRestoreLinkResponse>\n restoreFromToken: (restoreToken: string) => Promise<RestoreFromTokenResponse>\n restoreFromUrlToken: () => Promise<RestoreFromTokenResponse | null>\n getCurrentTicketId: () => string | null\n getWidgetSessionId: () => string\n}\n\ninterface PostHogExtensions {\n loadExternalDependency?: (\n posthog: PostHog,\n kind: PostHogExtensionKind,\n callback: (error?: string | Event, event?: Event) => void\n ) => void\n\n loadSiteApp?: (posthog: PostHog, appUrl: string, callback: (error?: string | Event, event?: Event) => void) => void\n\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n wrapConsoleError: (captureFn: (props: ErrorTracking.ErrorProperties) => void) => () => void\n }\n rrweb?: { record: any; version: string; wasMaxDepthReached?: () => boolean; resetMaxDepthState?: () => void }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n generateSurveys?: (posthog: PostHog, isSurveysEnabled: boolean) => any | undefined\n generateProductTours?: (posthog: PostHog, isEnabled: boolean) => any | undefined\n logs?: {\n initializeLogs?: (posthog: PostHog) => any | undefined\n }\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n /**\n * @deprecated\n *\n * this was introduced briefly, it is now always a no-op and only kept for backwards compatibility\n */\n loadWebVitalsCallbacks?: (useAttribution?: boolean) => PostHogExtensions['postHogWebVitalsCallbacks']\n tracingHeadersPatchFns?: {\n _patchFetch: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n _patchXHR: (hostnames: string[], distinctId: string, sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n integrations?: {\n [K in ExternalIntegrationKind]?: { start: (posthog: PostHog) => void; stop: () => void }\n }\n initSessionRecording?: (ph: PostHog) => LazyLoadedSessionRecordingInterface\n initConversations?: (config: ConversationsRemoteConfig, posthog: PostHog) => LazyLoadedConversationsInterface\n}\n\nconst global: typeof globalThis | undefined = typeof globalThis !== 'undefined' ? globalThis : win\n\n// React Native polyfills for posthog-js compatibility\nif (typeof self === 'undefined') {\n ;(global as any).self = global\n}\nif (typeof File === 'undefined') {\n ;(global as any).File = function () {}\n}\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 CompressionStream = global?.CompressionStream\nexport const userAgent = navigator?.userAgent\nexport const assignableWindow: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","import packageInfo from '../package.json'\n\n// overridden in posthog-core,\n// e.g. Config.DEBUG = Config.DEBUG || instance.config.debug\nconst Config = {\n DEBUG: false,\n LIB_VERSION: packageInfo.version,\n LIB_NAME: 'web',\n /** The actual JS SDK version, unaffected by _overrideSDKInfo. Used for the `ver` request param. */\n JS_SDK_VERSION: packageInfo.version,\n}\n\nexport default Config\n","function isGzipSupported() {\n return 'CompressionStream' in globalThis && 'TextEncoder' in globalThis && 'Response' in globalThis && 'function' == typeof Response.prototype.blob;\n}\nconst isNativeAsyncGzipReadError = (error)=>{\n if (!error || 'object' != typeof error) return false;\n const name = 'name' in error ? String(error.name) : '';\n return 'NotReadableError' === name;\n};\nasync function gzipCompress(input, isDebug = true, options) {\n try {\n const compressedStream = new CompressionStream('gzip');\n const writer = compressedStream.writable.getWriter();\n const writePromise = writer.write(new TextEncoder().encode(input)).then(()=>writer.close()).catch(async (err)=>{\n try {\n await writer.abort(err);\n } catch {}\n throw err;\n });\n const responsePromise = new Response(compressedStream.readable).blob();\n const [compressed] = await Promise.all([\n responsePromise,\n writePromise\n ]);\n return compressed;\n } catch (error) {\n if (options?.rethrow) throw error;\n if (isDebug) console.error('Failed to gzip compress data', error);\n return null;\n }\n}\nexport { gzipCompress, isGzipSupported, isNativeAsyncGzipReadError };\n","const DEFAULT_BLOCKED_UA_STRS = [\n 'amazonbot',\n 'amazonproductbot',\n 'app.hypefactors.com',\n 'applebot',\n 'archive.org_bot',\n 'awariobot',\n 'backlinksextendedbot',\n 'baiduspider',\n 'bingbot',\n 'bingpreview',\n 'chrome-lighthouse',\n 'dataforseobot',\n 'deepscan',\n 'duckduckbot',\n 'facebookexternal',\n 'facebookcatalog',\n 'http://yandex.com/bots',\n 'hubspot',\n 'ia_archiver',\n 'leikibot',\n 'linkedinbot',\n 'meta-externalagent',\n 'mj12bot',\n 'msnbot',\n 'nessus',\n 'petalbot',\n 'pinterest',\n 'prerender',\n 'rogerbot',\n 'screaming frog',\n 'sebot-wa',\n 'sitebulb',\n 'slackbot',\n 'slurp',\n 'trendictionbot',\n 'turnitin',\n 'twitterbot',\n 'vercel-screenshot',\n 'vercelbot',\n 'yahoo! slurp',\n 'yandexbot',\n 'zoombot',\n 'bot.htm',\n 'bot.php',\n '(bot;',\n 'bot/',\n 'crawler',\n 'ahrefsbot',\n 'ahrefssiteaudit',\n 'semrushbot',\n 'siteauditbot',\n 'splitsignalbot',\n 'gptbot',\n 'oai-searchbot',\n 'chatgpt-user',\n 'perplexitybot',\n 'better uptime bot',\n 'sentryuptimebot',\n 'uptimerobot',\n 'headlesschrome',\n 'cypress',\n 'google-hoteladsverifier',\n 'adsbot-google',\n 'apis-google',\n 'duplexweb-google',\n 'feedfetcher-google',\n 'google favicon',\n 'google web preview',\n 'google-read-aloud',\n 'googlebot',\n 'googleother',\n 'google-cloudvertexbot',\n 'googleweblight',\n 'mediapartners-google',\n 'storebot-google',\n 'google-inspectiontool',\n 'bytespider'\n];\nconst isBlockedUA = function(ua, customBlockedUserAgents = []) {\n if (!ua) return false;\n const uaLower = ua.toLowerCase();\n return DEFAULT_BLOCKED_UA_STRS.concat(customBlockedUserAgents).some((blockedUA)=>{\n const blockedUaLower = blockedUA.toLowerCase();\n return -1 !== uaLower.indexOf(blockedUaLower);\n });\n};\nexport { DEFAULT_BLOCKED_UA_STRS, isBlockedUA };\n","var types_PostHogPersistedProperty = /*#__PURE__*/ function(PostHogPersistedProperty) {\n PostHogPersistedProperty[\"AnonymousId\"] = \"anonymous_id\";\n PostHogPersistedProperty[\"DistinctId\"] = \"distinct_id\";\n PostHogPersistedProperty[\"Props\"] = \"props\";\n PostHogPersistedProperty[\"EnablePersonProcessing\"] = \"enable_person_processing\";\n PostHogPersistedProperty[\"PersonMode\"] = \"person_mode\";\n PostHogPersistedProperty[\"FeatureFlagDetails\"] = \"feature_flag_details\";\n PostHogPersistedProperty[\"FeatureFlags\"] = \"feature_flags\";\n PostHogPersistedProperty[\"FeatureFlagPayloads\"] = \"feature_flag_payloads\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagDetails\"] = \"bootstrap_feature_flag_details\";\n PostHogPersistedProperty[\"BootstrapFeatureFlags\"] = \"bootstrap_feature_flags\";\n PostHogPersistedProperty[\"BootstrapFeatureFlagPayloads\"] = \"bootstrap_feature_flag_payloads\";\n PostHogPersistedProperty[\"OverrideFeatureFlags\"] = \"override_feature_flags\";\n PostHogPersistedProperty[\"Queue\"] = \"queue\";\n PostHogPersistedProperty[\"LogsQueue\"] = \"logs_queue\";\n PostHogPersistedProperty[\"OptedOut\"] = \"opted_out\";\n PostHogPersistedProperty[\"SessionId\"] = \"session_id\";\n PostHogPersistedProperty[\"SessionStartTimestamp\"] = \"session_start_timestamp\";\n PostHogPersistedProperty[\"SessionLastTimestamp\"] = \"session_timestamp\";\n PostHogPersistedProperty[\"PersonProperties\"] = \"person_properties\";\n PostHogPersistedProperty[\"GroupProperties\"] = \"group_properties\";\n PostHogPersistedProperty[\"InstalledAppBuild\"] = \"installed_app_build\";\n PostHogPersistedProperty[\"InstalledAppVersion\"] = \"installed_app_version\";\n PostHogPersistedProperty[\"SessionReplay\"] = \"session_replay\";\n PostHogPersistedProperty[\"SurveyLastSeenDate\"] = \"survey_last_seen_date\";\n PostHogPersistedProperty[\"SurveysSeen\"] = \"surveys_seen\";\n PostHogPersistedProperty[\"Surveys\"] = \"surveys\";\n PostHogPersistedProperty[\"RemoteConfig\"] = \"remote_config\";\n PostHogPersistedProperty[\"FlagsEndpointWasHit\"] = \"flags_endpoint_was_hit\";\n PostHogPersistedProperty[\"DeviceId\"] = \"device_id\";\n return PostHogPersistedProperty;\n}({});\nvar types_Compression = /*#__PURE__*/ function(Compression) {\n Compression[\"GZipJS\"] = \"gzip-js\";\n Compression[\"Base64\"] = \"base64\";\n return Compression;\n}({});\nconst FeatureFlagError = {\n ERRORS_WHILE_COMPUTING: 'errors_while_computing_flags',\n FLAG_MISSING: 'flag_missing',\n QUOTA_LIMITED: 'quota_limited',\n TIMEOUT: 'timeout',\n CONNECTION_ERROR: 'connection_error',\n UNKNOWN_ERROR: 'unknown_error',\n apiError: (status)=>`api_error_${status}`\n};\nvar types_SurveyPosition = /*#__PURE__*/ function(SurveyPosition) {\n SurveyPosition[\"TopLeft\"] = \"top_left\";\n SurveyPosition[\"TopCenter\"] = \"top_center\";\n SurveyPosition[\"TopRight\"] = \"top_right\";\n SurveyPosition[\"MiddleLeft\"] = \"middle_left\";\n SurveyPosition[\"MiddleCenter\"] = \"middle_center\";\n SurveyPosition[\"MiddleRight\"] = \"middle_right\";\n SurveyPosition[\"Left\"] = \"left\";\n SurveyPosition[\"Right\"] = \"right\";\n SurveyPosition[\"Center\"] = \"center\";\n return SurveyPosition;\n}({});\nvar types_SurveyWidgetType = /*#__PURE__*/ function(SurveyWidgetType) {\n SurveyWidgetType[\"Button\"] = \"button\";\n SurveyWidgetType[\"Tab\"] = \"tab\";\n SurveyWidgetType[\"Selector\"] = \"selector\";\n return SurveyWidgetType;\n}({});\nvar types_SurveyType = /*#__PURE__*/ function(SurveyType) {\n SurveyType[\"Popover\"] = \"popover\";\n SurveyType[\"API\"] = \"api\";\n SurveyType[\"Widget\"] = \"widget\";\n SurveyType[\"ExternalSurvey\"] = \"external_survey\";\n return SurveyType;\n}({});\nvar types_SurveyQuestionDescriptionContentType = /*#__PURE__*/ function(SurveyQuestionDescriptionContentType) {\n SurveyQuestionDescriptionContentType[\"Html\"] = \"html\";\n SurveyQuestionDescriptionContentType[\"Text\"] = \"text\";\n return SurveyQuestionDescriptionContentType;\n}({});\nvar types_SurveyValidationType = /*#__PURE__*/ function(SurveyValidationType) {\n SurveyValidationType[\"MinLength\"] = \"min_length\";\n SurveyValidationType[\"MaxLength\"] = \"max_length\";\n return SurveyValidationType;\n}({});\nvar types_SurveyRatingDisplay = /*#__PURE__*/ function(SurveyRatingDisplay) {\n SurveyRatingDisplay[\"Number\"] = \"number\";\n SurveyRatingDisplay[\"Emoji\"] = \"emoji\";\n return SurveyRatingDisplay;\n}({});\nvar types_SurveyQuestionType = /*#__PURE__*/ function(SurveyQuestionType) {\n SurveyQuestionType[\"Open\"] = \"open\";\n SurveyQuestionType[\"MultipleChoice\"] = \"multiple_choice\";\n SurveyQuestionType[\"SingleChoice\"] = \"single_choice\";\n SurveyQuestionType[\"Rating\"] = \"rating\";\n SurveyQuestionType[\"Link\"] = \"link\";\n return SurveyQuestionType;\n}({});\nvar types_SurveyQuestionBranchingType = /*#__PURE__*/ function(SurveyQuestionBranchingType) {\n SurveyQuestionBranchingType[\"NextQuestion\"] = \"next_question\";\n SurveyQuestionBranchingType[\"End\"] = \"end\";\n SurveyQuestionBranchingType[\"ResponseBased\"] = \"response_based\";\n SurveyQuestionBranchingType[\"SpecificQuestion\"] = \"specific_question\";\n return SurveyQuestionBranchingType;\n}({});\nvar types_SurveyMatchType = /*#__PURE__*/ function(SurveyMatchType) {\n SurveyMatchType[\"Regex\"] = \"regex\";\n SurveyMatchType[\"NotRegex\"] = \"not_regex\";\n SurveyMatchType[\"Exact\"] = \"exact\";\n SurveyMatchType[\"IsNot\"] = \"is_not\";\n SurveyMatchType[\"Icontains\"] = \"icontains\";\n SurveyMatchType[\"NotIcontains\"] = \"not_icontains\";\n return SurveyMatchType;\n}({});\nvar types_SurveySchedule = /*#__PURE__*/ function(SurveySchedule) {\n SurveySchedule[\"Once\"] = \"once\";\n SurveySchedule[\"Recurring\"] = \"recurring\";\n SurveySchedule[\"Always\"] = \"always\";\n return SurveySchedule;\n}({});\nvar types_ActionStepStringMatching = /*#__PURE__*/ function(ActionStepStringMatching) {\n ActionStepStringMatching[\"Contains\"] = \"contains\";\n ActionStepStringMatching[\"Exact\"] = \"exact\";\n ActionStepStringMatching[\"Regex\"] = \"regex\";\n return ActionStepStringMatching;\n}({});\nconst knownUnsafeEditableEvent = [\n '$snapshot',\n '$pageview',\n '$pageleave',\n '$set',\n 'survey dismissed',\n 'survey sent',\n 'survey shown',\n '$identify',\n '$groupidentify',\n '$create_alias',\n '$$client_ingestion_warning',\n '$web_experiment_applied',\n '$feature_enrollment_update',\n '$feature_flag_called'\n];\nexport { types_ActionStepStringMatching as ActionStepStringMatching, types_Compression as Compression, FeatureFlagError, types_PostHogPersistedProperty as PostHogPersistedProperty, types_SurveyMatchType as SurveyMatchType, types_SurveyPosition as SurveyPosition, types_SurveyQuestionBranchingType as SurveyQuestionBranchingType, types_SurveyQuestionDescriptionContentType as SurveyQuestionDescriptionContentType, types_SurveyQuestionType as SurveyQuestionType, types_SurveyRatingDisplay as SurveyRatingDisplay, types_SurveySchedule as SurveySchedule, types_SurveyType as SurveyType, types_SurveyValidationType as SurveyValidationType, types_SurveyWidgetType as SurveyWidgetType, knownUnsafeEditableEvent };\n","function includes(str, needle) {\n return -1 !== str.indexOf(needle);\n}\nconst trim = function(str) {\n return str.trim();\n};\nconst stripLeadingDollar = function(s) {\n return s.replace(/^\\$/, '');\n};\nfunction isDistinctIdStringLike(value) {\n return [\n 'distinct_id',\n 'distinctid'\n ].includes(value.toLowerCase());\n}\nfunction deepSortKeys(value) {\n if (null === value || 'object' != typeof value) return value;\n if (Array.isArray(value)) return value.map(deepSortKeys);\n return Object.keys(value).sort().reduce((acc, key)=>{\n acc[key] = deepSortKeys(value[key]);\n return acc;\n }, {});\n}\nfunction getPersonPropertiesHash(distinct_id, userPropertiesToSet, userPropertiesToSetOnce) {\n return JSON.stringify({\n distinct_id,\n userPropertiesToSet: userPropertiesToSet ? deepSortKeys(userPropertiesToSet) : void 0,\n userPropertiesToSetOnce: userPropertiesToSetOnce ? deepSortKeys(userPropertiesToSetOnce) : void 0\n });\n}\nexport { getPersonPropertiesHash, includes, isDistinctIdStringLike, stripLeadingDollar, trim };\n","import { knownUnsafeEditableEvent } from \"../types.mjs\";\nimport { includes } from \"./string-utils.mjs\";\nconst nativeIsArray = Array.isArray;\nconst ObjProto = Object.prototype;\nconst type_utils_hasOwnProperty = ObjProto.hasOwnProperty;\nconst type_utils_toString = ObjProto.toString;\nconst isArray = nativeIsArray || function(obj) {\n return '[object Array]' === type_utils_toString.call(obj);\n};\nconst isFunction = (x)=>'function' == typeof x;\nconst isNativeFunction = (x)=>isFunction(x) && -1 !== x.toString().indexOf('[native code]');\nconst isObject = (x)=>x === Object(x) && !isArray(x);\nconst isEmptyObject = (x)=>{\n if (isObject(x)) {\n for(const key in x)if (type_utils_hasOwnProperty.call(x, key)) return false;\n return true;\n }\n return false;\n};\nconst isUndefined = (x)=>void 0 === x;\nconst isString = (x)=>'[object String]' == type_utils_toString.call(x);\nconst isEmptyString = (x)=>isString(x) && 0 === x.trim().length;\nconst isNull = (x)=>null === x;\nconst isNullish = (x)=>isUndefined(x) || isNull(x);\nconst isNumber = (x)=>'[object Number]' == type_utils_toString.call(x) && x === x;\nconst isPositiveNumber = (value)=>isNumber(value) && value > 0;\nconst isBoolean = (x)=>'[object Boolean]' === type_utils_toString.call(x);\nconst isFormData = (x)=>x instanceof FormData;\nconst isFile = (x)=>x instanceof File;\nconst isPlainError = (x)=>x instanceof Error;\nconst isKnownUnsafeEditableEvent = (x)=>includes(knownUnsafeEditableEvent, x);\nfunction isPrimitive(value) {\n return null === value || 'object' != typeof value;\n}\nfunction isBuiltin(candidate, className) {\n return Object.prototype.toString.call(candidate) === `[object ${className}]`;\n}\nfunction isError(candidate) {\n switch(Object.prototype.toString.call(candidate)){\n case '[object Error]':\n case '[object Exception]':\n case '[object DOMException]':\n case '[object DOMError]':\n case '[object WebAssembly.Exception]':\n return true;\n default:\n return isInstanceOf(candidate, Error);\n }\n}\nfunction isErrorEvent(event) {\n return isBuiltin(event, 'ErrorEvent');\n}\nfunction isEvent(candidate) {\n return 'undefined' != typeof Event && isInstanceOf(candidate, Event);\n}\nfunction isPlainObject(candidate) {\n return isBuiltin(candidate, 'Object');\n}\nfunction isInstanceOf(candidate, base) {\n try {\n return candidate instanceof base;\n } catch {\n return false;\n }\n}\nconst yesLikeValues = [\n true,\n 'true',\n 1,\n '1',\n 'yes'\n];\nconst isYesLike = (val)=>includes(yesLikeValues, val);\nconst noLikeValues = [\n false,\n 'false',\n 0,\n '0',\n 'no'\n];\nconst isNoLike = (val)=>includes(noLikeValues, val);\nexport { type_utils_hasOwnProperty as hasOwnProperty, isArray, isBoolean, isBuiltin, isEmptyObject, isEmptyString, isError, isErrorEvent, isEvent, isFile, isFormData, isFunction, isKnownUnsafeEditableEvent, isNativeFunction, isNoLike, isNull, isNullish, isNumber, isObject, isPlainError, isPlainObject, isPositiveNumber, isPrimitive, isString, isUndefined, isYesLike, noLikeValues, yesLikeValues };\n","import { isNumber } from \"./type-utils.mjs\";\nfunction clampToRange(value, min, max, logger, fallbackValue) {\n if (min > max) {\n logger.warn('min cannot be greater than max.');\n min = max;\n }\n if (isNumber(value)) if (value > max) {\n logger.warn(' cannot be greater than max: ' + max + '. Using max value instead.');\n return max;\n } else {\n if (!(value < min)) return value;\n logger.warn(' cannot be less than min: ' + min + '. Using min value instead.');\n return min;\n }\n logger.warn(' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue);\n return clampToRange(fallbackValue || max, min, max, logger);\n}\nfunction getRemoteConfigBool(field, key, defaultValue = true) {\n if (null == field) return defaultValue;\n if ('boolean' == typeof field) return field;\n if ('object' == typeof field) {\n const value = field[key];\n return 'boolean' == typeof value ? value : defaultValue;\n }\n return defaultValue;\n}\nfunction getRemoteConfigNumber(field, key) {\n if (null == field || 'object' != typeof field) return;\n const value = field[key];\n if ('number' == typeof value && Number.isFinite(value)) return value;\n if ('string' == typeof value) {\n const trimmed = value.trim();\n if ('' === trimmed) return;\n const parsed = Number(trimmed);\n return Number.isFinite(parsed) ? parsed : void 0;\n }\n}\nfunction isValidSampleRate(value) {\n return 'number' == typeof value && Number.isFinite(value) && value >= 0 && value <= 1;\n}\nexport { clampToRange, getRemoteConfigBool, getRemoteConfigNumber, isValidSampleRate };\n","import { clampToRange } from \"./number-utils.mjs\";\nconst ONE_DAY_IN_MS = 86400000;\nclass BucketedRateLimiter {\n constructor(options){\n this._buckets = {};\n this._onBucketRateLimited = options._onBucketRateLimited;\n this._bucketSize = clampToRange(options.bucketSize, 0, 100, options._logger);\n this._refillRate = clampToRange(options.refillRate, 0, this._bucketSize, options._logger);\n this._refillInterval = clampToRange(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);\n }\n _applyRefill(bucket, now) {\n const elapsedMs = now - bucket.lastAccess;\n const refillIntervals = Math.floor(elapsedMs / this._refillInterval);\n if (refillIntervals > 0) {\n const tokensToAdd = refillIntervals * this._refillRate;\n bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);\n bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;\n }\n }\n consumeRateLimit(key) {\n const now = Date.now();\n const keyStr = String(key);\n let bucket = this._buckets[keyStr];\n if (bucket) this._applyRefill(bucket, now);\n else {\n bucket = {\n tokens: this._bucketSize,\n lastAccess: now\n };\n this._buckets[keyStr] = bucket;\n }\n if (0 === bucket.tokens) return true;\n bucket.tokens--;\n if (0 === bucket.tokens) this._onBucketRateLimited?.(key);\n return 0 === bucket.tokens;\n }\n stop() {\n this._buckets = {};\n }\n}\nexport { BucketedRateLimiter };\n","import { includes } from \"./string-utils.mjs\";\nimport { isFunction, isUndefined } from \"./type-utils.mjs\";\nconst FACEBOOK = 'Facebook';\nconst MOBILE = 'Mobile';\nconst IOS = 'iOS';\nconst ANDROID = 'Android';\nconst TABLET = 'Tablet';\nconst ANDROID_TABLET = ANDROID + ' ' + TABLET;\nconst IPAD = 'iPad';\nconst APPLE = 'Apple';\nconst APPLE_WATCH = APPLE + ' Watch';\nconst SAFARI = 'Safari';\nconst BLACKBERRY = 'BlackBerry';\nconst SAMSUNG = 'Samsung';\nconst SAMSUNG_BROWSER = SAMSUNG + 'Browser';\nconst SAMSUNG_INTERNET = SAMSUNG + ' Internet';\nconst CHROME = 'Chrome';\nconst CHROME_OS = CHROME + ' OS';\nconst CHROME_IOS = CHROME + ' ' + IOS;\nconst INTERNET_EXPLORER = 'Internet Explorer';\nconst INTERNET_EXPLORER_MOBILE = INTERNET_EXPLORER + ' ' + MOBILE;\nconst OPERA = 'Opera';\nconst OPERA_MINI = OPERA + ' Mini';\nconst EDGE = 'Edge';\nconst MICROSOFT_EDGE = 'Microsoft ' + EDGE;\nconst FIREFOX = 'Firefox';\nconst FIREFOX_IOS = FIREFOX + ' ' + IOS;\nconst NINTENDO = 'Nintendo';\nconst PLAYSTATION = 'PlayStation';\nconst XBOX = 'Xbox';\nconst ANDROID_MOBILE = ANDROID + ' ' + MOBILE;\nconst MOBILE_SAFARI = MOBILE + ' ' + SAFARI;\nconst WINDOWS = 'Windows';\nconst WINDOWS_PHONE = WINDOWS + ' Phone';\nconst NOKIA = 'Nokia';\nconst OUYA = 'Ouya';\nconst GENERIC = 'Generic';\nconst GENERIC_MOBILE = GENERIC + ' ' + MOBILE.toLowerCase();\nconst GENERIC_TABLET = GENERIC + ' ' + TABLET.toLowerCase();\nconst KONQUEROR = 'Konqueror';\nconst BROWSER_VERSION_REGEX_SUFFIX = '(\\\\d+(\\\\.\\\\d+)?)';\nconst DEFAULT_BROWSER_VERSION_REGEX = new RegExp('Version/' + BROWSER_VERSION_REGEX_SUFFIX);\nconst XBOX_REGEX = new RegExp(XBOX, 'i');\nconst PLAYSTATION_REGEX = new RegExp(PLAYSTATION + ' \\\\w+', 'i');\nconst NINTENDO_REGEX = new RegExp(NINTENDO + ' \\\\w+', 'i');\nconst BLACKBERRY_REGEX = new RegExp(BLACKBERRY + '|PlayBook|BB10', 'i');\nconst windowsVersionMap = {\n 'NT3.51': 'NT 3.11',\n 'NT4.0': 'NT 4.0',\n '5.0': '2000',\n '5.1': 'XP',\n '5.2': 'XP',\n '6.0': 'Vista',\n '6.1': '7',\n '6.2': '8',\n '6.3': '8.1',\n '6.4': '10',\n '10.0': '10'\n};\nfunction isSafari(userAgent) {\n return includes(userAgent, SAFARI) && !includes(userAgent, CHROME) && !includes(userAgent, ANDROID);\n}\nconst safariCheck = (ua, vendor)=>vendor && includes(vendor, APPLE) || isSafari(ua);\nconst detectBrowser = function(user_agent, vendor) {\n vendor = vendor || '';\n if (includes(user_agent, ' OPR/') && includes(user_agent, 'Mini')) return OPERA_MINI;\n if (includes(user_agent, ' OPR/')) return OPERA;\n if (BLACKBERRY_REGEX.test(user_agent)) return BLACKBERRY;\n if (includes(user_agent, 'IE' + MOBILE) || includes(user_agent, 'WPDesktop')) return INTERNET_EXPLORER_MOBILE;\n if (includes(user_agent, SAMSUNG_BROWSER)) return SAMSUNG_INTERNET;\n else if (includes(user_agent, EDGE) || includes(user_agent, 'Edg/')) return MICROSOFT_EDGE;\n else if (includes(user_agent, 'FBIOS')) return FACEBOOK + ' ' + MOBILE;\n else if (includes(user_agent, 'UCWEB') || includes(user_agent, 'UCBrowser')) return 'UC Browser';\n else if (includes(user_agent, 'CriOS')) return CHROME_IOS;\n else if (includes(user_agent, 'CrMo')) return CHROME;\n else if (includes(user_agent, CHROME)) return CHROME;\n else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) return ANDROID_MOBILE;\n else if (includes(user_agent, 'FxiOS')) return FIREFOX_IOS;\n else if (includes(user_agent.toLowerCase(), KONQUEROR.toLowerCase())) return KONQUEROR;\n else if (safariCheck(user_agent, vendor)) return includes(user_agent, MOBILE) ? MOBILE_SAFARI : SAFARI;\n else if (includes(user_agent, FIREFOX)) return FIREFOX;\n else if (includes(user_agent, 'MSIE') || includes(user_agent, 'Trident/')) return INTERNET_EXPLORER;\n else if (includes(user_agent, 'Gecko')) return FIREFOX;\n return '';\n};\nconst versionRegexes = {\n [INTERNET_EXPLORER_MOBILE]: [\n new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [MICROSOFT_EDGE]: [\n new RegExp(EDGE + '?\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [CHROME]: [\n new RegExp('(' + CHROME + '|CrMo)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [CHROME_IOS]: [\n new RegExp('CriOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n 'UC Browser': [\n new RegExp('(UCBrowser|UCWEB)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [SAFARI]: [\n DEFAULT_BROWSER_VERSION_REGEX\n ],\n [MOBILE_SAFARI]: [\n DEFAULT_BROWSER_VERSION_REGEX\n ],\n [OPERA]: [\n new RegExp('(' + OPERA + '|OPR)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [FIREFOX]: [\n new RegExp(FIREFOX + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [FIREFOX_IOS]: [\n new RegExp('FxiOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [KONQUEROR]: [\n new RegExp('Konqueror[:/]?' + BROWSER_VERSION_REGEX_SUFFIX, 'i')\n ],\n [BLACKBERRY]: [\n new RegExp(BLACKBERRY + ' ' + BROWSER_VERSION_REGEX_SUFFIX),\n DEFAULT_BROWSER_VERSION_REGEX\n ],\n [ANDROID_MOBILE]: [\n new RegExp('android\\\\s' + BROWSER_VERSION_REGEX_SUFFIX, 'i')\n ],\n [SAMSUNG_INTERNET]: [\n new RegExp(SAMSUNG_BROWSER + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n [INTERNET_EXPLORER]: [\n new RegExp('(rv:|MSIE )' + BROWSER_VERSION_REGEX_SUFFIX)\n ],\n Mozilla: [\n new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)\n ]\n};\nconst detectBrowserVersion = function(userAgent, vendor) {\n const browser = detectBrowser(userAgent, vendor);\n const regexes = versionRegexes[browser];\n if (isUndefined(regexes)) return null;\n for(let i = 0; i < regexes.length; i++){\n const regex = regexes[i];\n const matches = userAgent.match(regex);\n if (matches) return parseFloat(matches[matches.length - 2]);\n }\n return null;\n};\nconst osMatchers = [\n [\n new RegExp(XBOX + '; ' + XBOX + ' (.*?)[);]', 'i'),\n (match)=>[\n XBOX,\n match && match[1] || ''\n ]\n ],\n [\n new RegExp(NINTENDO, 'i'),\n [\n NINTENDO,\n ''\n ]\n ],\n [\n new RegExp(PLAYSTATION, 'i'),\n [\n PLAYSTATION,\n ''\n ]\n ],\n [\n BLACKBERRY_REGEX,\n [\n BLACKBERRY,\n ''\n ]\n ],\n [\n new RegExp(WINDOWS, 'i'),\n (_, user_agent)=>{\n if (/Phone/.test(user_agent) || /WPDesktop/.test(user_agent)) return [\n WINDOWS_PHONE,\n ''\n ];\n if (new RegExp(MOBILE).test(user_agent) && !/IEMobile\\b/.test(user_agent)) return [\n WINDOWS + ' ' + MOBILE,\n ''\n ];\n const match = /Windows NT ([0-9.]+)/i.exec(user_agent);\n if (match && match[1]) {\n const version = match[1];\n let osVersion = windowsVersionMap[version] || '';\n if (/arm/i.test(user_agent)) osVersion = 'RT';\n return [\n WINDOWS,\n osVersion\n ];\n }\n return [\n WINDOWS,\n ''\n ];\n }\n ],\n [\n /((iPhone|iPad|iPod).*?OS (\\d+)_(\\d+)_?(\\d+)?|iPhone)/,\n (match)=>{\n if (match && match[3]) {\n const versionParts = [\n match[3],\n match[4],\n match[5] || '0'\n ];\n return [\n IOS,\n versionParts.join('.')\n ];\n }\n return [\n IOS,\n ''\n ];\n }\n ],\n [\n /(watch.*\\/(\\d+\\.\\d+\\.\\d+)|watch os,(\\d+\\.\\d+),)/i,\n (match)=>{\n let version = '';\n if (match && match.length >= 3) version = isUndefined(match[2]) ? match[3] : match[2];\n return [\n 'watchOS',\n version\n ];\n }\n ],\n [\n new RegExp('(' + ANDROID + ' (\\\\d+)\\\\.(\\\\d+)\\\\.?(\\\\d+)?|' + ANDROID + ')', 'i'),\n (match)=>{\n if (match && match[2]) {\n const versionParts = [\n match[2],\n match[3],\n match[4] || '0'\n ];\n return [\n ANDROID,\n versionParts.join('.')\n ];\n }\n return [\n ANDROID,\n ''\n ];\n }\n ],\n [\n /Mac OS X (\\d+)[_.](\\d+)[_.]?(\\d+)?/i,\n (match)=>{\n const result = [\n 'Mac OS X',\n ''\n ];\n if (match && match[1]) {\n const versionParts = [\n match[1],\n match[2],\n match[3] || '0'\n ];\n result[1] = versionParts.join('.');\n }\n return result;\n }\n ],\n [\n /Mac/i,\n [\n 'Mac OS X',\n ''\n ]\n ],\n [\n /CrOS/,\n [\n CHROME_OS,\n ''\n ]\n ],\n [\n /Linux|debian/i,\n [\n 'Linux',\n ''\n ]\n ]\n];\nconst detectOS = function(user_agent) {\n for(let i = 0; i < osMatchers.length; i++){\n const [rgex, resultOrFn] = osMatchers[i];\n const match = rgex.exec(user_agent);\n const result = match && (isFunction(resultOrFn) ? resultOrFn(match, user_agent) : resultOrFn);\n if (result) return result;\n }\n return [\n '',\n ''\n ];\n};\nconst detectDevice = function(user_agent) {\n if (NINTENDO_REGEX.test(user_agent)) return NINTENDO;\n if (PLAYSTATION_REGEX.test(user_agent)) return PLAYSTATION;\n if (XBOX_REGEX.test(user_agent)) return XBOX;\n if (new RegExp(OUYA, 'i').test(user_agent)) return OUYA;\n if (new RegExp('(' + WINDOWS_PHONE + '|WPDesktop)', 'i').test(user_agent)) return WINDOWS_PHONE;\n else if (/iPad/.test(user_agent)) return IPAD;\n else if (/iPod/.test(user_agent)) return 'iPod Touch';\n else if (/iPhone/.test(user_agent)) return 'iPhone';\n else if (/(watch)(?: ?os[,/]|\\d,\\d\\/)[\\d.]+/i.test(user_agent)) return APPLE_WATCH;\n else if (BLACKBERRY_REGEX.test(user_agent)) return BLACKBERRY;\n else if (/(kobo)\\s(ereader|touch)/i.test(user_agent)) return 'Kobo';\n else if (new RegExp(NOKIA, 'i').test(user_agent)) return NOKIA;\n else if (/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i.test(user_agent) || /(kf[a-z]+)( bui|\\)).+silk\\//i.test(user_agent)) return 'Kindle Fire';\n else if (/(Android|ZTE)/i.test(user_agent)) if (!(!new RegExp(MOBILE).test(user_agent) || /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(user_agent))) return ANDROID;\n else {\n if (/pixel[\\daxl ]{1,6}/i.test(user_agent) && !/pixel c/i.test(user_agent) || /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(user_agent) || /lmy47v/i.test(user_agent) && !/QTAQZ3/i.test(user_agent)) return ANDROID;\n return ANDROID_TABLET;\n }\n else if (new RegExp('(pda|' + MOBILE + ')', 'i').test(user_agent)) return GENERIC_MOBILE;\n else if (new RegExp(TABLET, 'i').test(user_agent) && !new RegExp(TABLET + ' pc', 'i').test(user_agent)) return GENERIC_TABLET;\n else return '';\n};\nconst detectDeviceType = function(user_agent, options) {\n const device = detectDevice(user_agent);\n if (device === IPAD || device === ANDROID_TABLET || 'Kobo' === device || 'Kindle Fire' === device || device === GENERIC_TABLET) return TABLET;\n if (device === NINTENDO || device === XBOX || device === PLAYSTATION || device === OUYA) return 'Console';\n if (device === APPLE_WATCH) return 'Wearable';\n if (device) return MOBILE;\n if (options?.userAgentDataPlatform === 'Android' && (options?.maxTouchPoints ?? 0) > 0) {\n const shortSide = Math.min(options?.screenWidth ?? 0, options?.screenHeight ?? 0);\n const shortSideDp = shortSide / (options?.devicePixelRatio ?? 1);\n return shortSideDp >= 600 ? TABLET : MOBILE;\n }\n return 'Desktop';\n};\nexport { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS };\n","let parsedStackResults;\nlet lastKeysCount;\nlet cachedFilenameChunkIds;\nfunction getFilenameToChunkIdMap(stackParser) {\n const chunkIdMap = globalThis._posthogChunkIds;\n if (!chunkIdMap) return;\n const chunkIdKeys = Object.keys(chunkIdMap);\n if (cachedFilenameChunkIds && chunkIdKeys.length === lastKeysCount) return cachedFilenameChunkIds;\n lastKeysCount = chunkIdKeys.length;\n cachedFilenameChunkIds = chunkIdKeys.reduce((acc, stackKey)=>{\n if (!parsedStackResults) parsedStackResults = {};\n const result = parsedStackResults[stackKey];\n if (result) acc[result[0]] = result[1];\n else {\n const parsedStack = stackParser(stackKey);\n for(let i = parsedStack.length - 1; i >= 0; i--){\n const stackFrame = parsedStack[i];\n const filename = stackFrame?.filename;\n const chunkId = chunkIdMap[stackKey];\n if (filename && chunkId) {\n acc[filename] = chunkId;\n parsedStackResults[stackKey] = [\n filename,\n chunkId\n ];\n break;\n }\n }\n }\n