@posthog/types 1.313.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 (48) hide show
  1. package/LICENSE +299 -0
  2. package/README.md +103 -0
  3. package/dist/capture.d.ts +65 -0
  4. package/dist/capture.d.ts.map +1 -0
  5. package/dist/capture.js +18 -0
  6. package/dist/capture.mjs +0 -0
  7. package/dist/common.d.ts +10 -0
  8. package/dist/common.d.ts.map +1 -0
  9. package/dist/common.js +18 -0
  10. package/dist/common.mjs +0 -0
  11. package/dist/feature-flags.d.ts +44 -0
  12. package/dist/feature-flags.d.ts.map +1 -0
  13. package/dist/feature-flags.js +18 -0
  14. package/dist/feature-flags.mjs +0 -0
  15. package/dist/index.d.ts +15 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +18 -0
  18. package/dist/index.mjs +0 -0
  19. package/dist/posthog-config.d.ts +1218 -0
  20. package/dist/posthog-config.d.ts.map +1 -0
  21. package/dist/posthog-config.js +18 -0
  22. package/dist/posthog-config.mjs +0 -0
  23. package/dist/posthog.d.ts +395 -0
  24. package/dist/posthog.d.ts.map +1 -0
  25. package/dist/posthog.js +18 -0
  26. package/dist/posthog.mjs +0 -0
  27. package/dist/request.d.ts +11 -0
  28. package/dist/request.d.ts.map +1 -0
  29. package/dist/request.js +18 -0
  30. package/dist/request.mjs +0 -0
  31. package/dist/segment.d.ts +52 -0
  32. package/dist/segment.d.ts.map +1 -0
  33. package/dist/segment.js +18 -0
  34. package/dist/segment.mjs +0 -0
  35. package/dist/session-recording.d.ts +60 -0
  36. package/dist/session-recording.d.ts.map +1 -0
  37. package/dist/session-recording.js +18 -0
  38. package/dist/session-recording.mjs +0 -0
  39. package/package.json +43 -0
  40. package/src/capture.ts +101 -0
  41. package/src/common.ts +9 -0
  42. package/src/feature-flags.ts +60 -0
  43. package/src/index.ts +74 -0
  44. package/src/posthog-config.ts +1395 -0
  45. package/src/posthog.ts +490 -0
  46. package/src/request.ts +14 -0
  47. package/src/segment.ts +56 -0
  48. package/src/session-recording.ts +106 -0
