@armco/analytics 0.2.10 → 0.2.12
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/core/analytics.d.ts +48 -0
- package/core/analytics.js +311 -0
- package/core/errors.d.ts +26 -0
- package/core/errors.js +54 -0
- package/core/types.d.ts +133 -0
- package/index.d.ts +24 -2
- package/index.js +24 -13
- package/package.json +9 -28
- package/plugins/auto-track/click.d.ts +15 -0
- package/plugins/auto-track/click.js +95 -0
- package/plugins/auto-track/error.d.ts +15 -0
- package/plugins/auto-track/error.js +65 -0
- package/plugins/auto-track/form.d.ts +13 -0
- package/plugins/auto-track/form.js +54 -0
- package/plugins/auto-track/page.d.ts +14 -0
- package/plugins/auto-track/page.js +71 -0
- package/plugins/enrichment/session.d.ts +18 -0
- package/plugins/enrichment/session.js +81 -0
- package/plugins/enrichment/user.d.ts +20 -0
- package/plugins/enrichment/user.js +152 -0
- package/plugins/node/http-request-tracking.d.ts +54 -0
- package/plugins/node/http-request-tracking.js +158 -0
- package/storage/cookie-storage.d.ts +8 -0
- package/storage/cookie-storage.js +60 -0
- package/storage/hybrid-storage.d.ts +12 -0
- package/storage/hybrid-storage.js +108 -0
- package/storage/local-storage.d.ts +8 -0
- package/storage/local-storage.js +65 -0
- package/storage/memory-storage.d.ts +9 -0
- package/storage/memory-storage.js +22 -0
- package/transport/beacon-transport.d.ts +16 -0
- package/transport/beacon-transport.js +50 -0
- package/transport/fetch-transport.d.ts +20 -0
- package/transport/fetch-transport.js +112 -0
- package/utils/config-loader.d.ts +3 -0
- package/utils/config-loader.js +59 -0
- package/utils/helpers.d.ts +15 -0
- package/utils/helpers.js +148 -0
- package/utils/logging.d.ts +17 -0
- package/utils/logging.js +54 -0
- package/utils/validation.d.ts +9 -0
- package/utils/validation.js +146 -0
- package/.npmignore +0 -6
- package/analytics.d.ts +0 -19
- package/analytics.js +0 -537
- package/constants.d.ts +0 -3
- package/constants.js +0 -3
- package/flush.d.ts +0 -3
- package/flush.js +0 -36
- package/helper.d.ts +0 -1
- package/helper.js +0 -3
- package/index.interface.d.ts +0 -28
- package/location.d.ts +0 -6
- package/location.js +0 -42
- package/session.d.ts +0 -4
- package/session.js +0 -76
- package/tsconfig.prod.tsbuildinfo +0 -1
- /package/{index.interface.js → core/types.js} +0 -0
package/session.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import Cookies from "js-cookie";
|
|
2
|
-
import { v4 as uuidv4 } from "uuid";
|
|
3
|
-
const SESSION_COOKIE_NAME = "ar-session-id";
|
|
4
|
-
const SESSION_EXPIRATION_TIME = 30;
|
|
5
|
-
let localStorageTimeout;
|
|
6
|
-
function generateSessionId() {
|
|
7
|
-
return uuidv4();
|
|
8
|
-
}
|
|
9
|
-
export function startSession() {
|
|
10
|
-
const sessionId = generateSessionId();
|
|
11
|
-
const expirationDate = new Date();
|
|
12
|
-
let tabId = sessionStorage.getItem("tabId");
|
|
13
|
-
if (!tabId) {
|
|
14
|
-
const timestamp = expirationDate.getTime();
|
|
15
|
-
tabId = `${uuidv4()}-${timestamp}`;
|
|
16
|
-
sessionStorage.setItem("tabId", tabId);
|
|
17
|
-
}
|
|
18
|
-
const cookieName = `${SESSION_COOKIE_NAME}-${tabId}`;
|
|
19
|
-
refreshSessionId(sessionId, cookieName);
|
|
20
|
-
return sessionId;
|
|
21
|
-
}
|
|
22
|
-
function refreshSessionId(sessionId, cookieName) {
|
|
23
|
-
const expirationDate = new Date();
|
|
24
|
-
expirationDate.setMinutes(expirationDate.getMinutes() + SESSION_EXPIRATION_TIME);
|
|
25
|
-
try {
|
|
26
|
-
Cookies.set(cookieName, sessionId, { expires: expirationDate });
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
clearTimeout(localStorageTimeout);
|
|
30
|
-
localStorageTimeout = setTimeout(() => localStorage.removeItem(cookieName), SESSION_EXPIRATION_TIME * 1000);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function getSessionId() {
|
|
34
|
-
let sessionId;
|
|
35
|
-
const tabId = sessionStorage.getItem("tabId");
|
|
36
|
-
if (!tabId) {
|
|
37
|
-
return startSession();
|
|
38
|
-
}
|
|
39
|
-
const cookieName = `${SESSION_COOKIE_NAME}-${tabId}`;
|
|
40
|
-
sessionId = Cookies.get(cookieName);
|
|
41
|
-
if (!sessionId) {
|
|
42
|
-
sessionId = localStorage.getItem(cookieName);
|
|
43
|
-
}
|
|
44
|
-
if (!sessionId) {
|
|
45
|
-
return startSession();
|
|
46
|
-
}
|
|
47
|
-
refreshSessionId(sessionId, cookieName);
|
|
48
|
-
return sessionId;
|
|
49
|
-
}
|
|
50
|
-
export function extendSession() {
|
|
51
|
-
const tabId = sessionStorage.getItem("tabId");
|
|
52
|
-
if (!tabId) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const cookieName = `${SESSION_COOKIE_NAME}-${tabId}`;
|
|
56
|
-
let sessionId = Cookies.get(cookieName);
|
|
57
|
-
if (!sessionId) {
|
|
58
|
-
sessionId = localStorage.getItem(cookieName);
|
|
59
|
-
}
|
|
60
|
-
if (sessionId) {
|
|
61
|
-
refreshSessionId(sessionId, cookieName);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export function terminateSession() {
|
|
65
|
-
const tabId = sessionStorage.getItem("tabId");
|
|
66
|
-
if (!tabId) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const cookieName = `${SESSION_COOKIE_NAME}-${tabId}`;
|
|
70
|
-
if (typeof window !== "undefined" && window.Cookies) {
|
|
71
|
-
Cookies.remove(cookieName);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
localStorage.removeItem(cookieName);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../analytics.ts","../constants.ts","../flush.ts","../global-modules.d.ts","../helper.ts","../index.interface.ts","../index.ts","../location.ts","../session.ts"],"version":"5.8.2"}
|
|
File without changes
|