posthog-js 1.288.1 → 1.290.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/array.full.es5.js +1 -1
  2. package/dist/array.full.es5.js.map +1 -1
  3. package/dist/array.full.js +1 -1
  4. package/dist/array.full.js.map +1 -1
  5. package/dist/array.full.no-external.js +1 -1
  6. package/dist/array.full.no-external.js.map +1 -1
  7. package/dist/array.js +1 -1
  8. package/dist/array.js.map +1 -1
  9. package/dist/array.no-external.js +1 -1
  10. package/dist/array.no-external.js.map +1 -1
  11. package/dist/customizations.full.js +1 -1
  12. package/dist/lazy-recorder.js +1 -1
  13. package/dist/main.js +1 -1
  14. package/dist/main.js.map +1 -1
  15. package/dist/module.d.ts +17 -0
  16. package/dist/module.full.d.ts +17 -0
  17. package/dist/module.full.js +1 -1
  18. package/dist/module.full.js.map +1 -1
  19. package/dist/module.full.no-external.d.ts +17 -0
  20. package/dist/module.full.no-external.js +1 -1
  21. package/dist/module.full.no-external.js.map +1 -1
  22. package/dist/module.js +1 -1
  23. package/dist/module.js.map +1 -1
  24. package/dist/module.no-external.d.ts +17 -0
  25. package/dist/module.no-external.js +1 -1
  26. package/dist/module.no-external.js.map +1 -1
  27. package/dist/posthog-recorder.js +1 -1
  28. package/dist/src/posthog-core.d.ts +3 -0
  29. package/dist/src/types.d.ts +14 -0
  30. package/dist/surveys-preview.d.ts +17 -0
  31. package/lib/package.json +1 -1
  32. package/lib/src/entrypoints/array.full.es5.js +9 -0
  33. package/lib/src/entrypoints/array.full.es5.js.map +1 -1
  34. package/lib/src/posthog-core.d.ts +3 -0
  35. package/lib/src/posthog-core.js +129 -27
  36. package/lib/src/posthog-core.js.map +1 -1
  37. package/lib/src/types.d.ts +14 -0
  38. package/lib/src/types.js.map +1 -1
  39. package/package.json +1 -1
  40. package/react/dist/esm/index.js +42 -24
  41. package/react/dist/esm/index.js.map +1 -1
  42. package/react/dist/types/index.d.ts +5 -2
  43. package/react/dist/umd/index.js +42 -24
  44. package/react/dist/umd/index.js.map +1 -1