@@ -0,0 +1,1218 @@
1
+ /**
2
+ * PostHog configuration types
3
+ */
4
+ import type { JsonType, Properties } from './common';
5
+ import type { BeforeSendFn, CaptureResult } from './capture';
6
+ import type { RequestResponse } from './request';
7
+ import type { CapturedNetworkRequest, NetworkRequest, SessionRecordingCanvasOptions } from './session-recording';
8
+ import type { SegmentAnalytics } from './segment';
9
+ import type { PostHog } from './posthog';
10
+ export type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label';
11
+ export type DomAutocaptureEvents = 'click' | 'change' | 'submit';
12
+ /**
13
+ * If an array is passed for an allowlist, autocapture events will only be sent for elements matching
14
+ * at least one of the elements in the array. Multiple allowlists can be used
15
+ */
16
+ export interface AutocaptureConfig {
17
+ /**
18
+ * List of URLs to allow autocapture on, can be strings to match
19
+ * or regexes e.g. ['https://example.com', 'test.com/.*']
20
+ * this is useful when you want to autocapture on specific pages only
21
+ *
22
+ * if you set both url_allowlist and url_ignorelist,
23
+ * we check the allowlist first and then the ignorelist.
24
+ * the ignorelist can override the allowlist
25
+ */
26
+ url_allowlist?: (string | RegExp)[];
27
+ /**
28
+ * List of URLs to not allow autocapture on, can be strings to match
29
+ * or regexes e.g. ['https://example.com', 'test.com/.*']
30
+ * this is useful when you want to autocapture on most pages but not some specific ones
31
+ *
32
+ * if you set both url_allowlist and url_ignorelist,
33
+ * we check the allowlist first and then the ignorelist.
34
+ * the ignorelist can override the allowlist
35
+ */
36
+ url_ignorelist?: (string | RegExp)[];
37
+ /**
38
+ * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']
39
+ */
40
+ dom_event_allowlist?: DomAutocaptureEvents[];
41
+ /**
42
+ * List of DOM elements to allow autocapture on
43
+ * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']
44
+ *
45
+ * We consider the tree of elements from the root to the target element of the click event
46
+ * so for the tree `div > div > button > svg`
47
+ * if the allowlist has `button` then we allow the capture when the `button` or the `svg` is the click target
48
+ * but not if either of the `div`s are detected as the click target
49
+ */
50
+ element_allowlist?: AutocaptureCompatibleElement[];
51
+ /**
52
+ * List of CSS selectors to allow autocapture on
53
+ * e.g. ['[ph-capture]']
54
+ * we consider the tree of elements from the root to the target element of the click event
55
+ * so for the tree div > div > button > svg
56
+ * and allow list config `['[id]']`
57
+ * we will capture the click if the click-target or its parents has any id
58
+ *
59
+ * Everything is allowed when there's no allowlist
60
+ */
61
+ css_selector_allowlist?: string[];
62
+ /**
63
+ * Exclude certain element attributes from autocapture
64
+ * E.g. ['aria-label'] or [data-attr-pii]
65
+ */
66
+ element_attribute_ignorelist?: string[];
67
+ /**
68
+ * When set to true, autocapture will capture the text of any element that is cut or copied.
69
+ */
70
+ capture_copied_text?: boolean;
71
+ }
72
+ export interface RageclickConfig {
73
+ /**
74
+ * List of CSS selectors to ignore rageclicks on
75
+ * e.g. ['.my-calendar-button']
76
+ * we consider the tree of elements from the root to the target element of the click event
77
+ * so for the tree div > div > button > svg
78
+ * and ignore list config `['[id]']`
79
+ * we will ignore the rageclick if the click-target or its parents has any id
80
+ *
81
+ * Nothing is ignored when there's an empty ignorelist, e.g. []
82
+ * If no ignorelist is set, we default to ignoring .ph-no-rageclick
83
+ * If an element has .ph-no-capture, it will always be ignored by rageclick and autocapture
84
+ */
85
+ css_selector_ignorelist?: string[];
86
+ /**
87
+ * Controls automatic exclusion of elements by text content from rageclick detection.
88
+ * Useful for pagination buttons, loading spinners, and other repeatedly-clicked UI elements.
89
+ * - `true` (default): Use default keywords ['next', 'previous', 'prev', '>', '<']
90
+ * - `false`: Disable content-based exclusion
91
+ * - `string[]`: Use custom keywords (max 10 items, otherwise use css_selector_ignorelist)
92
+ *
93
+ * Checks if element text content or aria-label contains any of the keywords (case-insensitive)
94
+ * @default true
95
+ */
96
+ content_ignorelist?: boolean | string[];
97
+ /**
98
+ * Maximum pixel distance between clicks to still be considered a rage click.
99
+ * @default 30
100
+ */
101
+ threshold_px?: number;
102
+ /**
103
+ * Number of consecutive clicks within the timeout to qualify as a rage click.
104
+ * @default 3
105
+ */
106
+ click_count?: number;
107
+ /**
108
+ * Maximum time window (in milliseconds) between the first and last click.
109
+ * @default 1000
110
+ */
111
+ timeout_ms?: number;
112
+ }
113
+ export interface BootstrapConfig {
114
+ distinctID?: string;
115
+ isIdentifiedID?: boolean;
116
+ featureFlags?: Record<string, boolean | string>;
117
+ featureFlagPayloads?: Record<string, JsonType>;
118
+ /**
119
+ * 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:
120
+ * - unique to this user
121
+ * - a valid UUID v7
122
+ * - the timestamp part must be <= the timestamp of the first event in the session
123
+ * - the timestamp of the last event in the session must be < the timestamp part + 24 hours
124
+ * **/
125
+ sessionID?: string;
126
+ }
127
+ export type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP';
128
+ export interface PerformanceCaptureConfig {
129
+ /**
130
+ * Works with session replay to use the browser's native performance observer to capture performance metrics
131
+ */
132
+ network_timing?: boolean;
133
+ /**
134
+ * Use chrome's web vitals library to wrap fetch and capture web vitals
135
+ */
136
+ web_vitals?: boolean;
137
+ /**
138
+ * We observe very large values reported by the Chrome web vitals library
139
+ * These outliers are likely not real, useful values, and we exclude them
140
+ * You can set this to 0 in order to include all values, NB this is not recommended
141
+ *
142
+ * @default 15 * 60 * 1000 (15 minutes)
143
+ */
144
+ __web_vitals_max_value?: number;
145
+ /**
146
+ * By default all 4 metrics are captured
147
+ * You can set this config to restrict which metrics are captured
148
+ * e.g. ['CLS', 'FCP'] to only capture those two metrics
149
+ * NB setting this does not override whether the capture is enabled
150
+ *
151
+ * @default ['LCP', 'CLS', 'FCP', 'INP']
152
+ */
153
+ web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[];
154
+ /**
155
+ * We delay flushing web vitals metrics to reduce the number of events we send
156
+ * This is the maximum time we will wait before sending the metrics
157
+ *
158
+ * @default 5000
159
+ */
160
+ web_vitals_delayed_flush_ms?: number;
161
+ }
162
+ export interface DeadClickCandidate {
163
+ node: Element;
164
+ originalEvent: MouseEvent;
165
+ timestamp: number;
166
+ scrollDelayMs?: number;
167
+ mutationDelayMs?: number;
168
+ selectionChangedDelayMs?: number;
169
+ absoluteDelayMs?: number;
170
+ }
171
+ export type ExceptionAutoCaptureConfig = {
172
+ /**
173
+ * Determines whether PostHog should capture unhandled errors.
174
+ *
175
+ * @default true
176
+ */
177
+ capture_unhandled_errors: boolean;
178
+ /**
179
+ * Determines whether PostHog should capture unhandled promise rejections.
180
+ *
181
+ * @default true
182
+ */
183
+ capture_unhandled_rejections: boolean;
184
+ /**
185
+ * Determines whether PostHog should capture console errors.
186
+ *
187
+ * @default false
188
+ */
189
+ capture_console_errors: boolean;
190
+ };
191
+ export type DeadClicksAutoCaptureConfig = {
192
+ /**
193
+ * We'll not consider a click to be a dead click, if it's followed by a scroll within `scroll_threshold_ms` milliseconds
194
+ *
195
+ * @default 100
196
+ */
197
+ scroll_threshold_ms?: number;
198
+ /**
199
+ * 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
200
+ *
201
+ * @default 100
202
+ */
203
+ selection_change_threshold_ms?: number;
204
+ /**
205
+ * We'll not consider a click to be a dead click, if it's followed by a mutation within `mutation_threshold_ms` milliseconds
206
+ *
207
+ * @default 2500
208
+ */
209
+ mutation_threshold_ms?: number;
210
+ /**
211
+ * By default, clicks with modifier keys (ctrl, shift, alt, meta/cmd) held down are not considered dead clicks,
212
+ * since these typically indicate intentional actions like "open in new tab".
213
+ *
214
+ * Set this to true to capture dead clicks even when modifier keys are held.
215
+ *
216
+ * @default false
217
+ */
218
+ capture_clicks_with_modifier_keys?: boolean;
219
+ /**
220
+ * Allows setting behavior for when a dead click is captured.
221
+ * For e.g. to support capture to heatmaps
222
+ *
223
+ * If not provided the default behavior is to auto-capture dead click events
224
+ *
225
+ * Only intended to be provided by our own SDK
226
+ */
227
+ __onCapture?: ((click: DeadClickCandidate, properties: Properties) => void) | undefined;
228
+ } & Pick<AutocaptureConfig, 'element_attribute_ignorelist'>;
229
+ export interface HeatmapConfig {
230
+ /**
231
+ * How often to send batched data in `$heatmap_data` events
232
+ * If set to 0 or not set, sends using the default interval of 1 second
233
+ *
234
+ * @default 1000
235
+ */
236
+ flush_interval_milliseconds: number;
237
+ }
238
+ export type ConfigDefaults = '2025-11-30' | '2025-05-24' | 'unset';
239
+ export type ExternalIntegrationKind = 'intercom' | 'crispChat';
240
+ export interface ErrorTrackingOptions {
241
+ /**
242
+ * Decide whether exceptions thrown by browser extensions should be captured
243
+ *
244
+ * @default false
245
+ */
246
+ captureExtensionExceptions?: boolean;
247
+ /**
248
+ * UNSTABLE: determines whether exception caused by the PostHog SDK will be captured
249
+ *
250
+ * @default false
251
+ */
252
+ __capturePostHogExceptions?: boolean;
253
+ /**
254
+ * ADVANCED: alters the refill rate for the token bucket mutation throttling
255
+ * Normally only altered alongside posthog support guidance.
256
+ * Accepts values between 0 and 100
257
+ *
258
+ * @default 1
259
+ */
260
+ __exceptionRateLimiterRefillRate?: number;
261
+ /**
262
+ * ADVANCED: alters the bucket size for the token bucket mutation throttling
263
+ * Normally only altered alongside posthog support guidance.
264
+ * Accepts values between 0 and 100
265
+ *
266
+ * @default 10
267
+ */
268
+ __exceptionRateLimiterBucketSize?: number;
269
+ }
270
+ /**
271
+ * Mask input options for session recording
272
+ */
273
+ export interface MaskInputOptions {
274
+ color?: boolean;
275
+ date?: boolean;
276
+ 'datetime-local'?: boolean;
277
+ email?: boolean;
278
+ month?: boolean;
279
+ number?: boolean;
280
+ range?: boolean;
281
+ search?: boolean;
282
+ tel?: boolean;
283
+ text?: boolean;
284
+ time?: boolean;
285
+ url?: boolean;
286
+ week?: boolean;
287
+ textarea?: boolean;
288
+ select?: boolean;
289
+ password?: boolean;
290
+ }
291
+ /**
292
+ * Slim DOM options for session recording
293
+ */
294
+ export interface SlimDOMOptions {
295
+ script?: boolean;
296
+ comment?: boolean;
297
+ headFavicon?: boolean;
298
+ headWhitespace?: boolean;
299
+ headMetaDescKeywords?: boolean;
300
+ headMetaSocial?: boolean;
301
+ headMetaRobots?: boolean;
302
+ headMetaHttpEquiv?: boolean;
303
+ headMetaAuthorship?: boolean;
304
+ headMetaVerification?: boolean;
305
+ headTitleMutations?: boolean;
306
+ }
307
+ export interface SessionRecordingOptions {
308
+ /**
309
+ * Derived from `rrweb.record` options
310
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
311
+ * @default 'ph-no-capture'
312
+ */
313
+ blockClass?: string | RegExp;
314
+ /**
315
+ * Derived from `rrweb.record` options
316
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
317
+ * @default null
318
+ */
319
+ blockSelector?: string | null;
320
+ /**
321
+ * Derived from `rrweb.record` options
322
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
323
+ * @default 'ph-ignore-input'
324
+ */
325
+ ignoreClass?: string | RegExp;
326
+ /**
327
+ * Derived from `rrweb.record` options
328
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
329
+ * @default 'ph-mask'
330
+ */
331
+ maskTextClass?: string | RegExp;
332
+ /**
333
+ * Derived from `rrweb.record` options
334
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
335
+ */
336
+ maskTextSelector?: string | null;
337
+ /**
338
+ * Derived from `rrweb.record` options
339
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
340
+ */
341
+ maskTextFn?: ((text: string, element?: HTMLElement) => string) | null;
342
+ /**
343
+ * Derived from `rrweb.record` options
344
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
345
+ */
346
+ maskAllInputs?: boolean;
347
+ /**
348
+ * Derived from `rrweb.record` options
349
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
350
+ */
351
+ maskInputOptions?: Partial<MaskInputOptions>;
352
+ /**
353
+ * Derived from `rrweb.record` options
354
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
355
+ */
356
+ maskInputFn?: ((text: string, element?: HTMLElement) => string) | null;
357
+ /**
358
+ * Derived from `rrweb.record` options
359
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
360
+ * @default {}
361
+ */
362
+ slimDOMOptions?: true | Partial<SlimDOMOptions> | 'all';
363
+ /**
364
+ * Derived from `rrweb.record` options
365
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
366
+ * @default false
367
+ */
368
+ collectFonts?: boolean;
369
+ /**
370
+ * Derived from `rrweb.record` options
371
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
372
+ * @default true
373
+ */
374
+ inlineStylesheet?: boolean;
375
+ /**
376
+ * Derived from `rrweb.record` options
377
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
378
+ * @default false
379
+ */
380
+ recordCrossOriginIframes?: boolean;
381
+ /**
382
+ * Derived from `rrweb.record` options
383
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
384
+ * @default false
385
+ */
386
+ recordHeaders?: boolean;
387
+ /**
388
+ * Derived from `rrweb.record` options
389
+ * @see https://github.com/rrweb-io/rrweb/blob/master/guide.md
390
+ * @default false
391
+ */
392
+ recordBody?: boolean;
393
+ /**
394
+ * Allows local config to override remote canvas recording settings from the flags response
395
+ */
396
+ captureCanvas?: SessionRecordingCanvasOptions;
397
+ /**
398
+ * Modify the network request before it is captured. Returning null or undefined stops it being captured
399
+ */
400
+ maskCapturedNetworkRequestFn?: ((data: CapturedNetworkRequest) => CapturedNetworkRequest | null | undefined) | null;
401
+ /** @deprecated - use maskCapturedNetworkRequestFn instead */
402
+ maskNetworkRequestFn?: ((data: NetworkRequest) => NetworkRequest | null | undefined) | null;
403
+ /**
404
+ * ADVANCED: while a user is active we take a full snapshot of the browser every interval.
405
+ * For very few sites playback performance might be better with different interval.
406
+ * Set to 0 to disable
407
+ *
408
+ * @default 1000 * 60 * 5 (5 minutes)
409
+ */
410
+ full_snapshot_interval_millis?: number;
411
+ /**
412
+ * ADVANCED: whether to partially compress rrweb events before sending them to the server,
413
+ * defaults to true, can be set to false to disable partial compression
414
+ * NB requests are still compressed when sent to the server regardless of this setting
415
+ *
416
+ * @default true
417
+ */
418
+ compress_events?: boolean;
419
+ /**
420
+ * ADVANCED: alters the threshold before a recording considers a user has become idle.
421
+ * Normally only altered alongside changes to session_idle_timeout_ms.
422
+ *
423
+ * @default 1000 * 60 * 5 (5 minutes)
424
+ */
425
+ session_idle_threshold_ms?: number;
426
+ /**
427
+ * ADVANCED: alters the refill rate for the token bucket mutation throttling
428
+ * Normally only altered alongside posthog support guidance.
429
+ * Accepts values between 0 and 100
430
+ *
431
+ * @default 10
432
+ */
433
+ __mutationThrottlerRefillRate?: number;
434
+ /**
435
+ * ADVANCED: alters the bucket size for the token bucket mutation throttling
436
+ * Normally only altered alongside posthog support guidance.
437
+ * Accepts values between 0 and 100
438
+ *
439
+ * @default 100
440
+ */
441
+ __mutationThrottlerBucketSize?: number;
442
+ /**
443
+ * When true, minimum duration is checked against the actual buffer data (first to last timestamp)
444
+ * rather than session duration. This ensures recordings are not sent until they contain the minimum
445
+ * duration of actual data, even across page navigations.
446
+ *
447
+ * @default false
448
+ */
449
+ strictMinimumDuration?: boolean;
450
+ }
451
+ export interface RequestQueueConfig {
452
+ /**
453
+ * ADVANCED - alters the frequency which PostHog sends events to the server.
454
+ * generally speaking this is only set when apps have automatic page refreshes, or very short visits.
455
+ * Defaults to 3 seconds when not set
456
+ * Allowed values between 250 and 5000
457
+ * */
458
+ flush_interval_ms?: number;
459
+ }
460
+ /**
461
+ * Survey configuration options
462
+ */
463
+ export interface SurveyConfig {
464
+ prefillFromUrl?: boolean;
465
+ autoSubmitIfComplete?: boolean;
466
+ autoSubmitDelay?: number;
467
+ }
468
+ type NextOptions = {
469
+ revalidate: false | 0 | number;
470
+ tags: string[];
471
+ };
472
+ /**
473
+ * Configuration options for the PostHog JavaScript SDK.
474
+ * @see https://posthog.com/docs/libraries/js#config
475
+ */
476
+ export interface PostHogConfig {
477
+ /** URL of your PostHog instance.
478
+ *
479
+ * @default 'https://us.i.posthog.com'
480
+ */
481
+ api_host: string;
482
+ /**
483
+ * URL to use for feature flag requests specifically.
484
+ * If not set, feature flag requests will use the URL derived from `api_host`.
485
+ * This is useful when you want to route feature flag requests to a different endpoint than other analytic APIs.
486
+ *
487
+ * @default null
488
+ */
489
+ flags_api_host?: string | null;
490
+ /**
491
+ * If using a reverse proxy for `api_host` then this should be the actual PostHog app URL (e.g. https://us.posthog.com).
492
+ * This ensures that links to PostHog point to the correct host.
493
+ *
494
+ * @default null
495
+ */
496
+ ui_host: string | null;
497
+ /**
498
+ * The transport method to use for API requests.
499
+ *
500
+ * @default 'fetch'
501
+ */
502
+ api_transport?: 'XHR' | 'fetch';
503
+ /**
504
+ * The token for your PostHog project.
505
+ * It should NOT be provided manually in the config, but rather passed as the first parameter to `posthog.init()`.
506
+ */
507
+ token: string;
508
+ /**
509
+ * The name this instance will be identified by.
510
+ * You don't need to set this most of the time,
511
+ * but can be useful if you have several Posthog instances running at the same time.
512
+ *
513
+ * @default 'posthog'
514
+ */
515
+ name: string;
516
+ /**
517
+ * Determines whether PostHog should autocapture events.
518
+ * This setting does not affect capturing pageview events (see `capture_pageview`).
519
+ *
520
+ * by default autocapture is ignored on elements that match a `ph-no-capture` css class on the element or a parent
521
+ * @default true
522
+ */
523
+ autocapture: boolean | AutocaptureConfig;
524
+ /**
525
+ * Determines whether PostHog should capture rage clicks.
526
+ *
527
+ * 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
528
+ * @default true
529
+ */
530
+ rageclick: boolean | RageclickConfig;
531
+ /**
532
+ * Determines if cookie should be set on the top level domain (example.com).
533
+ * If PostHog-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,
534
+ * it'll set the cookie on the subdomain only (test.example.com).
535
+ *
536
+ * 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.
537
+ * The current list of excluded platforms is `herokuapp.com`, `vercel.app`, and `netlify.app`.
538
+ *
539
+ * @see `isCrossDomainCookie`
540
+ * @default true
541
+ */
542
+ cross_subdomain_cookie: boolean;
543
+ /**
544
+ * Determines how PostHog stores information about the user. See [persistence](https://posthog.com/docs/libraries/js#persistence) for details.
545
+ *
546
+ * @default 'localStorage+cookie'
547
+ */
548
+ persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage';
549
+ /**
550
+ * The name for the super properties persistent store
551
+ *
552
+ * @default ''
553
+ */
554
+ persistence_name: string;
555
+ /** @deprecated - Use 'persistence_name' instead */
556
+ cookie_name?: string;
557
+ /**
558
+ * List of custom property names that should be stored in cookies (in addition to the default ones)
559
+ * when using 'localStorage+cookie' persistence mode. This allows these properties to be shared
560
+ * across subdomains when cross_subdomain_cookie is enabled.
561
+ *
562
+ * @default []
563
+ */
564
+ cookie_persisted_properties?: readonly string[];
565
+ /**
566
+ * A function to be called once the PostHog scripts have loaded successfully.
567
+ *
568
+ * @param posthog_instance - The PostHog instance that has been loaded.
569
+ */
570
+ loaded: (posthog_instance: PostHog) => void;
571
+ /**
572
+ * Determines whether PostHog should save referrer information.
573
+ *
574
+ * @default true
575
+ */
576
+ save_referrer: boolean;
577
+ /**
578
+ * Determines whether PostHog should save marketing parameters.
579
+ * These are `utm_*` paramaters and friends.
580
+ *
581
+ * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.
582
+ * @default true
583
+ */
584
+ save_campaign_params: boolean;
585
+ /** @deprecated - Use `save_campaign_params` instead */
586
+ store_google?: boolean;
587
+ /**
588
+ * Used to extend the list of campaign parameters that are saved by default.
589
+ *
590
+ * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.
591
+ * @default []
592
+ */
593
+ custom_campaign_params: string[];
594
+ /**
595
+ * Used to extend the list of user agents that are blocked by default.
596
+ *
597
+ * @see {DEFAULT_BLOCKED_UA_STRS} from './utils/blocked-uas' - Default list of blocked user agents.
598
+ * @default []
599
+ */
600
+ custom_blocked_useragents: string[];
601
+ /**
602
+ * Determines whether PostHog should be in debug mode.
603
+ * You can enable this to get more detailed logging.
604
+ *
605
+ * You can also enable this on your website by appending `?__posthog_debug=true` at the end of your URL
606
+ * You can also call `posthog.debug()` in your code to enable debug mode
607
+ *
608
+ * @default false
609
+ */
610
+ debug: boolean;
611
+ /** @deprecated Use `debug` instead */
612
+ verbose?: boolean;
613
+ /**
614
+ * Determines whether PostHog should capture pageview events automatically.
615
+ * Can be:
616
+ * - `true`: Capture regular pageviews (default)
617
+ * - `false`: Don't capture any pageviews
618
+ * - `'history_change'`: Only capture pageviews on history API changes (pushState, replaceState, popstate)
619
+ *
620
+ * @default true
621
+ */
622
+ capture_pageview: boolean | 'history_change';
623
+ /**
624
+ * Determines whether PostHog should capture pageleave events.
625
+ * If set to `true`, it will capture pageleave events for all pages.
626
+ * If set to `'if_capture_pageview'`, it will only capture pageleave events if `capture_pageview` is also set to `true` or `'history_change'`.
627
+ *
628
+ * @default 'if_capture_pageview'
629
+ */
630
+ capture_pageleave: boolean | 'if_capture_pageview';
631
+ /**
632
+ * Determines the number of days to store cookies for.
633
+ *
634
+ * @default 365
635
+ */
636
+ cookie_expiration: number;
637
+ /**
638
+ * Determines whether PostHog should upgrade old cookies.
639
+ * 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.
640
+ * This option only works in the initialization, so make sure you set it when you create the library.
641
+ *
642
+ * @default false
643
+ */
644
+ upgrade: boolean;
645
+ /**
646
+ * Determines whether PostHog should disable session recording.
647
+ *
648
+ * @default false
649
+ */
650
+ disable_session_recording: boolean;
651
+ /**
652
+ * Determines whether PostHog should disable persistence.
653
+ * 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.
654
+ *
655
+ * @default false
656
+ */
657
+ disable_persistence: boolean;
658
+ /** @deprecated - use `disable_persistence` instead */
659
+ disable_cookie?: boolean;
660
+ /**
661
+ * Determines whether PostHog should disable all surveys functionality.
662
+ *
663
+ * @default false
664
+ */
665
+ disable_surveys: boolean;
666
+ /**
667
+ * 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.
668
+ *
669
+ * @default false
670
+ */
671
+ disable_surveys_automatic_display: boolean;
672
+ /**
673
+ * Determines whether PostHog should disable all product tours functionality.
674
+ *
675
+ * @default true (disabled until feature is ready for GA)
676
+ */
677
+ disable_product_tours: boolean;
678
+ /**
679
+ * Survey-specific configuration options.
680
+ *
681
+ * @default undefined
682
+ */
683
+ surveys?: SurveyConfig;
684
+ /**
685
+ * Determines whether PostHog should disable all conversations functionality.
686
+ *
687
+ * @default false
688
+ */
689
+ disable_conversations: boolean;
690
+ /**
691
+ * Determines whether PostHog should disable web experiments.
692
+ *
693
+ * Currently disabled while we're in BETA. It will be toggled to `true` in a future release.
694
+ *
695
+ * @default true
696
+ */
697
+ disable_web_experiments: boolean;
698
+ /**
699
+ * Determines whether PostHog should disable any external dependency loading.
700
+ * This will prevent PostHog from requesting any external scripts such as those needed for Session Replay, Surveys or Site Apps.
701
+ *
702
+ * @default false
703
+ */
704
+ disable_external_dependency_loading: boolean;
705
+ /**
706
+ * A function to be called when a script is being loaded.
707
+ * This can be used to modify the script before it is loaded.
708
+ * This is useful for adding a nonce to the script, for example.
709
+ *
710
+ * @param script - The script element that is being loaded.
711
+ * @returns The modified script element, or null if the script should not be loaded.
712
+ */
713
+ prepare_external_dependency_script?: (script: HTMLScriptElement) => HTMLScriptElement | null;
714
+ /**
715
+ * A function to be called when a stylesheet is being loaded.
716
+ * This can be used to modify the stylesheet before it is loaded.
717
+ * This is useful for adding a nonce to the stylesheet, for example.
718
+ *
719
+ * @param stylesheet - The stylesheet element that is being loaded.
720
+ * @returns The modified stylesheet element, or null if the stylesheet should not be loaded.
721
+ */
722
+ prepare_external_dependency_stylesheet?: (stylesheet: HTMLStyleElement) => HTMLStyleElement | null;
723
+ /**
724
+ * Determines whether PostHog should enable recording console logs.
725
+ * When undefined, it falls back to the remote config setting.
726
+ *
727
+ * @default undefined
728
+ */
729
+ enable_recording_console_log?: boolean;
730
+ /**
731
+ * Determines whether PostHog should use secure cookies.
732
+ * If this is `true`, PostHog cookies will be marked as secure,
733
+ * meaning they will only be transmitted over HTTPS.
734
+ *
735
+ * @default window.location.protocol === 'https:'
736
+ */
737
+ secure_cookie: boolean;
738
+ /**
739
+ * Determines if users should be opted out of PostHog tracking by default,
740
+ * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.
741
+ *
742
+ * @default false
743
+ */
744
+ opt_out_capturing_by_default: boolean;
745
+ /**
746
+ * Determines where we'll save the information about whether users are opted out of capturing.
747
+ *
748
+ * @default 'localStorage'
749
+ */
750
+ opt_out_capturing_persistence_type: 'localStorage' | 'cookie';
751
+ /**
752
+ * Determines if users should be opted out of browser data storage by this PostHog instance by default,
753
+ * requiring additional logic to opt them into capturing by calling `posthog.opt_in_capturing()`.
754
+ *
755
+ * @default false
756
+ */
757
+ opt_out_persistence_by_default?: boolean;
758
+ /**
759
+ * Determines if users should be opted out of user agent filtering such as googlebot or other bots.
760
+ * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,
761
+ * but will process all events as if they were from a browser.
762
+ *
763
+ * @default false
764
+ */
765
+ opt_out_useragent_filter: boolean;
766
+ /** @deprecated Use `consent_persistence_name` instead. This will be removed in a future major version. **/
767
+ opt_out_capturing_cookie_prefix: string | null;
768
+ /**
769
+ * Determines the key for the cookie / local storage used to store the information about whether users are opted in/out of capturing.
770
+ * When `null`, we used a key based on your token.
771
+ *
772
+ * @default null
773
+ * @see `ConsentManager._storageKey`
774
+ */
775
+ consent_persistence_name: string | null;
776
+ /**
777
+ * Determines if users should be opted in to site apps.
778
+ *
779
+ * @default false
780
+ */
781
+ opt_in_site_apps: boolean;
782
+ /**
783
+ * Determines whether PostHog should respect the Do Not Track header when computing
784
+ * consent in `ConsentManager`.
785
+ *
786
+ * @see `ConsentManager`
787
+ * @default false
788
+ */
789
+ respect_dnt: boolean;
790
+ /**
791
+ * A list of properties that should never be sent with capture calls.
792
+ *
793
+ * @default []
794
+ */
795
+ property_denylist: string[];
796
+ /** @deprecated - use `property_denylist` instead */
797
+ property_blacklist?: string[];
798
+ /**
799
+ * A list of headers that should be sent with requests to the PostHog API.
800
+ *
801
+ * @default {}
802
+ */
803
+ request_headers: {
804
+ [header_name: string]: string;
805
+ };
806
+ /** @deprecated - use `request_headers` instead */
807
+ xhr_headers?: {
808
+ [header_name: string]: string;
809
+ };
810
+ /**
811
+ * A function that is called when a request to the PostHog API fails.
812
+ *
813
+ * @param error - The `RequestResponse` object that occurred.
814
+ */
815
+ on_request_error?: (error: RequestResponse) => void;
816
+ /** @deprecated - use `on_request_error` instead */
817
+ on_xhr_error?: (failedRequest: XMLHttpRequest) => void;
818
+ /**
819
+ * Determines whether PostHog should batch requests to the PostHog API.
820
+ *
821
+ * @default true
822
+ */
823
+ request_batching: boolean;
824
+ /**
825
+ * Determines the maximum length of the properties string that can be sent with capture calls.
826
+ *
827
+ * @default 65535
828
+ */
829
+ properties_string_max_length: number;
830
+ /**
831
+ * Configuration defaults for breaking changes. When set to a specific date,
832
+ * enables new default behaviors that were introduced on that date.
833
+ *
834
+ * - `'unset'`: Use legacy default behaviors
835
+ * - `'2025-05-24'`: Use updated default behaviors (e.g. capture_pageview defaults to 'history_change')
836
+ * - `'2025-11-30'`: Defaults from '2025-05-24' plus additional changes (e.g. strict minimum duration for replay and rageclick content ignore list defaults to active)
837
+ *
838
+ * @default 'unset'
839
+ */
840
+ defaults: ConfigDefaults;
841
+ /**
842
+ * EXPERIMENTAL: Defers initialization of non-critical extensions (autocapture, session recording, etc.)
843
+ * to the next event loop tick using setTimeout. This reduces main thread blocking during SDK
844
+ * initialization for better page load performance, while keeping critical functionality
845
+ * (persistence, sessions, capture) available immediately.
846
+ *
847
+ * When enabled:
848
+ * - Persistence, sessions, and basic capture work immediately
849
+ * - Extensions (autocapture, recording, heatmaps, etc.) start after yielding back to the browser
850
+ *
851
+ * @default false (will be true for defaults >= '2025-11-06' in the future)
852
+ * @experimental
853
+ */
854
+ __preview_deferred_init_extensions: boolean;
855
+ /**
856
+ * Determines the session recording options.
857
+ *
858
+ * @see `SessionRecordingOptions`
859
+ * @default {}
860
+ */
861
+ session_recording: SessionRecordingOptions;
862
+ /**
863
+ * Determines the error tracking options.
864
+ *
865
+ * @see `ErrorTrackingOptions`
866
+ * @default {}
867
+ */
868
+ error_tracking: ErrorTrackingOptions;
869
+ /**
870
+ * Determines the session idle timeout in seconds.
871
+ * Any new event that's happened after this timeout will create a new session.
872
+ *
873
+ * @default 30 * 60 -- 30 minutes
874
+ */
875
+ session_idle_timeout_seconds: number;
876
+ /**
877
+ * Prevent autocapture from capturing any attribute names on elements.
878
+ *
879
+ * @default false
880
+ */
881
+ mask_all_element_attributes: boolean;
882
+ /**
883
+ * Prevent autocapture from capturing `textContent` on elements.
884
+ *
885
+ * @default false
886
+ */
887
+ mask_all_text: boolean;
888
+ /**
889
+ * Mask personal data properties from the current URL.
890
+ * This will mask personal data properties such as advertising IDs (gclid, fbclid, etc.), and you can also add
891
+ * custom properties to mask with `custom_personal_data_properties`.
892
+ * @default false
893
+ * @see {PERSONAL_DATA_CAMPAIGN_PARAMS} - Default campaign parameters that are masked by default.
894
+ * @see {PostHogConfig.custom_personal_data_properties} - Custom list of personal data properties to mask.
895
+ */
896
+ mask_personal_data_properties: boolean;
897
+ /**
898
+ * Custom list of personal data properties to mask.
899
+ *
900
+ * E.g. if you added `email` to this list, then any `email` property in the URL will be masked.
901
+ * https://www.example.com/login?email=john.doe%40example.com => https://www.example.com/login?email=<MASKED>
902
+ *
903
+ * @default []
904
+ * @see {PostHogConfig.mask_personal_data_properties} - Must be enabled for this to take effect.
905
+ */
906
+ custom_personal_data_properties: string[];
907
+ /**
908
+ * One of the very first things the PostHog library does when init() is called
909
+ * is make a request to the /flags endpoint on PostHog's backend.
910
+ * This endpoint contains information on how to run the PostHog library
911
+ * so events are properly received in the backend, and it also contains
912
+ * feature flag evaluation information for the current user.
913
+ *
914
+ * This endpoint is required to run most features of this library.
915
+ * However, if you're not using any of the described features,
916
+ * you may wish to turn off the call completely to avoid an extra request
917
+ * and reduce resource usage on both the client and the server.
918
+ *
919
+ * WARNING: Disabling this will also prevent remote configuration from loading,
920
+ * which could mean features like web vitals, surveys, and other features configured
921
+ * in PostHog settings are disabled unless explicitly enabled via client-side config.
922
+ * When setting this to true, make sure to explicitly configure any features you
923
+ * want to use (e.g., capture_performance, autocapture, etc.) in your SDK's init config.
924
+ *
925
+ * @default false
926
+ */
927
+ advanced_disable_flags?: boolean;
928
+ /**
929
+ * @deprecated Use `advanced_disable_flags` instead. This will be removed in a future major version.
930
+ *
931
+ * One of the very first things the PostHog library does when init() is called
932
+ * is make a request to the /decide endpoint on PostHog's backend.
933
+ * This endpoint contains information on how to run the PostHog library
934
+ * so events are properly received in the backend.
935
+ *
936
+ * This endpoint is required to run most features of the library.
937
+ * However, if you're not using any of the described features,
938
+ * you may wish to turn off the call completely to avoid an extra request
939
+ * and reduce resource usage on both the client and the server.
940
+ *
941
+ * @default false
942
+ */
943
+ advanced_disable_decide?: boolean;
944
+ /**
945
+ * Will keep /flags running, but without evaluating any feature flags.
946
+ * Useful for when you need to load the config data associated with the flags endpoint
947
+ * (e.g. /flags?v=2&config=true) without evaluating any feature flags. Most folks use this
948
+ * to save money on feature flag evaluation (by bootstrapping feature flags on the server side).
949
+ *
950
+ * @default false
951
+ */
952
+ advanced_disable_feature_flags: boolean;
953
+ /**
954
+ * Stops from firing feature flag requests on first page load.
955
+ * Only requests feature flags when user identity or properties are updated,
956
+ * or you manually request for flags to be loaded.
957
+ *
958
+ * @default false
959
+ */
960
+ advanced_disable_feature_flags_on_first_load: boolean;
961
+ /**
962
+ * Evaluation environments for feature flags.
963
+ * When set, only feature flags that have at least one matching evaluation tag
964
+ * will be evaluated for this SDK instance. Feature flags with no evaluation tags
965
+ * will always be evaluated.
966
+ *
967
+ * Examples: ['production', 'web', 'checkout']
968
+ *
969
+ * @default undefined
970
+ */
971
+ evaluation_environments?: readonly string[];
972
+ /**
973
+ * Determines whether PostHog should disable toolbar metrics.
974
+ * This is our internal instrumentation for our toolbar in your website.
975
+ *
976
+ * @default false
977
+ */
978
+ advanced_disable_toolbar_metrics: boolean;
979
+ /**
980
+ * Determines whether PostHog should only evaluate feature flags for surveys.
981
+ * Useful for when you want to use this library to evaluate feature flags for surveys only but you have additional feature flags
982
+ * that you evaluate on the server side.
983
+ *
984
+ * @default false
985
+ */
986
+ advanced_only_evaluate_survey_feature_flags: boolean;
987
+ /**
988
+ * When this is enabled, surveys will always be initialized, regardless of the /flags response or remote config settings.
989
+ * This is useful if you want to use surveys but disable all other flag-dependent functionality.
990
+ * Used internally for displaying external surveys without making a /flags request.
991
+ *
992
+ * @default false
993
+ */
994
+ advanced_enable_surveys: boolean;
995
+ /**
996
+ * Sets timeout for fetching feature flags
997
+ *
998
+ * @default 3000
999
+ */
1000
+ feature_flag_request_timeout_ms: number;
1001
+ /**
1002
+ * Sets timeout for fetching surveys
1003
+ *
1004
+ * @default 10000
1005
+ */
1006
+ surveys_request_timeout_ms: number;
1007
+ /**
1008
+ * Function to get the device ID.
1009
+ * This doesn't usually need to be set, but can be useful if you want to use a custom device ID.
1010
+ *
1011
+ * @param uuid - The UUID we would use for the device ID.
1012
+ * @returns The device ID.
1013
+ *
1014
+ * @default (uuid) => uuid
1015
+ */
1016
+ get_device_id: (uuid: string) => string;
1017
+ /**
1018
+ * This function or array of functions - if provided - are called immediately before sending data to the server.
1019
+ * It allows you to edit data before it is sent, or choose not to send it all.
1020
+ * if provided as an array the functions are called in the order they are provided
1021
+ * any one function returning null means the event will not be sent
1022
+ */
1023
+ before_send?: BeforeSendFn | BeforeSendFn[];
1024
+ /** @deprecated - use `before_send` instead */
1025
+ sanitize_properties: ((properties: Properties, event_name: string) => Properties) | null;
1026
+ /** @deprecated - use `before_send` instead */
1027
+ _onCapture: (eventName: string, eventData: CaptureResult) => void;
1028
+ /**
1029
+ * Determines whether to capture performance metrics.
1030
+ * These include Network Timing and Web Vitals.
1031
+ *
1032
+ * When `undefined`, fallback to the remote configuration.
1033
+ * If `false`, neither network timing nor web vitals will work.
1034
+ * If an object, that will override the remote configuration.
1035
+ *
1036
+ * @see {PerformanceCaptureConfig}
1037
+ * @default undefined
1038
+ */
1039
+ capture_performance?: boolean | PerformanceCaptureConfig;
1040
+ /**
1041
+ * Determines whether to disable compression when sending events to the server.
1042
+ * WARNING: Should only be used for testing. Could negatively impact performance.
1043
+ *
1044
+ * @default false
1045
+ */
1046
+ disable_compression: boolean;
1047
+ /**
1048
+ * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,
1049
+ * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.
1050
+ *
1051
+ * Since there is a delay between initializing PostHog and fetching feature flags,
1052
+ * feature flags are not always available immediately.
1053
+ * This makes them unusable if you want to do something like redirecting a user
1054
+ * to a different page based on a feature flag.
1055
+ *
1056
+ * You can, therefore, fetch the feature flags in your server and pre-fill them here,
1057
+ * allowing PostHog to know the feature flag values immediately.
1058
+ *
1059
+ * After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.
1060
+ *
1061
+ * @default {}
1062
+ */
1063
+ bootstrap: BootstrapConfig;
1064
+ /**
1065
+ * The segment analytics object.
1066
+ *
1067
+ * @see https://posthog.com/docs/libraries/segment
1068
+ */
1069
+ segment?: SegmentAnalytics;
1070
+ /**
1071
+ * Determines whether to capture heatmaps.
1072
+ *
1073
+ * @see {HeatmapConfig}
1074
+ * @default undefined
1075
+ */
1076
+ capture_heatmaps?: boolean | HeatmapConfig;
1077
+ enable_heatmaps?: boolean;
1078
+ /**
1079
+ * Determines whether to capture dead clicks.
1080
+ *
1081
+ * @see {DeadClicksAutoCaptureConfig}
1082
+ * @default undefined
1083
+ */
1084
+ capture_dead_clicks?: boolean | DeadClicksAutoCaptureConfig;
1085
+ /**
1086
+ * Determines whether to capture exceptions.
1087
+ *
1088
+ * @see {ExceptionAutoCaptureConfig}
1089
+ * @default undefined
1090
+ */
1091
+ capture_exceptions?: boolean | ExceptionAutoCaptureConfig;
1092
+ /**
1093
+ * Determines whether to disable scroll properties.
1094
+ * These allow you to keep track of how far down someone scrolled in your website.
1095
+ *
1096
+ * @default false
1097
+ */
1098
+ disable_scroll_properties?: boolean;
1099
+ /**
1100
+ * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`
1101
+ * It will use `window.document.documentElement` if not specified.
1102
+ */
1103
+ scroll_root_selector?: string | string[];
1104
+ /**
1105
+ * You can control whether events from PostHog-js have person processing enabled with the `person_profiles` config setting.
1106
+ * There are three options:
1107
+ * - `person_profiles: 'always'` - we will process persons data for all events
1108
+ * - `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`.
1109
+ * - `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.
1110
+ *
1111
+ * @default 'identified_only'
1112
+ */
1113
+ person_profiles?: 'always' | 'never' | 'identified_only';
1114
+ /** @deprecated - use `person_profiles` instead */
1115
+ process_person?: 'always' | 'never' | 'identified_only';
1116
+ /**
1117
+ * Client side rate limiting
1118
+ */
1119
+ rate_limiting?: {
1120
+ /**
1121
+ * The average number of events per second that should be permitted
1122
+ *
1123
+ * @default 10
1124
+ */
1125
+ events_per_second?: number;
1126
+ /**
1127
+ * How many events can be captured in a burst. This defaults to 10 times the events_per_second count
1128
+ *
1129
+ * @default 10 * `events_per_second`
1130
+ */
1131
+ events_burst_limit?: number;
1132
+ };
1133
+ /**
1134
+ * Used when sending data via `fetch`, use with care.
1135
+ * This is intentionally meant to be used with NextJS `fetch`
1136
+ *
1137
+ * Incorrect `cache` usage may cause out-of-date data for feature flags, actions tracking, etc.
1138
+ * See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options
1139
+ */
1140
+ fetch_options?: {
1141
+ cache?: RequestCache;
1142
+ next_options?: NextOptions;
1143
+ };
1144
+ /**
1145
+ * Used to change the behavior of the request queue.
1146
+ * This is an advanced feature and should be used with caution.
1147
+ */
1148
+ request_queue_config?: RequestQueueConfig;
1149
+ /**
1150
+ * Used to set-up external integrations with PostHog data - such as session replays, distinct id, etc.
1151
+ */
1152
+ integrations?: Record<ExternalIntegrationKind, boolean>;
1153
+ /**
1154
+ * Enables cookieless mode. In this mode, PostHog will not set any cookies, or use session or local storage. User
1155
+ * identity is handled by generating a privacy-preserving hash on PostHog's servers.
1156
+ * - 'always' - enable cookieless mode immediately on startup, use this if you do not intend to show a cookie banner
1157
+ * - '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.
1158
+ *
1159
+ * 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.
1160
+ * */
1161
+ cookieless_mode?: 'always' | 'on_reject';
1162
+ /**
1163
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
1164
+ * A list of hostnames for which to inject PostHog tracing headers to all requests
1165
+ * (X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID, X-POSTHOG-WINDOW-ID)
1166
+ * */
1167
+ __add_tracing_headers?: string[];
1168
+ /**
1169
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
1170
+ * Enables the new RemoteConfig approach to loading config instead of /flags?v=2&config=true
1171
+ * */
1172
+ __preview_remote_config?: boolean;
1173
+ /**
1174
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
1175
+ * Whether to use the new /flags/ endpoint
1176
+ * */
1177
+ __preview_flags_v2?: boolean;
1178
+ /**
1179
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - ONLY USE WHEN TALKING TO POSTHOG SUPPORT
1180
+ * Enables deprecated eager loading of session recording code, not just rrweb and network plugin
1181
+ * we are switching the default to lazy loading because the bundle will ultimately be 18% smaller then
1182
+ * keeping this around for a few days in case there are unexpected consequences that testing did not uncover
1183
+ * */
1184
+ __preview_eager_load_replay?: boolean;
1185
+ /**
1186
+ * Prevents posthog-js from using the `navigator.sendBeacon` API to send events.
1187
+ * Enabling this option may hurt the reliability of sending $pageleave events
1188
+ */
1189
+ __preview_disable_beacon?: boolean;
1190
+ /**
1191
+ * Disables sending credentials when using XHR requests.
1192
+ */
1193
+ __preview_disable_xhr_credentials?: boolean;
1194
+ /**
1195
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
1196
+ * Enables collection of bot traffic as $bot_pageview events with detailed bot detection
1197
+ * properties instead of dropping them entirely. Use it alongside opt_out_useragent_filter
1198
+ */
1199
+ __preview_capture_bot_pageviews?: boolean;
1200
+ /**
1201
+ * @deprecated - does nothing
1202
+ * was present only for PostHog testing of replay lazy loading
1203
+ * */
1204
+ __preview_lazy_load_replay?: boolean;
1205
+ /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */
1206
+ api_method?: string;
1207
+ /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */
1208
+ inapp_protocol?: string;
1209
+ /** @deprecated - NOT USED ANYMORE, kept here for backwards compatibility reasons */
1210
+ inapp_link_new_window?: boolean;
1211
+ /**
1212
+ * @deprecated - THIS OPTION HAS NO EFFECT, kept here for backwards compatibility reasons.
1213
+ * Use a custom transformation or "Discard IP data" project setting instead: @see https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address.
1214
+ */
1215
+ ip: boolean;
1216
+ }
1217
+ export {};
1218
+ //# sourceMappingURL=posthog-config.d.ts.map