@leanbase.com/js 0.1.2 → 0.2.0-alpha.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 (136) hide show
  1. package/dist/autocapture-utils.d.ts +17 -0
  2. package/dist/autocapture.d.ts +35 -0
  3. package/dist/config.d.ts +5 -0
  4. package/dist/constants.d.ts +54 -0
  5. package/dist/entrypoints/main.cjs.d.ts +4 -0
  6. package/dist/entrypoints/module.es.d.ts +4 -0
  7. package/dist/extensions/rageclick.d.ts +9 -0
  8. package/dist/iife.d.ts +19 -0
  9. package/dist/index.d.ts +2 -779
  10. package/dist/leanbase-logger.d.ts +6 -0
  11. package/dist/leanbase-persistence.d.ts +64 -0
  12. package/dist/leanbase.d.ts +49 -0
  13. package/dist/leanbase.iife.js +1 -4745
  14. package/dist/leanbase.iife.js.map +1 -1
  15. package/dist/main.js +2 -0
  16. package/dist/main.js.map +1 -0
  17. package/dist/module.d.ts +780 -0
  18. package/dist/module.js +2 -0
  19. package/dist/module.js.map +1 -0
  20. package/dist/page-view.d.ts +29 -0
  21. package/dist/scroll-manager.d.ts +21 -0
  22. package/dist/session-props.d.ts +32 -0
  23. package/dist/sessionid.d.ts +50 -0
  24. package/dist/storage.d.ts +24 -0
  25. package/{src/types.ts → dist/types.d.ts} +145 -235
  26. package/dist/utils/blocked-uas.d.ts +17 -0
  27. package/dist/utils/element-utils.d.ts +5 -0
  28. package/dist/utils/event-utils.d.ts +22 -0
  29. package/dist/utils/index.d.ts +44 -0
  30. package/dist/utils/request-utils.d.ts +12 -0
  31. package/dist/utils/simple-event-emitter.d.ts +6 -0
  32. package/dist/utils/user-agent-utils.d.ts +18 -0
  33. package/dist/uuidv7.d.ts +43 -0
  34. package/dist/version.d.ts +1 -0
  35. package/lib/autocapture-utils.d.ts +17 -0
  36. package/{src/autocapture-utils.ts → lib/autocapture-utils.js} +196 -280
  37. package/lib/autocapture-utils.js.map +1 -0
  38. package/lib/autocapture.d.ts +35 -0
  39. package/lib/autocapture.js +311 -0
  40. package/lib/autocapture.js.map +1 -0
  41. package/lib/config.d.ts +5 -0
  42. package/lib/config.js +7 -0
  43. package/lib/config.js.map +1 -0
  44. package/lib/constants.d.ts +54 -0
  45. package/{src/constants.ts → lib/constants.js} +58 -55
  46. package/lib/constants.js.map +1 -0
  47. package/lib/entrypoints/main.cjs.d.ts +4 -0
  48. package/lib/entrypoints/main.cjs.js +3 -0
  49. package/lib/entrypoints/main.cjs.js.map +1 -0
  50. package/lib/entrypoints/module.es.d.ts +4 -0
  51. package/lib/entrypoints/module.es.js +3 -0
  52. package/lib/entrypoints/module.es.js.map +1 -0
  53. package/lib/extensions/rageclick.d.ts +9 -0
  54. package/lib/extensions/rageclick.js +27 -0
  55. package/lib/extensions/rageclick.js.map +1 -0
  56. package/lib/iife.d.ts +19 -0
  57. package/lib/iife.js +67 -0
  58. package/lib/iife.js.map +1 -0
  59. package/{src/index.ts → lib/index.d.ts} +2 -2
  60. package/lib/index.js +2 -0
  61. package/lib/index.js.map +1 -0
  62. package/lib/leanbase-logger.d.ts +6 -0
  63. package/lib/leanbase-logger.js +25 -0
  64. package/lib/leanbase-logger.js.map +1 -0
  65. package/lib/leanbase-persistence.d.ts +64 -0
  66. package/lib/leanbase-persistence.js +287 -0
  67. package/lib/leanbase-persistence.js.map +1 -0
  68. package/lib/leanbase.d.ts +49 -0
  69. package/lib/leanbase.js +294 -0
  70. package/lib/leanbase.js.map +1 -0
  71. package/lib/page-view.d.ts +29 -0
  72. package/lib/page-view.js +81 -0
  73. package/lib/page-view.js.map +1 -0
  74. package/lib/scroll-manager.d.ts +21 -0
  75. package/lib/scroll-manager.js +79 -0
  76. package/lib/scroll-manager.js.map +1 -0
  77. package/lib/session-props.d.ts +32 -0
  78. package/lib/session-props.js +73 -0
  79. package/lib/session-props.js.map +1 -0
  80. package/lib/sessionid.d.ts +50 -0
  81. package/{src/sessionid.ts → lib/sessionid.js} +128 -204
  82. package/lib/sessionid.js.map +1 -0
  83. package/lib/storage.d.ts +24 -0
  84. package/{src/storage.ts → lib/storage.js} +182 -225
  85. package/lib/storage.js.map +1 -0
  86. package/lib/types.d.ts +544 -0
  87. package/lib/types.js +7 -0
  88. package/lib/types.js.map +1 -0
  89. package/lib/utils/blocked-uas.d.ts +17 -0
  90. package/{src/utils/blocked-uas.ts → lib/utils/blocked-uas.js} +19 -48
  91. package/lib/utils/blocked-uas.js.map +1 -0
  92. package/lib/utils/element-utils.d.ts +5 -0
  93. package/{src/utils/element-utils.ts → lib/utils/element-utils.js} +13 -17
  94. package/lib/utils/element-utils.js.map +1 -0
  95. package/lib/utils/event-utils.d.ts +22 -0
  96. package/lib/utils/event-utils.js +258 -0
  97. package/lib/utils/event-utils.js.map +1 -0
  98. package/lib/utils/index.d.ts +44 -0
  99. package/lib/utils/index.js +183 -0
  100. package/lib/utils/index.js.map +1 -0
  101. package/lib/utils/request-utils.d.ts +12 -0
  102. package/lib/utils/request-utils.js +107 -0
  103. package/lib/utils/request-utils.js.map +1 -0
  104. package/lib/utils/simple-event-emitter.d.ts +6 -0
  105. package/lib/utils/simple-event-emitter.js +24 -0
  106. package/lib/utils/simple-event-emitter.js.map +1 -0
  107. package/lib/utils/user-agent-utils.d.ts +18 -0
  108. package/lib/utils/user-agent-utils.js +369 -0
  109. package/lib/utils/user-agent-utils.js.map +1 -0
  110. package/lib/uuidv7.d.ts +43 -0
  111. package/{src/uuidv7.ts → lib/uuidv7.js} +103 -131
  112. package/lib/uuidv7.js.map +1 -0
  113. package/lib/version.d.ts +1 -0
  114. package/lib/version.js +2 -0
  115. package/lib/version.js.map +1 -0
  116. package/package.json +23 -11
  117. package/dist/index.cjs +0 -3032
  118. package/dist/index.cjs.map +0 -1
  119. package/dist/index.mjs +0 -3030
  120. package/dist/index.mjs.map +0 -1
  121. package/src/autocapture.ts +0 -415
  122. package/src/config.ts +0 -8
  123. package/src/extensions/rageclick.ts +0 -34
  124. package/src/iife.ts +0 -87
  125. package/src/leanbase-logger.ts +0 -26
  126. package/src/leanbase-persistence.ts +0 -374
  127. package/src/leanbase.ts +0 -424
  128. package/src/page-view.ts +0 -124
  129. package/src/scroll-manager.ts +0 -103
  130. package/src/session-props.ts +0 -114
  131. package/src/utils/event-utils.ts +0 -304
  132. package/src/utils/index.ts +0 -222
  133. package/src/utils/request-utils.ts +0 -128
  134. package/src/utils/simple-event-emitter.ts +0 -27
  135. package/src/utils/user-agent-utils.ts +0 -357
  136. package/src/version.ts +0 -1
