posthog-js 1.121.3 → 1.121.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.
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/es.js +1 -1
- package/dist/es.js.map +1 -1
- package/dist/lib/src/autocapture.d.ts +19 -24
- package/dist/lib/src/extensions/rageclick.d.ts +1 -2
- package/dist/lib/src/posthog-core.d.ts +3 -3
- package/dist/lib/src/types.d.ts +0 -9
- package/dist/lib/src/utils/index.d.ts +0 -2
- package/dist/module.d.ts +32 -12
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/recorder-v2.js.map +1 -1
- package/dist/recorder.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/autocapture-utils.js.map +1 -1
- package/lib/src/autocapture.d.ts +19 -24
- package/lib/src/autocapture.js +114 -168
- package/lib/src/autocapture.js.map +1 -1
- package/lib/src/decide.js +5 -6
- package/lib/src/decide.js.map +1 -1
- package/lib/src/extensions/rageclick.d.ts +1 -2
- package/lib/src/extensions/rageclick.js +1 -5
- package/lib/src/extensions/rageclick.js.map +1 -1
- package/lib/src/posthog-core.d.ts +3 -3
- package/lib/src/posthog-core.js +2 -24
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/types.d.ts +0 -9
- package/lib/src/types.js.map +1 -1
- package/lib/src/utils/index.d.ts +0 -2
- package/lib/src/utils/index.js +0 -14
- package/lib/src/utils/index.js.map +1 -1
- package/package.json +1 -1
package/lib/src/types.d.ts
CHANGED
|
@@ -224,10 +224,6 @@ export type FlagVariant = {
|
|
|
224
224
|
};
|
|
225
225
|
export interface DecideResponse {
|
|
226
226
|
supportedCompression: Compression[];
|
|
227
|
-
config: {
|
|
228
|
-
enable_collect_everything: boolean;
|
|
229
|
-
};
|
|
230
|
-
custom_properties: AutoCaptureCustomProperty[];
|
|
231
227
|
featureFlags: Record<string, string | boolean>;
|
|
232
228
|
featureFlagPayloads: Record<string, JsonType>;
|
|
233
229
|
errorsWhileComputingFlags: boolean;
|
|
@@ -265,11 +261,6 @@ export interface DecideResponse {
|
|
|
265
261
|
export type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>, context?: {
|
|
266
262
|
errorsLoading?: boolean;
|
|
267
263
|
}) => void;
|
|
268
|
-
export interface AutoCaptureCustomProperty {
|
|
269
|
-
name: string;
|
|
270
|
-
css_selector: string;
|
|
271
|
-
event_selectors: string[];
|
|
272
|
-
}
|
|
273
264
|
export interface GDPROptions {
|
|
274
265
|
capture?: (event: string, properties: Properties, options: CaptureOptions) => void; /** function used for capturing a PostHog event to record the opt-in action */
|
|
275
266
|
captureEventName?: string; /** event name to be used for capturing the opt-in action */
|
package/lib/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAuMA,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'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n */\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 * 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\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 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 disable_surveys: 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 of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: 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 /** @deprecated - use `property_denylist` instead */\n property_blacklist: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: any\n __preview_send_client_session_params?: boolean\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 `process_person` config setting. There are three options:\n * - `process_person: 'always'` _(default)_ - we will process persons data for all events\n * - `process_person: '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: False`.\n * - `process_person: '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 process_person?: 'always' | 'never' | 'identified_only'\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n 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 // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => 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 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 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 type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n}\n\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?: 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"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAuMA,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'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport interface CaptureResult {\n uuid: string\n event: string\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n */\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 * 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\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 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 disable_surveys: 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 of user agent filtering such as googlebot or other bots. Defaults to `false` */\n opt_out_useragent_filter: 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 /** @deprecated - use `property_denylist` instead */\n property_blacklist: string[]\n property_denylist: string[]\n request_headers: { [header_name: string]: string }\n on_request_error?: (error: RequestResponse) => void\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n inapp_protocol: string\n inapp_link_new_window: boolean\n request_batching: boolean\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n properties_string_max_length: number\n session_recording: SessionRecordingOptions\n session_idle_timeout_seconds: number\n mask_all_element_attributes: boolean\n mask_all_text: boolean\n advanced_disable_decide: boolean\n advanced_disable_feature_flags: boolean\n advanced_disable_feature_flags_on_first_load: boolean\n advanced_disable_toolbar_metrics: boolean\n feature_flag_request_timeout_ms: number\n get_device_id: (uuid: string) => string\n name: string\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n capture_performance?: boolean\n // Should only be used for testing. Could negatively impact performance.\n disable_compression: boolean\n bootstrap: BootstrapConfig\n segment?: any\n __preview_send_client_session_params?: boolean\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 `process_person` config setting. There are three options:\n * - `process_person: 'always'` _(default)_ - we will process persons data for all events\n * - `process_person: '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: False`.\n * - `process_person: '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 process_person?: 'always' | 'never' | 'identified_only'\n}\n\nexport interface OptInOutCapturingOptions {\n capture: (event: string, properties: Properties, options: CaptureOptions) => void\n capture_event_name: string\n capture_properties: Properties\n enable_persistence: boolean\n clear_persistence: boolean\n persistence_type: 'cookie' | 'localStorage' | 'localStorage+cookie'\n cookie_prefix: string\n cookie_expiration: number\n cross_subdomain_cookie: boolean\n secure_cookie: boolean\n}\n\nexport interface IsFeatureEnabledOptions {\n send_event: boolean\n}\n\nexport interface SessionRecordingOptions {\n blockClass?: string | RegExp\n blockSelector?: string | null\n ignoreClass?: string\n maskTextClass?: string | RegExp\n maskTextSelector?: string | null\n maskTextFn?: ((text: string, element: HTMLElement | null) => string) | null\n maskAllInputs?: boolean\n maskInputOptions?: MaskInputOptions\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n slimDOMOptions?: SlimDOMOptions | 'all' | true\n collectFonts?: boolean\n inlineStylesheet?: boolean\n recordCrossOriginIframes?: boolean\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n /** Modify the network request before it is captured. Returning null or undefined stops it being captured */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n // our settings here only support a subset of those proposed for rrweb's network capture plugin\n recordHeaders?: boolean\n recordBody?: boolean\n}\n\nexport type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\nexport interface RequestOptions {\n url: string\n // Data can be a single object or an array of objects when batched\n data?: Record<string, any> | Record<string, any>[]\n headers?: Record<string, any>\n transport?: 'XHR' | 'fetch' | 'sendBeacon'\n method?: 'POST' | 'GET'\n urlQueryArgs?: { compression: Compression }\n callback?: RequestCallback\n timeout?: number\n noRetries?: boolean\n compression?: Compression | 'best-available'\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestOptions extends RequestOptions {\n batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestOptions extends QueuedRequestOptions {\n retriesPerformedSoFar?: number\n}\n\nexport interface CaptureOptions {\n $set?: Properties /** used with $identify */\n $set_once?: Properties /** used with $identify */\n _url?: string /** Used to override the desired endpoint for the captured event */\n _batchKey?: string /** key of queue, e.g. 'sessionRecording' vs 'event' */\n _noTruncate?: boolean /** if set, overrides and disables config.properties_string_max_length */\n send_instantly?: boolean /** if set skips the batched queue */\n transport?: RequestOptions['transport'] /** if set, overrides the desired transport method */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport interface DecideResponse {\n supportedCompression: Compression[]\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n autocapture_opt_out?: boolean\n 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 // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n recordCanvas?: boolean | null\n canvasFps?: number | null\n // the API returns a decimal between 0 and 1 as a string\n canvasQuality?: string | null\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n }\n surveys?: boolean\n toolbarParams: ToolbarParams\n editorParams?: ToolbarParams /** @deprecated, renamed to toolbarParams, still present on older API responses */\n toolbarVersion: 'toolbar' /** @deprecated, moved to toolbarParams */\n isAuthenticated: boolean\n siteApps: { id: number; url: string }[]\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\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 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 type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonType = string | number | boolean | null | { [key: string]: JsonType } | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n}\n\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?: 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"]}
|
package/lib/src/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Breaker, EventHandler, Properties } from '../types';
|
|
2
2
|
export declare const _trim: (str: string) => string;
|
|
3
|
-
export declare const _bind_instance_methods: (obj: Record<string, any>) => void;
|
|
4
3
|
export declare function _eachArray<E = any>(obj: E[] | null | undefined, iterator: (value: E, key: number) => void | Breaker, thisArg?: any): void;
|
|
5
4
|
/**
|
|
6
5
|
* @param {*=} obj
|
|
@@ -23,7 +22,6 @@ export declare const _formatDate: (d: Date) => string;
|
|
|
23
22
|
export declare const _try: <T>(fn: () => T) => T | undefined;
|
|
24
23
|
export declare const _safewrap: <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F) => F;
|
|
25
24
|
export declare const _safewrap_class: (klass: Function, functions: string[]) => void;
|
|
26
|
-
export declare const _safewrap_instance_methods: (obj: Record<string, any>) => void;
|
|
27
25
|
export declare const _strip_empty_properties: (p: Properties) => Properties;
|
|
28
26
|
export declare const _strip_leading_dollar: (s: string) => string;
|
|
29
27
|
export declare function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(object: T, maxStringLength: number | null): T;
|
package/lib/src/utils/index.js
CHANGED
|
@@ -18,13 +18,6 @@ var breaker = {};
|
|
|
18
18
|
export var _trim = function (str) {
|
|
19
19
|
return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
|
20
20
|
};
|
|
21
|
-
export var _bind_instance_methods = function (obj) {
|
|
22
|
-
for (var func in obj) {
|
|
23
|
-
if (_isFunction(obj[func])) {
|
|
24
|
-
obj[func] = obj[func].bind(obj);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
21
|
export function _eachArray(obj, iterator, thisArg) {
|
|
29
22
|
if (_isArray(obj)) {
|
|
30
23
|
if (nativeForEach && obj.forEach === nativeForEach) {
|
|
@@ -200,13 +193,6 @@ export var _safewrap_class = function (klass, functions) {
|
|
|
200
193
|
klass.prototype[functions[i]] = _safewrap(klass.prototype[functions[i]]);
|
|
201
194
|
}
|
|
202
195
|
};
|
|
203
|
-
export var _safewrap_instance_methods = function (obj) {
|
|
204
|
-
for (var func in obj) {
|
|
205
|
-
if (_isFunction(obj[func])) {
|
|
206
|
-
obj[func] = _safewrap(obj[func]);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
196
|
export var _strip_empty_properties = function (p) {
|
|
211
197
|
var ret = {};
|
|
212
198
|
_each(p, function (v, k) {
|
|
@@ -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,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,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;AAChE,CAAC,CAAA;AAED,MAAM,CAAC,IAAM,sBAAsB,GAAG,UAAU,GAAwB;IACpE,KAAK,IAAM,IAAI,IAAI,G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AQ,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 _isFormData,\n _isFunction,\n _isNull,\n _isNullish,\n _isObject,\n _isString,\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 (_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 (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(\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/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\nexport const _strip_leading_dollar = 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 _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"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,EACH,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,SAAS,EACT,SAAS,EACT,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;AAChE,CAAC,CAAA;AAED,MAAM,UAAU,UAAU,CACtB,GAA2B,EAC3B,QAAmD,EACnD,OAAa;IAEb,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE;QACf,IAAI,aAAa,IAAI,GAAG,CAAC,OAAO,KAAK,aAAa,EAAE;YAChD,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;SACjC;aAAM,IAAI,QAAQ,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE;YACtD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACxC,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAA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,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;SAC7D;aAAM;YACH,gFAAgF;YAChF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;SACvC;IACL,CAAC,CAAA;IAED,IAAI,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 _isFormData,\n _isFunction,\n _isNull,\n _isNullish,\n _isObject,\n _isString,\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 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 (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(\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/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 _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\nexport const _strip_leading_dollar = 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 _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