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