@cloudcare/browser-core 1.1.3 → 1.2.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.
- package/cjs/{cookie.js → browser/cookie.js} +6 -37
- package/cjs/browser/fetchObservable.js +91 -0
- package/cjs/browser/xhrObservable.js +118 -0
- package/cjs/configuration/configuration.js +70 -0
- package/cjs/configuration/transportConfiguration.js +64 -0
- package/cjs/console/consoleObservable.js +84 -0
- package/cjs/dataMap.js +26 -21
- package/cjs/error/trackRuntimeError.js +27 -0
- package/cjs/helper/catchUserErrors.js +20 -0
- package/cjs/helper/contextHistory.js +134 -0
- package/cjs/helper/createEventRateLimiter.js +47 -0
- package/cjs/helper/deviceInfo.js +8 -25
- package/cjs/helper/display.js +31 -0
- package/cjs/helper/enums.js +28 -2
- package/cjs/helper/errorTools.js +63 -2
- package/cjs/helper/instrumentMethod.js +93 -0
- package/cjs/helper/lifeCycle.js +5 -3
- package/cjs/helper/observable.js +40 -2
- package/cjs/helper/tools.js +185 -9
- package/cjs/index.js +153 -23
- package/cjs/init.js +17 -27
- package/cjs/report/reportObservable.js +112 -0
- package/cjs/session/sessionConstants.js +13 -0
- package/cjs/session/sessionCookieStore.js +188 -0
- package/cjs/session/sessionManagement.js +96 -0
- package/cjs/session/sessionStore.js +150 -0
- package/cjs/synthetics/syntheticsWorkerValues.js +32 -0
- package/cjs/synthetics/usr.js +32 -0
- package/cjs/tracekit/computeStackTrace.js +73 -563
- package/cjs/tracekit/index.js +3 -15
- package/cjs/tracekit/tracekit.js +113 -0
- package/cjs/transport/batch.js +332 -0
- package/cjs/transport/httpRequest.js +112 -0
- package/cjs/transport/index.js +29 -0
- package/cjs/transport/sendWithRetryStrategy.js +177 -0
- package/cjs/transport/startBatchWithReplica.js +24 -0
- package/esm/{cookie.js → browser/cookie.js} +4 -35
- package/esm/browser/fetchObservable.js +77 -0
- package/esm/browser/xhrObservable.js +106 -0
- package/esm/configuration/configuration.js +55 -0
- package/esm/configuration/transportConfiguration.js +54 -0
- package/esm/console/consoleObservable.js +70 -0
- package/esm/dataMap.js +26 -21
- package/esm/error/trackRuntimeError.js +16 -0
- package/esm/helper/catchUserErrors.js +12 -0
- package/esm/helper/contextHistory.js +106 -0
- package/esm/helper/createEventRateLimiter.js +38 -0
- package/esm/helper/deviceInfo.js +6 -25
- package/esm/helper/display.js +21 -0
- package/esm/helper/enums.js +25 -1
- package/esm/helper/errorTools.js +58 -3
- package/esm/helper/instrumentMethod.js +81 -0
- package/esm/helper/lifeCycle.js +5 -3
- package/esm/helper/observable.js +39 -3
- package/esm/helper/tools.js +147 -1
- package/esm/index.js +17 -7
- package/esm/init.js +17 -22
- package/esm/report/reportObservable.js +98 -0
- package/esm/session/sessionConstants.js +3 -0
- package/esm/session/sessionCookieStore.js +168 -0
- package/esm/session/sessionManagement.js +78 -0
- package/esm/session/sessionStore.js +139 -0
- package/esm/synthetics/syntheticsWorkerValues.js +15 -0
- package/esm/synthetics/usr.js +18 -0
- package/esm/tracekit/computeStackTrace.js +73 -557
- package/esm/tracekit/index.js +1 -1
- package/esm/tracekit/tracekit.js +103 -0
- package/esm/transport/batch.js +316 -0
- package/esm/transport/httpRequest.js +104 -0
- package/esm/transport/index.js +3 -0
- package/esm/transport/sendWithRetryStrategy.js +165 -0
- package/esm/transport/startBatchWithReplica.js +15 -0
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/{cookie.js → browser/cookie.js} +6 -34
- package/src/browser/fetchObservable.js +86 -0
- package/src/browser/xhrObservable.js +102 -0
- package/src/configuration/configuration.js +61 -0
- package/src/configuration/transportConfiguration.js +42 -0
- package/src/console/consoleObservable.js +65 -0
- package/src/dataMap.js +26 -21
- package/src/error/trackRuntimeError.js +19 -0
- package/src/helper/catchUserErrors.js +12 -0
- package/src/helper/contextHistory.js +85 -0
- package/src/helper/createEventRateLimiter.js +37 -0
- package/src/helper/deviceInfo.js +5 -51
- package/src/helper/display.js +21 -0
- package/src/helper/enums.js +38 -14
- package/src/helper/errorTools.js +76 -12
- package/src/helper/instrumentMethod.js +97 -0
- package/src/helper/lifeCycle.js +5 -3
- package/src/helper/observable.js +33 -2
- package/src/helper/tools.js +135 -4
- package/src/index.js +18 -7
- package/src/init.js +17 -18
- package/src/report/reportObservable.js +113 -0
- package/src/session/sessionConstants.js +3 -0
- package/src/session/sessionCookieStore.js +159 -0
- package/src/session/sessionManagement.js +89 -0
- package/src/session/sessionStore.js +139 -0
- package/src/synthetics/syntheticsWorkerValues.js +22 -0
- package/src/synthetics/usr.js +18 -0
- package/src/tracekit/computeStackTrace.js +75 -551
- package/src/tracekit/index.js +1 -1
- package/src/tracekit/tracekit.js +100 -0
- package/src/transport/batch.js +289 -0
- package/src/transport/httpRequest.js +109 -0
- package/src/transport/index.js +3 -0
- package/src/transport/sendWithRetryStrategy.js +186 -0
- package/src/transport/startBatchWithReplica.js +26 -0
- package/cjs/configuration.js +0 -193
- package/cjs/errorCollection.js +0 -167
- package/cjs/fetchProxy.js +0 -161
- package/cjs/helper/errorFilter.js +0 -47
- package/cjs/sessionManagement.js +0 -221
- package/cjs/tracekit/report.js +0 -289
- package/cjs/transport.js +0 -373
- package/cjs/xhrProxy.js +0 -122
- package/esm/configuration.js +0 -176
- package/esm/errorCollection.js +0 -141
- package/esm/fetchProxy.js +0 -115
- package/esm/helper/errorFilter.js +0 -38
- package/esm/sessionManagement.js +0 -195
- package/esm/tracekit/report.js +0 -273
- package/esm/transport.js +0 -357
- package/esm/xhrProxy.js +0 -110
- package/src/configuration.js +0 -161
- package/src/errorCollection.js +0 -170
- package/src/fetchProxy.js +0 -108
- package/src/helper/errorFilter.js +0 -38
- package/src/sessionManagement.js +0 -224
- package/src/tracekit/report.js +0 -284
- package/src/transport.js +0 -380
- package/src/xhrProxy.js +0 -106
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { COOKIE_ACCESS_DELAY } from '../browser/cookie';
|
|
2
|
+
import { Observable } from '../helper/observable';
|
|
3
|
+
import { dateNow, UUID, throttle } from '../helper/tools';
|
|
4
|
+
import { SESSION_TIME_OUT_DELAY } from './sessionConstants';
|
|
5
|
+
import { retrieveSession, withCookieLockAccess } from './sessionCookieStore';
|
|
6
|
+
/**
|
|
7
|
+
* Different session concepts:
|
|
8
|
+
* - tracked, the session has an id and is updated along the user navigation
|
|
9
|
+
* - not tracked, the session does not have an id but it is updated along the user navigation
|
|
10
|
+
* - inactive, no session in store or session expired, waiting for a renew session
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export function startSessionStore(options, productKey, computeSessionState) {
|
|
14
|
+
var renewObservable = new Observable();
|
|
15
|
+
var expireObservable = new Observable();
|
|
16
|
+
var watchSessionTimeoutId = setInterval(watchSession, COOKIE_ACCESS_DELAY);
|
|
17
|
+
var sessionCache = retrieveActiveSession();
|
|
18
|
+
|
|
19
|
+
function expandOrRenewSession() {
|
|
20
|
+
var isTracked;
|
|
21
|
+
withCookieLockAccess({
|
|
22
|
+
options: options,
|
|
23
|
+
process: function process(cookieSession) {
|
|
24
|
+
var synchronizedSession = synchronizeSession(cookieSession);
|
|
25
|
+
isTracked = expandOrRenewCookie(synchronizedSession);
|
|
26
|
+
return synchronizedSession;
|
|
27
|
+
},
|
|
28
|
+
after: function after(cookieSession) {
|
|
29
|
+
if (isTracked && !hasSessionInCache()) {
|
|
30
|
+
renewSession(cookieSession);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
sessionCache = cookieSession;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function expandSession() {
|
|
39
|
+
withCookieLockAccess({
|
|
40
|
+
options: options,
|
|
41
|
+
process: function process(cookieSession) {
|
|
42
|
+
return hasSessionInCache() ? synchronizeSession(cookieSession) : undefined;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* allows two behaviors:
|
|
48
|
+
* - if the session is active, synchronize the session cache without updating the session cookie
|
|
49
|
+
* - if the session is not active, clear the session cookie and expire the session cache
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function watchSession() {
|
|
54
|
+
withCookieLockAccess({
|
|
55
|
+
options: options,
|
|
56
|
+
process: function process(cookieSession) {
|
|
57
|
+
return !isActiveSession(cookieSession) ? {} : undefined;
|
|
58
|
+
},
|
|
59
|
+
after: synchronizeSession
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function synchronizeSession(cookieSession) {
|
|
64
|
+
if (!isActiveSession(cookieSession)) {
|
|
65
|
+
cookieSession = {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (hasSessionInCache()) {
|
|
69
|
+
if (isSessionInCacheOutdated(cookieSession)) {
|
|
70
|
+
expireSession();
|
|
71
|
+
} else {
|
|
72
|
+
sessionCache = cookieSession;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return cookieSession;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function expandOrRenewCookie(cookieSession) {
|
|
80
|
+
var sessionState = computeSessionState(cookieSession[productKey]);
|
|
81
|
+
var trackingType = sessionState.trackingType;
|
|
82
|
+
var isTracked = sessionState.isTracked;
|
|
83
|
+
cookieSession[productKey] = trackingType;
|
|
84
|
+
|
|
85
|
+
if (isTracked && !cookieSession.id) {
|
|
86
|
+
cookieSession.id = UUID();
|
|
87
|
+
cookieSession.created = String(dateNow());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return isTracked;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function hasSessionInCache() {
|
|
94
|
+
return sessionCache[productKey] !== undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isSessionInCacheOutdated(cookieSession) {
|
|
98
|
+
return sessionCache.id !== cookieSession.id || sessionCache[productKey] !== cookieSession[productKey];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function expireSession() {
|
|
102
|
+
sessionCache = {};
|
|
103
|
+
expireObservable.notify();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function renewSession(cookieSession) {
|
|
107
|
+
sessionCache = cookieSession;
|
|
108
|
+
renewObservable.notify();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function retrieveActiveSession() {
|
|
112
|
+
var session = retrieveSession();
|
|
113
|
+
|
|
114
|
+
if (isActiveSession(session)) {
|
|
115
|
+
return session;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function isActiveSession(session) {
|
|
122
|
+
// created and expire can be undefined for versions which was not storing them
|
|
123
|
+
// these checks could be removed when older versions will not be available/live anymore
|
|
124
|
+
return (session.created === undefined || dateNow() - Number(session.created) < SESSION_TIME_OUT_DELAY) && (session.expire === undefined || dateNow() < Number(session.expire));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
expandOrRenewSession: throttle(expandOrRenewSession, COOKIE_ACCESS_DELAY),
|
|
129
|
+
expandSession: expandSession,
|
|
130
|
+
getSession: function getSession() {
|
|
131
|
+
return sessionCache;
|
|
132
|
+
},
|
|
133
|
+
renewObservable: renewObservable,
|
|
134
|
+
expireObservable: expireObservable,
|
|
135
|
+
stop: function stop() {
|
|
136
|
+
clearInterval(watchSessionTimeoutId);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getCookie } from '../browser/cookie';
|
|
2
|
+
export var SYNTHETICS_TEST_ID_COOKIE_NAME = 'guance-synthetics-public-id';
|
|
3
|
+
export var SYNTHETICS_RESULT_ID_COOKIE_NAME = 'guance-synthetics-result-id';
|
|
4
|
+
export var SYNTHETICS_INJECTS_RUM_COOKIE_NAME = 'guance-synthetics-injects-rum';
|
|
5
|
+
export function willSyntheticsInjectRum() {
|
|
6
|
+
return Boolean(window._GUANCE_SYNTHETICS_INJECTS_RUM || getCookie(SYNTHETICS_INJECTS_RUM_COOKIE_NAME));
|
|
7
|
+
}
|
|
8
|
+
export function getSyntheticsTestId() {
|
|
9
|
+
var value = window._GUANCE_SYNTHETICS_PUBLIC_ID || getCookie(SYNTHETICS_TEST_ID_COOKIE_NAME);
|
|
10
|
+
return typeof value === 'string' ? value : undefined;
|
|
11
|
+
}
|
|
12
|
+
export function getSyntheticsResultId() {
|
|
13
|
+
var value = window._GUANCE_SYNTHETICS_RESULT_ID || getCookie(SYNTHETICS_RESULT_ID_COOKIE_NAME);
|
|
14
|
+
return typeof value === 'string' ? value : undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getCookie, setCookie } from '../browser/cookie';
|
|
2
|
+
import { ONE_HOUR, UUID } from '../helper/tools';
|
|
3
|
+
export var ANONYMOUS_ID_COOKIE_NAME = '_dataflulx_usr_id';
|
|
4
|
+
export var ANONYMOUS_ID_EXPIRATION = 60 * 24 * ONE_HOUR;
|
|
5
|
+
export var startCacheUsrCache = function startCacheUsrCache(configuration) {
|
|
6
|
+
var usrCacheId = getCookie(ANONYMOUS_ID_COOKIE_NAME);
|
|
7
|
+
|
|
8
|
+
if (!usrCacheId) {
|
|
9
|
+
usrCacheId = UUID();
|
|
10
|
+
setCookie(ANONYMOUS_ID_COOKIE_NAME, usrCacheId, ANONYMOUS_ID_EXPIRATION, configuration.cookieOptions);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
getUsrId: function getUsrId() {
|
|
15
|
+
return usrCacheId;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|