@@ -566,6 +566,20 @@ export interface PostHogConfig {
566
566
  * @default 'unset'
567
567
  */
568
568
  defaults: ConfigDefaults;
569
+ /**
570
+ * EXPERIMENTAL: Defers initialization of non-critical extensions (autocapture, session recording, etc.)
571
+ * to the next event loop tick using setTimeout. This reduces main thread blocking during SDK
572
+ * initialization for better page load performance, while keeping critical functionality
573
+ * (persistence, sessions, capture) available immediately.
574
+ *
575
+ * When enabled:
576
+ * - Persistence, sessions, and basic capture work immediately
577
+ * - Extensions (autocapture, recording, heatmaps, etc.) start after yielding back to the browser
578
+ *
579
+ * @default false (will be true for defaults >= '2025-11-06' in the future)
580
+ * @experimental
581
+ */
582
+ __preview_deferred_init_extensions: boolean;
569
583
  /**
570
584
  * Determines the session recording options.
571
585
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAYa,QAAA,sBAAsB,GAAG,mBAAmB,CAAA;AA6vCzD,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,iCAAkB,CAAA;IAClB,gCAAiB,CAAA;AACrB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAkiBD,2EAA2E;AAC3E,yEAAyE;AACzE,iFAAiF;AACpE,QAAA,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA","sourcesContent":["import type { recordOptions } from './extensions/replay/types/rrweb'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { PostHog } from './posthog-core'\nimport { KnownUnsafeEditableEvent } from '@posthog/core'\nimport { Survey, SurveyConfig } from './posthog-surveys-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SAMPLED } from './extensions/replay/external/triggerMatching'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n *\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 `div`s 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 * Everything is allowed when there's no allowlist\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 /**\n * When set to true, autocapture will capture the text of any element that is cut or copied.\n */\n capture_copied_text?: boolean\n}\n\nexport interface RageclickConfig {\n /**\n * List of CSS selectors to ignore rageclicks on\n * e.g. ['.my-calendar-button']\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 ignore list config `['[id]']`\n * we will ignore the rageclick if the click-target or its parents has any id\n *\n * Nothing is ignored when there's an empty ignorelist, e.g. []\n * If no ignorelist is set, we default to ignoring .ph-no-rageclick\n * If an element has .ph-no-capture, it will always be ignored by rageclick and autocapture\n */\n css_selector_ignorelist?: string[]\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /**\n * Works with session replay to use the browser's native performance observer to capture performance metrics\n */\n network_timing?: boolean\n\n /**\n * Use chrome's web vitals library to wrap fetch and capture web vitals\n */\n web_vitals?: boolean\n\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n *\n * @default 15 * 60 * 1000 (15 minutes)\n */\n __web_vitals_max_value?: number\n\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n *\n * @default ['LCP', 'CLS', 'FCP', 'INP']\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n\n /**\n * We delay flushing web vitals metrics to reduce the number of events we send\n * This is the maximum time we will wait before sending the metrics\n *\n * @default 5000\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type ExceptionAutoCaptureConfig = {\n /**\n * Determines whether PostHog should capture unhandled errors.\n *\n * @default true\n */\n capture_unhandled_errors: boolean\n\n /**\n * Determines whether PostHog should capture unhandled promise rejections.\n *\n * @default true\n */\n capture_unhandled_rejections: boolean\n\n /**\n * Determines whether PostHog should capture console errors.\n *\n * @default false\n */\n capture_console_errors: boolean\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n /**\n * We'll not consider a click to be a dead click, if it's followed by a scroll within `scroll_threshold_ms` milliseconds\n *\n * @default 100\n */\n scroll_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a selection change within `selection_change_threshold_ms` milliseconds\n *\n * @default 100\n */\n selection_change_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a mutation within `mutation_threshold_ms` milliseconds\n *\n * @default 2500\n */\n mutation_threshold_ms?: number\n\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by our own SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /**\n * How often to send batched data in `$heatmap_data` events\n * If set to 0 or not set, sends using the default interval of 1 second\n *\n * @default 1000\n */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\nexport type ConfigDefaults = '2025-05-24' | 'unset'\n\nexport type ExternalIntegrationKind = 'intercom' | 'crispChat'\n\n/**\n * Configuration options for the PostHog JavaScript SDK.\n * @see https://posthog.com/docs/libraries/js#config\n */\nexport interface PostHogConfig {\n /** URL of your PostHog instance.\n *\n * @default 'https://us.i.posthog.com'\n */\n api_host: string\n\n /**\n * URL to use for feature flag requests specifically.\n * If not set, feature flag requests will use the URL derived from `api_host`.\n * This is useful when you want to route feature flag requests to a different endpoint than other analytic APIs.\n *\n * @default null\n */\n flags_api_host?: string | null\n\n /**\n * If using a reverse proxy for `api_host` then this should be the actual PostHog app URL (e.g. https://us.posthog.com).\n * This ensures that links to PostHog point to the correct host.\n *\n * @default null\n */\n ui_host: string | null\n\n /**\n * The transport method to use for API requests.\n *\n * @default 'fetch'\n */\n api_transport?: 'XHR' | 'fetch'\n\n /**\n * The token for your PostHog project.\n * It should NOT be provided manually in the config, but rather passed as the first parameter to `posthog.init()`.\n */\n token: string\n\n /**\n * The name this instance will be identified by.\n * You don't need to set this most of the time,\n * but can be useful if you have several Posthog instances running at the same time.\n *\n * @default 'posthog'\n */\n name: string\n\n /**\n * Determines whether PostHog should autocapture events.\n * This setting does not affect capturing pageview events (see `capture_pageview`).\n *\n * by default autocapture is ignored on elements that match a `ph-no-capture` css class on the element or a parent\n * @default true\n */\n autocapture: boolean | AutocaptureConfig\n\n /**\n * Determines whether PostHog should capture rage clicks.\n *\n * by default rageclicks are ignored on elements that match a `ph-no-capture` or `ph-no-rageclick` css class on the element or a parent\n * @default true\n */\n rageclick: boolean | RageclickConfig\n\n /**\n * Determines if cookie should be set on the top level domain (example.com).\n * If PostHog-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,\n * it'll set the cookie on the subdomain only (test.example.com).\n *\n * NOTE: It will be set to `false` if we detect that the domain is a subdomain of a platform that is excluded from cross-subdomain cookie setting.\n * The current list of excluded platforms is `herokuapp.com`, `vercel.app`, and `netlify.app`.\n *\n * @see `isCrossDomainCookie`\n * @default true\n */\n cross_subdomain_cookie: boolean\n\n /**\n * Determines how PostHog stores information about the user. See [persistence](https://posthog.com/docs/libraries/js#persistence) for details.\n *\n * @default 'localStorage+cookie'\n */\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n\n /**\n * The name for the super properties persistent store\n *\n * @default ''\n */\n persistence_name: string\n\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n\n /**\n * A function to be called once the PostHog scripts have loaded successfully.\n *\n * @param posthog_instance - The PostHog instance that has been loaded.\n */\n loaded: (posthog_instance: PostHog) => void\n\n /**\n * Determines whether PostHog should save referrer information.\n *\n * @default true\n */\n save_referrer: boolean\n\n /**\n * Determines whether PostHog should save marketing parameters.\n * These are `utm_*` paramaters and friends.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default true\n */\n save_campaign_params: boolean\n\n /** @deprecated - Use `save_campaign_params` instead */\n store_google?: boolean\n\n /**\n * Used to extend the list of campaign parameters that are saved by default.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default []\n */\n custom_campaign_params: string[]\n\n /**\n * Used to extend the list of user agents that are blocked by default.\n *\n * @see {DEFAULT_BLOCKED_UA_STRS} from './utils/blocked-uas' - Default list of blocked user agents.\n * @default []\n */\n custom_blocked_useragents: string[]\n\n /**\n * Determines whether PostHog should be in debug mode.\n * You can enable this to get more detailed logging.\n *\n * You can also enable this on your website by appending `?__posthog_debug=true` at the end of your URL\n * You can also call `posthog.debug()` in your code to enable debug mode\n *\n * @default false\n */\n debug: boolean\n\n /** @deprecated Use `debug` instead */\n verbose?: boolean\n\n /**\n * Determines whether PostHog should capture pageview events automatically.\n * Can be:\n * - `true`: Capture regular pageviews (default)\n * - `false`: Don't capture any pageviews\n * - `'history_change'`: Only capture pageviews on history API changes (pushState, replaceState, popstate)\n *\n * @default true\n */\n capture_pageview: boolean | 'history_change'\n\n /**\n * Determines whether PostHog should capture pageleave events.\n * If set to `true`, it will capture pageleave events for all pages.\n * If set to `'if_capture_pageview'`, it will only capture pageleave events if `capture_pageview` is also set to `true` or `'history_change'`.\n *\n * @default 'if_capture_pageview'\n */\n capture_pageleave: boolean | 'if_capture_pageview'\n\n /**\n * Determines the number of days to store cookies for.\n *\n * @default 365\n */\n cookie_expiration: number\n\n /**\n * Determines whether PostHog should upgrade old cookies.\n * If set to `true`, the library will check for a cookie from our old js library and import super properties from it, then the old cookie is deleted.\n * This option only works in the initialization, so make sure you set it when you create the library.\n *\n * @default false\n */\n upgrade: boolean\n\n /**\n * Determines whether PostHog should disable session recording.\n *\n * @default false\n */\n disable_session_recording: boolean\n\n /**\n * Determines whether PostHog should disable persistence.\n * If set to `true`, the library will not save any data to the browser. It will also delete any data previously saved to the browser.\n *\n * @default false\n */\n disable_persistence: boolean\n\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n\n /**\n * Determines whether PostHog should disable all surveys functionality.\n *\n * @default false\n */\n disable_surveys: boolean\n\n /**\n * Determines whether PostHog should disable automatic display of surveys. If this is true, popup or widget surveys will not be shown when display conditions are met.\n *\n * @default false\n */\n disable_surveys_automatic_display: boolean\n\n /**\n * Survey-specific configuration options.\n *\n * @default undefined\n */\n surveys?: SurveyConfig\n\n /**\n * Determines whether PostHog should disable web experiments.\n *\n * Currently disabled while we're in BETA. It will be toggled to `true` in a future release.\n *\n * @default true\n */\n disable_web_experiments: boolean\n\n /**\n * Determines whether PostHog should disable any external dependency loading.\n * This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps.\n *\n * @default false\n */\n disable_external_dependency_loading: boolean\n\n /**\n * A function to be called when a script is being loaded.\n * This can be used to modify the script before it is loaded.\n * This is useful for adding a nonce to the script, for example.\n *\n * @param script - The script element that is being loaded.\n * @returns The modified script element, or null if the script should not be loaded.\n */\n prepare_external_dependency_script?: (script: HTMLScriptElement) => HTMLScriptElement | null\n\n /**\n * A function to be called when a stylesheet is being loaded.\n * This can be used to modify the stylesheet before it is loaded.\n * This is useful for adding a nonce to the stylesheet, for example.\n *\n * @param stylesheet - The stylesheet element that is being loaded.\n * @returns The modified stylesheet element, or null if the stylesheet should not be loaded.\n */\n prepare_external_dependency_stylesheet?: (stylesheet: HTMLStyleElement) => HTMLStyleElement | null\n\n /**\n * Determines whether PostHog should enable recording console logs.\n * When undefined, it falls back to the remote config setting.\n *\n * @default undefined\n */\n enable_recording_console_log?: boolean\n\n /**\n * Determines whether PostHog should use secure cookies.\n * If this is `true`, PostHog cookies will be marked as secure,\n * meaning they will only be transmitted over HTTPS.\n *\n * @default window.location.protocol === 'https:'\n */\n secure_cookie: boolean\n\n /**\n * Determines if users should be opted out of PostHog tracking by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_capturing_by_default: boolean\n\n /**\n * Determines where we'll save the information about whether users are opted out of capturing.\n *\n * @default 'localStorage'\n */\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n\n /**\n * Determines if users should be opted out of browser data storage by this PostHog instance by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_persistence_by_default?: boolean\n\n /**\n * Determines if users should be opted out of user agent filtering such as googlebot or other bots.\n * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,\n * but will process all events as if they were from a browser.\n *\n * @default false\n */\n opt_out_useragent_filter: boolean\n\n /** @deprecated Use `consent_persistence_name` instead. This will be removed in a future major version. **/\n opt_out_capturing_cookie_prefix: string | null\n\n /**\n * Determines the key for the cookie / local storage used to store the information about whether users are opted in/out of capturing.\n * When `null`, we used a key based on your token.\n *\n * @default null\n * @see `ConsentManager._storageKey`\n */\n consent_persistence_name: string | null\n\n /**\n * Determines if users should be opted in to site apps.\n *\n * @default false\n */\n opt_in_site_apps: boolean\n\n /**\n * Determines whether PostHog should respect the Do Not Track header when computing\n * consent in `ConsentManager`.\n *\n * @see `ConsentManager`\n * @default false\n */\n respect_dnt: boolean\n\n /**\n * A list of properties that should never be sent with capture calls.\n *\n * @default []\n */\n property_denylist: string[]\n\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n\n /**\n * A list of headers that should be sent with requests to the PostHog API.\n *\n * @default {}\n */\n request_headers: { [header_name: string]: string }\n\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n\n /**\n * A function that is called when a request to the PostHog API fails.\n *\n * @param error - The `RequestResponse` object that occurred.\n */\n on_request_error?: (error: RequestResponse) => void\n\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n\n /**\n * Determines whether PostHog should batch requests to the PostHog API.\n *\n * @default true\n */\n request_batching: boolean\n\n /**\n * Determines the maximum length of the properties string that can be sent with capture calls.\n *\n * @default 65535\n */\n properties_string_max_length: number\n\n /**\n * Configuration defaults for breaking changes. When set to a specific date,\n * enables new default behaviors that were introduced on that date.\n *\n * - `'unset'`: Use legacy default behaviors\n * - `'2025-05-24'`: Use updated default behaviors (e.g. capture_pageview defaults to 'history_change')\n *\n * @default 'unset'\n */\n defaults: ConfigDefaults\n\n /**\n * Determines the session recording options.\n *\n * @see `SessionRecordingOptions`\n * @default {}\n */\n session_recording: SessionRecordingOptions\n\n /**\n * Determines the error tracking options.\n *\n * @see `ErrorTrackingOptions`\n * @default {}\n */\n error_tracking: ErrorTrackingOptions\n\n /**\n * Determines the session idle timeout in seconds.\n * Any new event that's happened after this timeout will create a new session.\n *\n * @default 30 * 60 -- 30 minutes\n */\n session_idle_timeout_seconds: number\n\n /**\n * Prevent autocapture from capturing any attribute names on elements.\n *\n * @default false\n */\n mask_all_element_attributes: boolean\n\n /**\n * Prevent autocapture from capturing `textContent` on elements.\n *\n * @default false\n */\n mask_all_text: boolean\n\n /**\n * Mask personal data properties from the current URL.\n * This will mask personal data properties such as advertising IDs (gclid, fbclid, etc.), and you can also add\n * custom properties to mask with `custom_personal_data_properties`.\n * @default false\n * @see {PERSONAL_DATA_CAMPAIGN_PARAMS} - Default campaign parameters that are masked by default.\n * @see {PostHogConfig.custom_personal_data_properties} - Custom list of personal data properties to mask.\n */\n mask_personal_data_properties: boolean\n\n /**\n * Custom list of personal data properties to mask.\n *\n * E.g. if you added `email` to this list, then any `email` property in the URL will be masked.\n * https://www.example.com/login?email=john.doe%40example.com => https://www.example.com/login?email=<MASKED>\n *\n * @default []\n * @see {PostHogConfig.mask_personal_data_properties} - Must be enabled for this to take effect.\n */\n custom_personal_data_properties: string[]\n\n /**\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /flags endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend, and it also contains\n * feature flag evaluation information for the current user.\n *\n * This endpoint is required to run most features of this library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * WARNING: Disabling this will also prevent remote configuration from loading,\n * which could mean features like web vitals, surveys, and other features configured\n * in PostHog settings are disabled unless explicitly enabled via client-side config.\n * When setting this to true, make sure to explicitly configure any features you\n * want to use (e.g., capture_performance, autocapture, etc.) in your SDK's init config.\n *\n * @default false\n */\n advanced_disable_flags?: boolean\n\n /**\n * @deprecated Use `advanced_disable_flags` instead. This will be removed in a future major version.\n *\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /decide endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend.\n *\n * This endpoint is required to run most features of the library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * @default false\n */\n advanced_disable_decide?: boolean\n\n /**\n * Will keep /flags running, but without evaluating any feature flags.\n * Useful for when you need to load the config data associated with the flags endpoint\n * (e.g. /flags?v=2&config=true) without evaluating any feature flags. Most folks use this\n * to save money on feature flag evaluation (by bootstrapping feature flags on the server side).\n *\n * @default false\n */\n advanced_disable_feature_flags: boolean\n\n /**\n * Stops from firing feature flag requests on first page load.\n * Only requests feature flags when user identity or properties are updated,\n * or you manually request for flags to be loaded.\n *\n * @default false\n */\n advanced_disable_feature_flags_on_first_load: boolean\n\n /**\n * Evaluation environments for feature flags.\n * When set, only feature flags that have at least one matching evaluation tag\n * will be evaluated for this SDK instance. Feature flags with no evaluation tags\n * will always be evaluated.\n *\n * Examples: ['production', 'web', 'checkout']\n *\n * @default undefined\n */\n evaluation_environments?: readonly string[]\n\n /**\n * Determines whether PostHog should disable toolbar metrics.\n * This is our internal instrumentation for our toolbar in your website.\n *\n * @default false\n */\n advanced_disable_toolbar_metrics: boolean\n\n /**\n * Determines whether PostHog should only evaluate feature flags for surveys.\n * Useful for when you want to use this library to evaluate feature flags for surveys only but you have additional feature flags\n * that you evaluate on the server side.\n *\n * @default false\n */\n advanced_only_evaluate_survey_feature_flags: boolean\n /**\n * When this is enabled, surveys will always be initialized, regardless of the /flags response or remote config settings.\n * This is useful if you want to use surveys but disable all other flag-dependent functionality.\n * Used internally for displaying external surveys without making a /flags request.\n *\n * @default false\n */\n advanced_enable_surveys: boolean\n\n /**\n * Sets timeout for fetching feature flags\n *\n * @default 3000\n */\n feature_flag_request_timeout_ms: number\n\n /**\n * Sets timeout for fetching surveys\n *\n * @default 10000\n */\n surveys_request_timeout_ms: number\n\n /**\n * Function to get the device ID.\n * This doesn't usually need to be set, but can be useful if you want to use a custom device ID.\n *\n * @param uuid - The UUID we would use for the device ID.\n * @returns The device ID.\n *\n * @default (uuid) => uuid\n */\n get_device_id: (uuid: string) => string\n\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n\n /** @deprecated - use `before_send` instead */\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n\n /** @deprecated - use `before_send` instead */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n\n /**\n * Determines whether to capture performance metrics.\n * These include Network Timing and Web Vitals.\n *\n * When `undefined`, fallback to the remote configuration.\n * If `false`, neither network timing nor web vitals will work.\n * If an object, that will override the remote configuration.\n *\n * @see {PerformanceCaptureConfig}\n * @default undefined\n */\n capture_performance?: boolean | PerformanceCaptureConfig\n\n /**\n * Determines whether to disable compression when sending events to the server.\n * WARNING: Should only be used for testing. Could negatively impact performance.\n *\n * @default false\n */\n disable_compression: boolean\n\n /**\n * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,\n * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.\n *\n * Since there is a delay between initializing PostHog and fetching feature flags,\n * feature flags are not always available immediately.\n * This makes them unusable if you want to do something like redirecting a user\n * to a different page based on a feature flag.\n *\n * You can, therefore, fetch the feature flags in your server and pre-fill them here,\n * allowing PostHog to know the feature flag values immediately.\n *\n * After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.\n *\n * @default {}\n */\n bootstrap: BootstrapConfig\n\n /**\n * The segment analytics object.\n *\n * @see https://posthog.com/docs/libraries/segment\n */\n segment?: SegmentAnalytics\n\n /**\n * Determines whether to capture heatmaps.\n *\n * @see {HeatmapConfig}\n * @default undefined\n */\n capture_heatmaps?: boolean | HeatmapConfig\n\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n\n /**\n * Determines whether to capture dead clicks.\n *\n * @see {DeadClicksAutoCaptureConfig}\n * @default undefined\n */\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n\n /**\n * Determines whether to capture exceptions.\n *\n * @see {ExceptionAutoCaptureConfig}\n * @default undefined\n */\n capture_exceptions?: boolean | ExceptionAutoCaptureConfig\n\n /**\n * Determines whether to disable scroll properties.\n * These allow you to keep track of how far down someone scrolled in your website.\n *\n * @default false\n */\n disable_scroll_properties?: boolean\n\n /**\n * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n * It will use `window.document.documentElement` if not specified.\n */\n scroll_root_selector?: string | string[]\n\n /**\n * You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting.\n * There are three options:\n * - `person_profiles: 'always'` - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` _(default)_ - 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 * @default 'identified_only'\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /**\n * Client side rate limiting\n */\n rate_limiting?: {\n /**\n * The average number of events per second that should be permitted\n *\n * @default 10\n */\n events_per_second?: number\n\n /**\n * How many events can be captured in a burst. This defaults to 10 times the events_per_second count\n *\n * @default 10 * `events_per_second`\n */\n events_burst_limit?: number\n }\n\n /**\n * Used when sending data via `fetch`, use with care.\n * This is intentionally meant to be used with NextJS `fetch`\n *\n * Incorrect `cache` usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\n }\n\n /**\n * Used to change the behavior of the request queue.\n * This is an advanced feature and should be used with caution.\n */\n request_queue_config?: RequestQueueConfig\n\n /**\n * Used to set-up external integrations with PostHog data - such as session replays, distinct id, etc.\n */\n integrations?: Record<ExternalIntegrationKind, boolean>\n\n /**\n * Enables cookieless mode. In this mode, PostHog will not set any cookies, or use session or local storage. User\n * identity is handled by generating a privacy-preserving hash on PostHog's servers.\n * - 'always' - enable cookieless mode immediately on startup, use this if you do not intend to show a cookie banner\n * - 'on_reject' - enable cookieless mode only if the user rejects cookies, use this if you want to show a cookie banner. If the user accepts cookies, cookieless mode will not be used, and PostHog will use cookies and local storage as usual.\n *\n * Note that you MUST enable cookieless mode in your PostHog project's settings, otherwise all your cookieless events will be ignored. We plan to remove this requirement in the future.\n * */\n cookieless_mode?: 'always' | 'on_reject'\n\n // ------- PREVIEW CONFIGS -------\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * A list of hostnames for which to inject PostHog tracing headers to all requests\n * (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID, X-POSTHOG-WINDOW-ID)\n * */\n __add_tracing_headers?: string[]\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables the new RemoteConfig approach to loading config instead of /flags?v=2&config=true\n * */\n __preview_remote_config?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to use the new /flags/ endpoint\n * */\n __preview_flags_v2?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - ONLY USE WHEN TALKING TO POSTHOG SUPPORT\n * Enables deprecated eager loading of session recording code, not just rrweb and network plugin\n * we are switching the default to lazy loading because the bundle will ultimately be 18% smaller then\n * keeping this around for a few days in case there are unexpected consequences that testing did not uncover\n * */\n __preview_eager_load_replay?: boolean\n\n /**\n * Prevents posthog-js from using the `navigator.sendBeacon` API to send events.\n * Enabling this option may hurt the reliability of sending $pageleave events\n */\n __preview_disable_beacon?: boolean\n\n /**\n * Disables sending credentials when using XHR requests.\n */\n __preview_disable_xhr_credentials?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables collection of bot traffic as $bot_pageview events with detailed bot detection\n * properties instead of dropping them entirely. Use it alongside opt_out_useragent_filter\n */\n __preview_capture_bot_pageviews?: boolean\n\n // ------- RETIRED CONFIGS - NO REPLACEMENT OR USAGE -------\n\n /**\n * @deprecated - does nothing\n * was present only for PostHog testing of replay lazy loading\n * */\n __preview_lazy_load_replay?: boolean\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n api_method?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_protocol?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_link_new_window?: boolean\n\n /**\n * @deprecated - THIS OPTION HAS NO EFFECT, kept here for backwards compatibility reasons.\n * Use a custom transformation or \"Discard IP data\" project setting instead: @see https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address.\n */\n ip: boolean\n}\n\nexport interface ErrorTrackingOptions {\n /**\n * Decide whether exceptions thrown by browser extensions should be captured\n *\n * @default false\n */\n captureExtensionExceptions?: boolean\n\n /**\n * UNSTABLE: determines whether exception caused by the PostHog SDK will be captured\n *\n * @default false\n */\n __capturePostHogExceptions?: boolean\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 1\n */\n __exceptionRateLimiterRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __exceptionRateLimiterBucketSize?: number\n}\n\nexport interface SessionRecordingOptions {\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-no-capture'\n */\n blockClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default null\n */\n blockSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-ignore-input'\n */\n ignoreClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-mask'\n */\n maskTextClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskAllInputs?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputOptions?: recordOptions['maskInputOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default {}\n */\n slimDOMOptions?: recordOptions['slimDOMOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n collectFonts?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default true\n */\n inlineStylesheet?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordCrossOriginIframes?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordHeaders?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordBody?: boolean\n\n /**\n * Allows local config to override remote canvas recording settings from the flags response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n\n /**\n * Modify the network request before it is captured. Returning null or undefined stops it being captured\n */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n\n /**\n * ADVANCED: while a user is active we take a full snapshot of the browser every interval.\n * For very few sites playback performance might be better with different interval.\n * Set to 0 to disable\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n full_snapshot_interval_millis?: number\n\n /**\n * ADVANCED: whether to partially compress rrweb events before sending them to the server,\n * defaults to true, can be set to false to disable partial compression\n * NB requests are still compressed when sent to the server regardless of this setting\n *\n * @default true\n */\n compress_events?: boolean\n\n /**\n * ADVANCED: alters the threshold before a recording considers a user has become idle.\n * Normally only altered alongside changes to session_idle_timeout_ms.\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n session_idle_threshold_ms?: number\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __mutationThrottlerRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 100\n */\n __mutationThrottlerBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\n\nexport interface RequestWithOptions {\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 disableTransport?: ('XHR' | 'fetch' | 'sendBeacon')[]\n disableXHRCredentials?: boolean\n compression?: Compression | 'best-available'\n fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestWithOptions extends RequestWithOptions {\n /** key of queue, e.g. 'sessionRecording' vs 'event' */\n batchKey?: string\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestWithOptions extends QueuedRequestWithOptions {\n retriesPerformedSoFar?: number\n}\n\n// we used to call a request that was sent to the queue with options attached `RequestQueueOptions`\n// so we can't call the options used to configure the behavior of the RequestQueue that as well,\n// so instead we call them config\nexport interface RequestQueueConfig {\n /**\n * ADVANCED - alters the frequency which PostHog sends events to the server.\n * generally speaking this is only set when apps have automatic page refreshes, or very short visits.\n * Defaults to 3 seconds when not set\n * Allowed values between 250 and 5000\n * */\n flush_interval_ms?: number\n}\n\nexport interface CaptureOptions {\n /**\n * Used when `$identify` is called\n * Will set person properties overriding previous values\n */\n $set?: Properties\n\n /**\n * Used when `$identify` is called\n * Will set person properties but only once, it will NOT override previous values\n */\n $set_once?: Properties\n\n /**\n * Used to override the desired endpoint for the captured event\n */\n _url?: string\n\n /**\n * key of queue, e.g. 'sessionRecording' vs 'event'\n */\n _batchKey?: string\n\n /**\n * If set, overrides and disables config.properties_string_max_length\n */\n _noTruncate?: boolean\n\n /**\n * If set, skips the batched queue\n */\n send_instantly?: boolean\n\n /**\n * If set, skips the client side rate limiting\n */\n skip_client_rate_limiting?: boolean\n\n /**\n * If set, overrides the desired transport method\n */\n transport?: RequestWithOptions['transport']\n\n /**\n * If set, overrides the current timestamp\n */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n /**\n * If set, records the canvas\n *\n * @default false\n */\n recordCanvas?: boolean | null\n\n /**\n * If set, records the canvas at the given FPS\n * Can be set in the remote configuration\n * Limited between 0 and 12\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as 4\n *\n * @default null-ish\n */\n canvasFps?: number | null\n\n /**\n * If set, records the canvas at the given quality\n * Can be set in the remote configuration\n * Must be a string that is a valid decimal between 0 and 1\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as \"0.4\"\n *\n * @default null-ish\n */\n canvasQuality?: string | null\n}\n\n/** the config stored in persistence when session recording remote config is received */\nexport type SessionRecordingPersistedConfig = Omit<\n SessionRecordingRemoteConfig,\n | 'recordCanvas'\n | 'canvasFps'\n | 'canvasQuality'\n | 'networkPayloadCapture'\n | 'sampleRate'\n | 'minimumDurationMilliseconds'\n> & {\n enabled: boolean\n networkPayloadCapture: SessionRecordingRemoteConfig['networkPayloadCapture'] & {\n capturePerformance: RemoteConfig['capturePerformance']\n }\n canvasRecording: {\n enabled: SessionRecordingRemoteConfig['recordCanvas']\n fps: SessionRecordingRemoteConfig['canvasFps']\n quality: SessionRecordingRemoteConfig['canvasQuality']\n }\n // we don't allow string config here\n sampleRate: number | null\n minimumDurationMilliseconds: number | null | undefined\n}\n\nexport type SessionRecordingRemoteConfig = SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n masking?: Pick<SessionRecordingOptions, 'maskAllInputs' | 'maskTextSelector' | 'blockSelector'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n /**\n * Controls how event, url, sampling, and linked flag triggers are combined\n *\n * `any` means that if any of the triggers match, the session will be recorded\n * `all` means that all the triggers must match for the session to be recorded\n *\n * originally it was (event || url) && (sampling || linked flag)\n * which nobody wanted, now the default is all\n */\n triggerMatchType?: 'any' | 'all'\n}\n\n/**\n * Remote configuration for the PostHog instance\n *\n * All of these settings can be configured directly in your PostHog instance\n * Any configuration set in the client overrides the information from the server\n */\nexport interface RemoteConfig {\n /**\n * Supported compression algorithms\n */\n supportedCompression: Compression[]\n\n /**\n * If set, disables autocapture\n */\n autocapture_opt_out?: boolean\n\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n\n /**\n * Whether we should use a custom endpoint for analytics\n *\n * @default { endpoint: \"/e\" }\n */\n analytics?: {\n endpoint?: string\n }\n\n /**\n * Whether the `$elements_chain` property should be sent as a string or as an array\n *\n * @default false\n */\n elementsChainAsString?: boolean\n\n /**\n * Error tracking configuration options\n */\n errorTracking?: {\n autocaptureExceptions?: boolean\n captureExtensionExceptions?: boolean\n suppressionRules?: ErrorTrackingSuppressionRule[]\n }\n\n /**\n * This is currently in development and may have breaking changes without a major version bump\n */\n autocaptureExceptions?: boolean | { endpoint?: string }\n\n /**\n * Session recording configuration options\n */\n sessionRecording?: SessionRecordingRemoteConfig | false\n\n /**\n * Whether surveys are enabled\n */\n surveys?: boolean | Survey[]\n\n /**\n * Parameters for the toolbar\n */\n toolbarParams: ToolbarParams\n\n /**\n * @deprecated renamed to toolbarParams, still present on older API responses\n */\n editorParams?: ToolbarParams\n\n /**\n * @deprecated, moved to toolbarParams\n */\n toolbarVersion: 'toolbar'\n\n /**\n * Whether the user is authenticated\n */\n isAuthenticated: boolean\n\n /**\n * List of site apps with their IDs and URLs\n */\n siteApps: { id: string; url: string }[]\n\n /**\n * Whether heatmaps are enabled\n */\n heatmaps?: boolean\n\n /**\n * Whether to only capture identified users by default\n */\n defaultIdentifiedOnly?: boolean\n\n /**\n * Whether to capture dead clicks\n */\n captureDeadClicks?: boolean\n\n /**\n * Indicates if the team has any flags enabled (if not we don't need to load them)\n */\n hasFeatureFlags?: boolean\n}\n\n/**\n * Flags returns feature flags and their payloads, and optionally returns everything else from the remote config\n * assuming it's called with `config=true`\n */\nexport interface FlagsResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n requestId?: string\n flags: Record<string, FeatureFlagDetail>\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processedBuffer: boolean\n processEvent?: (globals: SiteAppGlobals) => void\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport type FeatureFlagDetail = {\n key: string\n enabled: boolean\n // Only used when overriding a flag payload.\n original_enabled?: boolean | undefined\n variant: string | undefined\n // Only used when overriding a flag payload.\n original_variant?: string | undefined\n reason: EvaluationReason | undefined\n metadata: FeatureFlagMetadata | undefined\n}\n\nexport type FeatureFlagMetadata = {\n id: number\n version: number | undefined\n description: string | undefined\n payload: JsonType | undefined\n // Only used when overriding a flag payload.\n original_payload?: JsonType | undefined\n}\n\nexport type EvaluationReason = {\n code: string\n condition_index: number | undefined\n description: string | undefined\n}\n\nexport type RemoteConfigFeatureFlagCallback = (payload: JsonType) => void\n\nexport interface PersistentStore {\n _is_supported: () => boolean\n _error: (error: any) => void\n _parse: (name: string) => any\n _get: (name: string) => any\n _set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n _remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | undefined | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureStage = 'concept' | 'alpha' | 'beta' | 'general-availability'\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined,\n]\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = (typeof severityLevels)[number]\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n\nexport type PropertyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\n\nexport interface ErrorTrackingSuppressionRule {\n type: 'AND' | 'OR'\n values: ErrorTrackingSuppressionRuleValue[]\n}\n\nexport interface ErrorTrackingSuppressionRuleValue {\n key: '$exception_types' | '$exception_values'\n operator: PropertyMatchType\n value: string | string[]\n type: string\n}\n\nexport type SessionStartReason =\n | 'sampling_overridden'\n | 'recording_initialized'\n | 'linked_flag_matched'\n | 'linked_flag_overridden'\n | typeof SAMPLED\n | 'session_id_changed'\n | 'url_trigger_matched'\n | 'event_trigger_matched'\n\nexport type OverrideConfig = {\n sampling: boolean\n linked_flag: boolean\n url_trigger: boolean\n event_trigger: boolean\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAYa,QAAA,sBAAsB,GAAG,mBAAmB,CAAA;AA4wCzD,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,iCAAkB,CAAA;IAClB,gCAAiB,CAAA;AACrB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAkiBD,2EAA2E;AAC3E,yEAAyE;AACzE,iFAAiF;AACpE,QAAA,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAU,CAAA","sourcesContent":["import type { recordOptions } from './extensions/replay/types/rrweb'\nimport type { SegmentAnalytics } from './extensions/segment-integration'\nimport { PostHog } from './posthog-core'\nimport { KnownUnsafeEditableEvent } from '@posthog/core'\nimport { Survey, SurveyConfig } from './posthog-surveys-types'\n// only importing types here, so won't affect the bundle\n// eslint-disable-next-line posthog-js/no-external-replay-imports\nimport type { SAMPLED } from './extensions/replay/external/triggerMatching'\n\nexport type Property = any\nexport type Properties = Record<string, Property>\n\nexport const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'\n\n/**\n * These are known events PostHog events that can be processed by the `beforeCapture` function\n * That means PostHog functionality does not rely on receiving 100% of these for calculations\n * So, it is safe to sample them to reduce the volume of events sent to PostHog\n */\nexport type KnownEventName =\n | '$heatmaps_data'\n | '$opt_in'\n | '$exception'\n | '$$heatmap'\n | '$web_vitals'\n | '$dead_click'\n | '$autocapture'\n | typeof COPY_AUTOCAPTURE_EVENT\n | '$rageclick'\n\nexport type EventName =\n | KnownUnsafeEditableEvent\n | KnownEventName\n // magic value so that the type of EventName is a set of known strings or any other string\n // which means you get autocomplete for known strings\n // but no type complaints when you add an arbitrary string\n | (string & {})\n\nexport interface CaptureResult {\n uuid: string\n event: EventName\n properties: Properties\n $set?: Properties\n $set_once?: Properties\n timestamp?: Date\n}\n\nexport type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'\nexport type DomAutocaptureEvents = 'click' | 'change' | 'submit'\n\n/**\n * If an array is passed for an allowlist, autocapture events will only be sent for elements matching\n * at least one of the elements in the array. Multiple allowlists can be used\n */\nexport interface AutocaptureConfig {\n /**\n * List of URLs to allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on specific pages only\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_allowlist?: (string | RegExp)[]\n\n /**\n * List of URLs to not allow autocapture on, can be strings to match\n * or regexes e.g. ['https://example.com', 'test.com/.*']\n * this is useful when you want to autocapture on most pages but not some specific ones\n *\n * if you set both url_allowlist and url_ignorelist,\n * we check the allowlist first and then the ignorelist.\n * the ignorelist can override the allowlist\n */\n url_ignorelist?: (string | RegExp)[]\n\n /**\n * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']\n */\n dom_event_allowlist?: DomAutocaptureEvents[]\n\n /**\n * List of DOM elements to allow autocapture on\n * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']\n *\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 `div`s 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 * Everything is allowed when there's no allowlist\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 /**\n * When set to true, autocapture will capture the text of any element that is cut or copied.\n */\n capture_copied_text?: boolean\n}\n\nexport interface RageclickConfig {\n /**\n * List of CSS selectors to ignore rageclicks on\n * e.g. ['.my-calendar-button']\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 ignore list config `['[id]']`\n * we will ignore the rageclick if the click-target or its parents has any id\n *\n * Nothing is ignored when there's an empty ignorelist, e.g. []\n * If no ignorelist is set, we default to ignoring .ph-no-rageclick\n * If an element has .ph-no-capture, it will always be ignored by rageclick and autocapture\n */\n css_selector_ignorelist?: string[]\n}\n\nexport interface BootstrapConfig {\n distinctID?: string\n isIdentifiedID?: boolean\n featureFlags?: Record<string, boolean | string>\n featureFlagPayloads?: Record<string, JsonType>\n\n /**\n * Optionally provide a sessionID, this is so that you can provide an existing sessionID here to continue a user's session across a domain or device. It MUST be:\n * - unique to this user\n * - a valid UUID v7\n * - the timestamp part must be <= the timestamp of the first event in the session\n * - the timestamp of the last event in the session must be < the timestamp part + 24 hours\n * **/\n sessionID?: string\n}\n\nexport type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'\n\nexport interface PerformanceCaptureConfig {\n /**\n * Works with session replay to use the browser's native performance observer to capture performance metrics\n */\n network_timing?: boolean\n\n /**\n * Use chrome's web vitals library to wrap fetch and capture web vitals\n */\n web_vitals?: boolean\n\n /**\n * We observe very large values reported by the Chrome web vitals library\n * These outliers are likely not real, useful values, and we exclude them\n * You can set this to 0 in order to include all values, NB this is not recommended\n *\n * @default 15 * 60 * 1000 (15 minutes)\n */\n __web_vitals_max_value?: number\n\n /**\n * By default all 4 metrics are captured\n * You can set this config to restrict which metrics are captured\n * e.g. ['CLS', 'FCP'] to only capture those two metrics\n * NB setting this does not override whether the capture is enabled\n *\n * @default ['LCP', 'CLS', 'FCP', 'INP']\n */\n web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]\n\n /**\n * We delay flushing web vitals metrics to reduce the number of events we send\n * This is the maximum time we will wait before sending the metrics\n *\n * @default 5000\n */\n web_vitals_delayed_flush_ms?: number\n}\n\nexport interface DeadClickCandidate {\n node: Element\n originalEvent: MouseEvent\n timestamp: number\n // time between click and the most recent scroll\n scrollDelayMs?: number\n // time between click and the most recent mutation\n mutationDelayMs?: number\n // time between click and the most recent selection changed event\n selectionChangedDelayMs?: number\n // if neither scroll nor mutation seen before threshold passed\n absoluteDelayMs?: number\n}\n\nexport type ExceptionAutoCaptureConfig = {\n /**\n * Determines whether PostHog should capture unhandled errors.\n *\n * @default true\n */\n capture_unhandled_errors: boolean\n\n /**\n * Determines whether PostHog should capture unhandled promise rejections.\n *\n * @default true\n */\n capture_unhandled_rejections: boolean\n\n /**\n * Determines whether PostHog should capture console errors.\n *\n * @default false\n */\n capture_console_errors: boolean\n}\n\nexport type DeadClicksAutoCaptureConfig = {\n /**\n * We'll not consider a click to be a dead click, if it's followed by a scroll within `scroll_threshold_ms` milliseconds\n *\n * @default 100\n */\n scroll_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a selection change within `selection_change_threshold_ms` milliseconds\n *\n * @default 100\n */\n selection_change_threshold_ms?: number\n\n /**\n * We'll not consider a click to be a dead click, if it's followed by a mutation within `mutation_threshold_ms` milliseconds\n *\n * @default 2500\n */\n mutation_threshold_ms?: number\n\n /**\n * Allows setting behavior for when a dead click is captured.\n * For e.g. to support capture to heatmaps\n *\n * If not provided the default behavior is to auto-capture dead click events\n *\n * Only intended to be provided by our own SDK\n */\n __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined\n} & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>\n\nexport interface HeatmapConfig {\n /**\n * How often to send batched data in `$heatmap_data` events\n * If set to 0 or not set, sends using the default interval of 1 second\n *\n * @default 1000\n */\n flush_interval_milliseconds: number\n}\n\nexport type BeforeSendFn = (cr: CaptureResult | null) => CaptureResult | null\n\nexport type ConfigDefaults = '2025-05-24' | 'unset'\n\nexport type ExternalIntegrationKind = 'intercom' | 'crispChat'\n\n/**\n * Configuration options for the PostHog JavaScript SDK.\n * @see https://posthog.com/docs/libraries/js#config\n */\nexport interface PostHogConfig {\n /** URL of your PostHog instance.\n *\n * @default 'https://us.i.posthog.com'\n */\n api_host: string\n\n /**\n * URL to use for feature flag requests specifically.\n * If not set, feature flag requests will use the URL derived from `api_host`.\n * This is useful when you want to route feature flag requests to a different endpoint than other analytic APIs.\n *\n * @default null\n */\n flags_api_host?: string | null\n\n /**\n * If using a reverse proxy for `api_host` then this should be the actual PostHog app URL (e.g. https://us.posthog.com).\n * This ensures that links to PostHog point to the correct host.\n *\n * @default null\n */\n ui_host: string | null\n\n /**\n * The transport method to use for API requests.\n *\n * @default 'fetch'\n */\n api_transport?: 'XHR' | 'fetch'\n\n /**\n * The token for your PostHog project.\n * It should NOT be provided manually in the config, but rather passed as the first parameter to `posthog.init()`.\n */\n token: string\n\n /**\n * The name this instance will be identified by.\n * You don't need to set this most of the time,\n * but can be useful if you have several Posthog instances running at the same time.\n *\n * @default 'posthog'\n */\n name: string\n\n /**\n * Determines whether PostHog should autocapture events.\n * This setting does not affect capturing pageview events (see `capture_pageview`).\n *\n * by default autocapture is ignored on elements that match a `ph-no-capture` css class on the element or a parent\n * @default true\n */\n autocapture: boolean | AutocaptureConfig\n\n /**\n * Determines whether PostHog should capture rage clicks.\n *\n * by default rageclicks are ignored on elements that match a `ph-no-capture` or `ph-no-rageclick` css class on the element or a parent\n * @default true\n */\n rageclick: boolean | RageclickConfig\n\n /**\n * Determines if cookie should be set on the top level domain (example.com).\n * If PostHog-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,\n * it'll set the cookie on the subdomain only (test.example.com).\n *\n * NOTE: It will be set to `false` if we detect that the domain is a subdomain of a platform that is excluded from cross-subdomain cookie setting.\n * The current list of excluded platforms is `herokuapp.com`, `vercel.app`, and `netlify.app`.\n *\n * @see `isCrossDomainCookie`\n * @default true\n */\n cross_subdomain_cookie: boolean\n\n /**\n * Determines how PostHog stores information about the user. See [persistence](https://posthog.com/docs/libraries/js#persistence) for details.\n *\n * @default 'localStorage+cookie'\n */\n persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'\n\n /**\n * The name for the super properties persistent store\n *\n * @default ''\n */\n persistence_name: string\n\n /** @deprecated - Use 'persistence_name' instead */\n cookie_name?: string\n\n /**\n * A function to be called once the PostHog scripts have loaded successfully.\n *\n * @param posthog_instance - The PostHog instance that has been loaded.\n */\n loaded: (posthog_instance: PostHog) => void\n\n /**\n * Determines whether PostHog should save referrer information.\n *\n * @default true\n */\n save_referrer: boolean\n\n /**\n * Determines whether PostHog should save marketing parameters.\n * These are `utm_*` paramaters and friends.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default true\n */\n save_campaign_params: boolean\n\n /** @deprecated - Use `save_campaign_params` instead */\n store_google?: boolean\n\n /**\n * Used to extend the list of campaign parameters that are saved by default.\n *\n * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.\n * @default []\n */\n custom_campaign_params: string[]\n\n /**\n * Used to extend the list of user agents that are blocked by default.\n *\n * @see {DEFAULT_BLOCKED_UA_STRS} from './utils/blocked-uas' - Default list of blocked user agents.\n * @default []\n */\n custom_blocked_useragents: string[]\n\n /**\n * Determines whether PostHog should be in debug mode.\n * You can enable this to get more detailed logging.\n *\n * You can also enable this on your website by appending `?__posthog_debug=true` at the end of your URL\n * You can also call `posthog.debug()` in your code to enable debug mode\n *\n * @default false\n */\n debug: boolean\n\n /** @deprecated Use `debug` instead */\n verbose?: boolean\n\n /**\n * Determines whether PostHog should capture pageview events automatically.\n * Can be:\n * - `true`: Capture regular pageviews (default)\n * - `false`: Don't capture any pageviews\n * - `'history_change'`: Only capture pageviews on history API changes (pushState, replaceState, popstate)\n *\n * @default true\n */\n capture_pageview: boolean | 'history_change'\n\n /**\n * Determines whether PostHog should capture pageleave events.\n * If set to `true`, it will capture pageleave events for all pages.\n * If set to `'if_capture_pageview'`, it will only capture pageleave events if `capture_pageview` is also set to `true` or `'history_change'`.\n *\n * @default 'if_capture_pageview'\n */\n capture_pageleave: boolean | 'if_capture_pageview'\n\n /**\n * Determines the number of days to store cookies for.\n *\n * @default 365\n */\n cookie_expiration: number\n\n /**\n * Determines whether PostHog should upgrade old cookies.\n * If set to `true`, the library will check for a cookie from our old js library and import super properties from it, then the old cookie is deleted.\n * This option only works in the initialization, so make sure you set it when you create the library.\n *\n * @default false\n */\n upgrade: boolean\n\n /**\n * Determines whether PostHog should disable session recording.\n *\n * @default false\n */\n disable_session_recording: boolean\n\n /**\n * Determines whether PostHog should disable persistence.\n * If set to `true`, the library will not save any data to the browser. It will also delete any data previously saved to the browser.\n *\n * @default false\n */\n disable_persistence: boolean\n\n /** @deprecated - use `disable_persistence` instead */\n disable_cookie?: boolean\n\n /**\n * Determines whether PostHog should disable all surveys functionality.\n *\n * @default false\n */\n disable_surveys: boolean\n\n /**\n * Determines whether PostHog should disable automatic display of surveys. If this is true, popup or widget surveys will not be shown when display conditions are met.\n *\n * @default false\n */\n disable_surveys_automatic_display: boolean\n\n /**\n * Survey-specific configuration options.\n *\n * @default undefined\n */\n surveys?: SurveyConfig\n\n /**\n * Determines whether PostHog should disable web experiments.\n *\n * Currently disabled while we're in BETA. It will be toggled to `true` in a future release.\n *\n * @default true\n */\n disable_web_experiments: boolean\n\n /**\n * Determines whether PostHog should disable any external dependency loading.\n * This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps.\n *\n * @default false\n */\n disable_external_dependency_loading: boolean\n\n /**\n * A function to be called when a script is being loaded.\n * This can be used to modify the script before it is loaded.\n * This is useful for adding a nonce to the script, for example.\n *\n * @param script - The script element that is being loaded.\n * @returns The modified script element, or null if the script should not be loaded.\n */\n prepare_external_dependency_script?: (script: HTMLScriptElement) => HTMLScriptElement | null\n\n /**\n * A function to be called when a stylesheet is being loaded.\n * This can be used to modify the stylesheet before it is loaded.\n * This is useful for adding a nonce to the stylesheet, for example.\n *\n * @param stylesheet - The stylesheet element that is being loaded.\n * @returns The modified stylesheet element, or null if the stylesheet should not be loaded.\n */\n prepare_external_dependency_stylesheet?: (stylesheet: HTMLStyleElement) => HTMLStyleElement | null\n\n /**\n * Determines whether PostHog should enable recording console logs.\n * When undefined, it falls back to the remote config setting.\n *\n * @default undefined\n */\n enable_recording_console_log?: boolean\n\n /**\n * Determines whether PostHog should use secure cookies.\n * If this is `true`, PostHog cookies will be marked as secure,\n * meaning they will only be transmitted over HTTPS.\n *\n * @default window.location.protocol === 'https:'\n */\n secure_cookie: boolean\n\n /**\n * Determines if users should be opted out of PostHog tracking by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_capturing_by_default: boolean\n\n /**\n * Determines where we'll save the information about whether users are opted out of capturing.\n *\n * @default 'localStorage'\n */\n opt_out_capturing_persistence_type: 'localStorage' | 'cookie'\n\n /**\n * Determines if users should be opted out of browser data storage by this PostHog instance by default,\n * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.\n *\n * @default false\n */\n opt_out_persistence_by_default?: boolean\n\n /**\n * Determines if users should be opted out of user agent filtering such as googlebot or other bots.\n * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,\n * but will process all events as if they were from a browser.\n *\n * @default false\n */\n opt_out_useragent_filter: boolean\n\n /** @deprecated Use `consent_persistence_name` instead. This will be removed in a future major version. **/\n opt_out_capturing_cookie_prefix: string | null\n\n /**\n * Determines the key for the cookie / local storage used to store the information about whether users are opted in/out of capturing.\n * When `null`, we used a key based on your token.\n *\n * @default null\n * @see `ConsentManager._storageKey`\n */\n consent_persistence_name: string | null\n\n /**\n * Determines if users should be opted in to site apps.\n *\n * @default false\n */\n opt_in_site_apps: boolean\n\n /**\n * Determines whether PostHog should respect the Do Not Track header when computing\n * consent in `ConsentManager`.\n *\n * @see `ConsentManager`\n * @default false\n */\n respect_dnt: boolean\n\n /**\n * A list of properties that should never be sent with capture calls.\n *\n * @default []\n */\n property_denylist: string[]\n\n /** @deprecated - use `property_denylist` instead */\n property_blacklist?: string[]\n\n /**\n * A list of headers that should be sent with requests to the PostHog API.\n *\n * @default {}\n */\n request_headers: { [header_name: string]: string }\n\n /** @deprecated - use `request_headers` instead */\n xhr_headers?: { [header_name: string]: string }\n\n /**\n * A function that is called when a request to the PostHog API fails.\n *\n * @param error - The `RequestResponse` object that occurred.\n */\n on_request_error?: (error: RequestResponse) => void\n\n /** @deprecated - use `on_request_error` instead */\n on_xhr_error?: (failedRequest: XMLHttpRequest) => void\n\n /**\n * Determines whether PostHog should batch requests to the PostHog API.\n *\n * @default true\n */\n request_batching: boolean\n\n /**\n * Determines the maximum length of the properties string that can be sent with capture calls.\n *\n * @default 65535\n */\n properties_string_max_length: number\n\n /**\n * Configuration defaults for breaking changes. When set to a specific date,\n * enables new default behaviors that were introduced on that date.\n *\n * - `'unset'`: Use legacy default behaviors\n * - `'2025-05-24'`: Use updated default behaviors (e.g. capture_pageview defaults to 'history_change')\n *\n * @default 'unset'\n */\n defaults: ConfigDefaults\n\n /**\n * EXPERIMENTAL: Defers initialization of non-critical extensions (autocapture, session recording, etc.)\n * to the next event loop tick using setTimeout. This reduces main thread blocking during SDK\n * initialization for better page load performance, while keeping critical functionality\n * (persistence, sessions, capture) available immediately.\n *\n * When enabled:\n * - Persistence, sessions, and basic capture work immediately\n * - Extensions (autocapture, recording, heatmaps, etc.) start after yielding back to the browser\n *\n * @default false (will be true for defaults >= '2025-11-06' in the future)\n * @experimental\n */\n __preview_deferred_init_extensions: boolean\n\n /**\n * Determines the session recording options.\n *\n * @see `SessionRecordingOptions`\n * @default {}\n */\n session_recording: SessionRecordingOptions\n\n /**\n * Determines the error tracking options.\n *\n * @see `ErrorTrackingOptions`\n * @default {}\n */\n error_tracking: ErrorTrackingOptions\n\n /**\n * Determines the session idle timeout in seconds.\n * Any new event that's happened after this timeout will create a new session.\n *\n * @default 30 * 60 -- 30 minutes\n */\n session_idle_timeout_seconds: number\n\n /**\n * Prevent autocapture from capturing any attribute names on elements.\n *\n * @default false\n */\n mask_all_element_attributes: boolean\n\n /**\n * Prevent autocapture from capturing `textContent` on elements.\n *\n * @default false\n */\n mask_all_text: boolean\n\n /**\n * Mask personal data properties from the current URL.\n * This will mask personal data properties such as advertising IDs (gclid, fbclid, etc.), and you can also add\n * custom properties to mask with `custom_personal_data_properties`.\n * @default false\n * @see {PERSONAL_DATA_CAMPAIGN_PARAMS} - Default campaign parameters that are masked by default.\n * @see {PostHogConfig.custom_personal_data_properties} - Custom list of personal data properties to mask.\n */\n mask_personal_data_properties: boolean\n\n /**\n * Custom list of personal data properties to mask.\n *\n * E.g. if you added `email` to this list, then any `email` property in the URL will be masked.\n * https://www.example.com/login?email=john.doe%40example.com => https://www.example.com/login?email=<MASKED>\n *\n * @default []\n * @see {PostHogConfig.mask_personal_data_properties} - Must be enabled for this to take effect.\n */\n custom_personal_data_properties: string[]\n\n /**\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /flags endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend, and it also contains\n * feature flag evaluation information for the current user.\n *\n * This endpoint is required to run most features of this library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * WARNING: Disabling this will also prevent remote configuration from loading,\n * which could mean features like web vitals, surveys, and other features configured\n * in PostHog settings are disabled unless explicitly enabled via client-side config.\n * When setting this to true, make sure to explicitly configure any features you\n * want to use (e.g., capture_performance, autocapture, etc.) in your SDK's init config.\n *\n * @default false\n */\n advanced_disable_flags?: boolean\n\n /**\n * @deprecated Use `advanced_disable_flags` instead. This will be removed in a future major version.\n *\n * One of the very first things the PostHog library does when init() is called\n * is make a request to the /decide endpoint on PostHog's backend.\n * This endpoint contains information on how to run the PostHog library\n * so events are properly received in the backend.\n *\n * This endpoint is required to run most features of the library.\n * However, if you're not using any of the described features,\n * you may wish to turn off the call completely to avoid an extra request\n * and reduce resource usage on both the client and the server.\n *\n * @default false\n */\n advanced_disable_decide?: boolean\n\n /**\n * Will keep /flags running, but without evaluating any feature flags.\n * Useful for when you need to load the config data associated with the flags endpoint\n * (e.g. /flags?v=2&config=true) without evaluating any feature flags. Most folks use this\n * to save money on feature flag evaluation (by bootstrapping feature flags on the server side).\n *\n * @default false\n */\n advanced_disable_feature_flags: boolean\n\n /**\n * Stops from firing feature flag requests on first page load.\n * Only requests feature flags when user identity or properties are updated,\n * or you manually request for flags to be loaded.\n *\n * @default false\n */\n advanced_disable_feature_flags_on_first_load: boolean\n\n /**\n * Evaluation environments for feature flags.\n * When set, only feature flags that have at least one matching evaluation tag\n * will be evaluated for this SDK instance. Feature flags with no evaluation tags\n * will always be evaluated.\n *\n * Examples: ['production', 'web', 'checkout']\n *\n * @default undefined\n */\n evaluation_environments?: readonly string[]\n\n /**\n * Determines whether PostHog should disable toolbar metrics.\n * This is our internal instrumentation for our toolbar in your website.\n *\n * @default false\n */\n advanced_disable_toolbar_metrics: boolean\n\n /**\n * Determines whether PostHog should only evaluate feature flags for surveys.\n * Useful for when you want to use this library to evaluate feature flags for surveys only but you have additional feature flags\n * that you evaluate on the server side.\n *\n * @default false\n */\n advanced_only_evaluate_survey_feature_flags: boolean\n /**\n * When this is enabled, surveys will always be initialized, regardless of the /flags response or remote config settings.\n * This is useful if you want to use surveys but disable all other flag-dependent functionality.\n * Used internally for displaying external surveys without making a /flags request.\n *\n * @default false\n */\n advanced_enable_surveys: boolean\n\n /**\n * Sets timeout for fetching feature flags\n *\n * @default 3000\n */\n feature_flag_request_timeout_ms: number\n\n /**\n * Sets timeout for fetching surveys\n *\n * @default 10000\n */\n surveys_request_timeout_ms: number\n\n /**\n * Function to get the device ID.\n * This doesn't usually need to be set, but can be useful if you want to use a custom device ID.\n *\n * @param uuid - The UUID we would use for the device ID.\n * @returns The device ID.\n *\n * @default (uuid) => uuid\n */\n get_device_id: (uuid: string) => string\n\n /**\n * This function or array of functions - if provided - are called immediately before sending data to the server.\n * It allows you to edit data before it is sent, or choose not to send it all.\n * if provided as an array the functions are called in the order they are provided\n * any one function returning null means the event will not be sent\n */\n before_send?: BeforeSendFn | BeforeSendFn[]\n\n /** @deprecated - use `before_send` instead */\n sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null\n\n /** @deprecated - use `before_send` instead */\n _onCapture: (eventName: string, eventData: CaptureResult) => void\n\n /**\n * Determines whether to capture performance metrics.\n * These include Network Timing and Web Vitals.\n *\n * When `undefined`, fallback to the remote configuration.\n * If `false`, neither network timing nor web vitals will work.\n * If an object, that will override the remote configuration.\n *\n * @see {PerformanceCaptureConfig}\n * @default undefined\n */\n capture_performance?: boolean | PerformanceCaptureConfig\n\n /**\n * Determines whether to disable compression when sending events to the server.\n * WARNING: Should only be used for testing. Could negatively impact performance.\n *\n * @default false\n */\n disable_compression: boolean\n\n /**\n * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,\n * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.\n *\n * Since there is a delay between initializing PostHog and fetching feature flags,\n * feature flags are not always available immediately.\n * This makes them unusable if you want to do something like redirecting a user\n * to a different page based on a feature flag.\n *\n * You can, therefore, fetch the feature flags in your server and pre-fill them here,\n * allowing PostHog to know the feature flag values immediately.\n *\n * After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.\n *\n * @default {}\n */\n bootstrap: BootstrapConfig\n\n /**\n * The segment analytics object.\n *\n * @see https://posthog.com/docs/libraries/segment\n */\n segment?: SegmentAnalytics\n\n /**\n * Determines whether to capture heatmaps.\n *\n * @see {HeatmapConfig}\n * @default undefined\n */\n capture_heatmaps?: boolean | HeatmapConfig\n\n /* @deprecated - use `capture_heatmaps` instead */\n enable_heatmaps?: boolean\n\n /**\n * Determines whether to capture dead clicks.\n *\n * @see {DeadClicksAutoCaptureConfig}\n * @default undefined\n */\n capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig\n\n /**\n * Determines whether to capture exceptions.\n *\n * @see {ExceptionAutoCaptureConfig}\n * @default undefined\n */\n capture_exceptions?: boolean | ExceptionAutoCaptureConfig\n\n /**\n * Determines whether to disable scroll properties.\n * These allow you to keep track of how far down someone scrolled in your website.\n *\n * @default false\n */\n disable_scroll_properties?: boolean\n\n /**\n * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`\n * It will use `window.document.documentElement` if not specified.\n */\n scroll_root_selector?: string | string[]\n\n /**\n * You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting.\n * There are three options:\n * - `person_profiles: 'always'` - we will process persons data for all events\n * - `person_profiles: 'never'` - we won't process persons for any event. This means that anonymous users will not be merged once they sign up or login, so you lose the ability to create funnels that track users from anonymous to identified. All events (including `$identify`) will be sent with `$process_person_profile: False`.\n * - `person_profiles: 'identified_only'` _(default)_ - 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 * @default 'identified_only'\n */\n person_profiles?: 'always' | 'never' | 'identified_only'\n\n /** @deprecated - use `person_profiles` instead */\n process_person?: 'always' | 'never' | 'identified_only'\n\n /**\n * Client side rate limiting\n */\n rate_limiting?: {\n /**\n * The average number of events per second that should be permitted\n *\n * @default 10\n */\n events_per_second?: number\n\n /**\n * How many events can be captured in a burst. This defaults to 10 times the events_per_second count\n *\n * @default 10 * `events_per_second`\n */\n events_burst_limit?: number\n }\n\n /**\n * Used when sending data via `fetch`, use with care.\n * This is intentionally meant to be used with NextJS `fetch`\n *\n * Incorrect `cache` usage may cause out-of-date data for feature flags, actions tracking, etc.\n * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\n */\n fetch_options?: {\n cache?: RequestInit['cache']\n next_options?: NextOptions\n }\n\n /**\n * Used to change the behavior of the request queue.\n * This is an advanced feature and should be used with caution.\n */\n request_queue_config?: RequestQueueConfig\n\n /**\n * Used to set-up external integrations with PostHog data - such as session replays, distinct id, etc.\n */\n integrations?: Record<ExternalIntegrationKind, boolean>\n\n /**\n * Enables cookieless mode. In this mode, PostHog will not set any cookies, or use session or local storage. User\n * identity is handled by generating a privacy-preserving hash on PostHog's servers.\n * - 'always' - enable cookieless mode immediately on startup, use this if you do not intend to show a cookie banner\n * - 'on_reject' - enable cookieless mode only if the user rejects cookies, use this if you want to show a cookie banner. If the user accepts cookies, cookieless mode will not be used, and PostHog will use cookies and local storage as usual.\n *\n * Note that you MUST enable cookieless mode in your PostHog project's settings, otherwise all your cookieless events will be ignored. We plan to remove this requirement in the future.\n * */\n cookieless_mode?: 'always' | 'on_reject'\n\n // ------- PREVIEW CONFIGS -------\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * A list of hostnames for which to inject PostHog tracing headers to all requests\n * (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID, X-POSTHOG-WINDOW-ID)\n * */\n __add_tracing_headers?: string[]\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables the new RemoteConfig approach to loading config instead of /flags?v=2&config=true\n * */\n __preview_remote_config?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Whether to use the new /flags/ endpoint\n * */\n __preview_flags_v2?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - ONLY USE WHEN TALKING TO POSTHOG SUPPORT\n * Enables deprecated eager loading of session recording code, not just rrweb and network plugin\n * we are switching the default to lazy loading because the bundle will ultimately be 18% smaller then\n * keeping this around for a few days in case there are unexpected consequences that testing did not uncover\n * */\n __preview_eager_load_replay?: boolean\n\n /**\n * Prevents posthog-js from using the `navigator.sendBeacon` API to send events.\n * Enabling this option may hurt the reliability of sending $pageleave events\n */\n __preview_disable_beacon?: boolean\n\n /**\n * Disables sending credentials when using XHR requests.\n */\n __preview_disable_xhr_credentials?: boolean\n\n /**\n * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION\n * Enables collection of bot traffic as $bot_pageview events with detailed bot detection\n * properties instead of dropping them entirely. Use it alongside opt_out_useragent_filter\n */\n __preview_capture_bot_pageviews?: boolean\n\n // ------- RETIRED CONFIGS - NO REPLACEMENT OR USAGE -------\n\n /**\n * @deprecated - does nothing\n * was present only for PostHog testing of replay lazy loading\n * */\n __preview_lazy_load_replay?: boolean\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n api_method?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_protocol?: string\n\n /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */\n inapp_link_new_window?: boolean\n\n /**\n * @deprecated - THIS OPTION HAS NO EFFECT, kept here for backwards compatibility reasons.\n * Use a custom transformation or \"Discard IP data\" project setting instead: @see https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address.\n */\n ip: boolean\n}\n\nexport interface ErrorTrackingOptions {\n /**\n * Decide whether exceptions thrown by browser extensions should be captured\n *\n * @default false\n */\n captureExtensionExceptions?: boolean\n\n /**\n * UNSTABLE: determines whether exception caused by the PostHog SDK will be captured\n *\n * @default false\n */\n __capturePostHogExceptions?: boolean\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 1\n */\n __exceptionRateLimiterRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __exceptionRateLimiterBucketSize?: number\n}\n\nexport interface SessionRecordingOptions {\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-no-capture'\n */\n blockClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default null\n */\n blockSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-ignore-input'\n */\n ignoreClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default 'ph-mask'\n */\n maskTextClass?: string | RegExp\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextSelector?: string | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskTextFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskAllInputs?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputOptions?: recordOptions['maskInputOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n */\n maskInputFn?: ((text: string, element?: HTMLElement) => string) | null\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default {}\n */\n slimDOMOptions?: recordOptions['slimDOMOptions']\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n collectFonts?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default true\n */\n inlineStylesheet?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordCrossOriginIframes?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordHeaders?: boolean\n\n /**\n * Derived from `rrweb.record` options\n * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md\n * @default false\n */\n recordBody?: boolean\n\n /**\n * Allows local config to override remote canvas recording settings from the flags response\n */\n captureCanvas?: SessionRecordingCanvasOptions\n\n /**\n * Modify the network request before it is captured. Returning null or undefined stops it being captured\n */\n maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null\n\n /** @deprecated - use maskCapturedNetworkRequestFn instead */\n maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null\n\n /**\n * ADVANCED: while a user is active we take a full snapshot of the browser every interval.\n * For very few sites playback performance might be better with different interval.\n * Set to 0 to disable\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n full_snapshot_interval_millis?: number\n\n /**\n * ADVANCED: whether to partially compress rrweb events before sending them to the server,\n * defaults to true, can be set to false to disable partial compression\n * NB requests are still compressed when sent to the server regardless of this setting\n *\n * @default true\n */\n compress_events?: boolean\n\n /**\n * ADVANCED: alters the threshold before a recording considers a user has become idle.\n * Normally only altered alongside changes to session_idle_timeout_ms.\n *\n * @default 1000 * 60 * 5 (5 minutes)\n */\n session_idle_threshold_ms?: number\n\n /**\n * ADVANCED: alters the refill rate for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 10\n */\n __mutationThrottlerRefillRate?: number\n\n /**\n * ADVANCED: alters the bucket size for the token bucket mutation throttling\n * Normally only altered alongside posthog support guidance.\n * Accepts values between 0 and 100\n *\n * @default 100\n */\n __mutationThrottlerBucketSize?: number\n}\n\nexport type SessionIdChangedCallback = (\n sessionId: string,\n windowId: string | null | undefined,\n changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }\n) => void\n\nexport enum Compression {\n GZipJS = 'gzip-js',\n Base64 = 'base64',\n}\n\n// Request types - these should be kept minimal to what request.ts needs\n\n// Minimal class to allow interop between different request methods (xhr / fetch)\nexport interface RequestResponse {\n statusCode: number\n text?: string\n json?: any\n}\n\nexport type RequestCallback = (response: RequestResponse) => void\n\n// See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options\ntype NextOptions = { revalidate: false | 0 | number; tags: string[] }\n\nexport interface RequestWithOptions {\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 disableTransport?: ('XHR' | 'fetch' | 'sendBeacon')[]\n disableXHRCredentials?: boolean\n compression?: Compression | 'best-available'\n fetchOptions?: {\n cache?: RequestInit['cache']\n next?: NextOptions\n }\n}\n\n// Queued request types - the same as a request but with additional queueing information\n\nexport interface QueuedRequestWithOptions extends RequestWithOptions {\n /** key of queue, e.g. 'sessionRecording' vs 'event' */\n batchKey?: string\n}\n\n// Used explicitly for retriable requests\nexport interface RetriableRequestWithOptions extends QueuedRequestWithOptions {\n retriesPerformedSoFar?: number\n}\n\n// we used to call a request that was sent to the queue with options attached `RequestQueueOptions`\n// so we can't call the options used to configure the behavior of the RequestQueue that as well,\n// so instead we call them config\nexport interface RequestQueueConfig {\n /**\n * ADVANCED - alters the frequency which PostHog sends events to the server.\n * generally speaking this is only set when apps have automatic page refreshes, or very short visits.\n * Defaults to 3 seconds when not set\n * Allowed values between 250 and 5000\n * */\n flush_interval_ms?: number\n}\n\nexport interface CaptureOptions {\n /**\n * Used when `$identify` is called\n * Will set person properties overriding previous values\n */\n $set?: Properties\n\n /**\n * Used when `$identify` is called\n * Will set person properties but only once, it will NOT override previous values\n */\n $set_once?: Properties\n\n /**\n * Used to override the desired endpoint for the captured event\n */\n _url?: string\n\n /**\n * key of queue, e.g. 'sessionRecording' vs 'event'\n */\n _batchKey?: string\n\n /**\n * If set, overrides and disables config.properties_string_max_length\n */\n _noTruncate?: boolean\n\n /**\n * If set, skips the batched queue\n */\n send_instantly?: boolean\n\n /**\n * If set, skips the client side rate limiting\n */\n skip_client_rate_limiting?: boolean\n\n /**\n * If set, overrides the desired transport method\n */\n transport?: RequestWithOptions['transport']\n\n /**\n * If set, overrides the current timestamp\n */\n timestamp?: Date\n}\n\nexport type FlagVariant = { flag: string; variant: string }\n\nexport type SessionRecordingCanvasOptions = {\n /**\n * If set, records the canvas\n *\n * @default false\n */\n recordCanvas?: boolean | null\n\n /**\n * If set, records the canvas at the given FPS\n * Can be set in the remote configuration\n * Limited between 0 and 12\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as 4\n *\n * @default null-ish\n */\n canvasFps?: number | null\n\n /**\n * If set, records the canvas at the given quality\n * Can be set in the remote configuration\n * Must be a string that is a valid decimal between 0 and 1\n * When canvas recording is enabled, if this is not set locally, then remote config sets this as \"0.4\"\n *\n * @default null-ish\n */\n canvasQuality?: string | null\n}\n\n/** the config stored in persistence when session recording remote config is received */\nexport type SessionRecordingPersistedConfig = Omit<\n SessionRecordingRemoteConfig,\n | 'recordCanvas'\n | 'canvasFps'\n | 'canvasQuality'\n | 'networkPayloadCapture'\n | 'sampleRate'\n | 'minimumDurationMilliseconds'\n> & {\n enabled: boolean\n networkPayloadCapture: SessionRecordingRemoteConfig['networkPayloadCapture'] & {\n capturePerformance: RemoteConfig['capturePerformance']\n }\n canvasRecording: {\n enabled: SessionRecordingRemoteConfig['recordCanvas']\n fps: SessionRecordingRemoteConfig['canvasFps']\n quality: SessionRecordingRemoteConfig['canvasQuality']\n }\n // we don't allow string config here\n sampleRate: number | null\n minimumDurationMilliseconds: number | null | undefined\n}\n\nexport type SessionRecordingRemoteConfig = SessionRecordingCanvasOptions & {\n endpoint?: string\n consoleLogRecordingEnabled?: boolean\n // the API returns a decimal between 0 and 1 as a string\n sampleRate?: string | null\n minimumDurationMilliseconds?: number\n linkedFlag?: string | FlagVariant | null\n networkPayloadCapture?: Pick<NetworkRecordOptions, 'recordBody' | 'recordHeaders'>\n masking?: Pick<SessionRecordingOptions, 'maskAllInputs' | 'maskTextSelector' | 'blockSelector'>\n urlTriggers?: SessionRecordingUrlTrigger[]\n scriptConfig?: { script?: string | undefined }\n urlBlocklist?: SessionRecordingUrlTrigger[]\n eventTriggers?: string[]\n /**\n * Controls how event, url, sampling, and linked flag triggers are combined\n *\n * `any` means that if any of the triggers match, the session will be recorded\n * `all` means that all the triggers must match for the session to be recorded\n *\n * originally it was (event || url) && (sampling || linked flag)\n * which nobody wanted, now the default is all\n */\n triggerMatchType?: 'any' | 'all'\n}\n\n/**\n * Remote configuration for the PostHog instance\n *\n * All of these settings can be configured directly in your PostHog instance\n * Any configuration set in the client overrides the information from the server\n */\nexport interface RemoteConfig {\n /**\n * Supported compression algorithms\n */\n supportedCompression: Compression[]\n\n /**\n * If set, disables autocapture\n */\n autocapture_opt_out?: boolean\n\n /**\n * originally capturePerformance was replay only and so boolean true\n * is equivalent to { network_timing: true }\n * now capture performance can be separately enabled within replay\n * and as a standalone web vitals tracker\n * people can have them enabled separately\n * they work standalone but enhance each other\n * TODO: deprecate this so we make a new config that doesn't need this explanation\n */\n capturePerformance?: boolean | PerformanceCaptureConfig\n\n /**\n * Whether we should use a custom endpoint for analytics\n *\n * @default { endpoint: \"/e\" }\n */\n analytics?: {\n endpoint?: string\n }\n\n /**\n * Whether the `$elements_chain` property should be sent as a string or as an array\n *\n * @default false\n */\n elementsChainAsString?: boolean\n\n /**\n * Error tracking configuration options\n */\n errorTracking?: {\n autocaptureExceptions?: boolean\n captureExtensionExceptions?: boolean\n suppressionRules?: ErrorTrackingSuppressionRule[]\n }\n\n /**\n * This is currently in development and may have breaking changes without a major version bump\n */\n autocaptureExceptions?: boolean | { endpoint?: string }\n\n /**\n * Session recording configuration options\n */\n sessionRecording?: SessionRecordingRemoteConfig | false\n\n /**\n * Whether surveys are enabled\n */\n surveys?: boolean | Survey[]\n\n /**\n * Parameters for the toolbar\n */\n toolbarParams: ToolbarParams\n\n /**\n * @deprecated renamed to toolbarParams, still present on older API responses\n */\n editorParams?: ToolbarParams\n\n /**\n * @deprecated, moved to toolbarParams\n */\n toolbarVersion: 'toolbar'\n\n /**\n * Whether the user is authenticated\n */\n isAuthenticated: boolean\n\n /**\n * List of site apps with their IDs and URLs\n */\n siteApps: { id: string; url: string }[]\n\n /**\n * Whether heatmaps are enabled\n */\n heatmaps?: boolean\n\n /**\n * Whether to only capture identified users by default\n */\n defaultIdentifiedOnly?: boolean\n\n /**\n * Whether to capture dead clicks\n */\n captureDeadClicks?: boolean\n\n /**\n * Indicates if the team has any flags enabled (if not we don't need to load them)\n */\n hasFeatureFlags?: boolean\n}\n\n/**\n * Flags returns feature flags and their payloads, and optionally returns everything else from the remote config\n * assuming it's called with `config=true`\n */\nexport interface FlagsResponse extends RemoteConfig {\n featureFlags: Record<string, string | boolean>\n featureFlagPayloads: Record<string, JsonType>\n errorsWhileComputingFlags: boolean\n requestId?: string\n flags: Record<string, FeatureFlagDetail>\n}\n\nexport type SiteAppGlobals = {\n event: {\n uuid: string\n event: EventName\n properties: Properties\n timestamp?: Date\n elements_chain?: string\n distinct_id?: string\n }\n person: {\n properties: Properties\n }\n groups: Record<string, { id: string; type: string; properties: Properties }>\n}\n\nexport type SiteAppLoader = {\n id: string\n init: (config: { posthog: PostHog; callback: (success: boolean) => void }) => {\n processEvent?: (globals: SiteAppGlobals) => void\n }\n}\n\nexport type SiteApp = {\n id: string\n loaded: boolean\n errored: boolean\n processedBuffer: boolean\n processEvent?: (globals: SiteAppGlobals) => void\n}\n\nexport type FeatureFlagsCallback = (\n flags: string[],\n variants: Record<string, string | boolean>,\n context?: {\n errorsLoading?: boolean\n }\n) => void\n\nexport type FeatureFlagDetail = {\n key: string\n enabled: boolean\n // Only used when overriding a flag payload.\n original_enabled?: boolean | undefined\n variant: string | undefined\n // Only used when overriding a flag payload.\n original_variant?: string | undefined\n reason: EvaluationReason | undefined\n metadata: FeatureFlagMetadata | undefined\n}\n\nexport type FeatureFlagMetadata = {\n id: number\n version: number | undefined\n description: string | undefined\n payload: JsonType | undefined\n // Only used when overriding a flag payload.\n original_payload?: JsonType | undefined\n}\n\nexport type EvaluationReason = {\n code: string\n condition_index: number | undefined\n description: string | undefined\n}\n\nexport type RemoteConfigFeatureFlagCallback = (payload: JsonType) => void\n\nexport interface PersistentStore {\n _is_supported: () => boolean\n _error: (error: any) => void\n _parse: (name: string) => any\n _get: (name: string) => any\n _set: (\n name: string,\n value: any,\n expire_days?: number | null,\n cross_subdomain?: boolean,\n secure?: boolean,\n debug?: boolean\n ) => void\n _remove: (name: string, cross_subdomain?: boolean) => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport type Breaker = {}\nexport type EventHandler = (event: Event) => boolean | void\n\nexport type ToolbarUserIntent = 'add-action' | 'edit-action'\nexport type ToolbarSource = 'url' | 'localstorage'\nexport type ToolbarVersion = 'toolbar'\n\n/* sync with posthog */\nexport interface ToolbarParams {\n token?: string /** public posthog-js token */\n temporaryToken?: string /** private temporary user token */\n actionId?: number\n userIntent?: ToolbarUserIntent\n source?: ToolbarSource\n toolbarVersion?: ToolbarVersion\n instrument?: boolean\n distinctId?: string\n userEmail?: string\n dataAttributes?: string[]\n featureFlags?: Record<string, string | boolean>\n}\n\nexport type SnippetArrayItem = [method: string, ...args: any[]]\n\nexport type JsonRecord = { [key: string]: JsonType }\nexport type JsonType = string | number | boolean | null | undefined | JsonRecord | Array<JsonType>\n\n/** A feature that isn't publicly available yet.*/\nexport interface EarlyAccessFeature {\n // Sync this with the backend's EarlyAccessFeatureSerializer!\n name: string\n description: string\n stage: 'concept' | 'alpha' | 'beta'\n documentationUrl: string | null\n flagKey: string | null\n}\n\nexport type EarlyAccessFeatureStage = 'concept' | 'alpha' | 'beta' | 'general-availability'\nexport type EarlyAccessFeatureCallback = (earlyAccessFeatures: EarlyAccessFeature[]) => void\n\nexport interface EarlyAccessFeatureResponse {\n earlyAccessFeatures: EarlyAccessFeature[]\n}\n\nexport type Headers = Record<string, string>\n\n/* for rrweb/network@1\n ** when that is released as part of rrweb this can be removed\n ** don't rely on this type, it may change without notice\n */\nexport type InitiatorType =\n | 'audio'\n | 'beacon'\n | 'body'\n | 'css'\n | 'early-hint'\n | 'embed'\n | 'fetch'\n | 'frame'\n | 'iframe'\n | 'icon'\n | 'image'\n | 'img'\n | 'input'\n | 'link'\n | 'navigation'\n | 'object'\n | 'ping'\n | 'script'\n | 'track'\n | 'video'\n | 'xmlhttprequest'\n\nexport type NetworkRecordOptions = {\n initiatorTypes?: InitiatorType[]\n maskRequestFn?: (data: CapturedNetworkRequest) => CapturedNetworkRequest | undefined\n recordHeaders?: boolean | { request: boolean; response: boolean }\n recordBody?: boolean | string[] | { request: boolean | string[]; response: boolean | string[] }\n recordInitialRequests?: boolean\n /**\n * whether to record PerformanceEntry events for network requests\n */\n recordPerformance?: boolean\n /**\n * the PerformanceObserver will only observe these entry types\n */\n performanceEntryTypeToObserve: string[]\n /**\n * the maximum size of the request/response body to record\n * NB this will be at most 1MB even if set larger\n */\n payloadSizeLimitBytes: number\n /**\n * some domains we should never record the payload\n * for example other companies session replay ingestion payloads aren't super useful but are gigantic\n * if this isn't provided we use a default list\n * if this is provided - we add the provided list to the default list\n * i.e. we never record the payloads on the default deny list\n */\n payloadHostDenyList?: string[]\n}\n\n/** @deprecated - use CapturedNetworkRequest instead */\nexport type NetworkRequest = {\n url: string\n}\n\n// In rrweb this is called NetworkRequest, but we already exposed that as having only URL\n// we also want to vary from the rrweb NetworkRequest because we want to include\n// all PerformanceEntry properties too.\n// that has 4 required properties\n// readonly duration: DOMHighResTimeStamp;\n// readonly entryType: string;\n// readonly name: string;\n// readonly startTime: DOMHighResTimeStamp;\n// NB: properties below here are ALPHA, don't rely on them, they may change without notice\n\n// we mirror PerformanceEntry since we read into this type from a PerformanceObserver,\n// but we don't want to inherit its readonly-iness\ntype Writable<T> = { -readonly [P in keyof T]: T[P] }\n\nexport type CapturedNetworkRequest = Writable<Omit<PerformanceEntry, 'toJSON'>> & {\n // properties below here are ALPHA, don't rely on them, they may change without notice\n method?: string\n initiatorType?: InitiatorType\n status?: number\n timeOrigin?: number\n timestamp?: number\n startTime?: number\n endTime?: number\n requestHeaders?: Headers\n requestBody?: string | null\n responseHeaders?: Headers\n responseBody?: string | null\n // was this captured before fetch/xhr could have been wrapped\n isInitial?: boolean\n}\n\nexport type ErrorEventArgs = [\n event: string | Event,\n source?: string | undefined,\n lineno?: number | undefined,\n colno?: number | undefined,\n error?: Error | undefined,\n]\n\n// levels originally copied from Sentry to work with the sentry integration\n// and to avoid relying on a frequently changing @sentry/types dependency\n// but provided as an array of literal types, so we can constrain the level below\nexport const severityLevels = ['fatal', 'error', 'warning', 'log', 'info', 'debug'] as const\nexport declare type SeverityLevel = (typeof severityLevels)[number]\n\nexport interface SessionRecordingUrlTrigger {\n url: string\n matching: 'regex'\n}\n\nexport type PropertyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'\n\nexport interface ErrorTrackingSuppressionRule {\n type: 'AND' | 'OR'\n values: ErrorTrackingSuppressionRuleValue[]\n}\n\nexport interface ErrorTrackingSuppressionRuleValue {\n key: '$exception_types' | '$exception_values'\n operator: PropertyMatchType\n value: string | string[]\n type: string\n}\n\nexport type SessionStartReason =\n | 'sampling_overridden'\n | 'recording_initialized'\n | 'linked_flag_matched'\n | 'linked_flag_overridden'\n | typeof SAMPLED\n | 'session_id_changed'\n | 'url_trigger_matched'\n | 'event_trigger_matched'\n\nexport type OverrideConfig = {\n sampling: boolean\n linked_flag: boolean\n url_trigger: boolean\n event_trigger: boolean\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-js",
3
- "version": "1.288.1",
3
+ "version": "1.290.0",
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",
@@ -1,7 +1,10 @@
1
1
  import posthogJs from 'posthog-js';
2
2
  import React, { createContext, useRef, useMemo, useEffect, useContext, useState, useCallback, Children } from 'react';
3
3
 
4
- var PostHogContext = createContext({ client: posthogJs });
4
+ var PostHogContext = createContext({
5
+ client: posthogJs,
6
+ bootstrap: undefined,
7
+ });
5
8
 
6
9
  function isDeepEqual(obj1, obj2, visited) {
7
10
  if (visited === void 0) { visited = new WeakMap(); }
@@ -33,6 +36,7 @@ function isDeepEqual(obj1, obj2, visited) {
33
36
  }
34
37
 
35
38
  function PostHogProvider(_a) {
39
+ var _b, _c;
36
40
  var children = _a.children, client = _a.client, apiKey = _a.apiKey, options = _a.options;
37
41
  var previousInitializationRef = useRef(null);
38
42
  var posthog = useMemo(function () {
@@ -79,60 +83,84 @@ function PostHogProvider(_a) {
79
83
  };
80
84
  }
81
85
  }, [client, apiKey, JSON.stringify(options)]);
82
- return React.createElement(PostHogContext.Provider, { value: { client: posthog } }, children);
86
+ return (React.createElement(PostHogContext.Provider, { value: { client: posthog, bootstrap: (_b = options === null || options === void 0 ? void 0 : options.bootstrap) !== null && _b !== void 0 ? _b : (_c = client === null || client === void 0 ? void 0 : client.config) === null || _c === void 0 ? void 0 : _c.bootstrap } }, children));
83
87
  }
84
88
 
85
- var usePostHog = function () {
86
- var client = useContext(PostHogContext).client;
87
- return client;
89
+ var isFunction = function (f) {
90
+ return typeof f === 'function';
91
+ };
92
+ var isUndefined = function (x) {
93
+ return x === void 0;
94
+ };
95
+ var isNull = function (x) {
96
+ return x === null;
88
97
  };
89
98
 
90
99
  function useFeatureFlagEnabled(flag) {
91
- var client = usePostHog();
92
- var _a = useState(function () { return client.isFeatureEnabled(flag); }), featureEnabled = _a[0], setFeatureEnabled = _a[1];
100
+ var _a;
101
+ var _b = useContext(PostHogContext), client = _b.client, bootstrap = _b.bootstrap;
102
+ var _c = useState(function () { return client.isFeatureEnabled(flag); }), featureEnabled = _c[0], setFeatureEnabled = _c[1];
93
103
  useEffect(function () {
94
104
  return client.onFeatureFlags(function () {
95
105
  setFeatureEnabled(client.isFeatureEnabled(flag));
96
106
  });
97
107
  }, [client, flag]);
108
+ var bootstrapped = (_a = bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags) === null || _a === void 0 ? void 0 : _a[flag];
109
+ if (!client.featureFlags.hasLoadedFlags && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags)) {
110
+ return isUndefined(bootstrapped) ? undefined : !!bootstrapped;
111
+ }
98
112
  return featureEnabled;
99
113
  }
100
114
 
101
115
  function useFeatureFlagPayload(flag) {
102
- var client = usePostHog();
103
- var _a = useState(function () { return client.getFeatureFlagPayload(flag); }), featureFlagPayload = _a[0], setFeatureFlagPayload = _a[1];
116
+ var _a = useContext(PostHogContext), client = _a.client, bootstrap = _a.bootstrap;
117
+ var _b = useState(function () { return client.getFeatureFlagPayload(flag); }), featureFlagPayload = _b[0], setFeatureFlagPayload = _b[1];
104
118
  useEffect(function () {
105
119
  return client.onFeatureFlags(function () {
106
120
  setFeatureFlagPayload(client.getFeatureFlagPayload(flag));
107
121
  });
108
122
  }, [client, flag]);
123
+ if (!client.featureFlags.hasLoadedFlags && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlagPayloads)) {
124
+ return bootstrap.featureFlagPayloads[flag];
125
+ }
109
126
  return featureFlagPayload;
110
127
  }
111
128
 
112
129
  function useActiveFeatureFlags() {
113
- var client = usePostHog();
114
- var _a = useState(function () { return client.featureFlags.getFlags(); }), featureFlags = _a[0], setFeatureFlags = _a[1];
130
+ var _a = useContext(PostHogContext), client = _a.client, bootstrap = _a.bootstrap;
131
+ var _b = useState(function () { return client.featureFlags.getFlags(); }), featureFlags = _b[0], setFeatureFlags = _b[1];
115
132
  useEffect(function () {
116
133
  return client.onFeatureFlags(function (flags) {
117
134
  setFeatureFlags(flags);
118
135
  });
119
136
  }, [client]);
137
+ if (!client.featureFlags.hasLoadedFlags && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags)) {
138
+ return Object.keys(bootstrap.featureFlags);
139
+ }
120
140
  return featureFlags;
121
141
  }
