@usermaven/sdk-js 1.4.4 → 1.5.1-rc.91
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.
- package/README.md +149 -36
- package/dist/core/client.d.ts +54 -0
- package/dist/core/config.d.ts +3 -0
- package/dist/core/types.d.ts +128 -0
- package/dist/extensions/rage-click.d.ts +15 -0
- package/dist/extensions/scroll-depth.d.ts +19 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib.js +2 -0
- package/dist/persistence/local-storage.d.ts +13 -0
- package/dist/persistence/memory.d.ts +8 -0
- package/dist/tracking/autocapture.d.ts +25 -0
- package/dist/tracking/form-tracking.d.ts +27 -0
- package/dist/tracking/pageviews.d.ts +11 -0
- package/dist/transport/beacon.d.ts +9 -0
- package/dist/transport/fetch.d.ts +12 -0
- package/dist/transport/https.d.ts +10 -0
- package/dist/transport/transport.d.ts +3 -0
- package/dist/transport/xhr.d.ts +11 -0
- package/dist/usermaven.cjs.js +2 -0
- package/dist/usermaven.es.js +1305 -0
- package/dist/utils/autocapture-utils.d.ts +13 -0
- package/dist/utils/common.d.ts +27 -0
- package/dist/utils/cookie.d.ts +14 -0
- package/dist/utils/helpers.d.ts +9 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/queue.d.ts +23 -0
- package/package.json +58 -49
- package/LICENSE +0 -23
- package/dist/npm/usermaven.cjs.js +0 -2696
- package/dist/npm/usermaven.d.ts +0 -546
- package/dist/npm/usermaven.es.js +0 -2689
- package/dist/web/lib.js +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getClassName(el: Element): string;
|
|
2
|
+
export declare function getSafeText(el: Element): string;
|
|
3
|
+
export declare function isElementNode(el: Element | undefined | null): el is HTMLElement;
|
|
4
|
+
export declare function isTag(el: Element | undefined | null, tag: string): el is HTMLElement;
|
|
5
|
+
export declare function isTextNode(el: Element | undefined | null): el is HTMLElement;
|
|
6
|
+
export declare function isDocumentFragment(el: Element | ParentNode | undefined | null): el is DocumentFragment;
|
|
7
|
+
export declare const usefulElements: string[];
|
|
8
|
+
export declare function shouldCaptureDomEvent(el: Element, event: Event): boolean;
|
|
9
|
+
export declare function shouldCaptureElement(el: Element): boolean;
|
|
10
|
+
export declare function isSensitiveElement(el: Element): boolean;
|
|
11
|
+
export declare function shouldCaptureValue(value: string): boolean;
|
|
12
|
+
export declare function isAngularStyleAttr(attributeName: string): boolean;
|
|
13
|
+
export declare function loadScript(scriptUrlToLoad: string, callback: (event: Event) => void): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type Breaker = {};
|
|
2
|
+
export type EventHandler = (event: Event) => boolean | void;
|
|
3
|
+
export declare const _isArray: (arg: any) => arg is any[];
|
|
4
|
+
export declare function _eachArray<E = any>(obj: E[] | null | undefined, iterator: (value: E, key: number) => void | Breaker, thisArg?: any): void;
|
|
5
|
+
export declare const _trim: (str: string) => string;
|
|
6
|
+
export declare const _bind_instance_methods: (obj: Record<string, any>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* @param {*=} obj
|
|
9
|
+
* @param {function(...*)=} iterator
|
|
10
|
+
* @param {Object=} thisArg
|
|
11
|
+
*/
|
|
12
|
+
export declare function _each(obj: any, iterator: (value: any, key: any) => void | Breaker, thisArg?: any): void;
|
|
13
|
+
export declare const _extend: (obj: Record<string, any>, ...args: Record<string, any>[]) => Record<string, any>;
|
|
14
|
+
export declare function _includes<T = any>(str: T[] | string, needle: T): boolean;
|
|
15
|
+
export declare const _isFunction: (f: any) => f is (...args: any[]) => any;
|
|
16
|
+
export declare const _isUndefined: (obj: any) => obj is undefined;
|
|
17
|
+
export declare const _register_event: (element: Element | Window | Document | Node, type: string, handler: EventHandler, oldSchool?: boolean, useCapture?: boolean) => void;
|
|
18
|
+
export declare const _safewrap: <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F) => F;
|
|
19
|
+
export declare const _safewrap_instance_methods: (obj: Record<string, any>) => void;
|
|
20
|
+
export declare function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(object: T, maxStringLength: number | null): T;
|
|
21
|
+
export declare const _isBlockedUA: (ua: string) => boolean;
|
|
22
|
+
export declare function _findClosestLink(element: HTMLElement | null): HTMLElement | null;
|
|
23
|
+
export declare function _cleanObject(obj: Record<string, any>): Record<string, any>;
|
|
24
|
+
export declare function isWindowAvailable(): boolean;
|
|
25
|
+
export declare function generateRandom(length?: number): string;
|
|
26
|
+
export declare function toCamelCase(str: string): string;
|
|
27
|
+
export declare function convertKeysToCamelCase(obj: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class CookieManager {
|
|
2
|
+
private domain?;
|
|
3
|
+
private cookieDomain;
|
|
4
|
+
constructor(domain?: string | undefined);
|
|
5
|
+
set(name: string, value: string, expirationDays?: number, secure?: boolean, httpOnly?: boolean): void;
|
|
6
|
+
get(name: string): string | null;
|
|
7
|
+
delete(name: string, path?: string): void;
|
|
8
|
+
private getCookieDomain;
|
|
9
|
+
private extractRoot;
|
|
10
|
+
private isIpAddress;
|
|
11
|
+
private extractHostname;
|
|
12
|
+
private extractRootDomain;
|
|
13
|
+
private extractTopLevelDomain;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LogLevel } from '../utils/logger';
|
|
2
|
+
export declare function generateId(): string;
|
|
3
|
+
export declare function isValidEmail(email: string): boolean;
|
|
4
|
+
export declare function debounce<T extends (...args: P) => any, P extends any[]>(func: T, wait: number): (...args: P) => void;
|
|
5
|
+
export declare function getUtmParams(): Record<string, string>;
|
|
6
|
+
export declare function parseQueryString(queryString: string): Record<string, string>;
|
|
7
|
+
export declare function isString(value: any): boolean;
|
|
8
|
+
export declare function isObject(value: any): boolean;
|
|
9
|
+
export declare function parseLogLevel(value: string | null): LogLevel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
DEBUG = 0,
|
|
3
|
+
INFO = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
ERROR = 3
|
|
6
|
+
}
|
|
7
|
+
export declare class Logger {
|
|
8
|
+
private level;
|
|
9
|
+
constructor(level: LogLevel);
|
|
10
|
+
debug(message: string, ...args: any[]): void;
|
|
11
|
+
info(message: string, ...args: any[]): void;
|
|
12
|
+
warn(message: string, ...args: any[]): void;
|
|
13
|
+
error(message: string, ...args: any[]): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function getLogger(level?: LogLevel): Logger;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Transport } from '../core/types';
|
|
2
|
+
import { Logger } from '../utils/logger';
|
|
3
|
+
export declare class RetryQueue {
|
|
4
|
+
private transport;
|
|
5
|
+
private maxRetries;
|
|
6
|
+
private retryInterval;
|
|
7
|
+
private batchSize;
|
|
8
|
+
private batchInterval;
|
|
9
|
+
private logger;
|
|
10
|
+
private queue;
|
|
11
|
+
private processing;
|
|
12
|
+
private batchTimeoutId;
|
|
13
|
+
private persistence;
|
|
14
|
+
private isOnline;
|
|
15
|
+
constructor(transport: Transport, maxRetries?: number, retryInterval?: number, batchSize?: number, batchInterval?: number, logger?: Logger, namespace?: string);
|
|
16
|
+
add(payload: any): void;
|
|
17
|
+
private initNetworkListeners;
|
|
18
|
+
private scheduleBatch;
|
|
19
|
+
private processBatch;
|
|
20
|
+
private handleBatchFailure;
|
|
21
|
+
private loadQueueFromStorage;
|
|
22
|
+
private saveQueueToStorage;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,57 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usermaven/sdk-js",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Usermaven JavaScript SDK
|
|
5
|
-
"main": "dist/
|
|
6
|
-
"module": "dist/
|
|
7
|
-
"types": "dist/
|
|
3
|
+
"version": "1.5.1-rc.91",
|
|
4
|
+
"description": "Usermaven JavaScript SDK",
|
|
5
|
+
"main": "dist/lib.js",
|
|
6
|
+
"module": "dist/usermaven.es.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist
|
|
10
|
-
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"keywords": [
|
|
12
|
+
"usermaven",
|
|
13
|
+
"analytics",
|
|
14
|
+
"tracking"
|
|
11
15
|
],
|
|
12
|
-
"author": "Usermaven <hello@usermaven.com>",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"clean": "rm -rf ./dist",
|
|
15
|
-
"devserver": "PORT=8081 nodemon --watch '__tests__/common/*.ts' --exec 'ts-node' __tests__/common/devserver.ts",
|
|
16
|
-
"test": "rollup -c && jest --detectOpenHandles --verbose false",
|
|
17
|
-
"build": "rollup -c"
|
|
18
|
-
},
|
|
19
|
-
"jest": {
|
|
20
|
-
"testEnvironment": "node",
|
|
21
|
-
"testMatch": [
|
|
22
|
-
"**/__tests__/*.spec.{ts,js}"
|
|
23
|
-
],
|
|
24
|
-
"automock": false,
|
|
25
|
-
"verbose": false
|
|
26
|
-
},
|
|
27
16
|
"license": "MIT",
|
|
28
17
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@types/
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"typescript": "
|
|
18
|
+
"@playwright/test": "^1.40.0",
|
|
19
|
+
"@testing-library/dom": "^10.4.0",
|
|
20
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
21
|
+
"@types/jest": "^29.5.13",
|
|
22
|
+
"@types/node": "^18.15.11",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
24
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
25
|
+
"@vitest/coverage-v8": "^2.1.2",
|
|
26
|
+
"body-parser": "^1.20.3",
|
|
27
|
+
"browserstack-local": "^1.5.5",
|
|
28
|
+
"browserstack-node-sdk": "^1.34.31",
|
|
29
|
+
"chalk": "^5.3.0",
|
|
30
|
+
"colors": "^1.4.0",
|
|
31
|
+
"concurrently": "^9.0.1",
|
|
32
|
+
"cors": "^2.8.5",
|
|
33
|
+
"dotenv": "^16.3.1",
|
|
34
|
+
"eslint": "^8.37.0",
|
|
35
|
+
"express": "^4.21.0",
|
|
36
|
+
"http-server": "^14.1.1",
|
|
37
|
+
"jsdom": "^25.0.1",
|
|
38
|
+
"morgan": "^1.10.0",
|
|
39
|
+
"playwright": "^1.40.0",
|
|
40
|
+
"prettier": "^2.8.7",
|
|
41
|
+
"typescript": "^5.0.3",
|
|
42
|
+
"vite": "^5.4.8",
|
|
43
|
+
"vite-plugin-dts": "^4.2.3",
|
|
44
|
+
"vitest": "^2.1.2",
|
|
45
|
+
"wait-on": "^8.0.1",
|
|
46
|
+
"winston": "^3.14.2"
|
|
53
47
|
},
|
|
54
|
-
"
|
|
55
|
-
|
|
48
|
+
"scripts": {
|
|
49
|
+
"dev": "vite build --watch",
|
|
50
|
+
"build": "tsc && vite build",
|
|
51
|
+
"preview": "vite preview",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:watch": "vitest",
|
|
54
|
+
"test:coverage": "vitest run --coverage",
|
|
55
|
+
"test:e2e": "npm run build && playwright test --config=./playwright.local.config.ts",
|
|
56
|
+
"test:e2e:ui": "npm run build && playwright test --ui --config=./playwright.local.config.ts",
|
|
57
|
+
"test:browserstack": "npx browserstack-node-sdk playwright test --config=./playwright.config.ts",
|
|
58
|
+
"lint": "eslint . --ext .ts",
|
|
59
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
60
|
+
"mock": "wait-on dist/lib.js && node server/mockServer.js",
|
|
61
|
+
"example:build": "tsc examples/test.ts --outDir examples",
|
|
62
|
+
"example:serve": "wait-on dist/lib.js && vite --config vite.config.ts",
|
|
63
|
+
"serve:test": "http-server . -p 3000",
|
|
64
|
+
"start": "concurrently \"npm run dev\" \"npm run example:serve\" \"npm run mock\" "
|
|
56
65
|
}
|
|
57
|
-
}
|
|
66
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 UserMaven, Inc.
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2021 Jitsu Labs, Inc
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|