@@ -1,22 +1,16 @@
1
- import { FeatureFlagValue, JsonType, PostHogCoreOptions } from '@posthog/core'
2
- import { KnownUnsafeEditableEvent } from '@posthog/core'
3
- import { Leanbase } from './leanbase'
4
-
5
- export const COPY_AUTOCAPTURE_EVENT = '$copy_autocapture'
6
-
7
- export type Property = any
8
- export type Properties = Record<string, Property>
9
-
10
- export type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label'
11
-
12
- export type DomAutocaptureEvents = 'click' | 'change' | 'submit'
13
-
1
+ import { FeatureFlagValue, JsonType, PostHogCoreOptions } from '@posthog/core';
2
+ import { KnownUnsafeEditableEvent } from '@posthog/core';
3
+ import { Leanbase } from './leanbase';
4
+ export declare const COPY_AUTOCAPTURE_EVENT = "$copy_autocapture";
5
+ export type Property = any;
6
+ export type Properties = Record<string, Property>;
7
+ export type AutocaptureCompatibleElement = 'a' | 'button' | 'form' | 'input' | 'select' | 'textarea' | 'label';
8
+ export type DomAutocaptureEvents = 'click' | 'change' | 'submit';
14
9
  export interface BootstrapConfig {
15
- distinctId?: string
16
- isIdentifiedId?: boolean
17
- featureFlags?: Record<string, FeatureFlagValue>
18
- featureFlagPayloads?: Record<string, JsonType>
19
-
10
+ distinctId?: string;
11
+ isIdentifiedId?: boolean;
12
+ featureFlags?: Record<string, FeatureFlagValue>;
13
+ featureFlagPayloads?: Record<string, JsonType>;
20
14
  /**
21
15
  * 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:
22
16
  * - unique to this user
@@ -24,9 +18,8 @@ export interface BootstrapConfig {
24
18
  * - the timestamp part must be <= the timestamp of the first event in the session
25
19
  * - the timestamp of the last event in the session must be < the timestamp part + 24 hours
26
20
  * **/
27
- sessionID?: string
21
+ sessionID?: string;
28
22
  }
