posthog-js 1.93.2 → 1.93.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,7 @@ export interface PostHogConfig {
70
70
  upgrade: boolean;
71
71
  disable_session_recording: boolean;
72
72
  disable_persistence: boolean;
73
+ /** @deprecated - use `disable_persistence` instead */
73
74
  disable_cookie: boolean;
74
75
  enable_recording_console_log?: boolean;
75
76
  secure_cookie: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAsLA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,iCAAkB,CAAA;IAClB,gCAAiB,CAAA;AACrB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","sourcesContent":["import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'\nimport { PostHog } from './posthog-core'\nimport { RetryQueue } from './retry-queue'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\nexport type CaptureCallback = (response: any, data: any) => void\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 */\n url_allowlist?: (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 */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\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\nexport type UUIDVersion = 'og' | 'v7'\n\nexport interface PostHogConfig {\n api_host: string\n api_method: string\n api_transport: string\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 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\n debug: boolean\n cookie_expiration: number\n upgrade: boolean\n disable_session_recording: boolean\n disable_persistence: boolean\n disable_cookie: boolean\n enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n opt_out_capturing_by_default: boolean\n opt_out_persistence_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n property_blacklist: string[]\n xhr_headers: { [header_name: string]: string }\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 get_device_id: (uuid: string) => string\n name: string\n callback_fn: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n }\n segment?: any\n __preview_measure_pageview_stats?: boolean\n __preview_send_client_session_params?: 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) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recorderVersion?: 'v1' | 'v2'\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // properties below here are ALPHA, don't rely on them, they may change without notice\n // TODO which of these do we actually expose?\n // if this isn't provided a default will be used\n // this only applies to the payload recorder\n // TODO I guess it should apply to the other recorder to\n initiatorTypes?: InitiatorType[]\n recordHeaders?: boolean | { request: boolean; response: boolean }\n // true means record all bodies\n // false means record no bodies\n // string[] means record bodies matching the provided content-type headers\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n // I can't think why you wouldn't want this... so\n // recordInitialRequests?: boolean\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\nexport interface XHROptions {\n transport?: 'XHR' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n verbose?: boolean\n blob?: boolean\n sendBeacon?: boolean\n}\n\nexport interface CaptureOptions extends XHROptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _metrics?: Properties\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n endpoint?: string /** defaults to '/e/' */\n send_instantly?: boolean /** if set skips the batched queue */\n timestamp?: Date\n}\n\nexport interface RetryQueueElement {\n retryAt: Date\n requestData: QueuedRequestData\n}\nexport interface QueuedRequestData {\n url: string\n data: Properties\n options: CaptureOptions\n headers?: Properties\n callback?: RequestCallback\n retriesPerformedSoFar?: number\n}\n\nexport interface XHRParams extends QueuedRequestData {\n retryQueue: RetryQueue\n onXHRError: (req: XMLHttpRequest) => void\n timeout?: number\n onResponse?: (req: XMLHttpRequest) => void\n}\n\nexport interface DecideResponse {\n status: number\n supportedCompression: Compression[]\n config: {\n enable_collect_everything: boolean\n }\n custom_properties: AutoCaptureCustomProperty[] // TODO: delete, not sent\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n capturePerformance?: boolean\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 errors_to_ignore: string[]\n }\n sessionRecording?: {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n recorderVersion?: 'v1' | 'v2'\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n}\n\nexport type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>) => void\n\n// TODO: delete custom_properties after changeless typescript refactor\nexport interface AutoCaptureCustomProperty {\n name: string\n css_selector: string\n event_selectors: string[]\n}\n\nexport interface CompressionData {\n data: string\n compression?: Compression\n}\n\nexport interface GDPROptions {\n capture?: (\n event: string,\n properties: Properties,\n options: CaptureOptions\n ) => void /** function used for capturing a PostHog event to record the opt-in action */\n captureEventName?: string /** event name to be used for capturing the opt-in action */\n captureProperties?: Properties /** set of properties to be captured along with the opt-in action */\n /** persistence mechanism used */\n persistenceType?: 'cookie' | 'localStorage' | 'localStorage+cookie'\n persistencePrefix?: string /** [__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name */\n cookieExpiration?: number /** number of days until the opt-in cookie expires */\n crossSubdomainCookie?: boolean /** whether the opt-in cookie is set as cross-subdomain or not */\n secureCookie?: boolean /** whether the opt-in cookie is set as secure or not */\n respectDnt?: boolean\n window?: Window\n}\n\nexport type RequestCallback = (response: Record<string, any>, data?: Properties) => 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: (name: string, value: any, expire_days?: number | null, cross_subdomain?: boolean, secure?: boolean) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport interface PostData {\n buffer?: BlobPart\n compression?: Compression\n data?: string\n}\n\nexport interface JSC {\n (): void\n [key: string]: (response: any) => void\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\nexport type Body =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n // rrweb uses URLSearchParams and ReadableStream<Uint8Array>\n // as part of the union for this type\n // because they don't support IE11\n // but, we do 🫠\n // what's going to happen here in IE11?\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null\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 // whether to record PerformanceEntry events for network requests\n recordPerformance?: boolean\n // the PerformanceObserver will only observe these entry types\n performanceEntryTypeToObserve: string[]\n // the maximum size of the request/response body to record\n // NB this will be at most 1MB even if set larger\n payloadSizeLimitBytes: number\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\nexport type CapturedNetworkRequest = 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?: Body\n responseHeaders?: Headers\n responseBody?: Body\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAuLA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,iCAAkB,CAAA;IAClB,gCAAiB,CAAA;AACrB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","sourcesContent":["import type { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'\nimport { PostHog } from './posthog-core'\nimport { RetryQueue } from './retry-queue'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\nexport type CaptureCallback = (response: any, data: any) => void\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 */\n url_allowlist?: (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 */\n element_allowlist?: AutocaptureCompatibleElement[]\n\n /**\n * List of CSS selectors to allow autocapture on\n * e.g. ['[ph-capture]']\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\nexport type UUIDVersion = 'og' | 'v7'\n\nexport interface PostHogConfig {\n api_host: string\n api_method: string\n api_transport: string\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 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\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 enable_recording_console_log?: boolean\n secure_cookie: boolean\n ip: boolean\n opt_out_capturing_by_default: boolean\n opt_out_persistence_by_default: boolean\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n opt_out_capturing_cookie_prefix: string | null\n opt_in_site_apps: boolean\n respect_dnt: boolean\n property_blacklist: string[]\n xhr_headers: { [header_name: string]: string }\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 get_device_id: (uuid: string) => string\n name: string\n callback_fn: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n }\n segment?: any\n __preview_measure_pageview_stats?: boolean\n __preview_send_client_session_params?: 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) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recorderVersion?: 'v1' | 'v2'\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // properties below here are ALPHA, don't rely on them, they may change without notice\n // TODO which of these do we actually expose?\n // if this isn't provided a default will be used\n // this only applies to the payload recorder\n // TODO I guess it should apply to the other recorder to\n initiatorTypes?: InitiatorType[]\n recordHeaders?: boolean | { request: boolean; response: boolean }\n // true means record all bodies\n // false means record no bodies\n // string[] means record bodies matching the provided content-type headers\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n // I can't think why you wouldn't want this... so\n // recordInitialRequests?: boolean\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\nexport interface XHROptions {\n transport?: 'XHR' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n verbose?: boolean\n blob?: boolean\n sendBeacon?: boolean\n}\n\nexport interface CaptureOptions extends XHROptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _metrics?: Properties\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n endpoint?: string /** defaults to '/e/' */\n send_instantly?: boolean /** if set skips the batched queue */\n timestamp?: Date\n}\n\nexport interface RetryQueueElement {\n retryAt: Date\n requestData: QueuedRequestData\n}\nexport interface QueuedRequestData {\n url: string\n data: Properties\n options: CaptureOptions\n headers?: Properties\n callback?: RequestCallback\n retriesPerformedSoFar?: number\n}\n\nexport interface XHRParams extends QueuedRequestData {\n retryQueue: RetryQueue\n onXHRError: (req: XMLHttpRequest) => void\n timeout?: number\n onResponse?: (req: XMLHttpRequest) => void\n}\n\nexport interface DecideResponse {\n status: number\n supportedCompression: Compression[]\n config: {\n enable_collect_everything: boolean\n }\n custom_properties: AutoCaptureCustomProperty[] // TODO: delete, not sent\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n capturePerformance?: boolean\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 errors_to_ignore: string[]\n }\n sessionRecording?: {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n recorderVersion?: 'v1' | 'v2'\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n}\n\nexport type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>) => void\n\n// TODO: delete custom_properties after changeless typescript refactor\nexport interface AutoCaptureCustomProperty {\n name: string\n css_selector: string\n event_selectors: string[]\n}\n\nexport interface CompressionData {\n data: string\n compression?: Compression\n}\n\nexport interface GDPROptions {\n capture?: (\n event: string,\n properties: Properties,\n options: CaptureOptions\n ) => void /** function used for capturing a PostHog event to record the opt-in action */\n captureEventName?: string /** event name to be used for capturing the opt-in action */\n captureProperties?: Properties /** set of properties to be captured along with the opt-in action */\n /** persistence mechanism used */\n persistenceType?: 'cookie' | 'localStorage' | 'localStorage+cookie'\n persistencePrefix?: string /** [__ph_opt_in_out] - custom prefix to be used in the cookie/localstorage name */\n cookieExpiration?: number /** number of days until the opt-in cookie expires */\n crossSubdomainCookie?: boolean /** whether the opt-in cookie is set as cross-subdomain or not */\n secureCookie?: boolean /** whether the opt-in cookie is set as secure or not */\n respectDnt?: boolean\n window?: Window\n}\n\nexport type RequestCallback = (response: Record<string, any>, data?: Properties) => 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: (name: string, value: any, expire_days?: number | null, cross_subdomain?: boolean, secure?: boolean) => void\n remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport interface PostData {\n buffer?: BlobPart\n compression?: Compression\n data?: string\n}\n\nexport interface JSC {\n (): void\n [key: string]: (response: any) => void\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\nexport type Body =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n // rrweb uses URLSearchParams and ReadableStream<Uint8Array>\n // as part of the union for this type\n // because they don't support IE11\n // but, we do 🫠\n // what's going to happen here in IE11?\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null\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 // whether to record PerformanceEntry events for network requests\n recordPerformance?: boolean\n // the PerformanceObserver will only observe these entry types\n performanceEntryTypeToObserve: string[]\n // the maximum size of the request/response body to record\n // NB this will be at most 1MB even if set larger\n payloadSizeLimitBytes: number\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\nexport type CapturedNetworkRequest = 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?: Body\n responseHeaders?: Headers\n responseBody?: Body\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n"]}
@@ -33,3 +33,4 @@ export declare const _utf8Encode: (string: string) => string;
33
33
  export declare const _register_event: (element: Element | Window | Document | Node, type: string, handler: EventHandler, oldSchool?: boolean, useCapture?: boolean) => void;
34
34
  export declare function loadScript(scriptUrlToLoad: string, callback: (error?: string | Event, event?: Event) => void): void;
35
35
  export declare function isCrossDomainCookie(documentLocation: Location | undefined): boolean;
36
+ export declare function isDistinctIdStringLike(value: string): boolean;
@@ -404,4 +404,7 @@ export function isCrossDomainCookie(documentLocation) {
404
404
  // for the hostname
405
405
  return hostname.split('.').slice(-2).join('.') !== 'herokuapp.com';
406
406
  }
407
+ export function isDistinctIdStringLike(value) {
408
+ return ['distinct_id', 'distinctid'].includes(value.toLowerCase());
409
+ }
407
410
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,cAAc,GACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAE1E,IAAM,OAAO,GAAY,EAAE,CAAA;AAE3B,aAAa;AACb,uCAAuC;AACvC,MAAM,CAAC,IAAM,KAAK,GAAG,UAAU,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,oCAAoC,EAAE,EAAE,CAAC,CAAA;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;IACtE,IAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,CAAA;IAE3C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QACtB,OAAO,KAAK,CAAA;KACf;IACD,gEAAgE;IAChE,mFAAmF;IACnF,mBAAmB;IACnB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,eAAe,CAAA;AACtE,CAAC","sourcesContent":["import { Breaker, EventHandler, Properties } from '../types'\nimport {\n _isArray,\n _isDate,\n _isFunction,\n _isNull,\n _isObject,\n _isString,\n _isUndefined,\n hasOwnProperty,\n} from './type-utils'\nimport { logger } from './logger'\nimport { window, document, nativeForEach, nativeIndexOf } 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 const _bind_instance_methods = function (obj: Record<string, any>): void {\n for (const func in obj) {\n if (_isFunction(obj[func])) {\n obj[func] = obj[func].bind(obj)\n }\n }\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 (_isNull(obj) || _isUndefined(obj)) {\n return\n }\n if (_isArray(obj)) {\n return _eachArray(obj, iterator, thisArg)\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 (error) {\n return false\n }\n return true\n}\n\nexport const _encodeDates = function (obj: Properties): Properties {\n _each(obj, function (v, k) {\n if (_isDate(v)) {\n obj[k] = _formatDate(v)\n } else if (_isObject(v)) {\n obj[k] = _encodeDates(v) // recurse\n }\n })\n return obj\n}\n\nexport const _timestamp = function (): number {\n Date.now =\n Date.now ||\n function () {\n return +new Date()\n }\n return Date.now()\n}\n\nexport const _formatDate = function (d: Date): string {\n // YYYY-MM-DDTHH:MM:SS in UTC\n function pad(n: number) {\n return n < 10 ? '0' + n : n\n }\n return (\n d.getUTCFullYear() +\n '-' +\n pad(d.getUTCMonth() + 1) +\n '-' +\n pad(d.getUTCDate()) +\n 'T' +\n pad(d.getUTCHours()) +\n ':' +\n pad(d.getUTCMinutes()) +\n ':' +\n pad(d.getUTCSeconds())\n )\n}\n\nexport const _try = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch (e) {\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('Implementation error. Please turn on debug and contact support@posthog.com.')\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const _safewrap_class = 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 _safewrap_instance_methods = function (obj: Record<string, any>): void {\n for (const func in obj) {\n if (_isFunction(obj[func])) {\n obj[func] = _safewrap(obj[func])\n }\n }\n}\n\nexport const _strip_empty_properties = 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\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\nconst LONG_STRINGS_ALLOW_LIST = ['$performance_raw']\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, key) => {\n if (key && LONG_STRINGS_ALLOW_LIST.indexOf(key as string) > -1) {\n return value\n }\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 _register_event = (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 loadScript(scriptUrlToLoad: string, callback: (error?: string | Event, event?: Event) => void): void {\n const addScript = () => {\n if (!document) {\n return callback('document not found')\n }\n const scriptTag = document.createElement('script')\n scriptTag.type = 'text/javascript'\n scriptTag.src = scriptUrlToLoad\n scriptTag.onload = (event) => callback(undefined, event)\n scriptTag.onerror = (error) => callback(error)\n\n const scripts = document.querySelectorAll('body > script')\n if (scripts.length > 0) {\n scripts[0].parentNode?.insertBefore(scriptTag, scripts[0])\n } else {\n // In exceptional situations this call might load before the DOM is fully ready.\n document.body.appendChild(scriptTag)\n }\n }\n\n if (document?.body) {\n addScript()\n } else {\n document?.addEventListener('DOMContentLoaded', addScript)\n }\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAY,EACZ,cAAc,GACjB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE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QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE;QAChB,SAAS,EAAE,CAAA;KACd;SAAM;QACH,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAA;KAC5D;AACL,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,gBAAsC;IACtE,IAAM,QAAQ,GAAG,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,QAAQ,CAAA;IAE3C,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE;QACtB,OAAO,KAAK,CAAA;KACf;IACD,gEAAgE;IAChE,mFAAmF;IACnF,mBAAmB;IACnB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,eAAe,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAChD,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import { Breaker, EventHandler, Properties } from '../types'\nimport {\n _isArray,\n _isDate,\n _isFunction,\n _isNull,\n _isObject,\n _isString,\n _isUndefined,\n hasOwnProperty,\n} from './type-utils'\nimport { logger } from './logger'\nimport { window, document, nativeForEach, nativeIndexOf } 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 const _bind_instance_methods = function (obj: Record<string, any>): void {\n for (const func in obj) {\n if (_isFunction(obj[func])) {\n obj[func] = obj[func].bind(obj)\n }\n }\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 (_isNull(obj) || _isUndefined(obj)) {\n return\n }\n if (_isArray(obj)) {\n return _eachArray(obj, iterator, thisArg)\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 (error) {\n return false\n }\n return true\n}\n\nexport const _encodeDates = function (obj: Properties): Properties {\n _each(obj, function (v, k) {\n if (_isDate(v)) {\n obj[k] = _formatDate(v)\n } else if (_isObject(v)) {\n obj[k] = _encodeDates(v) // recurse\n }\n })\n return obj\n}\n\nexport const _timestamp = function (): number {\n Date.now =\n Date.now ||\n function () {\n return +new Date()\n }\n return Date.now()\n}\n\nexport const _formatDate = function (d: Date): string {\n // YYYY-MM-DDTHH:MM:SS in UTC\n function pad(n: number) {\n return n < 10 ? '0' + n : n\n }\n return (\n d.getUTCFullYear() +\n '-' +\n pad(d.getUTCMonth() + 1) +\n '-' +\n pad(d.getUTCDate()) +\n 'T' +\n pad(d.getUTCHours()) +\n ':' +\n pad(d.getUTCMinutes()) +\n ':' +\n pad(d.getUTCSeconds())\n )\n}\n\nexport const _try = function <T>(fn: () => T): T | undefined {\n try {\n return fn()\n } catch (e) {\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('Implementation error. Please turn on debug and contact support@posthog.com.')\n logger.critical(e)\n }\n } as F\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport const _safewrap_class = 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 _safewrap_instance_methods = function (obj: Record<string, any>): void {\n for (const func in obj) {\n if (_isFunction(obj[func])) {\n obj[func] = _safewrap(obj[func])\n }\n }\n}\n\nexport const _strip_empty_properties = 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\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\nconst LONG_STRINGS_ALLOW_LIST = ['$performance_raw']\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, key) => {\n if (key && LONG_STRINGS_ALLOW_LIST.indexOf(key as string) > -1) {\n return value\n }\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 _register_event = (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 loadScript(scriptUrlToLoad: string, callback: (error?: string | Event, event?: Event) => void): void {\n const addScript = () => {\n if (!document) {\n return callback('document not found')\n }\n const scriptTag = document.createElement('script')\n scriptTag.type = 'text/javascript'\n scriptTag.src = scriptUrlToLoad\n scriptTag.onload = (event) => callback(undefined, event)\n scriptTag.onerror = (error) => callback(error)\n\n const scripts = document.querySelectorAll('body > script')\n if (scripts.length > 0) {\n scripts[0].parentNode?.insertBefore(scriptTag, scripts[0])\n } else {\n // In exceptional situations this call might load before the DOM is fully ready.\n document.body.appendChild(scriptTag)\n }\n }\n\n if (document?.body) {\n addScript()\n } else {\n document?.addEventListener('DOMContentLoaded', addScript)\n }\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.93.2",
3
+ "version": "1.93.4",
4
4
  "description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
5
5
  "repository": "https://github.com/PostHog/posthog-js",
6
6
  "author": "hey@posthog.com",