122
142
 
123
143
  function useFeatureFlagVariantKey(flag) {
124
- var client = usePostHog();
125
- var _a = useState(function () {
144
+ var _a = useContext(PostHogContext), client = _a.client, bootstrap = _a.bootstrap;
145
+ var _b = useState(function () {
126
146
  return client.getFeatureFlag(flag);
127
- }), featureFlagVariantKey = _a[0], setFeatureFlagVariantKey = _a[1];
147
+ }), featureFlagVariantKey = _b[0], setFeatureFlagVariantKey = _b[1];
128
148
  useEffect(function () {
129
149
  return client.onFeatureFlags(function () {
130
150
  setFeatureFlagVariantKey(client.getFeatureFlag(flag));
131
151
  });
132
152
  }, [client, flag]);
153
+ if (!client.featureFlags.hasLoadedFlags && (bootstrap === null || bootstrap === void 0 ? void 0 : bootstrap.featureFlags)) {
154
+ return bootstrap.featureFlags[flag];
155
+ }
133
156
  return featureFlagVariantKey;
134
157
  }
135
158
 
159
+ var usePostHog = function () {
160
+ var client = useContext(PostHogContext).client;
161
+ return client;
162
+ };
163
+
136
164
  /******************************************************************************
137
165
  Copyright (c) Microsoft Corporation.
138
166
 
@@ -192,16 +220,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
192
220
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
193
221
  };
194
222
 
195
- var isFunction = function (f) {
196
- return typeof f === 'function';
197
- };
198
- var isUndefined = function (x) {
199
- return x === void 0;
200
- };
201
- var isNull = function (x) {
202
- return x === null;
203
- };
204
-
205
223
  function VisibilityAndClickTracker(_a) {
206
224
  var children = _a.children, onIntersect = _a.onIntersect, onClick = _a.onClick, trackView = _a.trackView, options = _a.options, props = __rest(_a, ["children", "onIntersect", "onClick", "trackView", "options"]);
207
225
  var ref = useRef(null);