@leanbase.com/js 0.1.3 → 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 (137) 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/constants.d.ts +54 -0
  6. package/dist/entrypoints/main.cjs.d.ts +4 -0
  7. package/dist/entrypoints/module.es.d.ts +4 -0
  8. package/dist/extensions/rageclick.d.ts +9 -0
  9. package/dist/iife.d.ts +19 -0
  10. package/dist/index.d.ts +2 -779
  11. package/dist/leanbase-logger.d.ts +6 -0
  12. package/dist/leanbase-persistence.d.ts +64 -0
  13. package/dist/leanbase.d.ts +49 -0
  14. package/dist/leanbase.iife.js +1 -4747
  15. package/dist/leanbase.iife.js.map +1 -1
  16. package/dist/main.js +2 -0
  17. package/dist/main.js.map +1 -0
  18. package/dist/module.d.ts +780 -0
  19. package/dist/module.js +2 -0
  20. package/dist/module.js.map +1 -0
  21. package/dist/page-view.d.ts +29 -0
  22. package/dist/scroll-manager.d.ts +21 -0
  23. package/dist/session-props.d.ts +32 -0
  24. package/dist/sessionid.d.ts +50 -0
  25. package/dist/storage.d.ts +24 -0
  26. package/{src/types.ts → dist/types.d.ts} +145 -235
  27. package/dist/utils/blocked-uas.d.ts +17 -0
  28. package/dist/utils/element-utils.d.ts +5 -0
  29. package/dist/utils/event-utils.d.ts +22 -0
  30. package/dist/utils/index.d.ts +44 -0
  31. package/dist/utils/request-utils.d.ts +12 -0
  32. package/dist/utils/simple-event-emitter.d.ts +6 -0
  33. package/dist/utils/user-agent-utils.d.ts +18 -0
  34. package/dist/uuidv7.d.ts +43 -0
  35. package/dist/version.d.ts +1 -0
  36. package/lib/autocapture-utils.d.ts +17 -0
  37. package/{src/autocapture-utils.ts → lib/autocapture-utils.js} +196 -280
  38. package/lib/autocapture-utils.js.map +1 -0
  39. package/lib/autocapture.d.ts +35 -0
  40. package/lib/autocapture.js +311 -0
  41. package/lib/autocapture.js.map +1 -0
  42. package/lib/config.d.ts +5 -0
  43. package/lib/config.js +7 -0
  44. package/lib/config.js.map +1 -0
  45. package/lib/constants.d.ts +54 -0
  46. package/{src/constants.ts → lib/constants.js} +50 -57
  47. package/lib/constants.js.map +1 -0
  48. package/lib/entrypoints/main.cjs.d.ts +4 -0
  49. package/lib/entrypoints/main.cjs.js +3 -0
  50. package/lib/entrypoints/main.cjs.js.map +1 -0
  51. package/lib/entrypoints/module.es.d.ts +4 -0
  52. package/lib/entrypoints/module.es.js +3 -0
  53. package/lib/entrypoints/module.es.js.map +1 -0
  54. package/lib/extensions/rageclick.d.ts +9 -0
  55. package/lib/extensions/rageclick.js +27 -0
  56. package/lib/extensions/rageclick.js.map +1 -0
  57. package/lib/iife.d.ts +19 -0
  58. package/lib/iife.js +67 -0
  59. package/lib/iife.js.map +1 -0
  60. package/{src/index.ts → lib/index.d.ts} +2 -2
  61. package/lib/index.js +2 -0
  62. package/lib/index.js.map +1 -0
  63. package/lib/leanbase-logger.d.ts +6 -0
  64. package/lib/leanbase-logger.js +25 -0
  65. package/lib/leanbase-logger.js.map +1 -0
  66. package/lib/leanbase-persistence.d.ts +64 -0
  67. package/lib/leanbase-persistence.js +287 -0
  68. package/lib/leanbase-persistence.js.map +1 -0
  69. package/lib/leanbase.d.ts +49 -0
  70. package/lib/leanbase.js +294 -0
  71. package/lib/leanbase.js.map +1 -0
  72. package/lib/page-view.d.ts +29 -0
  73. package/lib/page-view.js +81 -0
  74. package/lib/page-view.js.map +1 -0
  75. package/lib/scroll-manager.d.ts +21 -0
  76. package/lib/scroll-manager.js +79 -0
  77. package/lib/scroll-manager.js.map +1 -0
  78. package/lib/session-props.d.ts +32 -0
  79. package/lib/session-props.js +73 -0
  80. package/lib/session-props.js.map +1 -0
  81. package/lib/sessionid.d.ts +50 -0
  82. package/{src/sessionid.ts → lib/sessionid.js} +128 -204
  83. package/lib/sessionid.js.map +1 -0
  84. package/lib/storage.d.ts +24 -0
  85. package/{src/storage.ts → lib/storage.js} +182 -225
  86. package/lib/storage.js.map +1 -0
  87. package/lib/types.d.ts +544 -0
  88. package/lib/types.js +7 -0
  89. package/lib/types.js.map +1 -0
  90. package/lib/utils/blocked-uas.d.ts +17 -0
  91. package/{src/utils/blocked-uas.ts → lib/utils/blocked-uas.js} +19 -48
  92. package/lib/utils/blocked-uas.js.map +1 -0
  93. package/lib/utils/element-utils.d.ts +5 -0
  94. package/{src/utils/element-utils.ts → lib/utils/element-utils.js} +13 -17
  95. package/lib/utils/element-utils.js.map +1 -0
  96. package/lib/utils/event-utils.d.ts +22 -0
  97. package/lib/utils/event-utils.js +258 -0
  98. package/lib/utils/event-utils.js.map +1 -0
  99. package/lib/utils/index.d.ts +44 -0
  100. package/lib/utils/index.js +183 -0
  101. package/lib/utils/index.js.map +1 -0
  102. package/lib/utils/request-utils.d.ts +12 -0
  103. package/lib/utils/request-utils.js +107 -0
  104. package/lib/utils/request-utils.js.map +1 -0
  105. package/lib/utils/simple-event-emitter.d.ts +6 -0
  106. package/lib/utils/simple-event-emitter.js +24 -0
  107. package/lib/utils/simple-event-emitter.js.map +1 -0
  108. package/lib/utils/user-agent-utils.d.ts +18 -0
  109. package/lib/utils/user-agent-utils.js +369 -0
  110. package/lib/utils/user-agent-utils.js.map +1 -0
  111. package/lib/uuidv7.d.ts +43 -0
  112. package/{src/uuidv7.ts → lib/uuidv7.js} +103 -131
  113. package/lib/uuidv7.js.map +1 -0
  114. package/lib/version.d.ts +1 -0
  115. package/lib/version.js +2 -0
  116. package/lib/version.js.map +1 -0
  117. package/package.json +56 -45
  118. package/dist/index.cjs +0 -3034
  119. package/dist/index.cjs.map +0 -1
  120. package/dist/index.mjs +0 -3032
  121. package/dist/index.mjs.map +0 -1
  122. package/src/autocapture.ts +0 -415
  123. package/src/config.ts +0 -8
  124. package/src/extensions/rageclick.ts +0 -34
  125. package/src/iife.ts +0 -87
  126. package/src/leanbase-logger.ts +0 -26
  127. package/src/leanbase-persistence.ts +0 -374
  128. package/src/leanbase.ts +0 -424
  129. package/src/page-view.ts +0 -124
  130. package/src/scroll-manager.ts +0 -103
  131. package/src/session-props.ts +0 -114
  132. package/src/utils/event-utils.ts +0 -304
  133. package/src/utils/index.ts +0 -222
  134. package/src/utils/request-utils.ts +0 -128
  135. package/src/utils/simple-event-emitter.ts +0 -27
  136. package/src/utils/user-agent-utils.ts +0 -357
  137. package/src/version.ts +0 -1
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ Copyright 2025 Leanflag Limited
2
+ This project is a fork of PostHog/posthog-js.
3
+
4
+ All rights reserved. This software is proprietary to Leanflag Limited and may only be used for Leanflag Limited products and internal purposes. Redistribution, modification, or commercial use outside of Leanflag Limited is strictly prohibited without explicit written permission from Leanflag Limited.
5
+
6
+
7
+ ---
8
+
9
+ Copyright 2020 Posthog / Hiberly, Inc.
10
+
11
+ Copyright 2015 Mixpanel, Inc.
12
+
13
+
14
+ Some files in this codebase contain code from getsentry/sentry-javascript by Software, Inc. dba Sentry.
15
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
16
+
17
+ MIT License
18
+
19
+ Copyright (c) 2012 Functional Software, Inc. dba Sentry
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
22
+ this software and associated documentation files (the "Software"), to deal in
23
+ the Software without restriction, including without limitation the rights to
24
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
25
+ of the Software, and to permit persons to whom the Software is furnished to do
26
+ so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in all
29
+ copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ import { AutocaptureConfig, LeanbaseConfig, Properties } from './types';
2
+ export declare function splitClassString(s: string): string[];
3
+ export declare function getClassNames(el: Element): string[];
4
+ export declare function makeSafeText(s: string | null | undefined): string | null;
5
+ export declare function getSafeText(el: Element): string;
6
+ export declare function getEventTarget(e: Event): Element | null;
7
+ export declare const autocaptureCompatibleElements: string[];
8
+ export declare function getParentElement(curEl: Element): Element | false;
9
+ export declare function shouldCaptureRageclick(el: Element | null, _config: LeanbaseConfig['rageclick']): boolean;
10
+ export declare function shouldCaptureDomEvent(el: Element, event: Event, autocaptureConfig?: AutocaptureConfig | undefined, captureOnAnyElement?: boolean, allowedEventTypes?: string[]): boolean;
11
+ export declare function shouldCaptureElement(el: Element): boolean;
12
+ export declare function isSensitiveElement(el: Element): boolean;
13
+ export declare function shouldCaptureValue(value: string, anchorRegexes?: boolean): boolean;
14
+ export declare function isAngularStyleAttr(attributeName: string): boolean;
15
+ export declare function getDirectAndNestedSpanText(target: Element): string;
16
+ export declare function getNestedSpanText(target: Element): string;
17
+ export declare function getElementsChainString(elements: Properties[]): string;
@@ -0,0 +1,35 @@
1
+ import RageClick from './extensions/rageclick';
2
+ import { Properties, RemoteConfig } from './types';
3
+ import { Leanbase } from './leanbase';
4
+ export declare function getAugmentPropertiesFromElement(elem: Element): Properties;
5
+ export declare function previousElementSibling(el: Element): Element | null;
6
+ export declare function getDefaultProperties(eventType: string): Properties;
7
+ export declare function getPropertiesFromElement(elem: Element, maskAllAttributes: boolean, maskText: boolean, elementAttributeIgnorelist: string[] | undefined): Properties;
8
+ export declare function autocapturePropertiesForElement(target: Element, { e, maskAllElementAttributes, maskAllText, elementAttributeIgnoreList, elementsChainAsString, }: {
9
+ e: Event;
10
+ maskAllElementAttributes: boolean;
11
+ maskAllText: boolean;
12
+ elementAttributeIgnoreList?: string[] | undefined;
13
+ elementsChainAsString: boolean;
14
+ }): {
15
+ props: Properties;
16
+ explicitNoCapture?: boolean;
17
+ };
18
+ export declare class Autocapture {
19
+ instance: Leanbase;
20
+ _initialized: boolean;
21
+ _isDisabledServerSide: boolean | null;
22
+ _elementSelectors: Set<string> | null;
23
+ rageclicks: RageClick;
24
+ _elementsChainAsString: boolean;
25
+ constructor(instance: Leanbase);
26
+ private get _config();
27
+ _addDomEventHandlers(): void;
28
+ startIfEnabled(): void;
29
+ onRemoteConfig(response: RemoteConfig): void;
30
+ setElementSelectors(selectors: Set<string>): void;
31
+ getElementSelectors(element: Element | null): string[] | null;
32
+ get isEnabled(): boolean;
33
+ private _captureEvent;
34
+ isBrowserSupported(): boolean;
35
+ }
@@ -0,0 +1,5 @@
1
+ declare const Config: {
2
+ DEBUG: boolean;
3
+ LIB_VERSION: string;
4
+ };
5
+ export default Config;
@@ -0,0 +1,54 @@
1
+ export declare const PEOPLE_DISTINCT_ID_KEY = "$people_distinct_id";
2
+ export declare const DISTINCT_ID = "distinct_id";
3
+ export declare const ALIAS_ID_KEY = "__alias";
4
+ export declare const CAMPAIGN_IDS_KEY = "__cmpns";
5
+ export declare const EVENT_TIMERS_KEY = "__timers";
6
+ export declare const AUTOCAPTURE_DISABLED_SERVER_SIDE = "$autocapture_disabled_server_side";
7
+ export declare const HEATMAPS_ENABLED_SERVER_SIDE = "$heatmaps_enabled_server_side";
8
+ export declare const EXCEPTION_CAPTURE_ENABLED_SERVER_SIDE = "$exception_capture_enabled_server_side";
9
+ export declare const ERROR_TRACKING_SUPPRESSION_RULES = "$error_tracking_suppression_rules";
10
+ export declare const ERROR_TRACKING_CAPTURE_EXTENSION_EXCEPTIONS = "$error_tracking_capture_extension_exceptions";
11
+ export declare const WEB_VITALS_ENABLED_SERVER_SIDE = "$web_vitals_enabled_server_side";
12
+ export declare const DEAD_CLICKS_ENABLED_SERVER_SIDE = "$dead_clicks_enabled_server_side";
13
+ export declare const WEB_VITALS_ALLOWED_METRICS = "$web_vitals_allowed_metrics";
14
+ export declare const SESSION_RECORDING_REMOTE_CONFIG = "$session_recording_remote_config";
15
+ export declare const SESSION_RECORDING_ENABLED_SERVER_SIDE = "$session_recording_enabled_server_side";
16
+ export declare const CONSOLE_LOG_RECORDING_ENABLED_SERVER_SIDE = "$console_log_recording_enabled_server_side";
17
+ export declare const SESSION_RECORDING_NETWORK_PAYLOAD_CAPTURE = "$session_recording_network_payload_capture";
18
+ export declare const SESSION_RECORDING_MASKING = "$session_recording_masking";
19
+ export declare const SESSION_RECORDING_CANVAS_RECORDING = "$session_recording_canvas_recording";
20
+ export declare const SESSION_RECORDING_SAMPLE_RATE = "$replay_sample_rate";
21
+ export declare const SESSION_RECORDING_MINIMUM_DURATION = "$replay_minimum_duration";
22
+ export declare const SESSION_RECORDING_SCRIPT_CONFIG = "$replay_script_config";
23
+ export declare const SESSION_ID = "$sesid";
24
+ export declare const SESSION_RECORDING_IS_SAMPLED = "$session_is_sampled";
25
+ export declare const SESSION_RECORDING_URL_TRIGGER_ACTIVATED_SESSION = "$session_recording_url_trigger_activated_session";
26
+ export declare const SESSION_RECORDING_EVENT_TRIGGER_ACTIVATED_SESSION = "$session_recording_event_trigger_activated_session";
27
+ export declare const ENABLED_FEATURE_FLAGS = "$enabled_feature_flags";
28
+ export declare const PERSISTENCE_EARLY_ACCESS_FEATURES = "$early_access_features";
29
+ export declare const PERSISTENCE_FEATURE_FLAG_DETAILS = "$feature_flag_details";
30
+ export declare const STORED_PERSON_PROPERTIES_KEY = "$stored_person_properties";
31
+ export declare const STORED_GROUP_PROPERTIES_KEY = "$stored_group_properties";
32
+ export declare const SURVEYS = "$surveys";
33
+ export declare const SURVEYS_ACTIVATED = "$surveys_activated";
34
+ export declare const FLAG_CALL_REPORTED = "$flag_call_reported";
35
+ export declare const USER_STATE = "$user_state";
36
+ export declare const CLIENT_SESSION_PROPS = "$client_session_props";
37
+ export declare const CAPTURE_RATE_LIMIT = "$capture_rate_limit";
38
+ /** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */
39
+ export declare const INITIAL_CAMPAIGN_PARAMS = "$initial_campaign_params";
40
+ /** @deprecated Delete this when INITIAL_PERSON_INFO has been around for long enough to ignore backwards compat */
41
+ export declare const INITIAL_REFERRER_INFO = "$initial_referrer_info";
42
+ export declare const INITIAL_PERSON_INFO = "$initial_person_info";
43
+ export declare const ENABLE_PERSON_PROCESSING = "$epp";
44
+ export declare const TOOLBAR_ID = "__POSTHOG_TOOLBAR__";
45
+ export declare const TOOLBAR_CONTAINER_CLASS = "toolbar-global-fade-container";
46
+ /**
47
+ * PREVIEW - MAY CHANGE WITHOUT WARNING - DO NOT USE IN PRODUCTION
48
+ * Sentinel value for distinct id, device id, session id. Signals that the server should generate the value
49
+ * */
50
+ export declare const COOKIELESS_SENTINEL_VALUE = "$posthog_cookieless";
51
+ export declare const COOKIELESS_MODE_FLAG_PROPERTY = "$cookieless_mode";
52
+ export declare const WEB_EXPERIMENTS = "$web_experiments";
53
+ export declare const PERSISTENCE_RESERVED_PROPERTIES: string[];
54
+ export declare const SURVEYS_REQUEST_TIMEOUT_MS = 10000;
@@ -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,4 @@
1
+ import { Leanbase } from '../leanbase';
2
+ import type { LeanbaseConfig } from '../types';
3
+ export { Leanbase };
4
+ export type { LeanbaseConfig };
@@ -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
+ }
package/dist/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;