@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
@@ -1,76 +1,69 @@
1
1
  /*
2
2
  * Constants
3
3
  */
4
-
5
- import { PostHogPersistedProperty } from '@posthog/core'
6
-
4
+ import { PostHogPersistedProperty } from '@posthog/core';
7
5
  /* PROPERTY KEYS */
8
-
9
6
  // This key is deprecated, but we want to check for it to see whether aliasing is allowed.
10
- export const PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id'
11
- export const DISTINCT_ID = 'distinct_id'
12
- export const ALIAS_ID_KEY = '__alias'
13
- export const CAMPAIGN_IDS_KEY = '__cmpns'
14
- export const EVENT_TIMERS_KEY = '__timers'
15
- export const AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side'
16
- export const HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side'
17
- export const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side'
18
- export const ERROR_TRACKING_SUPPRESSION_RULES = '$error_tracking_suppression_rules'
19
- export const ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS = '$error_tracking_capture_extension_exceptions'
20
- export const WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side'
21
- export const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side'
22
- export const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics'
23
- export const SESSION_RECORDING_REMOTE_CONFIG = '$session_recording_remote_config'
7
+ export const PEOPLE_DISTINCT_ID_KEY = '$people_distinct_id';
8
+ export const DISTINCT_ID = 'distinct_id';
9
+ export const ALIAS_ID_KEY = '__alias';
10
+ export const CAMPAIGN_IDS_KEY = '__cmpns';
11
+ export const EVENT_TIMERS_KEY = '__timers';
12
+ export const AUTOCAPTURE_DISABLED_SERVER_SIDE = '$autocapture_disabled_server_side';
13
+ export const HEATMAPS_ENABLED_SERVER_SIDE = '$heatmaps_enabled_server_side';
14
+ export const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = '$exception_capture_enabled_server_side';
15
+ export const ERROR_TRACKING_SUPPRESSION_RULES = '$error_tracking_suppression_rules';
16
+ export const ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS = '$error_tracking_capture_extension_exceptions';
17
+ export const WEB_VITALS_ENABLED_SERVER_SIDE = '$web_vitals_enabled_server_side';
18
+ export const DEAD_CLICKS_ENABLED_SERVER_SIDE = '$dead_clicks_enabled_server_side';
19
+ export const WEB_VITALS_ALLOWED_METRICS = '$web_vitals_allowed_metrics';
20
+ export const SESSION_RECORDING_REMOTE_CONFIG = '$session_recording_remote_config';
24
21
  // @deprecated can be removed along with eager loaded replay
25
- export const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side'
22
+ export const SESSION_RECORDING_ENABLED_SERVER_SIDE = '$session_recording_enabled_server_side';
26
23
  // @deprecated can be removed along with eager loaded replay
27
- export const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side'
24
+ export const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = '$console_log_recording_enabled_server_side';
28
25
  // @deprecated can be removed along with eager loaded replay
29
- export const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture'
26
+ export const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = '$session_recording_network_payload_capture';
30
27
  // @deprecated can be removed along with eager loaded replay
31
- export const SESSION_RECORDING_MASKING = '$session_recording_masking'
28
+ export const SESSION_RECORDING_MASKING = '$session_recording_masking';
32
29
  // @deprecated can be removed along with eager loaded replay
33
- export const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording'
30
+ export const SESSION_RECORDING_CANVAS_RECORDING = '$session_recording_canvas_recording';
34
31
  // @deprecated can be removed along with eager loaded replay
35
- export const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate'
32
+ export const SESSION_RECORDING_SAMPLE_RATE = '$replay_sample_rate';
36
33
  // @deprecated can be removed along with eager loaded replay
37
- export const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration'
34
+ export const SESSION_RECORDING_MINIMUM_DURATION = '$replay_minimum_duration';
38
35
  // @deprecated can be removed along with eager loaded replay