29
-
30
23
  /**
31
24
  * If an array is passed for an allowlist, autocapture events will only be sent for elements matching
32
25
  * at least one of the elements in the array. Multiple allowlists can be used
@@ -41,8 +34,7 @@ export interface AutocaptureConfig {
41
34
  * we check the allowlist first and then the ignorelist.
42
35
  * the ignorelist can override the allowlist
43
36
  */
44
- url_allowlist?: (string | RegExp)[]
45
-
37
+ url_allowlist?: (string | RegExp)[];
46
38
  /**
47
39
  * List of URLs to not allow autocapture on, can be strings to match
48
40
  * or regexes e.g. ['https://example.com', 'test.com/.*']
@@ -52,13 +44,11 @@ export interface AutocaptureConfig {
52
44
  * we check the allowlist first and then the ignorelist.
53
45
  * the ignorelist can override the allowlist
54
46
  */
55
- url_ignorelist?: (string | RegExp)[]
56
-
47
+ url_ignorelist?: (string | RegExp)[];
57
48
  /**
58
49
  * List of DOM events to allow autocapture on e.g. ['click', 'change', 'submit']
59
50
  */
60
- dom_event_allowlist?: DomAutocaptureEvents[]
61
-
51
+ dom_event_allowlist?: DomAutocaptureEvents[];
62
52
  /**
63
53
  * List of DOM elements to allow autocapture on
64
54
  * e.g. ['a', 'button', 'form', 'input', 'select', 'textarea', 'label']
@@ -68,8 +58,7 @@ export interface AutocaptureConfig {
68
58
  * if the allowlist has `button` then we allow the capture when the `button` or the `svg` is the click target
69
59
  * but not if either of the `div`s are detected as the click target
70
60
  */
71
- element_allowlist?: AutocaptureCompatibleElement[]
72
-
61
+ element_allowlist?: AutocaptureCompatibleElement[];
73
62
  /**
74
63
  * List of CSS selectors to allow autocapture on
75
64
  * e.g. ['[ph-capture]']
@@ -80,39 +69,33 @@ export interface AutocaptureConfig {
80
69
  *
81
70
  * Everything is allowed when there's no allowlist
82
71
  */
83
- css_selector_allowlist?: string[]
84
-
72
+ css_selector_allowlist?: string[];
85
73
  /**
86
74
  * Exclude certain element attributes from autocapture
87
75
  * E.g. ['aria-label'] or [data-attr-pii]
88
76
  */
89
- element_attribute_ignorelist?: string[]
90
-
77
+ element_attribute_ignorelist?: string[];
91
78
  /**
92
79
  * When set to true, autocapture will capture the text of any element that is cut or copied.
93
80
  */
94
- capture_copied_text?: boolean
81
+ capture_copied_text?: boolean;
95
82
  }
96
-
97
83
  export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
98
84
  /**
99
85
  * API host for Leanbase
100
86
  * @default 'https://i.leanbase.co'
101
87
  */
102
- host?: string
103
-
88
+ host?: string;
104
89
  /**
105
90
  * The token for your Leanbase project.
106
91
  * It should NOT be provided manually in the config, but rather passed as the first parameter to `leanbase.init()`.
107
92
  */
108
- token: string
109
-
93
+ token: string;
110
94
  /**
111
95
  * Enables debug mode, which provides more verbose logging for development purposes.
112
96
  * @default false
113
97
  */
