@leanbase.com/js 0.1.3 → 0.2.0-alpha.1

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 (141) hide show
  1. package/LICENSE +37 -0
  2. package/dist/autocapture-utils.d.ts +17 -0
  3. package/dist/autocapture.d.ts +35 -0
  4. package/dist/config.d.ts +5 -0
  5. package/dist/consent.d.ts +25 -0
  6. package/dist/constants.d.ts +54 -0
  7. package/dist/entrypoints/main.cjs.d.ts +4 -0
  8. package/dist/entrypoints/module.es.d.ts +4 -0
  9. package/dist/extensions/rageclick.d.ts +9 -0
  10. package/dist/iife.d.ts +19 -0
  11. package/dist/index.d.ts +2 -779
  12. package/dist/leanbase-logger.d.ts +6 -0
  13. package/dist/leanbase-persistence.d.ts +64 -0
  14. package/dist/leanbase.d.ts +53 -0
  15. package/dist/leanbase.iife.js +1 -4747
  16. package/dist/leanbase.iife.js.map +1 -1
  17. package/dist/main.js +2 -0
  18. package/dist/main.js.map +1 -0
  19. package/dist/module.d.ts +856 -0
  20. package/dist/module.js +2 -0
  21. package/dist/module.js.map +1 -0
  22. package/dist/page-view.d.ts +29 -0
  23. package/dist/scroll-manager.d.ts +21 -0
  24. package/dist/session-props.d.ts +32 -0
  25. package/dist/sessionid.d.ts +50 -0
  26. package/dist/storage.d.ts +24 -0
  27. package/{src/types.ts → dist/types.d.ts} +200 -242
  28. package/dist/utils/blocked-uas.d.ts +17 -0
  29. package/dist/utils/element-utils.d.ts +5 -0
  30. package/dist/utils/event-utils.d.ts +22 -0
  31. package/dist/utils/index.d.ts +46 -0
  32. package/dist/utils/request-utils.d.ts +12 -0
  33. package/dist/utils/simple-event-emitter.d.ts +6 -0
  34. package/dist/utils/user-agent-utils.d.ts +18 -0
  35. package/dist/uuidv7.d.ts +43 -0
  36. package/dist/version.d.ts +1 -0
  37. package/lib/autocapture-utils.d.ts +17 -0
  38. package/{src/autocapture-utils.ts → lib/autocapture-utils.js} +196 -280
  39. package/lib/autocapture-utils.js.map +1 -0
  40. package/lib/autocapture.d.ts +35 -0
  41. package/lib/autocapture.js +311 -0
  42. package/lib/autocapture.js.map +1 -0
  43. package/lib/config.d.ts +5 -0
  44. package/lib/config.js +7 -0
  45. package/lib/config.js.map +1 -0
  46. package/lib/consent.d.ts +25 -0
  47. package/lib/consent.js +101 -0
  48. package/lib/consent.js.map +1 -0
  49. package/lib/constants.d.ts +54 -0
  50. package/{src/constants.ts → lib/constants.js} +50 -57
  51. package/lib/constants.js.map +1 -0
  52. package/lib/entrypoints/main.cjs.d.ts +4 -0
  53. package/lib/entrypoints/main.cjs.js +3 -0
  54. package/lib/entrypoints/main.cjs.js.map +1 -0
  55. package/lib/entrypoints/module.es.d.ts +4 -0
  56. package/lib/entrypoints/module.es.js +3 -0
  57. package/lib/entrypoints/module.es.js.map +1 -0
  58. package/lib/extensions/rageclick.d.ts +9 -0
  59. package/lib/extensions/rageclick.js +27 -0
  60. package/lib/extensions/rageclick.js.map +1 -0
  61. package/lib/iife.d.ts +19 -0
  62. package/lib/iife.js +67 -0
  63. package/lib/iife.js.map +1 -0
  64. package/{src/index.ts → lib/index.d.ts} +2 -2
  65. package/lib/index.js +2 -0
  66. package/lib/index.js.map +1 -0
  67. package/lib/leanbase-logger.d.ts +6 -0
  68. package/lib/leanbase-logger.js +25 -0
  69. package/lib/leanbase-logger.js.map +1 -0
  70. package/lib/leanbase-persistence.d.ts +64 -0
  71. package/lib/leanbase-persistence.js +287 -0
  72. package/lib/leanbase-persistence.js.map +1 -0
  73. package/lib/leanbase.d.ts +53 -0
  74. package/lib/leanbase.js +359 -0
  75. package/lib/leanbase.js.map +1 -0
  76. package/lib/page-view.d.ts +29 -0
  77. package/lib/page-view.js +81 -0
  78. package/lib/page-view.js.map +1 -0
  79. package/lib/scroll-manager.d.ts +21 -0
  80. package/lib/scroll-manager.js +79 -0
  81. package/lib/scroll-manager.js.map +1 -0
  82. package/lib/session-props.d.ts +32 -0
  83. package/lib/session-props.js +73 -0
  84. package/lib/session-props.js.map +1 -0
  85. package/lib/sessionid.d.ts +50 -0
  86. package/{src/sessionid.ts → lib/sessionid.js} +128 -204
  87. package/lib/sessionid.js.map +1 -0
  88. package/lib/storage.d.ts +24 -0
  89. package/{src/storage.ts → lib/storage.js} +182 -225
  90. package/lib/storage.js.map +1 -0
  91. package/lib/types.d.ts +592 -0
  92. package/lib/types.js +7 -0
  93. package/lib/types.js.map +1 -0
  94. package/lib/utils/blocked-uas.d.ts +17 -0
  95. package/{src/utils/blocked-uas.ts → lib/utils/blocked-uas.js} +19 -48
  96. package/lib/utils/blocked-uas.js.map +1 -0
  97. package/lib/utils/element-utils.d.ts +5 -0
  98. package/{src/utils/element-utils.ts → lib/utils/element-utils.js} +13 -17
  99. package/lib/utils/element-utils.js.map +1 -0
  100. package/lib/utils/event-utils.d.ts +22 -0
  101. package/lib/utils/event-utils.js +258 -0
  102. package/lib/utils/event-utils.js.map +1 -0
  103. package/lib/utils/index.d.ts +46 -0
  104. package/lib/utils/index.js +192 -0
  105. package/lib/utils/index.js.map +1 -0
  106. package/lib/utils/request-utils.d.ts +12 -0
  107. package/lib/utils/request-utils.js +107 -0
  108. package/lib/utils/request-utils.js.map +1 -0
  109. package/lib/utils/simple-event-emitter.d.ts +6 -0
  110. package/lib/utils/simple-event-emitter.js +24 -0
  111. package/lib/utils/simple-event-emitter.js.map +1 -0
  112. package/lib/utils/user-agent-utils.d.ts +18 -0
  113. package/lib/utils/user-agent-utils.js +369 -0
  114. package/lib/utils/user-agent-utils.js.map +1 -0
  115. package/lib/uuidv7.d.ts +43 -0
  116. package/{src/uuidv7.ts → lib/uuidv7.js} +103 -131
  117. package/lib/uuidv7.js.map +1 -0
  118. package/lib/version.d.ts +1 -0
  119. package/lib/version.js +2 -0
  120. package/lib/version.js.map +1 -0
  121. package/package.json +56 -45
  122. package/dist/index.cjs +0 -3034
  123. package/dist/index.cjs.map +0 -1
  124. package/dist/index.mjs +0 -3032
  125. package/dist/index.mjs.map +0 -1
  126. package/src/autocapture.ts +0 -415
  127. package/src/config.ts +0 -8
  128. package/src/extensions/rageclick.ts +0 -34
  129. package/src/iife.ts +0 -87
  130. package/src/leanbase-logger.ts +0 -26
  131. package/src/leanbase-persistence.ts +0 -374
  132. package/src/leanbase.ts +0 -424
  133. package/src/page-view.ts +0 -124
  134. package/src/scroll-manager.ts +0 -103
  135. package/src/session-props.ts +0 -114
  136. package/src/utils/event-utils.ts +0 -304
  137. package/src/utils/index.ts +0 -222
  138. package/src/utils/request-utils.ts +0 -128
  139. package/src/utils/simple-event-emitter.ts +0 -27
  140. package/src/utils/user-agent-utils.ts +0 -357
  141. package/src/version.ts +0 -1