39
- export const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config'
40
- export const SESSION_ID = '$sesid'
41
- export const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled'
42
- export const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session'
43
- export const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session'
44
- export const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags'
45
- export const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features'
46
- export const PERSISTENCE_FEATURE_FLAG_DETAILS = '$feature_flag_details'
47
- export const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties'
48
- export const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties'
49
- export const SURVEYS = '$surveys'
50
- export const SURVEYS_ACTIVATED = '$surveys_activated'
51
- export const FLAG_CALL_REPORTED = '$flag_call_reported'
52
- export const USER_STATE = '$user_state'
53
- export const CLIENT_SESSION_PROPS = '$client_session_props'
54
- export const CAPTURE_RATE_LIMIT = '$capture_rate_limit'
55
-
36
+ export const SESSION_RECORDING_SCRIPT_CONFIG = '$replay_script_config';
37
+ export const SESSION_ID = '$sesid';
38
+ export const SESSION_RECORDING_IS_SAMPLED = '$session_is_sampled';
39
+ export const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = '$session_recording_url_trigger_activated_session';
40
+ export const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = '$session_recording_event_trigger_activated_session';
41
+ export const ENABLED_FEATURE_FLAGS = '$enabled_feature_flags';
42
+ export const PERSISTENCE_EARLY_ACCESS_FEATURES = '$early_access_features';
43
+ export const PERSISTENCE_FEATURE_FLAG_DETAILS = '$feature_flag_details';
44
+ export const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties';
45
+ export const STORED_GROUP_PROPERTIES_KEY = '$stored_group_properties';
46
+ export const SURVEYS = '$surveys';
47
+ export const SURVEYS_ACTIVATED = '$surveys_activated';
48
+ export const FLAG_CALL_REPORTED = '$flag_call_reported';
49
+ export const USER_STATE = '$user_state';
50
+ export const CLIENT_SESSION_PROPS = '$client_session_props';
51
+ export const CAPTURE_RATE_LIMIT = '$capture_rate_limit';
56
52
  /** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */
57
- export const INITIAL_CAMPAIGN_PARAMS = '$initial_campaign_params'
53
+ export const INITIAL_CAMPAIGN_PARAMS = '$initial_campaign_params';
58
54
  /** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */
59
- export const INITIAL_REFERRER_INFO = '$initial_referrer_info'
60
- export const INITIAL_PERSON_INFO = '$initial_person_info'
61
- export const ENABLE_PERSON_PROCESSING = '$epp'
62
- export const TOOLBAR_ID = '__POSTHOG_TOOLBAR__'
63
- export const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container'
64
-
55
+ export const INITIAL_REFERRER_INFO = '$initial_referrer_info';
56
+ export const INITIAL_PERSON_INFO = '$initial_person_info';
57
+ export const ENABLE_PERSON_PROCESSING = '$epp';
58
+ export const TOOLBAR_ID = '__POSTHOG_TOOLBAR__';
59
+ export const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container';
65
60
  /**
66
61
  * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
67
62
  * Sentinel value for distinct id, device id, session id. Signals that the server should generate the value
68
63
  * */
69
- export const COOKIELESS_SENTINEL_VALUE = '$posthog_cookieless'
70
- export const COOKIELESS_MODE_FLAG_PROPERTY = '$cookieless_mode'
71
-
72
- export const WEB_EXPERIMENTS = '$web_experiments'
73
-
64
+ export const COOKIELESS_SENTINEL_VALUE = '$posthog_cookieless';
65
+ export const COOKIELESS_MODE_FLAG_PROPERTY = '$cookieless_mode';
66
+ export const WEB_EXPERIMENTS = '$web_experiments';
74
67
  // These are properties that are reserved and will not be automatically included in events