114
- debug?: boolean
115
-
98
+ debug?: boolean;
116
99
  /**
117
100
  * Determines whether Leanbase should autocapture events.
118
101
  * This setting does not affect capturing pageview events (see `capture_pageview`).
@@ -120,8 +103,7 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
120
103
  * by default autocapture is ignored on elements that match a `ph-no-capture` css class on the element or a parent
121
104
  * @default true
122
105
  */
123
- autocapture: boolean | AutocaptureConfig
124
-
106
+ autocapture: boolean | AutocaptureConfig;
125
107
  /**
126
108
  * Determines whether Leanbase should capture pageview events automatically.
127
109
  * Can be:
@@ -131,16 +113,14 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
131
113
  *
132
114
  * @default true
133
115
  */
134
- capture_pageview: boolean | 'history_change'
135
-
116
+ capture_pageview: boolean | 'history_change';
136
117
  /**
137
118
  * Determines the session idle timeout in seconds.
138
119
  * Any new event that's happened after this timeout will create a new session.
139
120
  *
140
121
  * @default 30 * 60 -- 30 minutes
141
122
  */
142
- session_idle_timeout_seconds: number
143
-
123
+ session_idle_timeout_seconds: number;
144
124
  /**
145
125
  * An object containing the `distinctID`, `isIdentifiedID`, and `featureFlags` keys,
146
126
  * where `distinctID` is a string, and `featureFlags` is an object of key-value pairs.
@@ -157,8 +137,7 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
157
137
  *
158
138
  * @default {}
159
139
  */
160
- bootstrap: BootstrapConfig
161
-
140
+ bootstrap: BootstrapConfig;
162
141
  /**
163
142
  * Determines whether Leanbase should capture pageleave events.
164
143
  * If set to `true`, it will capture pageleave events for all pages.
@@ -166,50 +145,43 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
166
145
  *
167
146
  * @default 'if_capture_pageview'
168
147
  */
169
- capture_pageleave: boolean | 'if_capture_pageview'
170
-
148
+ capture_pageleave: boolean | 'if_capture_pageview';
171
149
  /**
172
150
  * Determines whether Leanbase should capture rage clicks.
173
151
  *
174
152
  * 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
175
153
  * @default true
176
154
  */
177
- rageclick: boolean | RageclickConfig
178
-
155
+ rageclick: boolean | RageclickConfig;
179
156
  /**
180
157
  * Determines where to store the Leanbase persistence information.
181
158
  */
182
- persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage'
183
-
159
+ persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage';
184
160
  /**
185
161
  * The name for the super properties persistent store
186
162
  *
187
163
  * @default ''
188
164
  */
189
- persistence_name: string
190
-
165
+ persistence_name: string;
191
166
  /**
192
167
  * Prevent autocapture from capturing any attribute names on elements.
193
168
  *
194
169
  * @default false
195
170
  */
196
- mask_all_element_attributes: boolean
197
-
171
+ mask_all_element_attributes: boolean;
198
172
  /**
199
173
  * Prevent autocapture from capturing `textContent` on elements.
200
174
  *
201
175
  * @default false
202
176
  */
203
- mask_all_text: boolean
204
-
177
+ mask_all_text: boolean;
205
178
  /**
206
179
  * Used to extend the list of campaign parameters that are saved by default.
207
180
  *
208
181
  * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.
209
182
  * @default []
210
183
  */
211
- custom_campaign_params: string[]
212
-
184
+ custom_campaign_params: string[];
213
185
  /**
214
186
  * Mask personal data properties from the current URL.
215
187
  * This will mask personal data properties such as advertising IDs (gclid, fbclid, etc.), and you can also add
@@ -218,8 +190,7 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
218
190
  * @see {PERSONAL_DATA_CAMPAIGN_PARAMS} - Default campaign parameters that are masked by default.
219
191
  * @see {LeanbaseConfig.custom_personal_data_properties} - Custom list of personal data properties to mask.
220
192
  */
221
- mask_personal_data_properties: boolean
222
-
193
+ mask_personal_data_properties: boolean;
223
194
  /**
224
195
  * Custom list of personal data properties to mask.
225
196
  *
@@ -229,15 +200,13 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
229
200
  * @default []
230
201
  * @see {LeanbaseConfig.mask_personal_data_properties} - Must be enabled for this to take effect.
231
202
  */
232
- custom_personal_data_properties: string[]
233
-
203
+ custom_personal_data_properties: string[];
234
204
  /**
235
205
  * Determines the number of days to store cookies for.
236
206
  *
237
207
  * @default 365
238
208
  */
