@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
@@ -0,0 +1,17 @@
1
+ export declare const DEFAULT_BLOCKED_UA_STRS: string[];
2
+ /**
3
+ * Block various web spiders from executing our JS and sending false capturing data
4
+ */
5
+ export declare const isBlockedUA: (ua: string, customBlockedUserAgents: string[]) => boolean;
6
+ export interface NavigatorUAData {
7
+ brands?: {
8
+ brand: string;
9
+ version: string;
10
+ }[];
11
+ }
12
+ declare global {
13
+ interface Navigator {
14
+ userAgentData?: NavigatorUAData;
15
+ }
16
+ }
17
+ export declare const isLikelyBot: (navigator: Navigator | undefined, customBlockedUserAgents: string[]) => boolean;
@@ -0,0 +1,5 @@
1
+ export declare function isElementInToolbar(el: EventTarget | null): boolean;
2
+ export declare function isElementNode(el: Node | Element | undefined | null): el is Element;
3
+ export declare function isTag(el: Element | undefined | null, tag: string): el is HTMLElement;
4
+ export declare function isTextNode(el: Element | undefined | null): el is HTMLElement;
5
+ export declare function isDocumentFragment(el: Element | ParentNode | undefined | null): el is DocumentFragment;
@@ -0,0 +1,22 @@
1
+ import { Properties } from '../types';
2
+ export declare const PERSONAL_DATA_CAMPAIGN_PARAMS: string[];
3
+ export declare const CAMPAIGN_PARAMS: string[];
4
+ export declare const EVENT_TO_PERSON_PROPERTIES: string[];
5
+ export declare const MASKED = "<masked>";
6
+ export declare const COOKIE_CAMPAIGN_PARAMS: string[];
7
+ export declare function getCampaignParams(customTrackedParams?: string[], maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[] | undefined): Record<string, string>;
8
+ export declare function getSearchInfo(): Record<string, any>;
9
+ export declare function getBrowserLanguage(): string | undefined;
10
+ export declare function getBrowserLanguagePrefix(): string | undefined;
11
+ export declare function getReferrer(): string;
12
+ export declare function getReferringDomain(): string;
13
+ export declare function getReferrerInfo(): Record<string, any>;
14
+ export declare function getPersonInfo(maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[]): {
15
+ r: string;
16
+ u: string | undefined;
17
+ };
18
+ export declare function getPersonPropsFromInfo(info: Record<string, any>): Record<string, any>;
19
+ export declare function getInitialPersonPropsFromInfo(info: Record<string, any>): Record<string, any>;
20
+ export declare function getTimezone(): string | undefined;
21
+ export declare function getTimezoneOffset(): number | undefined;
22
+ export declare function getEventProperties(maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[]): Properties;
@@ -0,0 +1,44 @@
1
+ import { Properties } from '../types';
2
+ export type Breaker = {};
3
+ export declare const ArrayProto: any[];
4
+ export declare const nativeForEach: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
5
+ export declare const nativeIndexOf: (searchElement: any, fromIndex?: number) => number;
6
+ declare const win: (Window & typeof globalThis) | undefined;
7
+ export declare const navigator: Navigator | undefined;
8
+ export declare const document: Document | undefined;
9
+ export declare const location: Location | undefined;
10
+ export declare const fetch: typeof globalThis.fetch | undefined;
11
+ export declare const XMLHttpRequest: {
12
+ new (): XMLHttpRequest;
13
+ prototype: XMLHttpRequest;
14
+ readonly UNSENT: 0;
15
+ readonly OPENED: 1;
16
+ readonly HEADERS_RECEIVED: 2;
17
+ readonly LOADING: 3;
18
+ readonly DONE: 4;
19
+ } | undefined;
20
+ export declare const AbortController: {
21
+ new (): AbortController;
22
+ prototype: AbortController;
23
+ } | undefined;
24
+ export declare const userAgent: string | undefined;
25
+ export { win as window };
26
+ export declare function eachArray<E = any>(obj: E[] | null | undefined, iterator: (value: E, key: number) => void | Breaker, thisArg?: any): void;
27
+ /**
28
+ * @param {*=} obj
29
+ * @param {function(...*)=} iterator
30
+ * @param {Object=} thisArg
31
+ */
32
+ export declare function each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void;
33
+ export declare const extend: (obj: Record<string, any>, ...args: Record<string, any>[]) => Record<string, any>;
34
+ export declare const extendArray: <T>(obj: T[], ...args: T[][]) => T[];
35
+ export declare const include: (obj: null | string | Array<any> | Record<string, any>, target: any) => boolean | Breaker;
36
+ /**
37
+ * Object.entries() polyfill
38
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries
39
+ */
40
+ export declare function entries<T = any>(obj: Record<string, T>): [string, T][];
41
+ export declare function addEventListener(element: Window | Document | Element | undefined, event: string, callback: EventListener, options?: AddEventListenerOptions): void;
42
+ export declare const stripEmptyProperties: (p: Properties) => Properties;
43
+ export declare function isCrossDomainCookie(documentLocation: Location | undefined): boolean;
44
+ export declare function copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(object: T, maxStringLength: number | null): T;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * IE11 doesn't support `new URL`
3
+ * so we can create an anchor element and use that to parse the URL
4
+ * there's a lot of overlap between HTMLHyperlinkElementUtils and URL
5
+ * meaning useful properties like `pathname` are available on both
6
+ */
7
+ export declare const convertToURL: (url: string) => HTMLAnchorElement | null;
8
+ export declare const formDataToQuery: (formdata: Record<string, any> | FormData, arg_separator?: string) => string;
9
+ export declare const getQueryParam: (url: string, param: string) => string;
10
+ export declare const maskQueryParams: <T extends string | undefined>(url: T, maskedParams: string[] | undefined, mask: string) => T extends string ? string : undefined;
11
+ export declare const _getHashParam: (hash: string, param: string) => string | null;
12
+ export declare const isLocalhost: () => boolean;
@@ -0,0 +1,6 @@
1
+ export declare class SimpleEventEmitter {
2
+ private _events;
3
+ constructor();
4
+ on(event: string, listener: (...args: any[]) => void): () => void;
5
+ emit(event: string, payload: any): void;
6
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * This function detects which browser is running this script.
3
+ * The order of the checks are important since many user agents
4
+ * include keywords used in later checks.
5
+ */
6
+ export declare const detectBrowser: (user_agent: string, vendor: string | undefined) => string;
7
+ /**
8
+ * This function detects which browser version is running this script,
9
+ * parsing major and minor version (e.g., 42.1). User agent strings from:
10
+ * http://www.useragentstring.com/pages/useragentstring.php
11
+ *
12
+ * `navigator.vendor` is passed in and used to help with detecting certain browsers
13
+ * NB `navigator.vendor` is deprecated and not present in every browser
14
+ */
15
+ export declare const detectBrowserVersion: (userAgent: string, vendor: string | undefined) => number | null;
16
+ export declare const detectOS: (user_agent: string) => [string, string];
17
+ export declare const detectDevice: (user_agent: string) => string;
18
+ export declare const detectDeviceType: (user_agent: string) => string;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * uuidv7: An experimental implementation of the proposed UUID Version 7
3
+ *
4
+ * @license Apache-2.0
5
+ * @copyright 2021-2023 LiosK
6
+ * @packageDocumentation
7
+ *
8
+ * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
9
+ */
10
+ /** Represents a UUID as a 16-byte byte array. */
11
+ export declare class UUID {
12
+ readonly bytes: Readonly<Uint8Array>;
13
+ /** @param bytes - The 16-byte byte array representation. */
14
+ constructor(bytes: Readonly<Uint8Array>);
15
+ /**
16
+ * Builds a byte array from UUIDv7 field values.
17
+ *
18
+ * @param unixTsMs - A 48-bit `unix_ts_ms` field value.
19
+ * @param randA - A 12-bit `rand_a` field value.
20
+ * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.
21
+ * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.
22
+ */
23
+ static fromFieldsV7(unixTsMs: number, randA: number, randBHi: number, randBLo: number): UUID;
24
+ /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */
25
+ toString(): string;
26
+ /** Creates an object from `this`. */
27
+ clone(): UUID;
28
+ /** Returns true if `this` is equivalent to `other`. */
29
+ equals(other: UUID): boolean;
30
+ /**
31
+ * Returns a negative integer, zero, or positive integer if `this` is less
32
+ * than, equal to, or greater than `other`, respectively.
33
+ */
34
+ compareTo(other: UUID): number;
35
+ }
36
+ /**
37
+ * Generates a UUIDv7 string.
38
+ *
39
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
40
+ * ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
41
+ */
42
+ export declare const uuidv7: () => string;
43
+ export declare const uuid7ToTimestampMs: (uuid: string) => number;
@@ -0,0 +1 @@
1
+ export declare const version = "0.2.0-alpha.0";
@@ -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;