posthog-js 1.200.0 → 1.200.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.
- package/dist/all-external-dependencies.js +1 -1
- package/dist/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/customizations.full.js.map +1 -1
- package/dist/dead-clicks-autocapture.js.map +1 -1
- package/dist/exception-autocapture.js.map +1 -1
- package/dist/external-scripts-loader.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +5 -0
- package/dist/module.full.d.ts +5 -0
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +5 -0
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +5 -0
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.js.map +1 -1
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/entrypoints/tracing-headers.d.ts +2 -2
- package/dist/src/types.d.ts +5 -0
- package/dist/src/utils/globals.d.ts +2 -2
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js.map +1 -1
- package/dist/tracing-headers.js +1 -1
- package/dist/tracing-headers.js.map +1 -1
- package/dist/web-vitals.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/constants.d.ts +6 -0
- package/lib/src/constants.js +6 -0
- package/lib/src/constants.js.map +1 -1
- package/lib/src/entrypoints/tracing-headers.d.ts +2 -2
- package/lib/src/entrypoints/tracing-headers.js +5 -3
- package/lib/src/entrypoints/tracing-headers.js.map +1 -1
- package/lib/src/extensions/replay/sessionrecording.js +3 -0
- package/lib/src/extensions/replay/sessionrecording.js.map +1 -1
- package/lib/src/extensions/tracing-headers.js +0 -1
- package/lib/src/extensions/tracing-headers.js.map +1 -1
- package/lib/src/posthog-core.js +36 -13
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/sessionid.js +6 -0
- package/lib/src/sessionid.js.map +1 -1
- package/lib/src/types.d.ts +5 -0
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/globals.d.ts +2 -2
- package/lib/src/utils/globals.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customizations.full.js","sources":["../src/utils/globals.ts","../src/types.ts","../src/utils/type-utils.ts","../src/config.ts","../src/utils/logger.ts","../src/utils/index.ts","../src/utils/request-utils.ts","../src/utils/user-agent-utils.ts","../src/utils/event-utils.ts","../src/utils/number-utils.ts","../src/customizations/before-send.ts","../src/customizations/setAllPersonProfilePropertiesAsPersonPropertiesForFlags.ts","../src/entrypoints/customizations.full.ts"],"sourcesContent":["import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ErrorEventArgs,\n ErrorMetadata,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n} from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n _POSTHOG_CONFIG?: RemoteConfig\n _POSTHOG_JS_APPS?: SiteAppLoader[]\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\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 parseErrorAsProperties?: (\n [event, source, lineno, colno, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n ) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (sessionManager: SessionIdManager) => () => void\n _patchXHR: (sessionManager: any) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\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: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","import { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { recordOptions } from './extensions/replay/sessionrecording-utils'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const 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] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = typeof knownUnsafeEditableEvent[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\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 type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\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 /** 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 * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n /**\n * we delay flushing web vitals metrics to reduce the number of events we send\n * this is the maximum time we will wait before sending the metrics\n * if not set it defaults to 5 seconds\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n // by default if a click is followed by a sroll within 100ms it is not a dead click\n scroll_threshold_ms?: number\n // by default if a click is followed by a selection change within 100ms it is not a dead click\n selection_change_threshold_ms?: number\n // by default if a click is followed by a mutation within 2500ms it is not a dead click\n mutation_threshold_ms?: number\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by the SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\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 type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\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 disable_web_experiments: 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 /**\n * this is a read-only function that can be used to react to event capture\n * @deprecated - use `before_send` instead - NB before_send is not read only\n */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\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 capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\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 /** Used when sending data via `fetch`, use with care, this is intentionally meant to be used with NextJS `fetch`\n * Incorrect usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\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 /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * enables the new RemoteConfig approach to loading config instead of decide\n * */\n __preview_remote_config?: 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?: recordOptions['maskInputOptions']\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: recordOptions['slimDOMOptions']\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\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 ADVANCED: whether to partially compress rrweb events before sending them to the server,\n defaults to true, can be set to false to disable partial compression\n NB requests are still compressed when sent to the server regardless of this setting\n */\n compress_events?: boolean\n /*\n ADVANCED: alters the threshold before a recording considers a user has become idle.\n Normally only altered alongside changes to session_idle_timeout_ms.\n Default is 5 minutes.\n */\n session_idle_threshold_ms?: number\n /*\n ADVANCED: alters the refill rate for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 10.\n */\n __mutationRateLimiterRefillRate?: number\n /*\n ADVANCED: alters the bucket size for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 100.\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => 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\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\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 fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\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 type SessionRecordingCanvasOptions = {\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}\n\nexport interface RemoteConfig {\n supportedCompression: Compression[]\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?: SessionRecordingCanvasOptions & {\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 linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\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: string; url: string }[]\n heatmaps?: boolean\n defaultIdentifiedOnly?: boolean\n captureDeadClicks?: boolean\n hasFeatureFlags?: boolean // Indicates if the team has any flags enabled (if not we don't need to load them)\n}\n\nexport interface DecideResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processEvent?: (globals: SiteAppGlobals) => void\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 JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | JsonRecord | 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\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\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\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import { includes } from '.'\nimport { window } from './globals'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\n\n// 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 }\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 = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check (at least the MutationObserver)\nexport const isAngularZonePresent = (): boolean => {\n return !!(window as any).Zone\n}\n\n// Underscore Addons\nexport const isObject = (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 = (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 = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (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 = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (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 = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (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 = (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\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\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}\n\nexport default Config\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nexport type Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n info: (...args: any[]) => void\n warn: (...args: any[]) => void\n error: (...args: any[]) => void\n critical: (...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string) => Logger\n}\n\nconst _createLogger = (prefix: string): Logger => {\n const logger: 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(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(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string) => _createLogger(`${prefix} ${additionalPrefix}`),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { Breaker, EventHandler, Properties } from '../types'\nimport { hasOwnProperty, isArray, isFormData, isFunction, isNull, isNullish, isString } from './type-utils'\nimport { logger } from './logger'\nimport { nativeForEach, nativeIndexOf, window } from './globals'\n\nconst breaker: Breaker = {}\n\n// UNDERSCORE\n// Embed part of the Underscore Library\nexport const trim = function (str: string): string {\n return str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '')\n}\n\nexport function eachArray<E = any>(\n obj: E[] | null | undefined,\n iterator: (value: E, key: number) => void | Breaker,\n thisArg?: any\n): void {\n if (isArray(obj)) {\n if (nativeForEach && obj.forEach === nativeForEach) {\n obj.forEach(iterator, thisArg)\n } else if ('length' in obj && obj.length === +obj.length) {\n for (let i = 0, l = obj.length; i < l; i++) {\n if (i in obj && iterator.call(thisArg, obj[i], i) === breaker) {\n return\n }\n }\n }\n }\n}\n\n/**\n * @param {*=} obj\n * @param {function(...*)=} iterator\n * @param {Object=} thisArg\n */\nexport function each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void {\n if (isNullish(obj)) {\n return\n }\n if (isArray(obj)) {\n return eachArray(obj, iterator, thisArg)\n }\n if (isFormData(obj)) {\n for (const pair of obj.entries()) {\n if (iterator.call(thisArg, pair[1], pair[0]) === breaker) {\n return\n }\n }\n return\n }\n for (const key in obj) {\n if (hasOwnProperty.call(obj, key)) {\n if (iterator.call(thisArg, obj[key], key) === breaker) {\n return\n }\n }\n }\n}\n\nexport const extend = function (obj: Record<string, any>, ...args: Record<string, any>[]): Record<string, any> {\n eachArray(args, function (source) {\n for (const prop in source) {\n if (source[prop] !== void 0) {\n obj[prop] = source[prop]\n }\n }\n })\n return obj\n}\n\nexport const include = function (\n obj: null | string | Array<any> | Record<string, any>,\n target: any\n): boolean | Breaker {\n let found = false\n if (isNull(obj)) {\n return found\n }\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) {\n return obj.indexOf(target) != -1\n }\n each(obj, function (value) {\n if (found || (found = value === target)) {\n return breaker\n }\n return\n })\n return found\n}\n\nexport function includes<T = any>(str: T[] | string, needle: T): boolean {\n return (str as any).indexOf(needle) !== -1\n}\n\n/**\n * Object.entries() polyfill\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\n */\nexport function entries<T = any>(obj: Record<string, T>): [string, T][] {\n const ownProps = Object.keys(obj)\n let i = ownProps.length\n const resArray = new Array(i) // preallocate the Array\n\n while (i--) {\n resArray[i] = [ownProps[i], obj[ownProps[i]]]\n }\n return resArray\n}\n\nexport const isValidRegex = function (str: string): boolean {\n try {\n new RegExp(str)\n } catch {\n return false\n }\n return true\n}\n\nexport const trySafe = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch {\n return undefined\n }\n}\n\nexport const safewrap = function <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F): F {\n return function (...args) {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return f.apply(this, args)\n } catch (e) {\n logger.critical(\n 'Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.'\n )\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const safewrapClass = function (klass: Function, functions: string[]): void {\n for (let i = 0; i < functions.length; i++) {\n klass.prototype[functions[i]] = safewrap(klass.prototype[functions[i]])\n }\n}\n\nexport const stripEmptyProperties = function (p: Properties): Properties {\n const ret: Properties = {}\n each(p, function (v, k) {\n if (isString(v) && v.length > 0) {\n ret[k] = v\n }\n })\n return ret\n}\n\nexport const stripLeadingDollar = function (s: string): string {\n return s.replace(/^\\$/, '')\n}\n\n/**\n * Deep copies an object.\n * It handles cycles by replacing all references to them with `undefined`\n * Also supports customizing native values\n *\n * @param value\n * @param customizer\n * @returns {{}|undefined|*}\n */\nfunction deepCircularCopy<T extends Record<string, any> = Record<string, any>>(\n value: T,\n customizer?: <K extends keyof T = keyof T>(value: T[K], key?: K) => T[K]\n): T | undefined {\n const COPY_IN_PROGRESS_SET = new Set()\n\n function internalDeepCircularCopy(value: T, key?: string): T | undefined {\n if (value !== Object(value)) return customizer ? customizer(value as any, key) : value // primitive value\n\n if (COPY_IN_PROGRESS_SET.has(value)) return undefined\n COPY_IN_PROGRESS_SET.add(value)\n let result: T\n\n if (isArray(value)) {\n result = [] as any as T\n eachArray(value, (it) => {\n result.push(internalDeepCircularCopy(it))\n })\n } else {\n result = {} as T\n each(value, (val, key) => {\n if (!COPY_IN_PROGRESS_SET.has(val)) {\n ;(result as any)[key] = internalDeepCircularCopy(val, key)\n }\n })\n }\n return result\n }\n return internalDeepCircularCopy(value)\n}\n\nexport function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(\n object: T,\n maxStringLength: number | null\n): T {\n return deepCircularCopy(object, (value: any) => {\n if (isString(value) && !isNull(maxStringLength)) {\n return (value as string).slice(0, maxStringLength)\n }\n return value\n }) as T\n}\n\nexport function _base64Encode(data: null): null\nexport function _base64Encode(data: undefined): undefined\nexport function _base64Encode(data: string): string\nexport function _base64Encode(data: string | null | undefined): string | null | undefined {\n const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='\n let o1,\n o2,\n o3,\n h1,\n h2,\n h3,\n h4,\n bits,\n i = 0,\n ac = 0,\n enc = ''\n const tmp_arr: string[] = []\n\n if (!data) {\n return data\n }\n\n data = utf8Encode(data)\n\n do {\n // pack three octets into four hexets\n o1 = data.charCodeAt(i++)\n o2 = data.charCodeAt(i++)\n o3 = data.charCodeAt(i++)\n\n bits = (o1 << 16) | (o2 << 8) | o3\n\n h1 = (bits >> 18) & 0x3f\n h2 = (bits >> 12) & 0x3f\n h3 = (bits >> 6) & 0x3f\n h4 = bits & 0x3f\n\n // use hexets to index into b64, and append result to encoded string\n tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4)\n } while (i < data.length)\n\n enc = tmp_arr.join('')\n\n switch (data.length % 3) {\n case 1:\n enc = enc.slice(0, -2) + '=='\n break\n case 2:\n enc = enc.slice(0, -1) + '='\n break\n }\n\n return enc\n}\n\nexport const utf8Encode = function (string: string): string {\n string = (string + '').replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n\n let utftext = '',\n start,\n end\n let stringl = 0,\n n\n\n start = end = 0\n stringl = string.length\n\n for (n = 0; n < stringl; n++) {\n const c1 = string.charCodeAt(n)\n let enc = null\n\n if (c1 < 128) {\n end++\n } else if (c1 > 127 && c1 < 2048) {\n enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128)\n } else {\n enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128)\n }\n if (!isNull(enc)) {\n if (end > start) {\n utftext += string.substring(start, end)\n }\n utftext += enc\n start = end = n + 1\n }\n }\n\n if (end > start) {\n utftext += string.substring(start, string.length)\n }\n\n return utftext\n}\n\nexport const registerEvent = (function () {\n // written by Dean Edwards, 2005\n // with input from Tino Zijdel - crisp@xs4all.nl\n // with input from Carl Sverre - mail@carlsverre.com\n // with input from PostHog\n // http://dean.edwards.name/weblog/2005/10/add-event/\n // https://gist.github.com/1930440\n\n /**\n * @param {Object} element\n * @param {string} type\n * @param {function(...*)} handler\n * @param {boolean=} oldSchool\n * @param {boolean=} useCapture\n */\n const register_event = function (\n element: Element | Window | Document | Node,\n type: string,\n handler: EventHandler,\n oldSchool?: boolean,\n useCapture?: boolean\n ) {\n if (!element) {\n logger.error('No valid element provided to register_event')\n return\n }\n\n if (element.addEventListener && !oldSchool) {\n element.addEventListener(type, handler, !!useCapture)\n } else {\n const ontype = 'on' + type\n const old_handler = (element as any)[ontype] // can be undefined\n ;(element as any)[ontype] = makeHandler(element, handler, old_handler)\n }\n }\n\n function makeHandler(\n element: Element | Window | Document | Node,\n new_handler: EventHandler,\n old_handlers: EventHandler\n ) {\n return function (event: Event): boolean | void {\n event = event || fixEvent(window?.event)\n\n // this basically happens in firefox whenever another script\n // overwrites the onload callback and doesn't pass the event\n // object to previously defined callbacks. All the browsers\n // that don't define window.event implement addEventListener\n // so the dom_loaded handler will still be fired as usual.\n if (!event) {\n return undefined\n }\n\n let ret = true\n let old_result: any\n\n if (isFunction(old_handlers)) {\n old_result = old_handlers(event)\n }\n const new_result = new_handler.call(element, event)\n\n if (false === old_result || false === new_result) {\n ret = false\n }\n\n return ret\n }\n }\n\n function fixEvent(event: Event | undefined): Event | undefined {\n if (event) {\n event.preventDefault = fixEvent.preventDefault\n event.stopPropagation = fixEvent.stopPropagation\n }\n return event\n }\n fixEvent.preventDefault = function () {\n ;(this as any as Event).returnValue = false\n }\n fixEvent.stopPropagation = function () {\n ;(this as any as Event).cancelBubble = true\n }\n\n return register_event\n})()\n\nexport function isCrossDomainCookie(documentLocation: Location | undefined) {\n const hostname = documentLocation?.hostname\n\n if (!isString(hostname)) {\n return false\n }\n // split and slice isn't a great way to match arbitrary domains,\n // but it's good enough for ensuring we only match herokuapp.com when it is the TLD\n // for the hostname\n return hostname.split('.').slice(-2).join('.') !== 'herokuapp.com'\n}\n\nexport function isDistinctIdStringLike(value: string): boolean {\n return ['distinct_id', 'distinctid'].includes(value.toLowerCase())\n}\n\nexport function find<T>(value: T[], predicate: (value: T) => boolean): T | undefined {\n for (let i = 0; i < value.length; i++) {\n if (predicate(value[i])) {\n return value[i]\n }\n }\n return undefined\n}\n","import { each, isValidRegex } from './'\n\nimport { isArray, isFile, isUndefined } from './type-utils'\nimport { logger } from './logger'\nimport { document } from './globals'\n\nconst localDomains = ['localhost', '127.0.0.1']\n\n/**\n * IE11 doesn't support `new URL`\n * so we can create an anchor element and use that to parse the URL\n * there's a lot of overlap between HTMLHyperlinkElementUtils and URL\n * meaning useful properties like `pathname` are available on both\n */\nexport const convertToURL = (url: string): HTMLAnchorElement | null => {\n const location = document?.createElement('a')\n if (isUndefined(location)) {\n return null\n }\n\n location.href = url\n return location\n}\n\nexport const isUrlMatchingRegex = function (url: string, pattern: string): boolean {\n if (!isValidRegex(pattern)) return false\n return new RegExp(pattern).test(url)\n}\n\nexport const formDataToQuery = function (formdata: Record<string, any> | FormData, arg_separator = '&'): string {\n let use_val: string\n let use_key: string\n const tph_arr: string[] = []\n\n each(formdata, function (val: File | string | undefined, key: string | undefined) {\n // the key might be literally the string undefined for e.g. if {undefined: 'something'}\n if (isUndefined(val) || isUndefined(key) || key === 'undefined') {\n return\n }\n\n use_val = encodeURIComponent(isFile(val) ? val.name : val.toString())\n use_key = encodeURIComponent(key)\n tph_arr[tph_arr.length] = use_key + '=' + use_val\n })\n\n return tph_arr.join(arg_separator)\n}\n\nexport const getQueryParam = function (url: string, param: string): string {\n const withoutHash: string = url.split('#')[0] || ''\n const queryParams: string = withoutHash.split('?')[1] || ''\n\n const queryParts = queryParams.split('&')\n let keyValuePair\n\n for (let i = 0; i < queryParts.length; i++) {\n const parts = queryParts[i].split('=')\n if (parts[0] === param) {\n keyValuePair = parts\n break\n }\n }\n\n if (!isArray(keyValuePair) || keyValuePair.length < 2) {\n return ''\n } else {\n let result = keyValuePair[1]\n try {\n result = decodeURIComponent(result)\n } catch {\n logger.error('Skipping decoding for malformed query param: ' + result)\n }\n return result.replace(/\\+/g, ' ')\n }\n}\n\nexport const _getHashParam = function (hash: string, param: string): string | null {\n const matches = hash.match(new RegExp(param + '=([^&]*)'))\n return matches ? matches[1] : null\n}\n\nexport const isLocalhost = (): boolean => {\n return localDomains.includes(location.hostname)\n}\n","import { includes } from './index'\nimport { isFunction, isUndefined } from './type-utils'\n\n/**\n * this device detection code is (at time of writing) about 3% of the size of the entire library\n * this is mostly because the identifiers user in regexes and results can't be minified away since\n * they have meaning\n *\n * so, there are some pre-uglifying choices in the code to help reduce the size\n * e.g. many repeated strings are stored as variables and then old-fashioned concatenated together\n *\n * TL;DR here be dragons\n */\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'\n\nconst BROWSER_VERSION_REGEX_SUFFIX = '(\\\\d+(\\\\.\\\\d+)?)'\nconst DEFAULT_BROWSER_VERSION_REGEX = new RegExp('Version/' + BROWSER_VERSION_REGEX_SUFFIX)\n\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')\n\nconst windowsVersionMap: Record<string, string> = {\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}\n\n/**\n * Safari detection turns out to be complicated. For e.g. https://stackoverflow.com/a/29696509\n * We can be slightly loose because some options have been ruled out (e.g. firefox on iOS)\n * before this check is made\n */\nfunction isSafari(userAgent: string): boolean {\n return includes(userAgent, SAFARI) && !includes(userAgent, CHROME) && !includes(userAgent, ANDROID)\n}\n\nconst safariCheck = (ua: string, vendor?: string) => (vendor && includes(vendor, APPLE)) || isSafari(ua)\n\n/**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\nexport const detectBrowser = function (user_agent: string, vendor: string | undefined): string {\n vendor = vendor || '' // vendor is undefined for at least IE9\n\n if (includes(user_agent, ' OPR/') && includes(user_agent, 'Mini')) {\n return OPERA_MINI\n } else if (includes(user_agent, ' OPR/')) {\n return OPERA\n } else if (BLACKBERRY_REGEX.test(user_agent)) {\n return BLACKBERRY\n } else if (includes(user_agent, 'IE' + MOBILE) || includes(user_agent, 'WPDesktop')) {\n return INTERNET_EXPLORER_MOBILE\n }\n // https://developer.samsung.com/internet/user-agent-string-format\n else if (includes(user_agent, SAMSUNG_BROWSER)) {\n return SAMSUNG_INTERNET\n } else if (includes(user_agent, EDGE) || includes(user_agent, 'Edg/')) {\n return MICROSOFT_EDGE\n } else if (includes(user_agent, 'FBIOS')) {\n return FACEBOOK + ' ' + MOBILE\n } else if (includes(user_agent, 'UCWEB') || includes(user_agent, 'UCBrowser')) {\n return 'UC Browser'\n } else if (includes(user_agent, 'CriOS')) {\n return CHROME_IOS // why not just Chrome?\n } else if (includes(user_agent, 'CrMo')) {\n return CHROME\n } else if (includes(user_agent, CHROME)) {\n return CHROME\n } else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) {\n return ANDROID_MOBILE\n } else if (includes(user_agent, 'FxiOS')) {\n return FIREFOX_IOS\n } else if (includes(user_agent.toLowerCase(), KONQUEROR.toLowerCase())) {\n return KONQUEROR\n } else if (safariCheck(user_agent, vendor)) {\n return includes(user_agent, MOBILE) ? MOBILE_SAFARI : SAFARI\n } else if (includes(user_agent, FIREFOX)) {\n return FIREFOX\n } else if (includes(user_agent, 'MSIE') || includes(user_agent, 'Trident/')) {\n return INTERNET_EXPLORER\n } else if (includes(user_agent, 'Gecko')) {\n return FIREFOX\n }\n\n return ''\n}\n\nconst versionRegexes: Record<string, RegExp[]> = {\n [INTERNET_EXPLORER_MOBILE]: [new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)],\n [MICROSOFT_EDGE]: [new RegExp(EDGE + '?\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [CHROME]: [new RegExp('(' + CHROME + '|CrMo)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [CHROME_IOS]: [new RegExp('CriOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n 'UC Browser': [new RegExp('(UCBrowser|UCWEB)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],\n [MOBILE_SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],\n [OPERA]: [new RegExp('(' + OPERA + '|OPR)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [FIREFOX]: [new RegExp(FIREFOX + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [FIREFOX_IOS]: [new RegExp('FxiOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [KONQUEROR]: [new RegExp('Konqueror[:/]?' + BROWSER_VERSION_REGEX_SUFFIX, 'i')],\n // not every blackberry user agent has the version after the name\n [BLACKBERRY]: [new RegExp(BLACKBERRY + ' ' + BROWSER_VERSION_REGEX_SUFFIX), DEFAULT_BROWSER_VERSION_REGEX],\n [ANDROID_MOBILE]: [new RegExp('android\\\\s' + BROWSER_VERSION_REGEX_SUFFIX, 'i')],\n [SAMSUNG_INTERNET]: [new RegExp(SAMSUNG_BROWSER + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [INTERNET_EXPLORER]: [new RegExp('(rv:|MSIE )' + BROWSER_VERSION_REGEX_SUFFIX)],\n Mozilla: [new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)],\n}\n\n/**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\nexport const detectBrowserVersion = function (userAgent: string, vendor: string | undefined): number | null {\n const browser = detectBrowser(userAgent, vendor)\n const regexes: RegExp[] | undefined = versionRegexes[browser as keyof typeof versionRegexes]\n if (isUndefined(regexes)) {\n return null\n }\n\n for (let i = 0; i < regexes.length; i++) {\n const regex = regexes[i]\n const matches = userAgent.match(regex)\n if (matches) {\n return parseFloat(matches[matches.length - 2])\n }\n }\n return null\n}\n\n// to avoid repeating regexes or calling them twice, we have an array of matches\n// the first regex that matches uses its matcher function to return the result\nconst osMatchers: [\n RegExp,\n [string, string] | ((match: RegExpMatchArray | null, user_agent: string) => [string, string])\n][] = [\n [\n new RegExp(XBOX + '; ' + XBOX + ' (.*?)[);]', 'i'),\n (match) => {\n return [XBOX, (match && match[1]) || '']\n },\n ],\n [new RegExp(NINTENDO, 'i'), [NINTENDO, '']],\n [new RegExp(PLAYSTATION, 'i'), [PLAYSTATION, '']],\n [BLACKBERRY_REGEX, [BLACKBERRY, '']],\n [\n new RegExp(WINDOWS, 'i'),\n (_, user_agent) => {\n if (/Phone/.test(user_agent) || /WPDesktop/.test(user_agent)) {\n return [WINDOWS_PHONE, '']\n }\n // not all JS versions support negative lookbehind, so we need two checks here\n if (new RegExp(MOBILE).test(user_agent) && !/IEMobile\\b/.test(user_agent)) {\n return [WINDOWS + ' ' + MOBILE, '']\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)) {\n osVersion = 'RT'\n }\n return [WINDOWS, osVersion]\n }\n return [WINDOWS, '']\n },\n ],\n [\n /((iPhone|iPad|iPod).*?OS (\\d+)_(\\d+)_?(\\d+)?|iPhone)/,\n (match) => {\n if (match && match[3]) {\n const versionParts = [match[3], match[4], match[5] || '0']\n return [IOS, versionParts.join('.')]\n }\n return [IOS, '']\n },\n ],\n [\n /(watch.*\\/(\\d+\\.\\d+\\.\\d+)|watch os,(\\d+\\.\\d+),)/i,\n (match) => {\n // e.g. Watch4,3/5.3.8 (16U680)\n let version = ''\n if (match && match.length >= 3) {\n version = isUndefined(match[2]) ? match[3] : match[2]\n }\n return ['watchOS', version]\n },\n ],\n [\n new RegExp('(' + ANDROID + ' (\\\\d+)\\\\.(\\\\d+)\\\\.?(\\\\d+)?|' + ANDROID + ')', 'i'),\n (match) => {\n if (match && match[2]) {\n const versionParts = [match[2], match[3], match[4] || '0']\n return [ANDROID, versionParts.join('.')]\n }\n return [ANDROID, '']\n },\n ],\n [\n /Mac OS X (\\d+)[_.](\\d+)[_.]?(\\d+)?/i,\n (match) => {\n const result: [string, string] = ['Mac OS X', '']\n if (match && match[1]) {\n const versionParts = [match[1], match[2], match[3] || '0']\n result[1] = versionParts.join('.')\n }\n return result\n },\n ],\n [\n /Mac/i,\n // mop up a few non-standard UAs that should match mac\n ['Mac OS X', ''],\n ],\n [/CrOS/, [CHROME_OS, '']],\n [/Linux|debian/i, ['Linux', '']],\n]\n\nexport const detectOS = function (user_agent: string): [string, string] {\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) {\n return result\n }\n }\n return ['', '']\n}\n\nexport const detectDevice = function (user_agent: string): string {\n if (NINTENDO_REGEX.test(user_agent)) {\n return NINTENDO\n } else if (PLAYSTATION_REGEX.test(user_agent)) {\n return PLAYSTATION\n } else if (XBOX_REGEX.test(user_agent)) {\n return XBOX\n } else if (new RegExp(OUYA, 'i').test(user_agent)) {\n return OUYA\n } else if (new RegExp('(' + WINDOWS_PHONE + '|WPDesktop)', 'i').test(user_agent)) {\n return WINDOWS_PHONE\n } else if (/iPad/.test(user_agent)) {\n return IPAD\n } else if (/iPod/.test(user_agent)) {\n return 'iPod Touch'\n } else if (/iPhone/.test(user_agent)) {\n return 'iPhone'\n } else if (/(watch)(?: ?os[,/]|\\d,\\d\\/)[\\d.]+/i.test(user_agent)) {\n return APPLE_WATCH\n } else if (BLACKBERRY_REGEX.test(user_agent)) {\n return BLACKBERRY\n } else if (/(kobo)\\s(ereader|touch)/i.test(user_agent)) {\n return 'Kobo'\n } else if (new RegExp(NOKIA, 'i').test(user_agent)) {\n return NOKIA\n } else if (\n // Kindle Fire without Silk / Echo Show\n /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i.test(user_agent) ||\n // Kindle Fire HD\n /(kf[a-z]+)( bui|\\)).+silk\\//i.test(user_agent)\n ) {\n return 'Kindle Fire'\n } else if (/(Android|ZTE)/i.test(user_agent)) {\n if (\n !new RegExp(MOBILE).test(user_agent) ||\n /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(user_agent)\n ) {\n if (\n (/pixel[\\daxl ]{1,6}/i.test(user_agent) && !/pixel c/i.test(user_agent)) ||\n /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(user_agent) ||\n (/lmy47v/i.test(user_agent) && !/QTAQZ3/i.test(user_agent))\n ) {\n return ANDROID\n }\n return ANDROID_TABLET\n } else {\n return ANDROID\n }\n } else if (new RegExp('(pda|' + MOBILE + ')', 'i').test(user_agent)) {\n return GENERIC_MOBILE\n } else if (new RegExp(TABLET, 'i').test(user_agent) && !new RegExp(TABLET + ' pc', 'i').test(user_agent)) {\n return GENERIC_TABLET\n } else {\n return ''\n }\n}\n\nexport const detectDeviceType = function (user_agent: string): string {\n const device = detectDevice(user_agent)\n if (\n device === IPAD ||\n device === ANDROID_TABLET ||\n device === 'Kobo' ||\n device === 'Kindle Fire' ||\n device === GENERIC_TABLET\n ) {\n return TABLET\n } else if (device === NINTENDO || device === XBOX || device === PLAYSTATION || device === OUYA) {\n return 'Console'\n } else if (device === APPLE_WATCH) {\n return 'Wearable'\n } else if (device) {\n return MOBILE\n } else {\n return 'Desktop'\n }\n}\n","import { getQueryParam, convertToURL } from './request-utils'\nimport { isNull } from './type-utils'\nimport { Properties } from '../types'\nimport Config from '../config'\nimport { each, extend, stripEmptyProperties, stripLeadingDollar } from './index'\nimport { document, location, userAgent, window } from './globals'\nimport { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS } from './user-agent-utils'\n\nconst URL_REGEX_PREFIX = 'https?://(.*)'\n\n// Should be kept in sync with https://github.com/PostHog/posthog/blob/master/plugin-server/src/utils/db/utils.ts#L60\nexport const CAMPAIGN_PARAMS = [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n 'gclid', // google ads\n 'gad_source', // google ads\n 'gclsrc', // google ads 360\n 'dclid', // google display ads\n 'gbraid', // google ads, web to app\n 'wbraid', // google ads, app to web\n 'fbclid', // facebook\n 'msclkid', // microsoft\n 'twclid', // twitter\n 'li_fat_id', // linkedin\n 'mc_cid', // mailchimp campaign id\n 'igshid', // instagram\n 'ttclid', // tiktok\n 'rdt_cid', // reddit\n]\n\nexport const EVENT_TO_PERSON_PROPERTIES = [\n // mobile params\n '$app_build',\n '$app_name',\n '$app_namespace',\n '$app_version',\n // web params\n '$browser',\n '$browser_version',\n '$device_type',\n '$current_url',\n '$pathname',\n '$os',\n '$os_name', // $os_name is a special case, it's treated as an alias of $os!\n '$os_version',\n '$referring_domain',\n '$referrer',\n]\n\nexport const Info = {\n campaignParams: function (customParams?: string[]): Record<string, string> {\n if (!document) {\n return {}\n }\n return this._campaignParamsFromUrl(document.URL, customParams)\n },\n\n _campaignParamsFromUrl: function (url: string, customParams?: string[]): Record<string, string> {\n const campaign_keywords = CAMPAIGN_PARAMS.concat(customParams || [])\n\n const params: Record<string, any> = {}\n each(campaign_keywords, function (kwkey) {\n const kw = getQueryParam(url, kwkey)\n params[kwkey] = kw ? kw : null\n })\n\n return params\n },\n\n _searchEngine: function (referrer: string): string | null {\n if (!referrer) {\n return null\n } else {\n if (referrer.search(URL_REGEX_PREFIX + 'google.([^/?]*)') === 0) {\n return 'google'\n } else if (referrer.search(URL_REGEX_PREFIX + 'bing.com') === 0) {\n return 'bing'\n } else if (referrer.search(URL_REGEX_PREFIX + 'yahoo.com') === 0) {\n return 'yahoo'\n } else if (referrer.search(URL_REGEX_PREFIX + 'duckduckgo.com') === 0) {\n return 'duckduckgo'\n } else {\n return null\n }\n }\n },\n\n _searchInfoFromReferrer: function (referrer: string): Record<string, any> {\n const search = Info._searchEngine(referrer)\n const param = search != 'yahoo' ? 'q' : 'p'\n const ret: Record<string, any> = {}\n\n if (!isNull(search)) {\n ret['$search_engine'] = search\n\n const keyword = document ? getQueryParam(document.referrer, param) : ''\n if (keyword.length) {\n ret['ph_keyword'] = keyword\n }\n }\n\n return ret\n },\n\n searchInfo: function (): Record<string, any> {\n const referrer = document?.referrer\n if (!referrer) {\n return {}\n }\n return this._searchInfoFromReferrer(referrer)\n },\n\n /**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\n browser: detectBrowser,\n\n /**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\n browserVersion: detectBrowserVersion,\n\n browserLanguage: function (): string | undefined {\n return (\n navigator.language || // Any modern browser\n (navigator as Record<string, any>).userLanguage // IE11\n )\n },\n\n browserLanguagePrefix: function (): string | undefined {\n const browserLanguage = this.browserLanguage()\n return typeof browserLanguage === 'string' ? browserLanguage.split('-')[0] : undefined\n },\n\n os: detectOS,\n\n device: detectDevice,\n\n deviceType: detectDeviceType,\n\n referrer: function (): string {\n return document?.referrer || '$direct'\n },\n\n referringDomain: function (): string {\n if (!document?.referrer) {\n return '$direct'\n }\n return convertToURL(document.referrer)?.host || '$direct'\n },\n\n referrerInfo: function (): Record<string, any> {\n return {\n $referrer: this.referrer(),\n $referring_domain: this.referringDomain(),\n }\n },\n\n initialPersonInfo: function (): Record<string, any> {\n // we're being a bit more economical with bytes here because this is stored in the cookie\n return {\n r: this.referrer().substring(0, 1000),\n u: location?.href.substring(0, 1000),\n }\n },\n\n initialPersonPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const { r: initial_referrer, u: initial_current_url } = info\n const referring_domain =\n initial_referrer == null\n ? undefined\n : initial_referrer == '$direct'\n ? '$direct'\n : convertToURL(initial_referrer)?.host\n\n const props: Record<string, string | undefined> = {\n $initial_referrer: initial_referrer,\n $initial_referring_domain: referring_domain,\n }\n if (initial_current_url) {\n props['$initial_current_url'] = initial_current_url\n const location = convertToURL(initial_current_url)\n props['$initial_host'] = location?.host\n props['$initial_pathname'] = location?.pathname\n const campaignParams = this._campaignParamsFromUrl(initial_current_url)\n each(campaignParams, function (v, k: string) {\n props['$initial_' + stripLeadingDollar(k)] = v\n })\n }\n if (initial_referrer) {\n const searchInfo = this._searchInfoFromReferrer(initial_referrer)\n each(searchInfo, function (v, k: string) {\n props['$initial_' + stripLeadingDollar(k)] = v\n })\n }\n return props\n },\n\n timezone: function (): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone\n } catch {\n return undefined\n }\n },\n\n timezoneOffset: function (): number | undefined {\n try {\n return new Date().getTimezoneOffset()\n } catch {\n return undefined\n }\n },\n\n properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n $device: Info.device(userAgent),\n $device_type: Info.deviceType(userAgent),\n $timezone: Info.timezone(),\n $timezone_offset: Info.timezoneOffset(),\n }),\n {\n $current_url: location?.href,\n $host: location?.host,\n $pathname: location?.pathname,\n $raw_user_agent: userAgent.length > 1000 ? userAgent.substring(0, 997) + '...' : userAgent,\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n $browser_language: Info.browserLanguage(),\n $browser_language_prefix: Info.browserLanguagePrefix(),\n $screen_height: window?.screen.height,\n $screen_width: window?.screen.width,\n $viewport_height: window?.innerHeight,\n $viewport_width: window?.innerWidth,\n $lib: 'web',\n $lib_version: Config.LIB_VERSION,\n $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),\n $time: Date.now() / 1000, // epoch time in seconds\n }\n )\n },\n\n people_properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n }),\n {\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n }\n )\n },\n}\n","import { isNumber } from './type-utils'\nimport { logger } from './logger'\n\n/**\n * Clamps a value to a range.\n * @param value the value to clamp\n * @param min the minimum value\n * @param max the maximum value\n * @param label if provided then enables logging and prefixes all logs with labels\n * @param fallbackValue if provided then returns this value if the value is not a valid number\n */\nexport function clampToRange(value: unknown, min: number, max: number, label?: string, fallbackValue?: number): number {\n if (min > max) {\n logger.warn('min cannot be greater than max.')\n min = max\n }\n\n if (!isNumber(value)) {\n label &&\n logger.warn(\n label + ' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue\n )\n return clampToRange(fallbackValue || max, min, max, label)\n } else if (value > max) {\n label && logger.warn(label + ' cannot be greater than max: ' + max + '. Using max value instead.')\n return max\n } else if (value < min) {\n label && logger.warn(label + ' cannot be less than min: ' + min + '. Using min value instead.')\n return min\n } else {\n return value\n }\n}\n","import { clampToRange } from '../utils/number-utils'\nimport { BeforeSendFn, CaptureResult, KnownEventName } from '../types'\nimport { includes } from '../utils'\nimport { isArray, isUndefined } from '../utils/type-utils'\n\nfunction appendArray(currentValue: string[] | undefined, sampleType: string | string[]): string[] {\n return [...(currentValue ? currentValue : []), ...(isArray(sampleType) ? sampleType : [sampleType])]\n}\n\nfunction updateThreshold(currentValue: number | undefined, percent: number): number {\n return (isUndefined(currentValue) ? 1 : currentValue) * percent\n}\n\nfunction simpleHash(str: string) {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i) // (hash * 31) + char code\n hash |= 0 // Convert to 32bit integer\n }\n return Math.abs(hash)\n}\n\n/*\n * receives percent as a number between 0 and 1\n */\nfunction sampleOnProperty(prop: string, percent: number): boolean {\n return simpleHash(prop) % 100 < clampToRange(percent * 100, 0, 100)\n}\n\n/**\n * Provides an implementation of sampling that samples based on the distinct ID.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * Setting 0.5 will cause roughly 50% of distinct ids to have events sent.\n * Not 50% of events for each distinct id.\n *\n * @param percent a number from 0 to 1, 1 means always send and, 0 means never send the event\n */\nexport function sampleByDistinctId(percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n return sampleOnProperty(captureResult.properties.distinct_id, percent)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: ['sampleByDistinctId'],\n $sample_threshold: percent,\n },\n }\n : null\n }\n}\n\n/**\n * Provides an implementation of sampling that samples based on the session ID.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * Setting 0.5 will cause roughly 50% of sessions to have events sent.\n * Not 50% of events for each session.\n *\n * @param percent a number from 0 to 1, 1 means always send and, 0 means never send the event\n */\nexport function sampleBySessionId(percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n return sampleOnProperty(captureResult.properties.$session_id, percent)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: appendArray(captureResult.properties.$sample_type, 'sampleBySessionId'),\n $sample_threshold: updateThreshold(captureResult.properties.$sample_threshold, percent),\n },\n }\n : null\n }\n}\n\n/**\n * Provides an implementation of sampling that samples based on the event name.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * @param eventNames an array of event names to sample, sampling is applied across events not per event name\n * @param percent a number from 0 to 1, 1 means always send, 0 means never send the event\n */\nexport function sampleByEvent(eventNames: KnownEventName[], percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n if (!includes(eventNames, captureResult.event)) {\n return captureResult\n }\n\n const number = Math.random()\n return number * 100 < clampToRange(percent * 100, 0, 100)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: appendArray(captureResult.properties?.$sample_type, 'sampleByEvent'),\n $sample_threshold: updateThreshold(captureResult.properties?.$sample_threshold, percent),\n $sampled_events: appendArray(captureResult.properties?.$sampled_events, eventNames),\n },\n }\n : null\n }\n}\n\nexport const printAndDropEverything: BeforeSendFn = (result) => {\n // eslint-disable-next-line no-console\n console.log('Would have sent event:', result)\n return null\n}\n","import { PostHog } from '../posthog-core'\nimport { CAMPAIGN_PARAMS, EVENT_TO_PERSON_PROPERTIES, Info } from '../utils/event-utils'\nimport { each, extend, includes } from '../utils'\n\nexport const setAllPersonProfilePropertiesAsPersonPropertiesForFlags = (posthog: PostHog): void => {\n const allProperties = extend({}, Info.properties(), Info.campaignParams(), Info.referrerInfo())\n const personProperties: Record<string, string> = {}\n each(allProperties, function (v, k: string) {\n if (includes(CAMPAIGN_PARAMS, k) || includes(EVENT_TO_PERSON_PROPERTIES, k)) {\n personProperties[k] = v\n }\n })\n\n posthog.setPersonPropertiesForFlags(personProperties)\n}\n","// this file is called customizations.full.ts because it includes all customizations\n// this naming scheme allows us to create a lighter version in the future with only the most popular customizations\n// without breaking backwards compatibility\n\nimport * as customizations from '../customizations'\nimport { assignableWindow } from '../utils/globals'\nassignableWindow.posthogCustomizations = customizations\n"],"names":["win","window","undefined","global","globalThis","nativeForEach","Array","prototype","forEach","navigator","document","location","fetch","XMLHttpRequest","AbortController","Compression","userAgent","assignableWindow","nativeIsArray","isArray","ObjProto","Object","hasOwnProperty","toString","obj","call","isUndefined","x","isNull","isNumber","Config","DEBUG","LIB_VERSION","_createLogger","prefix","logger","_log","level","console","consoleLog","_len","arguments","length","args","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","concat","createLogger","additionalPrefix","breaker","eachArray","iterator","thisArg","i","l","each","FormData","isFormData","pair","entries","key","extend","source","prop","includes","str","needle","indexOf","stripEmptyProperties","p","ret","v","k","stripLeadingDollar","s","replace","convertToURL","url","createElement","href","getQueryParam","param","keyValuePair","queryParts","split","parts","result","decodeURIComponent","_unused","MOBILE","IOS","ANDROID","TABLET","ANDROID_TABLET","IPAD","APPLE","APPLE_WATCH","SAFARI","BLACKBERRY","SAMSUNG","SAMSUNG_BROWSER","SAMSUNG_INTERNET","CHROME","CHROME_OS","CHROME_IOS","INTERNET_EXPLORER","INTERNET_EXPLORER_MOBILE","OPERA","OPERA_MINI","EDGE","MICROSOFT_EDGE","FIREFOX","FIREFOX_IOS","NINTENDO","PLAYSTATION","XBOX","ANDROID_MOBILE","MOBILE_SAFARI","WINDOWS","WINDOWS_PHONE","NOKIA","OUYA","GENERIC","GENERIC_MOBILE","toLowerCase","GENERIC_TABLET","KONQUEROR","BROWSER_VERSION_REGEX_SUFFIX","DEFAULT_BROWSER_VERSION_REGEX","RegExp","XBOX_REGEX","PLAYSTATION_REGEX","NINTENDO_REGEX","BLACKBERRY_REGEX","windowsVersionMap","safariCheck","ua","vendor","isSafari","detectBrowser","user_agent","test","FACEBOOK","versionRegexes","Mozilla","osMatchers","match","_","exec","version","osVersion","versionParts","join","detectDevice","URL_REGEX_PREFIX","CAMPAIGN_PARAMS","EVENT_TO_PERSON_PROPERTIES","Info","campaignParams","customParams","this","_campaignParamsFromUrl","URL","campaign_keywords","params","kwkey","kw","_searchEngine","referrer","search","_searchInfoFromReferrer","keyword","searchInfo","browser","browserVersion","regexes","regex","matches","parseFloat","browserLanguage","language","userLanguage","browserLanguagePrefix","os","rgex","resultOrFn","device","deviceType","referringDomain","_convertToURL","host","referrerInfo","$referrer","$referring_domain","initialPersonInfo","r","substring","u","initialPersonPropsFromInfo","_convertToURL2","initial_referrer","initial_current_url","props","$initial_referrer","$initial_referring_domain","pathname","timezone","Intl","DateTimeFormat","resolvedOptions","timeZone","timezoneOffset","Date","getTimezoneOffset","_unused2","properties","os_name","os_version","$os","$os_version","$browser","$device","$device_type","$timezone","$timezone_offset","$current_url","$host","$pathname","$raw_user_agent","$browser_version","$browser_language","$browser_language_prefix","$screen_height","screen","height","$screen_width","width","$viewport_height","innerHeight","$viewport_width","innerWidth","$lib","$lib_version","$insert_id","Math","random","$time","now","people_properties","clampToRange","value","min","max","label","fallbackValue","appendArray","currentValue","sampleType","updateThreshold","percent","sampleOnProperty","hash","charCodeAt","abs","simpleHash","log","captureResult","distinct_id","_objectSpread","$sample_type","$sample_threshold","eventNames","_captureResult$proper","_captureResult$proper2","_captureResult$proper3","event","$sampled_events","$session_id","posthog","allProperties","personProperties","setPersonPropertiesForFlags","posthogCustomizations","customizations"],"mappings":"yBAuBA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAmEzFC,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AAAA,EAAAA,EAAcnD,YAAU,GAAA,CAC3BsD,aAAcd,GAAYW,EAAcnD,WAAWsD,aAAc,qBACjEC,kBAAmBZ,GAAgBQ,EAAcnD,WAAWuD,kBAAmBX,OATlF,IAcnB,0DCjFwEmB,IACpE,IAAMC,EAAgB1N,EAAO,CAAE,EAAEgG,GAAK0D,aAAc1D,GAAKC,iBAAkBD,GAAKkC,gBAC1EyF,EAA2C,CAAA,EACjDjO,EAAKgO,GAAe,SAAUhN,EAAGC,IACzBR,EAAS2F,GAAiBnF,IAAMR,EAAS4F,GAA4BpF,MACrEgN,EAAiBhN,GAAKD,EAE9B,IAEA+M,EAAQG,4BAA4BD,EAAiB,ICPzDpR,EAAiBsR,sBAAwBC"}
|
|
1
|
+
{"version":3,"file":"customizations.full.js","sources":["../src/utils/globals.ts","../src/types.ts","../src/utils/type-utils.ts","../src/config.ts","../src/utils/logger.ts","../src/utils/index.ts","../src/utils/request-utils.ts","../src/utils/user-agent-utils.ts","../src/utils/event-utils.ts","../src/utils/number-utils.ts","../src/customizations/before-send.ts","../src/customizations/setAllPersonProfilePropertiesAsPersonPropertiesForFlags.ts","../src/entrypoints/customizations.full.ts"],"sourcesContent":["import { ErrorProperties } from '../extensions/exception-autocapture/error-conversion'\nimport type { PostHog } from '../posthog-core'\nimport { SessionIdManager } from '../sessionid'\nimport {\n DeadClicksAutoCaptureConfig,\n ErrorEventArgs,\n ErrorMetadata,\n Properties,\n RemoteConfig,\n SiteAppLoader,\n} from '../types'\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 Record<string, any> & {\n __PosthogExtensions__?: PostHogExtensions\n _POSTHOG_CONFIG?: RemoteConfig\n _POSTHOG_JS_APPS?: SiteAppLoader[]\n }\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 PostHogExtensionKind =\n | 'toolbar'\n | 'exception-autocapture'\n | 'web-vitals'\n | 'recorder'\n | 'tracing-headers'\n | 'surveys'\n | 'dead-clicks-autocapture'\n | 'remote-config'\n\nexport interface LazyLoadedDeadClicksAutocaptureInterface {\n start: (observerTarget: Node) => void\n stop: () => void\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 parseErrorAsProperties?: (\n [event, source, lineno, colno, error]: ErrorEventArgs,\n metadata?: ErrorMetadata\n ) => ErrorProperties\n errorWrappingFunctions?: {\n wrapOnError: (captureFn: (props: Properties) => void) => () => void\n wrapUnhandledRejection: (captureFn: (props: Properties) => void) => () => void\n }\n rrweb?: { record: any; version: string }\n rrwebPlugins?: { getRecordConsolePlugin: any; getRecordNetworkPlugin?: any }\n canActivateRepeatedly?: (survey: any) => boolean\n generateSurveys?: (posthog: PostHog) => any | undefined\n postHogWebVitalsCallbacks?: {\n onLCP: (metric: any) => void\n onCLS: (metric: any) => void\n onFCP: (metric: any) => void\n onINP: (metric: any) => void\n }\n tracingHeadersPatchFns?: {\n _patchFetch: (sessionManager?: SessionIdManager) => () => void\n _patchXHR: (sessionManager?: SessionIdManager) => () => void\n }\n initDeadClicksAutocapture?: (\n ph: PostHog,\n config: DeadClicksAutoCaptureConfig\n ) => LazyLoadedDeadClicksAutocaptureInterface\n}\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: AssignableWindow = win ?? ({} as any)\n\nexport { win as window }\n","import { PostHog } from './posthog-core'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { recordOptions } from './extensions/replay/sessionrecording-utils'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\nexport const 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] as const\n\n/**\n * These events can be processed by the `beforeCapture` function\n * but can cause unexpected confusion in data.\n *\n * Some features of PostHog rely on receiving 100% of these events\n */\nexport type KnownUnsafeEditableEvent = typeof knownUnsafeEditableEvent[number]\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\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 type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\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 /** 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 * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n /**\n * we delay flushing web vitals metrics to reduce the number of events we send\n * this is the maximum time we will wait before sending the metrics\n * if not set it defaults to 5 seconds\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n // by default if a click is followed by a sroll within 100ms it is not a dead click\n scroll_threshold_ms?: number\n // by default if a click is followed by a selection change within 100ms it is not a dead click\n selection_change_threshold_ms?: number\n // by default if a click is followed by a mutation within 2500ms it is not a dead click\n mutation_threshold_ms?: number\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by the SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\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 type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\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 disable_web_experiments: 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 /**\n * this is a read-only function that can be used to react to event capture\n * @deprecated - use `before_send` instead - NB before_send is not read only\n */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\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 capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\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 /** Used when sending data via `fetch`, use with care, this is intentionally meant to be used with NextJS `fetch`\n * Incorrect usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\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 /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * enables the new RemoteConfig approach to loading config instead of decide\n * */\n __preview_remote_config?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * whether to send a sentinel value for distinct id, device id, and session id, which will be replaced server-side by a cookieless hash\n * */\n __preview_experimental_cookieless_mode?: 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?: recordOptions['maskInputOptions']\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: recordOptions['slimDOMOptions']\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /**\n * Allows local config to override remote canvas recording settings from the decide response\n */\n captureCanvas?: SessionRecordingCanvasOptions\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 ADVANCED: whether to partially compress rrweb events before sending them to the server,\n defaults to true, can be set to false to disable partial compression\n NB requests are still compressed when sent to the server regardless of this setting\n */\n compress_events?: boolean\n /*\n ADVANCED: alters the threshold before a recording considers a user has become idle.\n Normally only altered alongside changes to session_idle_timeout_ms.\n Default is 5 minutes.\n */\n session_idle_threshold_ms?: number\n /*\n ADVANCED: alters the refill rate for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 10.\n */\n __mutationRateLimiterRefillRate?: number\n /*\n ADVANCED: alters the bucket size for the token bucket mutation throttling\n Normally only altered alongside posthog support guidance.\n Accepts values between 0 and 100\n Default is 100.\n */\n __mutationRateLimiterBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => 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\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\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 fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\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 type SessionRecordingCanvasOptions = {\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}\n\nexport interface RemoteConfig {\n supportedCompression: Compression[]\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?: SessionRecordingCanvasOptions & {\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 linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\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: string; url: string }[]\n heatmaps?: boolean\n defaultIdentifiedOnly?: boolean\n captureDeadClicks?: boolean\n hasFeatureFlags?: boolean // Indicates if the team has any flags enabled (if not we don't need to load them)\n}\n\nexport interface DecideResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processEvent?: (globals: SiteAppGlobals) => void\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 JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | JsonRecord | 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\nexport type ErrorMetadata = {\n handled?: boolean\n synthetic?: boolean\n syntheticException?: Error\n overrideExceptionType?: string\n overrideExceptionMessage?: string\n defaultExceptionType?: string\n defaultExceptionMessage?: string\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\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n","import { includes } from '.'\nimport { window } from './globals'\nimport { knownUnsafeEditableEvent, KnownUnsafeEditableEvent } from '../types'\n\n// 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 }\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 = (x: unknown): x is (...args: any[]) => any => {\n // eslint-disable-next-line posthog-js/no-direct-function-check\n return typeof x === 'function'\n}\n\nexport const isNativeFunction = (x: unknown): x is (...args: any[]) => any =>\n isFunction(x) && x.toString().indexOf('[native code]') !== -1\n\n// When angular patches functions they pass the above `isNativeFunction` check (at least the MutationObserver)\nexport const isAngularZonePresent = (): boolean => {\n return !!(window as any).Zone\n}\n\n// Underscore Addons\nexport const isObject = (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 = (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 = (x: unknown): x is undefined => x === void 0\n\nexport const isString = (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 = (x: unknown): boolean => isString(x) && x.trim().length === 0\n\nexport const isNull = (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 = (x: unknown): x is null | undefined => isUndefined(x) || isNull(x)\n\nexport const isNumber = (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 = (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\nexport const isKnownUnsafeEditableEvent = (x: unknown): x is KnownUnsafeEditableEvent => {\n return includes(knownUnsafeEditableEvent as unknown as string[], x)\n}\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}\n\nexport default Config\n","import Config from '../config'\nimport { isUndefined } from './type-utils'\nimport { assignableWindow, window } from './globals'\n\nexport type Logger = {\n _log: (level: 'log' | 'warn' | 'error', ...args: any[]) => void\n info: (...args: any[]) => void\n warn: (...args: any[]) => void\n error: (...args: any[]) => void\n critical: (...args: any[]) => void\n uninitializedWarning: (methodName: string) => void\n createLogger: (prefix: string) => Logger\n}\n\nconst _createLogger = (prefix: string): Logger => {\n const logger: 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(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(prefix, ...args)\n },\n\n uninitializedWarning: (methodName: string) => {\n logger.error(`You must initialize PostHog before calling ${methodName}`)\n },\n\n createLogger: (additionalPrefix: string) => _createLogger(`${prefix} ${additionalPrefix}`),\n }\n return logger\n}\n\nexport const logger = _createLogger('[PostHog.js]')\n\nexport const createLogger = logger.createLogger\n","import { Breaker, EventHandler, Properties } from '../types'\nimport { hasOwnProperty, isArray, isFormData, isFunction, isNull, isNullish, isString } from './type-utils'\nimport { logger } from './logger'\nimport { nativeForEach, nativeIndexOf, window } from './globals'\n\nconst breaker: Breaker = {}\n\n// UNDERSCORE\n// Embed part of the Underscore Library\nexport const trim = function (str: string): string {\n return str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, '')\n}\n\nexport function eachArray<E = any>(\n obj: E[] | null | undefined,\n iterator: (value: E, key: number) => void | Breaker,\n thisArg?: any\n): void {\n if (isArray(obj)) {\n if (nativeForEach && obj.forEach === nativeForEach) {\n obj.forEach(iterator, thisArg)\n } else if ('length' in obj && obj.length === +obj.length) {\n for (let i = 0, l = obj.length; i < l; i++) {\n if (i in obj && iterator.call(thisArg, obj[i], i) === breaker) {\n return\n }\n }\n }\n }\n}\n\n/**\n * @param {*=} obj\n * @param {function(...*)=} iterator\n * @param {Object=} thisArg\n */\nexport function each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void {\n if (isNullish(obj)) {\n return\n }\n if (isArray(obj)) {\n return eachArray(obj, iterator, thisArg)\n }\n if (isFormData(obj)) {\n for (const pair of obj.entries()) {\n if (iterator.call(thisArg, pair[1], pair[0]) === breaker) {\n return\n }\n }\n return\n }\n for (const key in obj) {\n if (hasOwnProperty.call(obj, key)) {\n if (iterator.call(thisArg, obj[key], key) === breaker) {\n return\n }\n }\n }\n}\n\nexport const extend = function (obj: Record<string, any>, ...args: Record<string, any>[]): Record<string, any> {\n eachArray(args, function (source) {\n for (const prop in source) {\n if (source[prop] !== void 0) {\n obj[prop] = source[prop]\n }\n }\n })\n return obj\n}\n\nexport const include = function (\n obj: null | string | Array<any> | Record<string, any>,\n target: any\n): boolean | Breaker {\n let found = false\n if (isNull(obj)) {\n return found\n }\n if (nativeIndexOf && obj.indexOf === nativeIndexOf) {\n return obj.indexOf(target) != -1\n }\n each(obj, function (value) {\n if (found || (found = value === target)) {\n return breaker\n }\n return\n })\n return found\n}\n\nexport function includes<T = any>(str: T[] | string, needle: T): boolean {\n return (str as any).indexOf(needle) !== -1\n}\n\n/**\n * Object.entries() polyfill\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries\n */\nexport function entries<T = any>(obj: Record<string, T>): [string, T][] {\n const ownProps = Object.keys(obj)\n let i = ownProps.length\n const resArray = new Array(i) // preallocate the Array\n\n while (i--) {\n resArray[i] = [ownProps[i], obj[ownProps[i]]]\n }\n return resArray\n}\n\nexport const isValidRegex = function (str: string): boolean {\n try {\n new RegExp(str)\n } catch {\n return false\n }\n return true\n}\n\nexport const trySafe = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch {\n return undefined\n }\n}\n\nexport const safewrap = function <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F): F {\n return function (...args) {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return f.apply(this, args)\n } catch (e) {\n logger.critical(\n 'Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.'\n )\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const safewrapClass = function (klass: Function, functions: string[]): void {\n for (let i = 0; i < functions.length; i++) {\n klass.prototype[functions[i]] = safewrap(klass.prototype[functions[i]])\n }\n}\n\nexport const stripEmptyProperties = function (p: Properties): Properties {\n const ret: Properties = {}\n each(p, function (v, k) {\n if (isString(v) && v.length > 0) {\n ret[k] = v\n }\n })\n return ret\n}\n\nexport const stripLeadingDollar = function (s: string): string {\n return s.replace(/^\\$/, '')\n}\n\n/**\n * Deep copies an object.\n * It handles cycles by replacing all references to them with `undefined`\n * Also supports customizing native values\n *\n * @param value\n * @param customizer\n * @returns {{}|undefined|*}\n */\nfunction deepCircularCopy<T extends Record<string, any> = Record<string, any>>(\n value: T,\n customizer?: <K extends keyof T = keyof T>(value: T[K], key?: K) => T[K]\n): T | undefined {\n const COPY_IN_PROGRESS_SET = new Set()\n\n function internalDeepCircularCopy(value: T, key?: string): T | undefined {\n if (value !== Object(value)) return customizer ? customizer(value as any, key) : value // primitive value\n\n if (COPY_IN_PROGRESS_SET.has(value)) return undefined\n COPY_IN_PROGRESS_SET.add(value)\n let result: T\n\n if (isArray(value)) {\n result = [] as any as T\n eachArray(value, (it) => {\n result.push(internalDeepCircularCopy(it))\n })\n } else {\n result = {} as T\n each(value, (val, key) => {\n if (!COPY_IN_PROGRESS_SET.has(val)) {\n ;(result as any)[key] = internalDeepCircularCopy(val, key)\n }\n })\n }\n return result\n }\n return internalDeepCircularCopy(value)\n}\n\nexport function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(\n object: T,\n maxStringLength: number | null\n): T {\n return deepCircularCopy(object, (value: any) => {\n if (isString(value) && !isNull(maxStringLength)) {\n return (value as string).slice(0, maxStringLength)\n }\n return value\n }) as T\n}\n\nexport function _base64Encode(data: null): null\nexport function _base64Encode(data: undefined): undefined\nexport function _base64Encode(data: string): string\nexport function _base64Encode(data: string | null | undefined): string | null | undefined {\n const b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='\n let o1,\n o2,\n o3,\n h1,\n h2,\n h3,\n h4,\n bits,\n i = 0,\n ac = 0,\n enc = ''\n const tmp_arr: string[] = []\n\n if (!data) {\n return data\n }\n\n data = utf8Encode(data)\n\n do {\n // pack three octets into four hexets\n o1 = data.charCodeAt(i++)\n o2 = data.charCodeAt(i++)\n o3 = data.charCodeAt(i++)\n\n bits = (o1 << 16) | (o2 << 8) | o3\n\n h1 = (bits >> 18) & 0x3f\n h2 = (bits >> 12) & 0x3f\n h3 = (bits >> 6) & 0x3f\n h4 = bits & 0x3f\n\n // use hexets to index into b64, and append result to encoded string\n tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4)\n } while (i < data.length)\n\n enc = tmp_arr.join('')\n\n switch (data.length % 3) {\n case 1:\n enc = enc.slice(0, -2) + '=='\n break\n case 2:\n enc = enc.slice(0, -1) + '='\n break\n }\n\n return enc\n}\n\nexport const utf8Encode = function (string: string): string {\n string = (string + '').replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n\n let utftext = '',\n start,\n end\n let stringl = 0,\n n\n\n start = end = 0\n stringl = string.length\n\n for (n = 0; n < stringl; n++) {\n const c1 = string.charCodeAt(n)\n let enc = null\n\n if (c1 < 128) {\n end++\n } else if (c1 > 127 && c1 < 2048) {\n enc = String.fromCharCode((c1 >> 6) | 192, (c1 & 63) | 128)\n } else {\n enc = String.fromCharCode((c1 >> 12) | 224, ((c1 >> 6) & 63) | 128, (c1 & 63) | 128)\n }\n if (!isNull(enc)) {\n if (end > start) {\n utftext += string.substring(start, end)\n }\n utftext += enc\n start = end = n + 1\n }\n }\n\n if (end > start) {\n utftext += string.substring(start, string.length)\n }\n\n return utftext\n}\n\nexport const registerEvent = (function () {\n // written by Dean Edwards, 2005\n // with input from Tino Zijdel - crisp@xs4all.nl\n // with input from Carl Sverre - mail@carlsverre.com\n // with input from PostHog\n // http://dean.edwards.name/weblog/2005/10/add-event/\n // https://gist.github.com/1930440\n\n /**\n * @param {Object} element\n * @param {string} type\n * @param {function(...*)} handler\n * @param {boolean=} oldSchool\n * @param {boolean=} useCapture\n */\n const register_event = function (\n element: Element | Window | Document | Node,\n type: string,\n handler: EventHandler,\n oldSchool?: boolean,\n useCapture?: boolean\n ) {\n if (!element) {\n logger.error('No valid element provided to register_event')\n return\n }\n\n if (element.addEventListener && !oldSchool) {\n element.addEventListener(type, handler, !!useCapture)\n } else {\n const ontype = 'on' + type\n const old_handler = (element as any)[ontype] // can be undefined\n ;(element as any)[ontype] = makeHandler(element, handler, old_handler)\n }\n }\n\n function makeHandler(\n element: Element | Window | Document | Node,\n new_handler: EventHandler,\n old_handlers: EventHandler\n ) {\n return function (event: Event): boolean | void {\n event = event || fixEvent(window?.event)\n\n // this basically happens in firefox whenever another script\n // overwrites the onload callback and doesn't pass the event\n // object to previously defined callbacks. All the browsers\n // that don't define window.event implement addEventListener\n // so the dom_loaded handler will still be fired as usual.\n if (!event) {\n return undefined\n }\n\n let ret = true\n let old_result: any\n\n if (isFunction(old_handlers)) {\n old_result = old_handlers(event)\n }\n const new_result = new_handler.call(element, event)\n\n if (false === old_result || false === new_result) {\n ret = false\n }\n\n return ret\n }\n }\n\n function fixEvent(event: Event | undefined): Event | undefined {\n if (event) {\n event.preventDefault = fixEvent.preventDefault\n event.stopPropagation = fixEvent.stopPropagation\n }\n return event\n }\n fixEvent.preventDefault = function () {\n ;(this as any as Event).returnValue = false\n }\n fixEvent.stopPropagation = function () {\n ;(this as any as Event).cancelBubble = true\n }\n\n return register_event\n})()\n\nexport function isCrossDomainCookie(documentLocation: Location | undefined) {\n const hostname = documentLocation?.hostname\n\n if (!isString(hostname)) {\n return false\n }\n // split and slice isn't a great way to match arbitrary domains,\n // but it's good enough for ensuring we only match herokuapp.com when it is the TLD\n // for the hostname\n return hostname.split('.').slice(-2).join('.') !== 'herokuapp.com'\n}\n\nexport function isDistinctIdStringLike(value: string): boolean {\n return ['distinct_id', 'distinctid'].includes(value.toLowerCase())\n}\n\nexport function find<T>(value: T[], predicate: (value: T) => boolean): T | undefined {\n for (let i = 0; i < value.length; i++) {\n if (predicate(value[i])) {\n return value[i]\n }\n }\n return undefined\n}\n","import { each, isValidRegex } from './'\n\nimport { isArray, isFile, isUndefined } from './type-utils'\nimport { logger } from './logger'\nimport { document } from './globals'\n\nconst localDomains = ['localhost', '127.0.0.1']\n\n/**\n * IE11 doesn't support `new URL`\n * so we can create an anchor element and use that to parse the URL\n * there's a lot of overlap between HTMLHyperlinkElementUtils and URL\n * meaning useful properties like `pathname` are available on both\n */\nexport const convertToURL = (url: string): HTMLAnchorElement | null => {\n const location = document?.createElement('a')\n if (isUndefined(location)) {\n return null\n }\n\n location.href = url\n return location\n}\n\nexport const isUrlMatchingRegex = function (url: string, pattern: string): boolean {\n if (!isValidRegex(pattern)) return false\n return new RegExp(pattern).test(url)\n}\n\nexport const formDataToQuery = function (formdata: Record<string, any> | FormData, arg_separator = '&'): string {\n let use_val: string\n let use_key: string\n const tph_arr: string[] = []\n\n each(formdata, function (val: File | string | undefined, key: string | undefined) {\n // the key might be literally the string undefined for e.g. if {undefined: 'something'}\n if (isUndefined(val) || isUndefined(key) || key === 'undefined') {\n return\n }\n\n use_val = encodeURIComponent(isFile(val) ? val.name : val.toString())\n use_key = encodeURIComponent(key)\n tph_arr[tph_arr.length] = use_key + '=' + use_val\n })\n\n return tph_arr.join(arg_separator)\n}\n\nexport const getQueryParam = function (url: string, param: string): string {\n const withoutHash: string = url.split('#')[0] || ''\n const queryParams: string = withoutHash.split('?')[1] || ''\n\n const queryParts = queryParams.split('&')\n let keyValuePair\n\n for (let i = 0; i < queryParts.length; i++) {\n const parts = queryParts[i].split('=')\n if (parts[0] === param) {\n keyValuePair = parts\n break\n }\n }\n\n if (!isArray(keyValuePair) || keyValuePair.length < 2) {\n return ''\n } else {\n let result = keyValuePair[1]\n try {\n result = decodeURIComponent(result)\n } catch {\n logger.error('Skipping decoding for malformed query param: ' + result)\n }\n return result.replace(/\\+/g, ' ')\n }\n}\n\nexport const _getHashParam = function (hash: string, param: string): string | null {\n const matches = hash.match(new RegExp(param + '=([^&]*)'))\n return matches ? matches[1] : null\n}\n\nexport const isLocalhost = (): boolean => {\n return localDomains.includes(location.hostname)\n}\n","import { includes } from './index'\nimport { isFunction, isUndefined } from './type-utils'\n\n/**\n * this device detection code is (at time of writing) about 3% of the size of the entire library\n * this is mostly because the identifiers user in regexes and results can't be minified away since\n * they have meaning\n *\n * so, there are some pre-uglifying choices in the code to help reduce the size\n * e.g. many repeated strings are stored as variables and then old-fashioned concatenated together\n *\n * TL;DR here be dragons\n */\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'\n\nconst BROWSER_VERSION_REGEX_SUFFIX = '(\\\\d+(\\\\.\\\\d+)?)'\nconst DEFAULT_BROWSER_VERSION_REGEX = new RegExp('Version/' + BROWSER_VERSION_REGEX_SUFFIX)\n\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')\n\nconst windowsVersionMap: Record<string, string> = {\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}\n\n/**\n * Safari detection turns out to be complicated. For e.g. https://stackoverflow.com/a/29696509\n * We can be slightly loose because some options have been ruled out (e.g. firefox on iOS)\n * before this check is made\n */\nfunction isSafari(userAgent: string): boolean {\n return includes(userAgent, SAFARI) && !includes(userAgent, CHROME) && !includes(userAgent, ANDROID)\n}\n\nconst safariCheck = (ua: string, vendor?: string) => (vendor && includes(vendor, APPLE)) || isSafari(ua)\n\n/**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\nexport const detectBrowser = function (user_agent: string, vendor: string | undefined): string {\n vendor = vendor || '' // vendor is undefined for at least IE9\n\n if (includes(user_agent, ' OPR/') && includes(user_agent, 'Mini')) {\n return OPERA_MINI\n } else if (includes(user_agent, ' OPR/')) {\n return OPERA\n } else if (BLACKBERRY_REGEX.test(user_agent)) {\n return BLACKBERRY\n } else if (includes(user_agent, 'IE' + MOBILE) || includes(user_agent, 'WPDesktop')) {\n return INTERNET_EXPLORER_MOBILE\n }\n // https://developer.samsung.com/internet/user-agent-string-format\n else if (includes(user_agent, SAMSUNG_BROWSER)) {\n return SAMSUNG_INTERNET\n } else if (includes(user_agent, EDGE) || includes(user_agent, 'Edg/')) {\n return MICROSOFT_EDGE\n } else if (includes(user_agent, 'FBIOS')) {\n return FACEBOOK + ' ' + MOBILE\n } else if (includes(user_agent, 'UCWEB') || includes(user_agent, 'UCBrowser')) {\n return 'UC Browser'\n } else if (includes(user_agent, 'CriOS')) {\n return CHROME_IOS // why not just Chrome?\n } else if (includes(user_agent, 'CrMo')) {\n return CHROME\n } else if (includes(user_agent, CHROME)) {\n return CHROME\n } else if (includes(user_agent, ANDROID) && includes(user_agent, SAFARI)) {\n return ANDROID_MOBILE\n } else if (includes(user_agent, 'FxiOS')) {\n return FIREFOX_IOS\n } else if (includes(user_agent.toLowerCase(), KONQUEROR.toLowerCase())) {\n return KONQUEROR\n } else if (safariCheck(user_agent, vendor)) {\n return includes(user_agent, MOBILE) ? MOBILE_SAFARI : SAFARI\n } else if (includes(user_agent, FIREFOX)) {\n return FIREFOX\n } else if (includes(user_agent, 'MSIE') || includes(user_agent, 'Trident/')) {\n return INTERNET_EXPLORER\n } else if (includes(user_agent, 'Gecko')) {\n return FIREFOX\n }\n\n return ''\n}\n\nconst versionRegexes: Record<string, RegExp[]> = {\n [INTERNET_EXPLORER_MOBILE]: [new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)],\n [MICROSOFT_EDGE]: [new RegExp(EDGE + '?\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [CHROME]: [new RegExp('(' + CHROME + '|CrMo)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [CHROME_IOS]: [new RegExp('CriOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n 'UC Browser': [new RegExp('(UCBrowser|UCWEB)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],\n [MOBILE_SAFARI]: [DEFAULT_BROWSER_VERSION_REGEX],\n [OPERA]: [new RegExp('(' + OPERA + '|OPR)\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [FIREFOX]: [new RegExp(FIREFOX + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [FIREFOX_IOS]: [new RegExp('FxiOS\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [KONQUEROR]: [new RegExp('Konqueror[:/]?' + BROWSER_VERSION_REGEX_SUFFIX, 'i')],\n // not every blackberry user agent has the version after the name\n [BLACKBERRY]: [new RegExp(BLACKBERRY + ' ' + BROWSER_VERSION_REGEX_SUFFIX), DEFAULT_BROWSER_VERSION_REGEX],\n [ANDROID_MOBILE]: [new RegExp('android\\\\s' + BROWSER_VERSION_REGEX_SUFFIX, 'i')],\n [SAMSUNG_INTERNET]: [new RegExp(SAMSUNG_BROWSER + '\\\\/' + BROWSER_VERSION_REGEX_SUFFIX)],\n [INTERNET_EXPLORER]: [new RegExp('(rv:|MSIE )' + BROWSER_VERSION_REGEX_SUFFIX)],\n Mozilla: [new RegExp('rv:' + BROWSER_VERSION_REGEX_SUFFIX)],\n}\n\n/**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\nexport const detectBrowserVersion = function (userAgent: string, vendor: string | undefined): number | null {\n const browser = detectBrowser(userAgent, vendor)\n const regexes: RegExp[] | undefined = versionRegexes[browser as keyof typeof versionRegexes]\n if (isUndefined(regexes)) {\n return null\n }\n\n for (let i = 0; i < regexes.length; i++) {\n const regex = regexes[i]\n const matches = userAgent.match(regex)\n if (matches) {\n return parseFloat(matches[matches.length - 2])\n }\n }\n return null\n}\n\n// to avoid repeating regexes or calling them twice, we have an array of matches\n// the first regex that matches uses its matcher function to return the result\nconst osMatchers: [\n RegExp,\n [string, string] | ((match: RegExpMatchArray | null, user_agent: string) => [string, string])\n][] = [\n [\n new RegExp(XBOX + '; ' + XBOX + ' (.*?)[);]', 'i'),\n (match) => {\n return [XBOX, (match && match[1]) || '']\n },\n ],\n [new RegExp(NINTENDO, 'i'), [NINTENDO, '']],\n [new RegExp(PLAYSTATION, 'i'), [PLAYSTATION, '']],\n [BLACKBERRY_REGEX, [BLACKBERRY, '']],\n [\n new RegExp(WINDOWS, 'i'),\n (_, user_agent) => {\n if (/Phone/.test(user_agent) || /WPDesktop/.test(user_agent)) {\n return [WINDOWS_PHONE, '']\n }\n // not all JS versions support negative lookbehind, so we need two checks here\n if (new RegExp(MOBILE).test(user_agent) && !/IEMobile\\b/.test(user_agent)) {\n return [WINDOWS + ' ' + MOBILE, '']\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)) {\n osVersion = 'RT'\n }\n return [WINDOWS, osVersion]\n }\n return [WINDOWS, '']\n },\n ],\n [\n /((iPhone|iPad|iPod).*?OS (\\d+)_(\\d+)_?(\\d+)?|iPhone)/,\n (match) => {\n if (match && match[3]) {\n const versionParts = [match[3], match[4], match[5] || '0']\n return [IOS, versionParts.join('.')]\n }\n return [IOS, '']\n },\n ],\n [\n /(watch.*\\/(\\d+\\.\\d+\\.\\d+)|watch os,(\\d+\\.\\d+),)/i,\n (match) => {\n // e.g. Watch4,3/5.3.8 (16U680)\n let version = ''\n if (match && match.length >= 3) {\n version = isUndefined(match[2]) ? match[3] : match[2]\n }\n return ['watchOS', version]\n },\n ],\n [\n new RegExp('(' + ANDROID + ' (\\\\d+)\\\\.(\\\\d+)\\\\.?(\\\\d+)?|' + ANDROID + ')', 'i'),\n (match) => {\n if (match && match[2]) {\n const versionParts = [match[2], match[3], match[4] || '0']\n return [ANDROID, versionParts.join('.')]\n }\n return [ANDROID, '']\n },\n ],\n [\n /Mac OS X (\\d+)[_.](\\d+)[_.]?(\\d+)?/i,\n (match) => {\n const result: [string, string] = ['Mac OS X', '']\n if (match && match[1]) {\n const versionParts = [match[1], match[2], match[3] || '0']\n result[1] = versionParts.join('.')\n }\n return result\n },\n ],\n [\n /Mac/i,\n // mop up a few non-standard UAs that should match mac\n ['Mac OS X', ''],\n ],\n [/CrOS/, [CHROME_OS, '']],\n [/Linux|debian/i, ['Linux', '']],\n]\n\nexport const detectOS = function (user_agent: string): [string, string] {\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) {\n return result\n }\n }\n return ['', '']\n}\n\nexport const detectDevice = function (user_agent: string): string {\n if (NINTENDO_REGEX.test(user_agent)) {\n return NINTENDO\n } else if (PLAYSTATION_REGEX.test(user_agent)) {\n return PLAYSTATION\n } else if (XBOX_REGEX.test(user_agent)) {\n return XBOX\n } else if (new RegExp(OUYA, 'i').test(user_agent)) {\n return OUYA\n } else if (new RegExp('(' + WINDOWS_PHONE + '|WPDesktop)', 'i').test(user_agent)) {\n return WINDOWS_PHONE\n } else if (/iPad/.test(user_agent)) {\n return IPAD\n } else if (/iPod/.test(user_agent)) {\n return 'iPod Touch'\n } else if (/iPhone/.test(user_agent)) {\n return 'iPhone'\n } else if (/(watch)(?: ?os[,/]|\\d,\\d\\/)[\\d.]+/i.test(user_agent)) {\n return APPLE_WATCH\n } else if (BLACKBERRY_REGEX.test(user_agent)) {\n return BLACKBERRY\n } else if (/(kobo)\\s(ereader|touch)/i.test(user_agent)) {\n return 'Kobo'\n } else if (new RegExp(NOKIA, 'i').test(user_agent)) {\n return NOKIA\n } else if (\n // Kindle Fire without Silk / Echo Show\n /(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\\))/i.test(user_agent) ||\n // Kindle Fire HD\n /(kf[a-z]+)( bui|\\)).+silk\\//i.test(user_agent)\n ) {\n return 'Kindle Fire'\n } else if (/(Android|ZTE)/i.test(user_agent)) {\n if (\n !new RegExp(MOBILE).test(user_agent) ||\n /(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(user_agent)\n ) {\n if (\n (/pixel[\\daxl ]{1,6}/i.test(user_agent) && !/pixel c/i.test(user_agent)) ||\n /(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(user_agent) ||\n (/lmy47v/i.test(user_agent) && !/QTAQZ3/i.test(user_agent))\n ) {\n return ANDROID\n }\n return ANDROID_TABLET\n } else {\n return ANDROID\n }\n } else if (new RegExp('(pda|' + MOBILE + ')', 'i').test(user_agent)) {\n return GENERIC_MOBILE\n } else if (new RegExp(TABLET, 'i').test(user_agent) && !new RegExp(TABLET + ' pc', 'i').test(user_agent)) {\n return GENERIC_TABLET\n } else {\n return ''\n }\n}\n\nexport const detectDeviceType = function (user_agent: string): string {\n const device = detectDevice(user_agent)\n if (\n device === IPAD ||\n device === ANDROID_TABLET ||\n device === 'Kobo' ||\n device === 'Kindle Fire' ||\n device === GENERIC_TABLET\n ) {\n return TABLET\n } else if (device === NINTENDO || device === XBOX || device === PLAYSTATION || device === OUYA) {\n return 'Console'\n } else if (device === APPLE_WATCH) {\n return 'Wearable'\n } else if (device) {\n return MOBILE\n } else {\n return 'Desktop'\n }\n}\n","import { getQueryParam, convertToURL } from './request-utils'\nimport { isNull } from './type-utils'\nimport { Properties } from '../types'\nimport Config from '../config'\nimport { each, extend, stripEmptyProperties, stripLeadingDollar } from './index'\nimport { document, location, userAgent, window } from './globals'\nimport { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS } from './user-agent-utils'\n\nconst URL_REGEX_PREFIX = 'https?://(.*)'\n\n// Should be kept in sync with https://github.com/PostHog/posthog/blob/master/plugin-server/src/utils/db/utils.ts#L60\nexport const CAMPAIGN_PARAMS = [\n 'utm_source',\n 'utm_medium',\n 'utm_campaign',\n 'utm_content',\n 'utm_term',\n 'gclid', // google ads\n 'gad_source', // google ads\n 'gclsrc', // google ads 360\n 'dclid', // google display ads\n 'gbraid', // google ads, web to app\n 'wbraid', // google ads, app to web\n 'fbclid', // facebook\n 'msclkid', // microsoft\n 'twclid', // twitter\n 'li_fat_id', // linkedin\n 'mc_cid', // mailchimp campaign id\n 'igshid', // instagram\n 'ttclid', // tiktok\n 'rdt_cid', // reddit\n]\n\nexport const EVENT_TO_PERSON_PROPERTIES = [\n // mobile params\n '$app_build',\n '$app_name',\n '$app_namespace',\n '$app_version',\n // web params\n '$browser',\n '$browser_version',\n '$device_type',\n '$current_url',\n '$pathname',\n '$os',\n '$os_name', // $os_name is a special case, it's treated as an alias of $os!\n '$os_version',\n '$referring_domain',\n '$referrer',\n]\n\nexport const Info = {\n campaignParams: function (customParams?: string[]): Record<string, string> {\n if (!document) {\n return {}\n }\n return this._campaignParamsFromUrl(document.URL, customParams)\n },\n\n _campaignParamsFromUrl: function (url: string, customParams?: string[]): Record<string, string> {\n const campaign_keywords = CAMPAIGN_PARAMS.concat(customParams || [])\n\n const params: Record<string, any> = {}\n each(campaign_keywords, function (kwkey) {\n const kw = getQueryParam(url, kwkey)\n params[kwkey] = kw ? kw : null\n })\n\n return params\n },\n\n _searchEngine: function (referrer: string): string | null {\n if (!referrer) {\n return null\n } else {\n if (referrer.search(URL_REGEX_PREFIX + 'google.([^/?]*)') === 0) {\n return 'google'\n } else if (referrer.search(URL_REGEX_PREFIX + 'bing.com') === 0) {\n return 'bing'\n } else if (referrer.search(URL_REGEX_PREFIX + 'yahoo.com') === 0) {\n return 'yahoo'\n } else if (referrer.search(URL_REGEX_PREFIX + 'duckduckgo.com') === 0) {\n return 'duckduckgo'\n } else {\n return null\n }\n }\n },\n\n _searchInfoFromReferrer: function (referrer: string): Record<string, any> {\n const search = Info._searchEngine(referrer)\n const param = search != 'yahoo' ? 'q' : 'p'\n const ret: Record<string, any> = {}\n\n if (!isNull(search)) {\n ret['$search_engine'] = search\n\n const keyword = document ? getQueryParam(document.referrer, param) : ''\n if (keyword.length) {\n ret['ph_keyword'] = keyword\n }\n }\n\n return ret\n },\n\n searchInfo: function (): Record<string, any> {\n const referrer = document?.referrer\n if (!referrer) {\n return {}\n }\n return this._searchInfoFromReferrer(referrer)\n },\n\n /**\n * This function detects which browser is running this script.\n * The order of the checks are important since many user agents\n * include keywords used in later checks.\n */\n browser: detectBrowser,\n\n /**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n *\n * `navigator.vendor` is passed in and used to help with detecting certain browsers\n * NB `navigator.vendor` is deprecated and not present in every browser\n */\n browserVersion: detectBrowserVersion,\n\n browserLanguage: function (): string | undefined {\n return (\n navigator.language || // Any modern browser\n (navigator as Record<string, any>).userLanguage // IE11\n )\n },\n\n browserLanguagePrefix: function (): string | undefined {\n const browserLanguage = this.browserLanguage()\n return typeof browserLanguage === 'string' ? browserLanguage.split('-')[0] : undefined\n },\n\n os: detectOS,\n\n device: detectDevice,\n\n deviceType: detectDeviceType,\n\n referrer: function (): string {\n return document?.referrer || '$direct'\n },\n\n referringDomain: function (): string {\n if (!document?.referrer) {\n return '$direct'\n }\n return convertToURL(document.referrer)?.host || '$direct'\n },\n\n referrerInfo: function (): Record<string, any> {\n return {\n $referrer: this.referrer(),\n $referring_domain: this.referringDomain(),\n }\n },\n\n initialPersonInfo: function (): Record<string, any> {\n // we're being a bit more economical with bytes here because this is stored in the cookie\n return {\n r: this.referrer().substring(0, 1000),\n u: location?.href.substring(0, 1000),\n }\n },\n\n initialPersonPropsFromInfo: function (info: Record<string, any>): Record<string, any> {\n const { r: initial_referrer, u: initial_current_url } = info\n const referring_domain =\n initial_referrer == null\n ? undefined\n : initial_referrer == '$direct'\n ? '$direct'\n : convertToURL(initial_referrer)?.host\n\n const props: Record<string, string | undefined> = {\n $initial_referrer: initial_referrer,\n $initial_referring_domain: referring_domain,\n }\n if (initial_current_url) {\n props['$initial_current_url'] = initial_current_url\n const location = convertToURL(initial_current_url)\n props['$initial_host'] = location?.host\n props['$initial_pathname'] = location?.pathname\n const campaignParams = this._campaignParamsFromUrl(initial_current_url)\n each(campaignParams, function (v, k: string) {\n props['$initial_' + stripLeadingDollar(k)] = v\n })\n }\n if (initial_referrer) {\n const searchInfo = this._searchInfoFromReferrer(initial_referrer)\n each(searchInfo, function (v, k: string) {\n props['$initial_' + stripLeadingDollar(k)] = v\n })\n }\n return props\n },\n\n timezone: function (): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone\n } catch {\n return undefined\n }\n },\n\n timezoneOffset: function (): number | undefined {\n try {\n return new Date().getTimezoneOffset()\n } catch {\n return undefined\n }\n },\n\n properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n $device: Info.device(userAgent),\n $device_type: Info.deviceType(userAgent),\n $timezone: Info.timezone(),\n $timezone_offset: Info.timezoneOffset(),\n }),\n {\n $current_url: location?.href,\n $host: location?.host,\n $pathname: location?.pathname,\n $raw_user_agent: userAgent.length > 1000 ? userAgent.substring(0, 997) + '...' : userAgent,\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n $browser_language: Info.browserLanguage(),\n $browser_language_prefix: Info.browserLanguagePrefix(),\n $screen_height: window?.screen.height,\n $screen_width: window?.screen.width,\n $viewport_height: window?.innerHeight,\n $viewport_width: window?.innerWidth,\n $lib: 'web',\n $lib_version: Config.LIB_VERSION,\n $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),\n $time: Date.now() / 1000, // epoch time in seconds\n }\n )\n },\n\n people_properties: function (): Properties {\n if (!userAgent) {\n return {}\n }\n\n const [os_name, os_version] = Info.os(userAgent)\n return extend(\n stripEmptyProperties({\n $os: os_name,\n $os_version: os_version,\n $browser: Info.browser(userAgent, navigator.vendor),\n }),\n {\n $browser_version: Info.browserVersion(userAgent, navigator.vendor),\n }\n )\n },\n}\n","import { isNumber } from './type-utils'\nimport { logger } from './logger'\n\n/**\n * Clamps a value to a range.\n * @param value the value to clamp\n * @param min the minimum value\n * @param max the maximum value\n * @param label if provided then enables logging and prefixes all logs with labels\n * @param fallbackValue if provided then returns this value if the value is not a valid number\n */\nexport function clampToRange(value: unknown, min: number, max: number, label?: string, fallbackValue?: number): number {\n if (min > max) {\n logger.warn('min cannot be greater than max.')\n min = max\n }\n\n if (!isNumber(value)) {\n label &&\n logger.warn(\n label + ' must be a number. using max or fallback. max: ' + max + ', fallback: ' + fallbackValue\n )\n return clampToRange(fallbackValue || max, min, max, label)\n } else if (value > max) {\n label && logger.warn(label + ' cannot be greater than max: ' + max + '. Using max value instead.')\n return max\n } else if (value < min) {\n label && logger.warn(label + ' cannot be less than min: ' + min + '. Using min value instead.')\n return min\n } else {\n return value\n }\n}\n","import { clampToRange } from '../utils/number-utils'\nimport { BeforeSendFn, CaptureResult, KnownEventName } from '../types'\nimport { includes } from '../utils'\nimport { isArray, isUndefined } from '../utils/type-utils'\n\nfunction appendArray(currentValue: string[] | undefined, sampleType: string | string[]): string[] {\n return [...(currentValue ? currentValue : []), ...(isArray(sampleType) ? sampleType : [sampleType])]\n}\n\nfunction updateThreshold(currentValue: number | undefined, percent: number): number {\n return (isUndefined(currentValue) ? 1 : currentValue) * percent\n}\n\nfunction simpleHash(str: string) {\n let hash = 0\n for (let i = 0; i < str.length; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i) // (hash * 31) + char code\n hash |= 0 // Convert to 32bit integer\n }\n return Math.abs(hash)\n}\n\n/*\n * receives percent as a number between 0 and 1\n */\nfunction sampleOnProperty(prop: string, percent: number): boolean {\n return simpleHash(prop) % 100 < clampToRange(percent * 100, 0, 100)\n}\n\n/**\n * Provides an implementation of sampling that samples based on the distinct ID.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * Setting 0.5 will cause roughly 50% of distinct ids to have events sent.\n * Not 50% of events for each distinct id.\n *\n * @param percent a number from 0 to 1, 1 means always send and, 0 means never send the event\n */\nexport function sampleByDistinctId(percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n return sampleOnProperty(captureResult.properties.distinct_id, percent)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: ['sampleByDistinctId'],\n $sample_threshold: percent,\n },\n }\n : null\n }\n}\n\n/**\n * Provides an implementation of sampling that samples based on the session ID.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * Setting 0.5 will cause roughly 50% of sessions to have events sent.\n * Not 50% of events for each session.\n *\n * @param percent a number from 0 to 1, 1 means always send and, 0 means never send the event\n */\nexport function sampleBySessionId(percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n return sampleOnProperty(captureResult.properties.$session_id, percent)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: appendArray(captureResult.properties.$sample_type, 'sampleBySessionId'),\n $sample_threshold: updateThreshold(captureResult.properties.$sample_threshold, percent),\n },\n }\n : null\n }\n}\n\n/**\n * Provides an implementation of sampling that samples based on the event name.\n * Using the provided percentage.\n * Can be used to create a beforeCapture fn for a PostHog instance.\n *\n * @param eventNames an array of event names to sample, sampling is applied across events not per event name\n * @param percent a number from 0 to 1, 1 means always send, 0 means never send the event\n */\nexport function sampleByEvent(eventNames: KnownEventName[], percent: number): BeforeSendFn {\n return (captureResult: CaptureResult | null): CaptureResult | null => {\n if (!captureResult) {\n return null\n }\n\n if (!includes(eventNames, captureResult.event)) {\n return captureResult\n }\n\n const number = Math.random()\n return number * 100 < clampToRange(percent * 100, 0, 100)\n ? {\n ...captureResult,\n properties: {\n ...captureResult.properties,\n $sample_type: appendArray(captureResult.properties?.$sample_type, 'sampleByEvent'),\n $sample_threshold: updateThreshold(captureResult.properties?.$sample_threshold, percent),\n $sampled_events: appendArray(captureResult.properties?.$sampled_events, eventNames),\n },\n }\n : null\n }\n}\n\nexport const printAndDropEverything: BeforeSendFn = (result) => {\n // eslint-disable-next-line no-console\n console.log('Would have sent event:', result)\n return null\n}\n","import { PostHog } from '../posthog-core'\nimport { CAMPAIGN_PARAMS, EVENT_TO_PERSON_PROPERTIES, Info } from '../utils/event-utils'\nimport { each, extend, includes } from '../utils'\n\nexport const setAllPersonProfilePropertiesAsPersonPropertiesForFlags = (posthog: PostHog): void => {\n const allProperties = extend({}, Info.properties(), Info.campaignParams(), Info.referrerInfo())\n const personProperties: Record<string, string> = {}\n each(allProperties, function (v, k: string) {\n if (includes(CAMPAIGN_PARAMS, k) || includes(EVENT_TO_PERSON_PROPERTIES, k)) {\n personProperties[k] = v\n }\n })\n\n posthog.setPersonPropertiesForFlags(personProperties)\n}\n","// this file is called customizations.full.ts because it includes all customizations\n// this naming scheme allows us to create a lighter version in the future with only the most popular customizations\n// without breaking backwards compatibility\n\nimport * as customizations from '../customizations'\nimport { assignableWindow } from '../utils/globals'\nassignableWindow.posthogCustomizations = customizations\n"],"names":["win","window","undefined","global","globalThis","nativeForEach","Array","prototype","forEach","navigator","document","location","fetch","XMLHttpRequest","AbortController","Compression","userAgent","assignableWindow","nativeIsArray","isArray","ObjProto","Object","hasOwnProperty","toString","obj","call","isUndefined","x","isNull","isNumber","Config","DEBUG","LIB_VERSION","_createLogger","prefix","logger","_log","level","console","consoleLog","_len","arguments","length","args","_key","info","_len2","_key2","warn","_len3","_key3","error","_len4","_key4","critical","_len5","_key5","uninitializedWarning","methodName","concat","createLogger","additionalPrefix","breaker","eachArray","iterator","thisArg","i","l","each","FormData","isFormData","pair","entries","key","extend","source","prop","includes","str","needle","indexOf","stripEmptyProperties","p","ret","v","k","stripLeadingDollar","s","replace","convertToURL","url","createElement","href","getQueryParam","param","keyValuePair","queryParts","split","parts","result","decodeURIComponent","_unused","MOBILE","IOS","ANDROID","TABLET","ANDROID_TABLET","IPAD","APPLE","APPLE_WATCH","SAFARI","BLACKBERRY","SAMSUNG","SAMSUNG_BROWSER","SAMSUNG_INTERNET","CHROME","CHROME_OS","CHROME_IOS","INTERNET_EXPLORER","INTERNET_EXPLORER_MOBILE","OPERA","OPERA_MINI","EDGE","MICROSOFT_EDGE","FIREFOX","FIREFOX_IOS","NINTENDO","PLAYSTATION","XBOX","ANDROID_MOBILE","MOBILE_SAFARI","WINDOWS","WINDOWS_PHONE","NOKIA","OUYA","GENERIC","GENERIC_MOBILE","toLowerCase","GENERIC_TABLET","KONQUEROR","BROWSER_VERSION_REGEX_SUFFIX","DEFAULT_BROWSER_VERSION_REGEX","RegExp","XBOX_REGEX","PLAYSTATION_REGEX","NINTENDO_REGEX","BLACKBERRY_REGEX","windowsVersionMap","safariCheck","ua","vendor","isSafari","detectBrowser","user_agent","test","FACEBOOK","versionRegexes","Mozilla","osMatchers","match","_","exec","version","osVersion","versionParts","join","detectDevice","URL_REGEX_PREFIX","CAMPAIGN_PARAMS","EVENT_TO_PERSON_PROPERTIES","Info","campaignParams","customParams","this","_campaignParamsFromUrl","URL","campaign_keywords","params","kwkey","kw","_searchEngine","referrer","search","_searchInfoFromReferrer","keyword","searchInfo","browser","browserVersion","regexes","regex","matches","parseFloat","browserLanguage","language","userLanguage","browserLanguagePrefix","os","rgex","resultOrFn","device","deviceType","referringDomain","_convertToURL","host","referrerInfo","$referrer","$referring_domain","initialPersonInfo","r","substring","u","initialPersonPropsFromInfo","_convertToURL2","initial_referrer","initial_current_url","props","$initial_referrer","$initial_referring_domain","pathname","timezone","Intl","DateTimeFormat","resolvedOptions","timeZone","timezoneOffset","Date","getTimezoneOffset","_unused2","properties","os_name","os_version","$os","$os_version","$browser","$device","$device_type","$timezone","$timezone_offset","$current_url","$host","$pathname","$raw_user_agent","$browser_version","$browser_language","$browser_language_prefix","$screen_height","screen","height","$screen_width","width","$viewport_height","innerHeight","$viewport_width","innerWidth","$lib","$lib_version","$insert_id","Math","random","$time","now","people_properties","clampToRange","value","min","max","label","fallbackValue","appendArray","currentValue","sampleType","updateThreshold","percent","sampleOnProperty","hash","charCodeAt","abs","simpleHash","log","captureResult","distinct_id","_objectSpread","$sample_type","$sample_threshold","eventNames","_captureResult$proper","_captureResult$proper2","_captureResult$proper3","event","$sampled_events","$session_id","posthog","allProperties","personProperties","setPersonPropertiesForFlags","posthogCustomizations","customizations"],"mappings":"yBAuBA,IAAMA,EAAkE,oBAAXC,OAAyBA,YAASC,EAmEzFC,EAA8D,oBAAfC,WAA6BA,WAAaJ,EAGlFK,EADaC,MAAMC,UACQC,QAG3BC,EAAYN,aAAM,EAANA,EAAQM,UACpBC,EAAWP,aAAM,EAANA,EAAQO,SACnBC,EAAWR,aAAM,EAANA,EAAQQ,SACXR,SAAAA,EAAQS,MAEzBT,SAAAA,EAAQU,gBAAkB,oBAAqB,IAAIV,EAAOU,gBAAmBV,EAAOU,eACzDV,SAAAA,EAAQW,gBAChC,ICkVKC,EDlVCC,EAAYP,aAAS,EAATA,EAAWO,UACvBC,EAAqCjB,QAAAA,EAAQ,CAAU,GCwVpE,SAPYe,GAAAA,EAAW,OAAA,UAAXA,EAAW,OAAA,QAAXA,CAOZ,CAPYA,IAAAA,EAgBZ,CAAA,ICpcA,IAAMG,EAAgBZ,MAAMa,QACtBC,EAAWC,OAAOd,UACXe,EAAiBF,EAASE,eACjCC,EAAWH,EAASG,SAEbJ,EACTD,GACA,SAAUM,GACN,MAA8B,mBAAvBD,EAASE,KAAKD,EACzB,EAkCSE,EAAeC,QAAqC,IAANA,EAS9CC,EAAUD,GAEN,OAANA,EASEE,EAAYF,GAEM,mBAApBJ,EAASE,KAAKE,GClEnBG,EAAS,CACXC,OAAO,EACPC,uBCQEC,EAAiBC,IACnB,IAAMC,EAAiB,CACnBC,KAAM,SAACC,GACH,GACIpC,GACiBgB,EAA8B,gBAC9CS,EAAYzB,EAAOqC,UACpBrC,EAAOqC,QACT,CAME,IALA,IAAMC,GACF,uBAAwBtC,EAAOqC,QAAQD,GAChCpC,EAAOqC,QAAQD,GAAmC,mBACnDpC,EAAOqC,QAAQD,IAEzBG,EAAAC,UAAAC,OAZmCC,MAAIrC,MAAAkC,EAAAA,EAAAA,OAAAI,EAAA,EAAAA,EAAAJ,EAAAI,IAAJD,EAAIC,EAAA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