239
- cookie_expiration: number
240
-
209
+ cookie_expiration: number;
241
210
  /**
242
211
  * Determines whether Leanbase should use secure cookies.
243
212
  * If this is `true`, Leanbase cookies will be marked as secure,
@@ -245,8 +214,7 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
245
214
  *
246
215
  * @default window.location.protocol === 'https:'
247
216
  */
248
- secure_cookie: boolean
249
-
217
+ secure_cookie: boolean;
250
218
  /**
251
219
  * Determines if cookie should be set on the top level domain (example.com).
252
220
  * If leanbase-js is loaded on a subdomain (test.example.com), and `cross_subdomain_cookie` is set to false,
@@ -258,16 +226,14 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
258
226
  * @see `isCrossDomainCookie`
259
227
  * @default true
260
228
  */
261
- cross_subdomain_cookie: boolean
262
-
229
+ cross_subdomain_cookie: boolean;
263
230
  /**
264
231
  * Determines whether Leanbase should disable persistence.
265
232
  * 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.
266
233
  *
267
234
  * @default false
268
235
  */
269
- disable_persistence: boolean
270
-
236
+ disable_persistence: boolean;
271
237
  /**
272
238
  * Enables cookieless mode. In this mode, Leanbase will not set any cookies, or use session or local storage. User
273
239
  * identity is handled by generating a privacy-preserving hash on Leanbase's servers.
@@ -276,15 +242,13 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
276
242
  *
277
243
  * Note that you MUST enable cookieless mode in your Leanbase project's settings, otherwise all your cookieless events will be ignored. We plan to remove this requirement in the future.
278
244
  * */
279
- cookieless_mode?: 'always' | 'on_reject'
280
-
245
+ cookieless_mode?: 'always' | 'on_reject';
281
246
  /**
282
247
  * Determines whether PostHog should save referrer information.
283
248
  *
284
249
  * @default true
285
250
  */
286
- save_referrer: boolean
287
-
251
+ save_referrer: boolean;
288
252
  /**
289
253
  * Determines whether PostHog should save marketing parameters.
290
254
  * These are `utm_*` paramaters and friends.
@@ -292,22 +256,19 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
292
256
  * @see {CAMPAIGN_PARAMS} from './utils/event-utils' - Default campaign parameters like utm_source, utm_medium, etc.
293
257
  * @default true
294
258
  */
295
- save_campaign_params: boolean
296
-
259
+ save_campaign_params: boolean;
297
260
  /**
298
261
  * Determines whether to disable scroll properties.
299
262
  * These allow you to keep track of how far down someone scrolled in your website.
300
263
  *
301
264
  * @default false
302
265
  */
303
- disable_scroll_properties?: boolean
304
-
266
+ disable_scroll_properties?: boolean;
305
267
  /**
306
268
  * Let the pageview scroll stats use a custom css selector for the root element, e.g. `main`
307
269
  * It will use `window.document.documentElement` if not specified.
308
270
  */
309
- scroll_root_selector?: string | string[]
310
-
271
+ scroll_root_selector?: string | string[];
311
272
  /**
312
273
  * Determines if users should be opted out of user agent filtering such as googlebot or other bots.
313
274
  * If this is set to `true`, PostHog will set `$browser_type` to either `bot` or `browser` for all events,
@@ -315,23 +276,20 @@ export interface LeanbaseConfig extends Partial<PostHogCoreOptions> {
315
276
  *
316
277
  * @default false
317
278
  */
318
- opt_out_useragent_filter: boolean
319
-
279
+ opt_out_useragent_filter: boolean;
320
280
  /**
321
281
  * Determines the maximum length of the properties string that can be sent with capture calls.
322
282
  *
323
283
  * @default 65535
324
284
  */
325
- properties_string_max_length: number
326
-
285
+ properties_string_max_length: number;
327
286
  /**
328
287
  * A function to be called once the Leanbase scripts have loaded successfully.
329
288
  *
330
289
  * @param instance - The Leanbase instance that has been loaded.
331
290
  */
332
- loaded: (instance: Leanbase) => void
291
+ loaded: (instance: Leanbase) => void;
333
292
  }
334
-
335
293
  export interface RageclickConfig {
336
294
  /**
337
295
  * List of CSS selectors to ignore rageclicks on
@@ -345,41 +303,33 @@ export interface RageclickConfig {
345
303
  * If no ignorelist is set, we default to ignoring .ph-no-rageclick
346
304
  * If an element has .ph-no-capture, it will always be ignored by rageclick and autocapture
347
305
  */
348
- css_selector_ignorelist?: string[]
306
+ css_selector_ignorelist?: string[];
349
307
  }