75
68
  export const PERSISTENCE_RESERVED_PROPERTIES = [
76
69
  PEOPLE_DISTINCT_ID_KEY,
@@ -103,6 +96,6 @@ export const PERSISTENCE_RESERVED_PROPERTIES = [
103
96
  PostHogPersistedProperty.RemoteConfig,
104
97
  PostHogPersistedProperty.Surveys,
105
98
  PostHogPersistedProperty.FeatureFlags,
106
- ]
107
-
108
- export const SURVEYS_REQUEST_TIMEOUT_MS = 10000
99
+ ];
100
+ export const SURVEYS_REQUEST_TIMEOUT_MS = 10000;
101
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAExD,mBAAmB;AAEnB,0FAA0F;AAC1F,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAA;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAA;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AACrC,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAA;A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AY;IACZ,gBAAgB;IAChB,gBAAgB;IAChB,qCAAqC;IACrC,4BAA4B;IAC5B,UAAU;IACV,qBAAqB;IACrB,gCAAgC;IAChC,UAAU;IACV,iCAAiC;IACjC,gCAAgC;IAChC,2BAA2B;IAC3B,4BAA4B;IAC5B,OAAO;IACP,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,uBAAuB;IACvB,qBAAqB;IACrB,wBAAwB;IACxB,mBAAmB;IACnB,sCAAsC;IACtC,wBAAwB,CAAC,KAAK;IAC9B,wBAAwB,CAAC,kBAAkB;IAC3C,wBAAwB,CAAC,mBAAmB;IAC5C,wBAAwB,CAAC,WAAW;IACpC,wBAAwB,CAAC,YAAY;IACrC,wBAAwB,CAAC,OAAO;IAChC,wBAAwB,CAAC,YAAY;CACxC,CAAA;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Leanbase } from '../leanbase';
2
+ import type { LeanbaseConfig } from '../types';
3
+ export { Leanbase };
4
+ export type { LeanbaseConfig };
@@ -0,0 +1,3 @@
1
+ import { Leanbase } from '../leanbase';
2
+ export { Leanbase };
3
+ //# sourceMappingURL=main.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.cjs.js","sourceRoot":"","sources":["../../src/entrypoints/main.cjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Leanbase } from '../leanbase';
2
+ import type { LeanbaseConfig } from '../types';
3
+ export { Leanbase };
4
+ export type { LeanbaseConfig };
@@ -0,0 +1,3 @@
1
+ import { Leanbase } from '../leanbase';
2
+ export { Leanbase };
3
+ //# sourceMappingURL=module.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.es.js","sourceRoot":"","sources":["../../src/entrypoints/module.es.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAGtC,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,9 @@
1
+ export default class RageClick {
2
+ clicks: {
3
+ x: number;
4
+ y: number;
5
+ timestamp: number;
6
+ }[];
7
+ constructor();
8
+ isRageClick(x: number, y: number, timestamp: number): boolean;
9
+ }
@@ -0,0 +1,27 @@
1
+ // Naive rage click implementation: If mouse has not moved further than RAGE_CLICK_THRESHOLD_PX
2
+ // over RAGE_CLICK_CLICK_COUNT clicks with max RAGE_CLICK_TIMEOUT_MS between clicks, it's
3
+ // counted as a rage click
4
+ const RAGE_CLICK_THRESHOLD_PX = 30;
5
+ const RAGE_CLICK_TIMEOUT_MS = 1000;
6
+ const RAGE_CLICK_CLICK_COUNT = 3;
7
+ export default class RageClick {
8
+ constructor() {
9
+ this.clicks = [];
10
+ }
11
+ isRageClick(x, y, timestamp) {
12
+ const lastClick = this.clicks[this.clicks.length - 1];
13
+ if (lastClick &&
14
+ Math.abs(x - lastClick.x) + Math.abs(y - lastClick.y) < RAGE_CLICK_THRESHOLD_PX &&
15
+ timestamp - lastClick.timestamp < RAGE_CLICK_TIMEOUT_MS) {
16
+ this.clicks.push({ x, y, timestamp });
17
+ if (this.clicks.length === RAGE_CLICK_CLICK_COUNT) {
18
+ return true;
19
+ }
20
+ }
21
+ else {
22
+ this.clicks = [{ x, y, timestamp }];
23
+ }
24
+ return false;
25
+ }
26
+ }
27
+ //# sourceMappingURL=rageclick.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rageclick.js","sourceRoot":"","sources":["../../src/extensions/rageclick.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,yFAAyF;AACzF,0BAA0B;AAE1B,MAAM,uBAAuB,GAAG,EAAE,CAAA;AAClC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AAClC,MAAM,sBAAsB,GAAG,CAAC,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,SAAS;IAG1B;QACI,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;IACpB,CAAC;IAED,WAAW,CAAC,CAAS,EAAE,CAAS,EAAE,SAAiB;QAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACrD,IACI,SAAS;YACT,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,uBAAuB;YAC/E,SAAS,GAAG,SAAS,CAAC,SAAS,GAAG,qBAAqB,EACzD,CAAC;YACC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;YAErC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,sBAAsB,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAA;YACf,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAA;QACvC,CAAC;QAED,OAAO,KAAK,CAAA;IAChB,CAAC;CACJ"}
package/lib/iife.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { Leanbase } from './leanbase';
2
+ import type { LeanbaseConfig } from './types';
3
+ type QueuedCall = {
4
+ fn: keyof typeof api;
5
+ args: any[];
6
+ };
7
+ declare const api: {
8
+ _instance: Leanbase | null;
9
+ _queue: QueuedCall[];
10
+ init(apiKey: string, options?: LeanbaseConfig): void;
11
+ capture(event: string, properties?: import("@posthog/core").PostHogEventProperties | undefined, options?: import("./types").LeanbasegCaptureOptions | undefined): void;
12
+ captureException(error: unknown, additionalProperties?: import("@posthog/core").PostHogEventProperties | undefined): void;
13
+ identify(distinctId?: string | undefined, properties?: import("@posthog/core").PostHogEventProperties | undefined, options?: import("./types").LeanbasegCaptureOptions | undefined): void;
14
+ group(groupType: string, groupKey: string | number, groupProperties?: import("@posthog/core").PostHogEventProperties | undefined, options?: import("@posthog/core").PostHogCaptureOptions | undefined): void;
15
+ alias(alias: string): void;
16
+ reset(): void;
17
+ getInstance(): Leanbase | null;
18
+ };
19
+ export default api;
package/lib/iife.js ADDED
@@ -0,0 +1,67 @@
1
+ import { Leanbase } from './leanbase';
2
+ import { isArray } from '@posthog/core';
3
+ const api = {
4
+ _instance: null,
5
+ _queue: [],
6
+ init(apiKey, options) {
7
+ this._instance = new Leanbase(apiKey, options);
8
+ const q = this._queue;
9
+ this._queue = [];
10
+ for (const { fn, args } of q) {
11
+ // @ts-expect-error dynamic dispatch to API methods
12
+ this[fn](...args);
13
+ }
14
+ },
15
+ capture(...args) {
16
+ if (this._instance) {
17
+ return this._instance.capture(...args);
18
+ }
19
+ this._queue.push({ fn: 'capture', args });
20
+ },
21
+ captureException(...args) {
22
+ if (this._instance) {
23
+ return this._instance.captureException(...args);
24
+ }
25
+ this._queue.push({ fn: 'captureException', args });
26
+ },
27
+ identify(...args) {
28
+ if (this._instance) {
29
+ return this._instance.identify(...args);
30
+ }
31
+ this._queue.push({ fn: 'identify', args });
32
+ },
33
+ group(...args) {
34
+ if (this._instance) {
35
+ return this._instance.group(...args);
36
+ }
37
+ this._queue.push({ fn: 'group', args });
38
+ },
39
+ alias(...args) {
40
+ if (this._instance) {
41
+ return this._instance.alias(...args);
42
+ }
43
+ this._queue.push({ fn: 'alias', args });
44
+ },
45
+ reset() {
46
+ this._instance?.reset();
47
+ this._instance = null;
48
+ },
49
+ getInstance() {
50
+ return this._instance;
51
+ },
52
+ };
53
+ (function attachToGlobal(g) {
54
+ // Prefer not to overwrite if a stub already exists (e.g., user queued calls before script loaded)
55
+ const existing = g.leanbase;
56
+ if (existing && typeof existing === 'object') {
57
+ // If there is a pre-existing queue-compatible stub, try to drain it into our API
58
+ if (isArray(existing._queue)) {
59
+ api._queue = existing._queue;
60
+ }
61
+ }
62
+ g.leanbase = api;
63
+ // Also expose PascalCase alias for familiarity
64
+ g.Leanbase = g.leanbase;
65
+ })(globalThis);
66
+ export default api;
67
+ //# sourceMappingURL=iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iife.js","sourceRoot":"","sources":["../src/iife.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,MAAM,GAAG,GAAG;IACR,SAAS,EAAE,IAAuB;IAClC,MAAM,EAAE,EAAkB;IAE1B,IAAI,CAAC,MAAc,EAAE,OAAwB;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;QACrB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,KAAK,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3B,mDAAmD;YACnD,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;QACrB,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,IAA+D;QACtE,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAA;QAC1C,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,CAAC;IAED,gBAAgB,CAAC,GAAG,IAAwE;QACxF,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAA;QACnD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,IA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iFAAiF;QACjF,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAa,CAAA;QACvC,CAAC;IACL,CAAC;IAED,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAA;IAChB,+CAA+C;IAC/C,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAA;AAC3B,CAAC,CAAC,CAAC,UAAwC,CAAC,CAAA;AAE5C,eAAe,GAAG,CAAA"}
@@ -1,2 +1,2 @@
1
- export { Leanbase } from './leanbase'
2
- export type { LeanbaseConfig as LeanbaseOptions } from './types'
1
+ export { Leanbase } from './leanbase';
2
+ export type { LeanbaseConfig as LeanbaseOptions } from './types';
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Leanbase } from './leanbase';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA"}
@@ -0,0 +1,6 @@
1
+ export declare const logger: {
2
+ info: (...args: any[]) => void;
3
+ warn: (...args: any[]) => void;
4
+ error: (...args: any[]) => void;
5
+ critical: (...args: any[]) => void;
6
+ };
@@ -0,0 +1,25 @@
1
+ /* eslint-disable no-console */
2
+ const PREFIX = '[Leanbase]';
3
+ export const logger = {
4
+ info: (...args) => {
5
+ if (typeof console !== 'undefined') {
6
+ console.log(PREFIX, ...args);
7
+ }
8
+ },
9
+ warn: (...args) => {
10
+ if (typeof console !== 'undefined') {
11
+ console.warn(PREFIX, ...args);
12
+ }
13
+ },
14
+ error: (...args) => {
15
+ if (typeof console !== 'undefined') {
16
+ console.error(PREFIX, ...args);
17
+ }
18
+ },
19
+ critical: (...args) => {
20
+ if (typeof console !== 'undefined') {
21
+ console.error(PREFIX, 'CRITICAL:', ...args);
22
+ }
23
+ },
24
+ };
25
+ //# sourceMappingURL=leanbase-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leanbase-logger.js","sourceRoot":"","sources":["../src/leanbase-logger.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,MAAM,MAAM,GAAG,YAAY,CAAA;AAE3B,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACrB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;QAChC,CAAC;IACL,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACrB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;QACjC,CAAC;IACL,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACtB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAA;QAClC,CAAC;IACL,CAAC;IACD,QAAQ,EAAE,CAAC,GAAG,IAAW,EAAE,EAAE;QACzB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,CAAA;QAC/C,CAAC;IACL,CAAC;CACJ,CAAA"}
@@ -0,0 +1,64 @@
1
+ import { LeanbaseConfig, Properties } from './types';
2
+ /**
3
+ * Leanbase Persistence Object
4
+ * @constructor
5
+ */
6
+ export declare class LeanbasePersistence {
7
+ private _config;
8
+ props: Properties;
9
+ private _storage;
10
+ private _campaign_params_saved;
11
+ private readonly _name;
12
+ _disabled: boolean | undefined;
13
+ private _secure;
14
+ private _expire_days;
15
+ private _default_expiry;
16
+ private _cross_subdomain;
17
+ /**
18
+ * @param {LeanbaseConfig} config initial PostHog configuration
19
+ * @param {boolean=} isDisabled should persistence be disabled (e.g. because of consent management)
20
+ */
21
+ constructor(config: LeanbaseConfig, isDisabled?: boolean);
22
+ /**
23
+ * Returns whether persistence is disabled. Only available in SDKs > 1.257.1. Do not use on extensions, otherwise
24
+ * it'll break backwards compatibility for any version before 1.257.1.
25
+ */
26
+ isDisabled?(): boolean;
27
+ private _buildStorage;
28
+ properties(): Properties;
29
+ load(): void;
30
+ /**
31
+ * NOTE: Saving frequently causes issues with Recordings and Consent Management Platform (CMP) tools which
32
+ * observe cookie changes, and modify their UI, often causing infinite loops.
33
+ * As such callers of this should ideally check that the data has changed beforehand
34
+ */
35
+ save(): void;
36
+ remove(): void;
37
+ clear(): void;
38
+ /**
39
+ * @param {Object} props
40
+ * @param {*=} default_value
41
+ * @param {number=} days
42
+ */
43
+ register_once(props: Properties, default_value: any, days?: number): boolean;
44
+ /**
45
+ * @param {Object} props
46
+ * @param {number=} days
47
+ */
48
+ register(props: Properties, days?: number): boolean;
49
+ unregister(prop: string): void;
50
+ update_campaign_params(): void;
51
+ update_search_keyword(): void;
52
+ update_referrer_info(): void;
53
+ set_initial_person_info(): void;
54
+ get_initial_props(): Properties;
55
+ safe_merge(props: Properties): Properties;
56
+ update_config(config: LeanbaseConfig, oldConfig: LeanbaseConfig, isDisabled?: boolean): void;
57
+ set_disabled(disabled: boolean): void;
58
+ set_cross_subdomain(cross_subdomain: boolean): void;
59
+ set_secure(secure: boolean): void;
60
+ set_event_timer(event_name: string, timestamp: number): void;
61
+ remove_event_timer(event_name: string): number;
62
+ get_property(prop: string): any;
63
+ set_property(prop: string, to: any): void;
64
+ }