@@ -0,0 +1,359 @@
1
+ import { PostHogCore, getFetch, isEmptyObject, isEmptyString, isNumber, isObject, isString, isUndefined, } from '@posthog/core';
2
+ import { LeanbasePersistence } from './leanbase-persistence';
3
+ import { addEventListener, copyAndTruncateStrings, document, extend, isCrossDomainCookie, navigator, userAgent, } from './utils';
4
+ import Config from './config';
5
+ import { Autocapture } from './autocapture';
6
+ import { logger } from './leanbase-logger';
7
+ import { COOKIELESS_MODE_FLAG_PROPERTY, COOKIELESS_SENTINEL_VALUE, USER_STATE } from './constants';
8
+ import { getEventProperties } from './utils/event-utils';
9
+ import { SessionIdManager } from './sessionid';
10
+ import { SessionPropsManager } from './session-props';
11
+ import { uuidv7 } from './uuidv7';
12
+ import { PageViewManager } from './page-view';
13
+ import { ScrollManager } from './scroll-manager';
14
+ import { isLikelyBot } from './utils/blocked-uas';
15
+ import { ConsentManager } from './consent';
16
+ const defaultConfig = () => ({
17
+ host: 'https://i.leanbase.co',
18
+ token: '',
19
+ autocapture: true,
20
+ rageclick: true,
21
+ persistence: 'localStorage+cookie',
22
+ capture_pageview: true,
23
+ capture_pageleave: 'if_capture_pageview',
24
+ persistence_name: '',
25
+ mask_all_element_attributes: false,
26
+ cookie_expiration: 365,
27
+ cross_subdomain_cookie: isCrossDomainCookie(document?.location),
28
+ custom_campaign_params: [],
29
+ custom_personal_data_properties: [],
30
+ disable_persistence: false,
31
+ mask_personal_data_properties: false,
32
+ secure_cookie: window?.location?.protocol === 'https:',
33
+ mask_all_text: false,
34
+ bootstrap: {},
35
+ session_idle_timeout_seconds: 30 * 60,
36
+ save_campaign_params: true,
37
+ save_referrer: true,
38
+ opt_out_useragent_filter: false,
39
+ properties_string_max_length: 65535,
40
+ opt_out_capturing_by_default: false,
41
+ opt_out_persistence_by_default: false,
42
+ opt_out_capturing_persistence_type: 'localStorage',
43
+ consent_persistence_name: null,
44
+ opt_out_capturing_cookie_prefix: null,
45
+ respect_dnt: false,
46
+ getDeviceId: (uuid) => uuid,
47
+ loaded: () => { },
48
+ });
49
+ export class Leanbase extends PostHogCore {
50
+ constructor(token, config) {
51
+ const mergedConfig = extend(defaultConfig(), config || {}, {
52
+ token,
53
+ });
54
+ super(token, mergedConfig);
55
+ this.personProcessingSetOncePropertiesSent = false;
56
+ this.isLoaded = false;
57
+ this.config = mergedConfig;
58
+ this.visibilityStateListener = null;
59
+ this.initialPageviewCaptured = false;
60
+ this.scrollManager = new ScrollManager(this);
61
+ this.pageViewManager = new PageViewManager(this);
62
+ this.consent = new ConsentManager(this);
63
+ this.init(token, mergedConfig);
64
+ }
65
+ init(token, config) {
66
+ this.setConfig(extend(defaultConfig(), config, {
67
+ token,
68
+ }));
69
+ this.isLoaded = true;
70
+ const persistenceDisabled = this._isPersistenceDisabled();
71
+ this.persistence = new LeanbasePersistence(this.config);
72
+ this.sessionPersistence =
73
+ this.config.persistence === 'sessionStorage' || this.config.persistence === 'memory'
74
+ ? this.persistence
75
+ : new LeanbasePersistence({ ...this.config, persistence: 'sessionStorage' }, persistenceDisabled);
76
+ const startInCookielessMode = this.config.cookieless_mode === 'always' ||
77
+ (this.config.cookieless_mode === 'on_reject' && this.consent.isExplicitlyOptedOut());
78
+ if (!startInCookielessMode) {
79
+ this.sessionManager = new SessionIdManager(this);
80
+ this.sessionPropsManager = new SessionPropsManager(this, this.sessionManager, this.persistence);
81
+ }
82
+ this.replayAutocapture = new Autocapture(this);
83
+ this.replayAutocapture.startIfEnabled();
84
+ if (this.config.preloadFeatureFlags !== false) {
85
+ this.reloadFeatureFlags();
86
+ }
87
+ this.config.loaded?.(this);
88
+ if (this.config.capture_pageview) {
89
+ setTimeout(() => {
90
+ if (this.consent.isOptedIn() || this.config.cookieless_mode === 'always') {
91
+ this.captureInitialPageview();
92
+ }
93
+ }, 1);
94
+ }
95
+ if (!this.config.disable_scroll_properties) {
96
+ this.scrollManager.startMeasuringScrollPosition();
97
+ }
98
+ // eslint-disable-next-line posthog-js/no-direct-undefined-check
99
+ if (this.config.bootstrap?.distinctId !== undefined) {
100
+ const uuid = this.config.getDeviceId(uuidv7());
101
+ const deviceID = this.config.bootstrap?.isIdentifiedId ? uuid : this.config.bootstrap.distinctId;
102
+ this.persistence.set_property(USER_STATE, this.config.bootstrap?.isIdentifiedId ? 'identified' : 'anonymous');
103
+ this.register({
104
+ distinct_id: this.config.bootstrap.distinctId,
105
+ $device_id: deviceID,
106
+ });
107
+ }
108
+ if (startInCookielessMode) {
109
+ this.persistence.register_once({
110
+ distinct_id: COOKIELESS_SENTINEL_VALUE,
111
+ $device_id: null,
112
+ }, '');
113
+ }
114
+ if (!startInCookielessMode && !this.getDistinctId()) {
115
+ const uuid = uuidv7();
116
+ this.persistence.register_once({
117
+ distinct_id: uuid,
118
+ $device_id: uuid,
119
+ }, '');
120
+ this.persistence.set_property(USER_STATE, 'anonymous');
121
+ }
122
+ addEventListener(document, 'DOMContentLoaded', () => {
123
+ this.loadRemoteConfig();
124
+ });
125
+ addEventListener(window, 'onpagehide' in self ? 'pagehide' : 'unload', this.capturePageLeave.bind(this), {
126
+ passive: false,
127
+ });
128
+ return this;
129
+ }
130
+ captureInitialPageview() {
131
+ if (!document) {
132
+ return;
133
+ }
134
+ if (document.visibilityState !== 'visible') {
135
+ if (!this.visibilityStateListener) {
136
+ this.visibilityStateListener = this.captureInitialPageview.bind(this);
137
+ addEventListener(document, 'visibilitychange', this.visibilityStateListener);
138
+ }
139
+ return;
140
+ }
141
+ if (!this.initialPageviewCaptured) {
142
+ this.initialPageviewCaptured = true;
143
+ this.capture('$pageview', { title: document.title });
144
+ if (this.visibilityStateListener) {
145
+ document.removeEventListener('visibilitychange', this.visibilityStateListener);
146
+ this.visibilityStateListener = null;
147
+ }
148
+ }
149
+ }
150
+ capturePageLeave() {
151
+ const { capture_pageleave, capture_pageview } = this.config;
152
+ if (capture_pageleave === true ||
153
+ (capture_pageleave === 'if_capture_pageview' &&
154
+ (capture_pageview === true || capture_pageview === 'history_change'))) {
155
+ this.capture('$pageleave');
156
+ }
157
+ }
158
+ async loadRemoteConfig() {
159
+ if (!this.isRemoteConfigLoaded) {
160
+ const remoteConfig = await this.reloadRemoteConfigAsync();
161
+ if (remoteConfig) {
162
+ this.onRemoteConfig(remoteConfig);
163
+ }
164
+ }
165
+ }
166
+ onRemoteConfig(config) {
167
+ if (!(document && document.body)) {
168
+ setTimeout(() => {
169
+ this.onRemoteConfig(config);
170
+ }, 500);
171
+ return;
172
+ }
173
+ this.isRemoteConfigLoaded = true;
174
+ this.replayAutocapture?.onRemoteConfig(config);
175
+ }
176
+ fetch(url, options) {
177
+ const fetchFn = getFetch();
178
+ if (!fetchFn) {
179
+ return Promise.reject(new Error('Fetch API is not available in this environment.'));
180
+ }
181
+ return fetchFn(url, options);
182
+ }
183
+ setConfig(config) {
184
+ const oldConfig = { ...this.config };
185
+ if (isObject(config)) {
186
+ extend(this.config, config);
187
+ this.persistence?.update_config(this.config, oldConfig);
188
+ this.replayAutocapture?.startIfEnabled();
189
+ }
190
+ const isTempStorage = this.config.persistence === 'sessionStorage' || this.config.persistence === 'memory';
191
+ this.sessionPersistence = isTempStorage
192
+ ? this.persistence
193
+ : new LeanbasePersistence({ ...this.config, persistence: 'sessionStorage' });
194
+ }
195
+ getLibraryId() {
196
+ return 'leanbase';
197
+ }
198
+ getLibraryVersion() {
199
+ return Config.LIB_VERSION;
200
+ }
201
+ getCustomUserAgent() {
202
+ return;
203
+ }
204
+ getPersistedProperty(key) {
205
+ return this.persistence?.get_property(key);
206
+ }
207
+ setPersistedProperty(key, value) {
208
+ this.persistence?.set_property(key, value);
209
+ }
210
+ calculateEventProperties(eventName, eventProperties, timestamp, uuid, readOnly) {
211
+ if (!this.persistence || !this.sessionPersistence) {
212
+ return eventProperties;
213
+ }
214
+ timestamp = timestamp || new Date();
215
+ const startTimestamp = readOnly ? undefined : this.persistence?.remove_event_timer(eventName);
216
+ let properties = { ...eventProperties };
217
+ properties['token'] = this.config.token;
218
+ if (this.config.cookieless_mode == 'always' ||
219
+ (this.config.cookieless_mode == 'on_reject' && this.consent.isExplicitlyOptedOut())) {
220
+ properties[COOKIELESS_MODE_FLAG_PROPERTY] = true;
221
+ }
222
+ if (eventName === '$snapshot') {
223
+ const persistenceProps = { ...this.persistence.properties() };
224
+ properties['distinct_id'] = persistenceProps.distinct_id;
225
+ if (!(isString(properties['distinct_id']) || isNumber(properties['distinct_id'])) ||
226
+ isEmptyString(properties['distinct_id'])) {
227
+ logger.error('Invalid distinct_id for replay event. This indicates a bug in your implementation');
228
+ }
229
+ return properties;
230
+ }
231
+ const infoProperties = getEventProperties(this.config.mask_personal_data_properties, this.config.custom_personal_data_properties);
232
+ if (this.sessionManager) {
233
+ const { sessionId, windowId } = this.sessionManager.checkAndGetSessionAndWindowId(readOnly, timestamp.getTime());
234
+ properties['$session_id'] = sessionId;
235
+ properties['$window_id'] = windowId;
236
+ }
237
+ if (this.sessionPropsManager) {
238
+ extend(properties, this.sessionPropsManager.getSessionProps());
239
+ }
240
+ let pageviewProperties = this.pageViewManager.doEvent();
241
+ if (eventName === '$pageview' && !readOnly) {
242
+ pageviewProperties = this.pageViewManager.doPageView(timestamp, uuid);
243
+ }
244
+ if (eventName === '$pageleave' && !readOnly) {
245
+ pageviewProperties = this.pageViewManager.doPageLeave(timestamp);
246
+ }
247
+ properties = extend(properties, pageviewProperties);
248
+ if (eventName === '$pageview' && document) {
249
+ properties['title'] = document.title;
250
+ }
251
+ if (!isUndefined(startTimestamp)) {
252
+ const duration_in_ms = timestamp.getTime() - startTimestamp;
253
+ properties['$duration'] = parseFloat((duration_in_ms / 1000).toFixed(3));
254
+ }
255
+ if (userAgent && this.config.opt_out_useragent_filter) {
256
+ properties['$browser_type'] = isLikelyBot(navigator, []) ? 'bot' : 'browser';
257
+ }
258
+ properties = extend({}, infoProperties, this.persistence.properties(), this.sessionPersistence.properties(), properties);
259
+ properties['$is_identified'] = this.isIdentified();
260
+ return properties;
261
+ }
262
+ isIdentified() {
263
+ return (this.persistence?.get_property(USER_STATE) === 'identified' ||
264
+ this.sessionPersistence?.get_property(USER_STATE) === 'identified');
265
+ }
266
+ isCapturing() {
267
+ return this.consent.isOptedIn();
268
+ }
269
+ /**
270
+ * Add additional set_once properties to the event when creating a person profile. This allows us to create the
271
+ * profile with mostly-accurate properties, despite earlier events not setting them. We do this by storing them in
272
+ * persistence.
273
+ * @param dataSetOnce
274
+ */
275
+ calculateSetOnceProperties(dataSetOnce) {
276
+ if (!this.persistence) {
277
+ return dataSetOnce;
278
+ }
279
+ if (this.personProcessingSetOncePropertiesSent) {
280
+ return dataSetOnce;
281
+ }
282
+ const initialProps = this.persistence.get_initial_props();
283
+ const sessionProps = this.sessionPropsManager?.getSetOnceProps();
284
+ const setOnceProperties = extend({}, initialProps, sessionProps || {}, dataSetOnce || {});
285
+ this.personProcessingSetOncePropertiesSent = true;
286
+ if (isEmptyObject(setOnceProperties)) {
287
+ return undefined;
288
+ }
289
+ return setOnceProperties;
290
+ }
291
+ capture(event, properties, options) {
292
+ if (!this.isLoaded || !this.sessionPersistence || !this.persistence) {
293
+ return;
294
+ }
295
+ if (!this.isCapturing()) {
296
+ return;
297
+ }
298
+ if (isUndefined(event) || !isString(event)) {
299
+ logger.error('No event name provided to posthog.capture');
300
+ return;
301
+ }
302
+ if (properties?.$current_url && !isString(properties?.$current_url)) {
303
+ logger.error('Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value.');
304
+ delete properties?.$current_url;
305
+ }
306
+ this.sessionPersistence.update_search_keyword();
307
+ if (this.config.save_campaign_params) {
308
+ this.sessionPersistence.update_campaign_params();
309
+ }
310
+ if (this.config.save_referrer) {
311
+ this.sessionPersistence.update_referrer_info();
312
+ }
313
+ if (this.config.save_campaign_params || this.config.save_referrer) {
314
+ this.persistence.set_initial_person_info();
315
+ }
316
+ const systemTime = new Date();
317
+ const timestamp = options?.timestamp || systemTime;
318
+ const uuid = uuidv7();
319
+ let data = {
320
+ uuid,
321
+ event,
322
+ properties: this.calculateEventProperties(event, properties || {}, timestamp, uuid),
323
+ };
324
+ const setProperties = options?.$set;
325
+ if (setProperties) {
326
+ data.$set = options?.$set;
327
+ }
328
+ const setOnceProperties = this.calculateSetOnceProperties(options?.$set_once);
329
+ if (setOnceProperties) {
330
+ data.$set_once = setOnceProperties;
331
+ }
332
+ data = copyAndTruncateStrings(data, options?._noTruncate ? null : this.config.properties_string_max_length);
333
+ data.timestamp = timestamp;
334
+ if (!isUndefined(options?.timestamp)) {
335
+ data.properties['$event_time_override_provided'] = true;
336
+ data.properties['$event_time_override_system_time'] = systemTime;
337
+ }
338
+ const finalSet = { ...data.properties['$set'], ...data['$set'] };
339
+ if (!isEmptyObject(finalSet)) {
340
+ this.setPersonPropertiesForFlags(finalSet);
341
+ }
342
+ super.capture(data.event, data.properties, options);
343
+ }
344
+ identify(distinctId, properties, options) {
345
+ super.identify(distinctId, properties, options);
346
+ }
347
+ destroy() {
348
+ this.persistence?.clear();
349
+ }
350
+ _isPersistenceDisabled() {
351
+ if (this.config.cookieless_mode === 'always') {
352
+ return true;
353
+ }
354
+ const isOptedOut = this.consent.isOptedOut();
355
+ const defaultPersistenceDisabled = this.config.opt_out_persistence_by_default || this.config.cookieless_mode === 'on_reject';
356
+ return this.config.disable_persistence || (isOptedOut && !!defaultPersistenceDisabled);
357
+ }
358
+ }
359
+ //# sourceMappingURL=leanbase.js.map
@@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from './leanbase';
2
+ interface PageViewEventProperties {
3
+ $pageview_id?: string;
4
+ $prev_pageview_id?: string;
5
+ $prev_pageview_pathname?: string;
6
+ $prev_pageview_duration?: number;
7
+ $prev_pageview_last_scroll?: number;
8
+ $prev_pageview_last_scroll_percentage?: number;
9
+ $prev_pageview_max_scroll?: number;
10
+ $prev_pageview_max_scroll_percentage?: number;
11
+ $prev_pageview_last_content?: number;
12
+ $prev_pageview_last_content_percentage?: number;
13
+ $prev_pageview_max_content?: number;
14
+ $prev_pageview_max_content_percentage?: number;
15
+ }
16
+ export declare class PageViewManager {
17
+ _currentPageview?: {
18
+ timestamp: Date;
19
+ pageViewId: string | undefined;
20
+ pathname: string | undefined;
21
+ };
22
+ _instance: Leanbase;
23
+ constructor(instance: Leanbase);
24
+ doPageView(timestamp: Date, pageViewId?: string): PageViewEventProperties;
25
+ doPageLeave(timestamp: Date): PageViewEventProperties;
26
+ doEvent(): PageViewEventProperties;
27
+ private _previousPageViewProperties;
28
+ }
29
+ export {};
@@ -0,0 +1,81 @@
1
+ import { window } from './utils';
2
+ import { clampToRange, isUndefined } from '@posthog/core';
3
+ import { extend } from './utils';
4
+ import { logger } from './leanbase-logger';
5
+ // This keeps track of the PageView state (such as the previous PageView's path, timestamp, id, and scroll properties).
6
+ // We store the state in memory, which means that for non-SPA sites, the state will be lost on page reload. This means
7
+ // that non-SPA sites should always send a $pageleave event on any navigation, before the page unloads. For SPA sites,
8
+ // they only need to send a $pageleave event when the user navigates away from the site, as the information is not lost
9
+ // on an internal navigation, and is included as the $prev_pageview_ properties in the next $pageview event.
10
+ // Practically, this means that to find the scroll properties for a given pageview, you need to find the event where
11
+ // event name is $pageview or $pageleave and where $prev_pageview_id matches the original pageview event's id.
12
+ export class PageViewManager {
13
+ constructor(instance) {
14
+ this._instance = instance;
15
+ }
16
+ doPageView(timestamp, pageViewId) {
17
+ const response = this._previousPageViewProperties(timestamp, pageViewId);
18
+ // On a pageview we reset the contexts
19
+ this._currentPageview = { pathname: window?.location.pathname ?? '', pageViewId, timestamp };
20
+ this._instance.scrollManager.resetContext();
21
+ return response;
22
+ }
23
+ doPageLeave(timestamp) {
24
+ return this._previousPageViewProperties(timestamp, this._currentPageview?.pageViewId);
25
+ }
26
+ doEvent() {
27
+ return { $pageview_id: this._currentPageview?.pageViewId };
28
+ }
29
+ _previousPageViewProperties(timestamp, pageviewId) {
30
+ const previousPageView = this._currentPageview;
31
+ if (!previousPageView) {
32
+ return { $pageview_id: pageviewId };
33
+ }
34
+ let properties = {
35
+ $pageview_id: pageviewId,
36
+ $prev_pageview_id: previousPageView.pageViewId,
37
+ };
38
+ const scrollContext = this._instance.scrollManager.getContext();
39
+ if (scrollContext && !this._instance.config.disable_scroll_properties) {
40
+ let { maxScrollHeight, lastScrollY, maxScrollY, maxContentHeight, lastContentY, maxContentY } = scrollContext;
41
+ if (!isUndefined(maxScrollHeight) &&
42
+ !isUndefined(lastScrollY) &&
43
+ !isUndefined(maxScrollY) &&
44
+ !isUndefined(maxContentHeight) &&
45
+ !isUndefined(lastContentY) &&
46
+ !isUndefined(maxContentY)) {
47
+ // Use ceil, so that e.g. scrolling 999.5px of a 1000px page is considered 100% scrolled
48
+ maxScrollHeight = Math.ceil(maxScrollHeight);
49
+ lastScrollY = Math.ceil(lastScrollY);
50
+ maxScrollY = Math.ceil(maxScrollY);
51
+ maxContentHeight = Math.ceil(maxContentHeight);
52
+ lastContentY = Math.ceil(lastContentY);
53
+ maxContentY = Math.ceil(maxContentY);
54
+ // if the maximum scroll height is near 0, then the percentage is 1
55
+ const lastScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(lastScrollY / maxScrollHeight, 0, 1, logger);
56
+ const maxScrollPercentage = maxScrollHeight <= 1 ? 1 : clampToRange(maxScrollY / maxScrollHeight, 0, 1, logger);
57
+ const lastContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(lastContentY / maxContentHeight, 0, 1, logger);
58
+ const maxContentPercentage = maxContentHeight <= 1 ? 1 : clampToRange(maxContentY / maxContentHeight, 0, 1, logger);
59
+ properties = extend(properties, {
60
+ $prev_pageview_last_scroll: lastScrollY,
61
+ $prev_pageview_last_scroll_percentage: lastScrollPercentage,
62
+ $prev_pageview_max_scroll: maxScrollY,
63
+ $prev_pageview_max_scroll_percentage: maxScrollPercentage,
64
+ $prev_pageview_last_content: lastContentY,
65
+ $prev_pageview_last_content_percentage: lastContentPercentage,
66
+ $prev_pageview_max_content: maxContentY,
67
+ $prev_pageview_max_content_percentage: maxContentPercentage,
68
+ });
69
+ }
70
+ }
71
+ if (previousPageView.pathname) {
72
+ properties.$prev_pageview_pathname = previousPageView.pathname;
73
+ }
74
+ if (previousPageView.timestamp) {
75
+ // Use seconds, for consistency with our other duration-related properties like $duration
76
+ properties.$prev_pageview_duration = (timestamp.getTime() - previousPageView.timestamp.getTime()) / 1000;
77
+ }
78
+ return properties;
79
+ }
80
+ }
81
+ //# sourceMappingURL=page-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-view.js","sourceRoot":"","sources":["../src/page-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAU,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAiB1C,uHAAuH;AACvH,sHAAsH;AACtH,sHAAsH;AACtH,uHAAuH;AACvH,4GAA4G;AAE5G,oHAAoH;AACpH,8GAA8G;AAE9G,MAAM,OAAO,eAAe;IAIxB,YAAY,QAAkB;QAC1B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC7B,CAAC;IAED,UAAU,CAAC,SAAe,EAAE,UAAmB;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,2BAA2B,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QAExE,sCAAsC;QACtC,IAAI,CAA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yB,EAAE,UAAU;oBACrC,oCAAoC,EAAE,mBAAmB;oBACzD,2BAA2B,EAAE,YAAY;oBACzC,sCAAsC,EAAE,qBAAqB;oBAC7D,0BAA0B,EAAE,WAAW;oBACvC,qCAAqC,EAAE,oBAAoB;iBAC9D,CAAC,CAAA;YACN,CAAC;QACL,CAAC;QAED,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;YAC5B,UAAU,CAAC,uBAAuB,GAAG,gBAAgB,CAAC,QAAQ,CAAA;QAClE,CAAC;QACD,IAAI,gBAAgB,CAAC,SAAS,EAAE,CAAC;YAC7B,yFAAyF;YACzF,UAAU,CAAC,uBAAuB,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,gBAAgB,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;QAC5G,CAAC;QAED,OAAO,UAAU,CAAA;IACrB,CAAC;CACJ"}
@@ -0,0 +1,21 @@
1
+ import { Leanbase } from './leanbase';
2
+ export interface ScrollContext {
3
+ maxScrollHeight?: number;
4
+ maxScrollY?: number;
5
+ lastScrollY?: number;
6
+ maxContentHeight?: number;
7
+ maxContentY?: number;
8
+ lastContentY?: number;
9
+ }
10
+ export declare class ScrollManager {
11
+ private _instance;
12
+ private _context;
13
+ constructor(_instance: Leanbase);
14
+ getContext(): ScrollContext | undefined;
15
+ resetContext(): ScrollContext | undefined;
16
+ private _updateScrollData;
17
+ startMeasuringScrollPosition(): void;
18
+ scrollElement(): Element | undefined;
19
+ scrollY(): number;
20
+ scrollX(): number;
21
+ }
@@ -0,0 +1,79 @@
1
+ import { window } from './utils';
2
+ import { addEventListener } from './utils';
3
+ import { isArray } from '@posthog/core';
4
+ // This class is responsible for tracking scroll events and maintaining the scroll context
5
+ export class ScrollManager {
6
+ constructor(_instance) {
7
+ this._instance = _instance;
8
+ this._updateScrollData = () => {
9
+ if (!this._context) {
10
+ this._context = {};
11
+ }
12
+ const el = this.scrollElement();
13
+ const scrollY = this.scrollY();
14
+ const scrollHeight = el ? Math.max(0, el.scrollHeight - el.clientHeight) : 0;
15
+ const contentY = scrollY + (el?.clientHeight || 0);
16
+ const contentHeight = el?.scrollHeight || 0;
17
+ this._context.lastScrollY = Math.ceil(scrollY);
18
+ this._context.maxScrollY = Math.max(scrollY, this._context.maxScrollY ?? 0);
19
+ this._context.maxScrollHeight = Math.max(scrollHeight, this._context.maxScrollHeight ?? 0);
20
+ this._context.lastContentY = contentY;
21
+ this._context.maxContentY = Math.max(contentY, this._context.maxContentY ?? 0);
22
+ this._context.maxContentHeight = Math.max(contentHeight, this._context.maxContentHeight ?? 0);
23
+ };
24
+ }
25
+ getContext() {
26
+ return this._context;
27
+ }
28
+ resetContext() {
29
+ const ctx = this._context;
30
+ // update the scroll properties for the new page, but wait until the next tick
31
+ // of the event loop
32
+ setTimeout(this._updateScrollData, 0);
33
+ return ctx;
34
+ }
35
+ // `capture: true` is required to get scroll events for other scrollable elements
36
+ // on the page, not just the window
37
+ // see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#usecapture
38
+ startMeasuringScrollPosition() {
39
+ addEventListener(window, 'scroll', this._updateScrollData, { capture: true });
40
+ addEventListener(window, 'scrollend', this._updateScrollData, { capture: true });
41
+ addEventListener(window, 'resize', this._updateScrollData);
42
+ }
43
+ scrollElement() {
44
+ if (this._instance.config.scroll_root_selector) {
45
+ const selectors = isArray(this._instance.config.scroll_root_selector)
46
+ ? this._instance.config.scroll_root_selector
47
+ : [this._instance.config.scroll_root_selector];
48
+ for (const selector of selectors) {
49
+ const element = window?.document.querySelector(selector);
50
+ if (element) {
51
+ return element;
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+ else {
57
+ return window?.document.documentElement;
58
+ }
59
+ }
60
+ scrollY() {
61
+ if (this._instance.config.scroll_root_selector) {
62
+ const element = this.scrollElement();
63
+ return (element && element.scrollTop) || 0;
64
+ }
65
+ else {
66
+ return window ? window.scrollY || window.pageYOffset || window.document.documentElement.scrollTop || 0 : 0;
67
+ }
68
+ }
69
+ scrollX() {
70
+ if (this._instance.config.scroll_root_selector) {
71
+ const element = this.scrollElement();
72
+ return (element && element.scrollLeft) || 0;
73
+ }
74
+ else {
75
+ return window ? window.scrollX || window.pageXOffset || window.document.documentElement.scrollLeft || 0 : 0;
76
+ }
77
+ }
78
+ }
79
+ //# sourceMappingURL=scroll-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-manager.js","sourceRoot":"","sources":["../src/scroll-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAevC,0FAA0F;AAC1F,MAAM,OAAO,aAAa;IAGtB,YAAoB,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;QAgB/B,sBAAiB,GAAG,GAAG,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACjB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;YACtB,CAAC;YAED,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YAE/B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;YAC9B,MAAM,YAAY,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAC5E,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,YAAY,IAAI,CAAC,CAAC,CAAA;YAClD,MAAM,aAAa,GAAG,EAAE,EAAE,YAAY,IAAI,CAAC,CAAA;YAE3C,IAAI,CAAC,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAC9C,IAAI,CAAC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OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACJ,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/G,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,32 @@
1
+ import type { SessionIdManager } from './sessionid';
2
+ import type { LeanbasePersistence } from './leanbase-persistence';
3
+ import type { Leanbase } from './leanbase';
4
+ interface LegacySessionSourceProps {
5
+ initialPathName: string;
6
+ referringDomain: string;
7
+ utm_medium?: string;
8
+ utm_source?: string;
9
+ utm_campaign?: string;
10
+ utm_content?: string;
11
+ utm_term?: string;
12
+ }
13
+ interface CurrentSessionSourceProps {
14
+ r: string;
15
+ u: string | undefined;
16
+ }
17
+ interface StoredSessionSourceProps {
18
+ sessionId: string;
19
+ props: LegacySessionSourceProps | CurrentSessionSourceProps;
20
+ }
21
+ export declare class SessionPropsManager {
22
+ private readonly _instance;
23
+ private readonly _sessionIdManager;
24
+ private readonly _persistence;
25
+ private readonly _sessionSourceParamGenerator;
26
+ constructor(instance: Leanbase, sessionIdManager: SessionIdManager, persistence: LeanbasePersistence, sessionSourceParamGenerator?: (instance?: Leanbase) => LegacySessionSourceProps | CurrentSessionSourceProps);
27
+ _getStored(): StoredSessionSourceProps | undefined;
28
+ _onSessionIdCallback: (sessionId: string) => void;
29
+ getSetOnceProps(): Record<string, any>;
30
+ getSessionProps(): Record<string, any>;
31
+ }
32
+ export {};