350
-
351
- export type PropertyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains'
352
-
308
+ export type PropertyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains';
353
309
  export interface ErrorTrackingSuppressionRule {
354
- type: 'AND' | 'OR'
355
- values: ErrorTrackingSuppressionRuleValue[]
310
+ type: 'AND' | 'OR';
311
+ values: ErrorTrackingSuppressionRuleValue[];
356
312
  }
357
-
358
313
  export interface ErrorTrackingSuppressionRuleValue {
359
- key: '$exception_types' | '$exception_values'
360
- operator: PropertyMatchType
361
- value: string | string[]
362
- type: string
314
+ key: '$exception_types' | '$exception_values';
315
+ operator: PropertyMatchType;
316
+ value: string | string[];
317
+ type: string;
363
318
  }
364
-
365
- export enum Compression {
366
- GZipJS = 'gzip-js',
367
- Base64 = 'base64',
319
+ export declare enum Compression {
320
+ GZipJS = "gzip-js",
321
+ Base64 = "base64"
368
322
  }
369
-
370
- export type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP'
371
-
323
+ export type SupportedWebVitalsMetrics = 'LCP' | 'CLS' | 'FCP' | 'INP';
372
324
  export interface PerformanceCaptureConfig {
373
325
  /**
374
326
  * Works with session replay to use the browser's native performance observer to capture performance metrics
375
327
  */
376
- network_timing?: boolean
377
-
328
+ network_timing?: boolean;
378
329
  /**
379
330
  * Use chrome's web vitals library to wrap fetch and capture web vitals
380
331
  */
381
- web_vitals?: boolean
382
-
332
+ web_vitals?: boolean;
383
333
  /**
384
334
  * We observe very large values reported by the Chrome web vitals library
385
335
  * These outliers are likely not real, useful values, and we exclude them
@@ -387,8 +337,7 @@ export interface PerformanceCaptureConfig {
387
337
  *
388
338
  * @default 15 * 60 * 1000 (15 minutes)
389
339
  */
390
- __web_vitals_max_value?: number
391
-
340
+ __web_vitals_max_value?: number;
392
341
  /**
393
342
  * By default all 4 metrics are captured
394
343
  * You can set this config to restrict which metrics are captured
@@ -397,17 +346,15 @@ export interface PerformanceCaptureConfig {
397
346
  *
398
347
  * @default ['LCP', 'CLS', 'FCP', 'INP']
399
348
  */
400
- web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[]
401
-
349
+ web_vitals_allowed_metrics?: SupportedWebVitalsMetrics[];
402
350
  /**
403
351
  * We delay flushing web vitals metrics to reduce the number of events we send
404
352
  * This is the maximum time we will wait before sending the metrics
405
353
  *
406
354
  * @default 5000
407
355
  */
408
- web_vitals_delayed_flush_ms?: number
356
+ web_vitals_delayed_flush_ms?: number;
409
357
  }
410
-
411
358
  /**
412
359
  * Remote configuration for the Leanbase instance
413
360
  *
@@ -418,13 +365,11 @@ export interface RemoteConfig {
418
365
  /**
419
366
  * Supported compression algorithms
420
367
  */
421
- supportedCompression: Compression[]
422
-
368
+ supportedCompression: Compression[];
423
369
  /**
424
370
  * If set, disables autocapture
425
371
  */
426
- autocapture_opt_out?: boolean
427
-
372
+ autocapture_opt_out?: boolean;
428
373
  /**
429
374
  * originally capturePerformance was replay only and so boolean true
430
375
  * is equivalent to { network_timing: true }
@@ -434,201 +379,166 @@ export interface RemoteConfig {
434
379
  * they work standalone but enhance each other
435
380
  * TODO: deprecate this so we make a new config that doesn't need this explanation
436
381
  */
437
- capturePerformance?: boolean | PerformanceCaptureConfig
438
-
382
+ capturePerformance?: boolean | PerformanceCaptureConfig;
439
383
  /**
440
384
  * Whether we should use a custom endpoint for analytics
441
385
  *
442
386
  * @default { endpoint: "/e" }
443
387
  */
444
388
  analytics?: {
445
- endpoint?: string
446
- }
447
-
389
+ endpoint?: string;
390
+ };
448
391
  /**
449
392
  * Whether the `$elements_chain` property should be sent as a string or as an array
450
393
  *
451
394
  * @default false
452
395
  */
453
- elementsChainAsString?: boolean
454
-
396
+ elementsChainAsString?: boolean;
455
397
  /**
456
398
  * Error tracking configuration options
457
399
  */
458
400
  errorTracking?: {
459
- autocaptureExceptions?: boolean
460
- captureExtensionExceptions?: boolean
461
- suppressionRules?: ErrorTrackingSuppressionRule[]
462
- }
463
-
401
+ autocaptureExceptions?: boolean;
402
+ captureExtensionExceptions?: boolean;
403
+ suppressionRules?: ErrorTrackingSuppressionRule[];
404
+ };
464
405
  /**
465
406
  * This is currently in development and may have breaking changes without a major version bump
466
407
  */
467
- autocaptureExceptions?: boolean | { endpoint?: string }
468
-
408
+ autocaptureExceptions?: boolean | {
409
+ endpoint?: string;
410
+ };
469
411
  /**
470
412
  * @deprecated, moved to toolbarParams
471
413
  */
472
- toolbarVersion: 'toolbar'
473
-
414
+ toolbarVersion: 'toolbar';
474
415
  /**
475
416
  * Whether the user is authenticated
476
417
  */
477
- isAuthenticated: boolean
478
-
418
+ isAuthenticated: boolean;
479
419
  /**
480
420
  * List of site apps with their IDs and URLs
481
421
  */
482
- siteApps: { id: string; url: string }[]
483
-
422
+ siteApps: {
423
+ id: string;
424
+ url: string;
425
+ }[];
484
426
  /**
485
427
  * Whether heatmaps are enabled
486
428
  */
487
- heatmaps?: boolean
488
-
429
+ heatmaps?: boolean;
489
430
  /**
490
431
  * Whether to only capture identified users by default
491
432
  */
492
- defaultIdentifiedOnly?: boolean
493
-
433
+ defaultIdentifiedOnly?: boolean;
494
434
  /**
495
435
  * Whether to capture dead clicks
496
436
  */
497
- captureDeadClicks?: boolean
498
-
437
+ captureDeadClicks?: boolean;
499
438
  /**
500
439
  * Indicates if the team has any flags enabled (if not we don't need to load them)
501
440
  */
502
- hasFeatureFlags?: boolean
441
+ hasFeatureFlags?: boolean;
503
442
  }
504
-
505
443
  /**
506
444
  * These are known events Leanbase events that can be processed by the `beforeCapture` function
507
445
  * That means Leanbase functionality does not rely on receiving 100% of these for calculations
508
446
  * So, it is safe to sample them to reduce the volume of events sent to Leanbase
509
447
  */
510
- export type KnownEventName =
511
- | '$heatmaps_data'
512
- | '$opt_in'
513
- | '$exception'
514
- | '$$heatmap'
515
- | '$web_vitals'
516
- | '$dead_click'
517
- | '$autocapture'
518
- | typeof COPY_AUTOCAPTURE_EVENT
519
- | '$rageclick'
520
-
521
- export type EventName = KnownUnsafeEditableEvent | KnownEventName | (string & {})
522
-
448
+ export type KnownEventName = '$heatmaps_data' | '$opt_in' | '$exception' | '$$heatmap' | '$web_vitals' | '$dead_click' | '$autocapture' | typeof COPY_AUTOCAPTURE_EVENT | '$rageclick';
449
+ export type EventName = KnownUnsafeEditableEvent | KnownEventName | (string & {});
523
450
  export interface PersistentStore {
524
- _is_supported: () => boolean
525
- _error: (error: any) => void
526
- _parse: (name: string) => any
527
- _get: (name: string) => any
528
- _set: (
529
- name: string,
530
- value: any,
531
- expire_days?: number | null,
532
- cross_subdomain?: boolean,
533
- secure?: boolean,
534
- debug?: boolean
535
- ) => void
536
- _remove: (name: string, cross_subdomain?: boolean) => void
451
+ _is_supported: () => boolean;
452
+ _error: (error: any) => void;
453
+ _parse: (name: string) => any;
454
+ _get: (name: string) => any;
455
+ _set: (name: string, value: any, expire_days?: number | null, cross_subdomain?: boolean, secure?: boolean, debug?: boolean) => void;
456
+ _remove: (name: string, cross_subdomain?: boolean) => void;
537
457
  }
538
-
539
458
  export interface RequestResponse {
540
- statusCode: number
541
- text?: string
542
- json?: any
459
+ statusCode: number;
460
+ text?: string;
461
+ json?: any;
543
462
  }
544
-
545
- export type RequestCallback = (response: RequestResponse) => void
546
-
547
- // See https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options
548
- type NextOptions = { revalidate: false | 0 | number; tags: string[] }
549
-
463
+ export type RequestCallback = (response: RequestResponse) => void;
464
+ type NextOptions = {
465
+ revalidate: false | 0 | number;
466
+ tags: string[];
467
+ };
550
468
  export interface RequestWithOptions {
551
- url: string
552
- data?: Record<string, any> | Record<string, any>[]
553
- headers?: Record<string, any>
554
- transport?: 'XHR' | 'fetch' | 'sendBeacon'
555
- method?: 'POST' | 'GET'
556
- urlQueryArgs?: { compression: Compression }
557
- callback?: RequestCallback
558
- timeout?: number
559
- noRetries?: boolean
560
- disableTransport?: ('XHR' | 'fetch' | 'sendBeacon')[]
561
- disableXHRCredentials?: boolean
562
- compression?: Compression | 'best-available'
469
+ url: string;
470
+ data?: Record<string, any> | Record<string, any>[];
471
+ headers?: Record<string, any>;
472
+ transport?: 'XHR' | 'fetch' | 'sendBeacon';
473
+ method?: 'POST' | 'GET';
474
+ urlQueryArgs?: {
475
+ compression: Compression;
476
+ };
477
+ callback?: RequestCallback;
478
+ timeout?: number;
479
+ noRetries?: boolean;
480
+ disableTransport?: ('XHR' | 'fetch' | 'sendBeacon')[];
481
+ disableXHRCredentials?: boolean;
482
+ compression?: Compression | 'best-available';
563
483
  fetchOptions?: {
564
- cache?: RequestInit['cache']
565
- next?: NextOptions
566
- }
484
+ cache?: RequestInit['cache'];
485
+ next?: NextOptions;
486
+ };
567
487
  }
568
-
569
- export type SessionIdChangedCallback = (
570
- sessionId: string,
571
- windowId: string | null | undefined,
572
- changeReason?: { noSessionId: boolean; activityTimeout: boolean; sessionPastMaximumLength: boolean }
573
- ) => void
574
-
488
+ export type SessionIdChangedCallback = (sessionId: string, windowId: string | null | undefined, changeReason?: {
489
+ noSessionId: boolean;
490
+ activityTimeout: boolean;
491
+ sessionPastMaximumLength: boolean;
492
+ }) => void;
575
493
  export type LeanbasegCaptureOptions = {
576
494
  /** If provided overrides the auto-generated event ID */
577
- uuid?: string
578
- disableGeoip?: boolean
495
+ uuid?: string;
496
+ disableGeoip?: boolean;
579
497
  /**
580
498
  * Used when `$identify` is called
581
499
  * Will set person properties overriding previous values
582
500
  */
583
- $set?: Properties
584
-
501
+ $set?: Properties;
585
502
  /**
586
503
  * Used when `$identify` is called
587
504
  * Will set person properties but only once, it will NOT override previous values
588
505
  */
589
- $set_once?: Properties
590
-
506
+ $set_once?: Properties;
591
507
  /**
592
508
  * Used to override the desired endpoint for the captured event
593
509
  */
594
- _url?: string
595
-
510
+ _url?: string;
596
511
  /**
597
512
  * key of queue, e.g. 'sessionRecording' vs 'event'
598
513
  */
599
- _batchKey?: string
600
-
514
+ _batchKey?: string;
601
515
  /**
602
516
  * If set, overrides and disables config.properties_string_max_length
603
517
  */
604
- _noTruncate?: boolean
605
-
518
+ _noTruncate?: boolean;
606
519
  /**
607
520
  * If set, skips the batched queue
608
521
  */
609
- send_instantly?: boolean
610
-
522
+ send_instantly?: boolean;
611
523
  /**
612
524
  * If set, skips the client side rate limiting
613
525
  */
614
- skip_client_rate_limiting?: boolean
615
-
526
+ skip_client_rate_limiting?: boolean;
616
527
  /**
617
528
  * If set, overrides the desired transport method
618
529
  */
619
- transport?: RequestWithOptions['transport']
620
-
530
+ transport?: RequestWithOptions['transport'];
621
531
  /**
622
532
  * If set, overrides the current timestamp
623
533
  */
624
- timestamp?: Date
625
- }
626
-
534
+ timestamp?: Date;
535
+ };
627
536
  export interface CaptureResult {
628
- uuid: string
629
- event: EventName
630
- properties: Properties
631
- $set?: Properties
632
- $set_once?: Properties
633
- timestamp?: Date
537
+ uuid: string;
538
+ event: EventName;
539
+ properties: Properties;
540
+ $set?: Properties;
541
+ $set_once?: Properties;
542
+ timestamp?: Date;
634
543
  }
544
+ export {};