@cloudcare/browser-core 3.2.26 → 3.2.29
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/browser/asyncClocks.js +0 -4
- package/cjs/browser/asyncClocks.js.map +1 -1
- package/cjs/configuration/configuration.js +1 -1
- package/cjs/configuration/configuration.js.map +1 -1
- package/cjs/configuration/remoteConfiguration.js +0 -85
- package/cjs/configuration/remoteConfiguration.js.map +1 -1
- package/cjs/configuration/transportConfiguration.js +0 -2
- package/cjs/configuration/transportConfiguration.js.map +1 -1
- package/cjs/dataMap.js +1 -2
- package/cjs/dataMap.js.map +1 -1
- package/cjs/helper/deviceInfo.js +2 -41
- package/cjs/helper/deviceInfo.js.map +1 -1
- package/cjs/helper/mobileUtil.js +2 -2
- package/cjs/helper/mobileUtil.js.map +1 -1
- package/cjs/helper/serialisation/rowData.js +0 -1
- package/cjs/helper/serialisation/rowData.js.map +1 -1
- package/cjs/helper/tools.js +6 -21
- package/cjs/helper/tools.js.map +1 -1
- package/cjs/index.js +7 -0
- package/cjs/index.js.map +1 -1
- package/cjs/session/sessionConstants.js +5 -1
- package/cjs/session/sessionConstants.js.map +1 -1
- package/cjs/session/sessionInCookie.js +1 -1
- package/cjs/session/sessionInCookie.js.map +1 -1
- package/cjs/session/sessionInLocalStorage.js +1 -1
- package/cjs/session/sessionInLocalStorage.js.map +1 -1
- package/cjs/session/sessionStore.js +18 -5
- package/cjs/session/sessionStore.js.map +1 -1
- package/cjs/session/sessionStoreOperations.js +34 -8
- package/cjs/session/sessionStoreOperations.js.map +1 -1
- package/cjs/transport/batch.js +9 -11
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/httpRequest.js +40 -6
- package/cjs/transport/httpRequest.js.map +1 -1
- package/esm/browser/asyncClocks.js +0 -4
- package/esm/browser/asyncClocks.js.map +1 -1
- package/esm/configuration/configuration.js +1 -1
- package/esm/configuration/configuration.js.map +1 -1
- package/esm/configuration/remoteConfiguration.js +0 -85
- package/esm/configuration/remoteConfiguration.js.map +1 -1
- package/esm/configuration/transportConfiguration.js +0 -2
- package/esm/configuration/transportConfiguration.js.map +1 -1
- package/esm/dataMap.js +1 -2
- package/esm/dataMap.js.map +1 -1
- package/esm/helper/deviceInfo.js +2 -41
- package/esm/helper/deviceInfo.js.map +1 -1
- package/esm/helper/mobileUtil.js +2 -2
- package/esm/helper/mobileUtil.js.map +1 -1
- package/esm/helper/serialisation/rowData.js +0 -1
- package/esm/helper/serialisation/rowData.js.map +1 -1
- package/esm/helper/tools.js +6 -21
- package/esm/helper/tools.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/session/sessionConstants.js +4 -0
- package/esm/session/sessionConstants.js.map +1 -1
- package/esm/session/sessionInCookie.js +2 -2
- package/esm/session/sessionInCookie.js.map +1 -1
- package/esm/session/sessionInLocalStorage.js +2 -2
- package/esm/session/sessionInLocalStorage.js.map +1 -1
- package/esm/session/sessionStore.js +18 -5
- package/esm/session/sessionStore.js.map +1 -1
- package/esm/session/sessionStoreOperations.js +34 -9
- package/esm/session/sessionStoreOperations.js.map +1 -1
- package/esm/transport/batch.js +9 -11
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/httpRequest.js +40 -6
- package/esm/transport/httpRequest.js.map +1 -1
- package/package.json +23 -24
- package/src/browser/asyncClocks.js +0 -3
- package/src/configuration/configuration.js +1 -1
- package/src/configuration/remoteConfiguration.js +0 -84
- package/src/configuration/transportConfiguration.js +0 -2
- package/src/dataMap.js +2 -2
- package/src/helper/deviceInfo.js +9 -37
- package/src/helper/mobileUtil.js +2 -2
- package/src/helper/serialisation/rowData.js +0 -1
- package/src/helper/tools.js +6 -23
- package/src/index.js +2 -1
- package/src/session/sessionConstants.js +4 -0
- package/src/session/sessionInCookie.js +3 -2
- package/src/session/sessionInLocalStorage.js +4 -2
- package/src/session/sessionStore.js +27 -8
- package/src/session/sessionStoreOperations.js +31 -13
- package/src/transport/batch.js +9 -11
- package/src/transport/httpRequest.js +53 -14
- package/types/index.d.ts +72 -58
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clearInterval, setInterval } from '../helper/timer'
|
|
2
2
|
import { Observable } from '../helper/observable'
|
|
3
|
+
import { display } from '../helper/display'
|
|
3
4
|
import { ONE_SECOND, dateNow, throttle, UUID, assign } from '../helper/tools'
|
|
4
5
|
import { selectCookieStrategy, initCookieStrategy } from './sessionInCookie'
|
|
5
6
|
import {
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
selectLocalStorageStrategy
|
|
14
15
|
} from './sessionInLocalStorage'
|
|
15
16
|
import { processSessionStoreOperations } from './sessionStoreOperations'
|
|
17
|
+
import { SessionPersistence } from './sessionConstants'
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* Every second, the storage will be polled to check for any change that can occur
|
|
@@ -26,14 +28,31 @@ export const STORAGE_POLL_DELAY = ONE_SECOND
|
|
|
26
28
|
* Else, checks if LocalStorage is allowed and available
|
|
27
29
|
*/
|
|
28
30
|
export function selectSessionStoreStrategyType(initConfiguration) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
switch (initConfiguration.sessionPersistence) {
|
|
32
|
+
case SessionPersistence.COOKIE:
|
|
33
|
+
return selectCookieStrategy(initConfiguration)
|
|
34
|
+
|
|
35
|
+
case SessionPersistence.LOCAL_STORAGE:
|
|
36
|
+
return selectLocalStorageStrategy()
|
|
37
|
+
|
|
38
|
+
case undefined: {
|
|
39
|
+
let sessionStoreStrategyType = selectCookieStrategy(initConfiguration)
|
|
40
|
+
if (
|
|
41
|
+
!sessionStoreStrategyType &&
|
|
42
|
+
initConfiguration.allowFallbackToLocalStorage
|
|
43
|
+
) {
|
|
44
|
+
sessionStoreStrategyType = selectLocalStorageStrategy()
|
|
45
|
+
}
|
|
46
|
+
return sessionStoreStrategyType
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
default:
|
|
50
|
+
display.error(
|
|
51
|
+
`Invalid session persistence '${String(
|
|
52
|
+
initConfiguration.sessionPersistence
|
|
53
|
+
)}'`
|
|
54
|
+
)
|
|
35
55
|
}
|
|
36
|
-
return sessionStoreStrategyType
|
|
37
56
|
}
|
|
38
57
|
|
|
39
58
|
/**
|
|
@@ -51,7 +70,7 @@ export function startSessionStore(
|
|
|
51
70
|
const expireObservable = new Observable()
|
|
52
71
|
const sessionStateUpdateObservable = new Observable()
|
|
53
72
|
const sessionStoreStrategy =
|
|
54
|
-
sessionStoreStrategyType.type ===
|
|
73
|
+
sessionStoreStrategyType.type === SessionPersistence.COOKIE
|
|
55
74
|
? initCookieStrategy(sessionStoreStrategyType.cookieOptions)
|
|
56
75
|
: initLocalStorageStrategy()
|
|
57
76
|
const { expireSession } = sessionStoreStrategy
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { setTimeout } from '../helper/timer'
|
|
2
|
-
import { UUID, assign } from '../helper/tools'
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
UUID,
|
|
4
|
+
assign,
|
|
5
|
+
ONE_SECOND,
|
|
6
|
+
timeStampNow,
|
|
7
|
+
elapsed
|
|
8
|
+
} from '../helper/tools'
|
|
9
|
+
import { expandSessionState, isSessionInExpiredState } from './sessionState'
|
|
10
|
+
import { addTelemetryDebug } from '../telemetry/telemetry'
|
|
9
11
|
export const LOCK_RETRY_DELAY = 10
|
|
10
12
|
export const LOCK_MAX_TRIES = 100
|
|
13
|
+
|
|
14
|
+
// Locks should be hold for a few milliseconds top, just the time it takes to read and write a
|
|
15
|
+
// cookie. Using one second should be enough in most situations.
|
|
16
|
+
export const LOCK_EXPIRATION_DELAY = ONE_SECOND
|
|
17
|
+
const LOCK_SEPARATOR = '--'
|
|
11
18
|
const bufferedOperations = []
|
|
12
19
|
let ongoingOperations
|
|
13
20
|
|
|
@@ -21,15 +28,11 @@ export function processSessionStoreOperations(
|
|
|
21
28
|
return persistSession(assign({}, session, { lock: currentLock }))
|
|
22
29
|
}
|
|
23
30
|
const retrieveStore = function () {
|
|
24
|
-
const session = sessionStoreStrategy.retrieveSession()
|
|
25
|
-
const lock = session.lock
|
|
26
|
-
if (session.lock) {
|
|
27
|
-
delete session.lock
|
|
28
|
-
}
|
|
31
|
+
const { lock, ...session } = sessionStoreStrategy.retrieveSession()
|
|
29
32
|
|
|
30
33
|
return {
|
|
31
34
|
session,
|
|
32
|
-
lock
|
|
35
|
+
lock: lock && !isLockExpired(lock) ? lock : undefined
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -41,6 +44,9 @@ export function processSessionStoreOperations(
|
|
|
41
44
|
return
|
|
42
45
|
}
|
|
43
46
|
if (isLockEnabled && numberOfRetries >= LOCK_MAX_TRIES) {
|
|
47
|
+
addTelemetryDebug('Aborted session operation after max lock retries', {
|
|
48
|
+
currentStore: retrieveStore()
|
|
49
|
+
})
|
|
44
50
|
next(sessionStoreStrategy)
|
|
45
51
|
return
|
|
46
52
|
}
|
|
@@ -53,7 +59,7 @@ export function processSessionStoreOperations(
|
|
|
53
59
|
return
|
|
54
60
|
}
|
|
55
61
|
// acquire lock
|
|
56
|
-
currentLock =
|
|
62
|
+
currentLock = createLock()
|
|
57
63
|
persistWithLock(currentStore.session)
|
|
58
64
|
// if lock is not acquired, retry later
|
|
59
65
|
currentStore = retrieveStore()
|
|
@@ -120,3 +126,15 @@ function next(sessionStore) {
|
|
|
120
126
|
processSessionStoreOperations(nextOperations, sessionStore)
|
|
121
127
|
}
|
|
122
128
|
}
|
|
129
|
+
|
|
130
|
+
export function createLock() {
|
|
131
|
+
return UUID() + LOCK_SEPARATOR + timeStampNow()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function isLockExpired(lock) {
|
|
135
|
+
const [, timeStamp] = lock.split(LOCK_SEPARATOR)
|
|
136
|
+
return (
|
|
137
|
+
!timeStamp ||
|
|
138
|
+
elapsed(Number(timeStamp), timeStampNow()) > LOCK_EXPIRATION_DELAY
|
|
139
|
+
)
|
|
140
|
+
}
|
package/src/transport/batch.js
CHANGED
|
@@ -39,7 +39,7 @@ export var processedMessageByDataMap = function (message) {
|
|
|
39
39
|
rowData.measurement = key
|
|
40
40
|
var tagsStr = []
|
|
41
41
|
var tags = extend({}, commonTags, value.tags)
|
|
42
|
-
var filterFileds = ['date', 'type', CUSTOM_KEYS]
|
|
42
|
+
var filterFileds = ['date', 'type', CUSTOM_KEYS]
|
|
43
43
|
each(tags, function (value_path, _key) {
|
|
44
44
|
var _value = findByPath(message, value_path)
|
|
45
45
|
filterFileds.push(_key)
|
|
@@ -57,7 +57,7 @@ export var processedMessageByDataMap = function (message) {
|
|
|
57
57
|
var _valueData = findByPath(message, value_path)
|
|
58
58
|
filterFileds.push(_key)
|
|
59
59
|
if (_valueData !== undefined && _valueData !== null) {
|
|
60
|
-
rowData.fields[_key] = escapeJsonValue(_valueData)
|
|
60
|
+
rowData.fields[_key] = escapeJsonValue(_valueData)
|
|
61
61
|
fieldsStr.push(
|
|
62
62
|
escapeRowData(_key) + '=' + escapeRowField(_valueData)
|
|
63
63
|
)
|
|
@@ -66,7 +66,7 @@ export var processedMessageByDataMap = function (message) {
|
|
|
66
66
|
var _valueData = findByPath(message, _value)
|
|
67
67
|
filterFileds.push(_key)
|
|
68
68
|
if (_valueData !== undefined && _valueData !== null) {
|
|
69
|
-
rowData.fields[_key] = escapeJsonValue(_valueData)
|
|
69
|
+
rowData.fields[_key] = escapeJsonValue(_valueData)
|
|
70
70
|
fieldsStr.push(
|
|
71
71
|
escapeRowData(_key) + '=' + escapeRowField(_valueData)
|
|
72
72
|
)
|
|
@@ -78,15 +78,13 @@ export var processedMessageByDataMap = function (message) {
|
|
|
78
78
|
isObject(message.context) &&
|
|
79
79
|
!isEmptyObject(message.context)
|
|
80
80
|
) {
|
|
81
|
-
// 自定义tag, 存储成field
|
|
82
81
|
var _tagKeys = []
|
|
83
82
|
each(message.context, function (_value, _key) {
|
|
84
|
-
// 如果和之前tag重名,则舍弃
|
|
85
83
|
if (filterFileds.indexOf(_key) > -1) return
|
|
86
84
|
filterFileds.push(_key)
|
|
87
85
|
if (_value !== undefined && _value !== null) {
|
|
88
86
|
_tagKeys.push(_key)
|
|
89
|
-
rowData.fields[_key] = escapeJsonValue(_value)
|
|
87
|
+
rowData.fields[_key] = escapeJsonValue(_value)
|
|
90
88
|
fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_value))
|
|
91
89
|
}
|
|
92
90
|
})
|
|
@@ -98,14 +96,13 @@ export var processedMessageByDataMap = function (message) {
|
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
if (message.type === RumEventType.LOGGER) {
|
|
101
|
-
// 这里处理日志类型数据自定义字段
|
|
102
99
|
each(message, function (value, key) {
|
|
103
100
|
if (
|
|
104
101
|
filterFileds.indexOf(key) === -1 &&
|
|
105
102
|
value !== undefined &&
|
|
106
103
|
value !== null
|
|
107
104
|
) {
|
|
108
|
-
rowData.fields[key] = escapeJsonValue(value)
|
|
105
|
+
rowData.fields[key] = escapeJsonValue(value)
|
|
109
106
|
fieldsStr.push(escapeRowData(key) + '=' + escapeRowField(value))
|
|
110
107
|
}
|
|
111
108
|
})
|
|
@@ -119,7 +116,7 @@ export var processedMessageByDataMap = function (message) {
|
|
|
119
116
|
hasFileds = true
|
|
120
117
|
}
|
|
121
118
|
rowStr = rowStr + ' ' + message.date
|
|
122
|
-
rowData.time = message.date
|
|
119
|
+
rowData.time = message.date
|
|
123
120
|
}
|
|
124
121
|
})
|
|
125
122
|
return {
|
|
@@ -231,7 +228,6 @@ export function createBatch(options) {
|
|
|
231
228
|
// it and always send a single request.
|
|
232
229
|
encoder.isAsync
|
|
233
230
|
) {
|
|
234
|
-
// 咱不支持json 模式
|
|
235
231
|
var encoderResult = encoder.finishSync()
|
|
236
232
|
|
|
237
233
|
// Send encoded messages
|
|
@@ -296,6 +292,8 @@ function formatPayloadFromEncoder(encoderResult, sendContentTypeByJson) {
|
|
|
296
292
|
data: data,
|
|
297
293
|
type: sendContentTypeByJson ? 'application/json;UTF-8' : undefined,
|
|
298
294
|
bytesCount: encoderResult.outputBytesCount,
|
|
299
|
-
encoding: encoderResult.encoding
|
|
295
|
+
encoding: encoderResult.encoding,
|
|
296
|
+
outputBase64Head: encoderResult.outputBase64Head,
|
|
297
|
+
outputBase64Tail: encoderResult.outputBase64Tail
|
|
300
298
|
}
|
|
301
299
|
}
|
|
@@ -104,22 +104,33 @@ export function fetchKeepAliveStrategy(
|
|
|
104
104
|
keepalive: true,
|
|
105
105
|
mode: 'cors'
|
|
106
106
|
}
|
|
107
|
+
const headers = {}
|
|
108
|
+
|
|
107
109
|
if (payload.type) {
|
|
108
|
-
|
|
109
|
-
'Content-Type': payload.type
|
|
110
|
-
}
|
|
110
|
+
headers['Content-Type'] = payload.type
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
if (payload.outputBase64Head) {
|
|
113
|
+
headers['x-base64-head'] = payload.outputBase64Head
|
|
114
|
+
}
|
|
115
|
+
if (payload.outputBase64Tail) {
|
|
116
|
+
headers['x-base64-tail'] = payload.outputBase64Tail
|
|
117
|
+
}
|
|
118
|
+
if (Object.keys(headers).length) {
|
|
119
|
+
fetchOption.headers = headers
|
|
120
|
+
}
|
|
121
|
+
fetch(url, fetchOption)
|
|
122
|
+
.then(
|
|
123
|
+
monitor(function (response) {
|
|
124
|
+
if (typeof onResponse === 'function') {
|
|
125
|
+
onResponse({ status: response.status, type: response.type })
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
)
|
|
129
|
+
.catch(
|
|
130
|
+
monitor(function () {
|
|
131
|
+
fetchStrategy(url, payload, onResponse)
|
|
132
|
+
})
|
|
133
|
+
)
|
|
123
134
|
} else {
|
|
124
135
|
sendXHR(url, payload, onResponse)
|
|
125
136
|
}
|
|
@@ -158,3 +169,31 @@ function sendXHR(url, payload, onResponse) {
|
|
|
158
169
|
)
|
|
159
170
|
request.send(data)
|
|
160
171
|
}
|
|
172
|
+
function fetchStrategy(url, payload, onResponse) {
|
|
173
|
+
const fetchOption = {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
body: payload.data,
|
|
176
|
+
keepalive: true,
|
|
177
|
+
mode: 'cors'
|
|
178
|
+
}
|
|
179
|
+
if (payload.type) {
|
|
180
|
+
fetchOption.headers = {
|
|
181
|
+
'Content-Type': payload.type
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
fetch(url, fetchOption)
|
|
185
|
+
.then(
|
|
186
|
+
monitor(function (response) {
|
|
187
|
+
if (typeof onResponse === 'function') {
|
|
188
|
+
onResponse({ status: response.status, type: response.type })
|
|
189
|
+
}
|
|
190
|
+
})
|
|
191
|
+
)
|
|
192
|
+
.catch(
|
|
193
|
+
monitor(function () {
|
|
194
|
+
if (typeof onResponse === 'function') {
|
|
195
|
+
onResponse({ status: 0 })
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
)
|
|
199
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface User {
|
|
|
7
7
|
name?: string | undefined
|
|
8
8
|
[key: string]: unknown
|
|
9
9
|
}
|
|
10
|
+
export type SessionPersistence = 'cookie' | 'local-storage'
|
|
11
|
+
|
|
10
12
|
export declare const ConsoleApiName: {
|
|
11
13
|
readonly log: 'log'
|
|
12
14
|
readonly debug: 'debug'
|
|
@@ -25,72 +27,79 @@ export type RawReportType = (typeof RawReportType)[keyof typeof RawReportType]
|
|
|
25
27
|
|
|
26
28
|
export interface SiteInitConfiguration {
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
30
|
+
* Data reporting token in openway mode, obtained from the TrueWatch Cloud console. Required.
|
|
29
31
|
*/
|
|
30
32
|
clientToken: string | undefined
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
|
-
*
|
|
35
|
+
* Data reporting address in public openway mode, obtained from the TrueWatch Cloud console. Required.
|
|
34
36
|
*/
|
|
35
37
|
site: string | undefined
|
|
36
38
|
}
|
|
37
39
|
export interface DatakitInitConfiguration {
|
|
38
|
-
/** DataKit
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* https://www.datakit.com
|
|
42
|
-
* http://100.20.34.3:8088
|
|
40
|
+
/** DataKit data reporting Origin:
|
|
41
|
+
* Protocol (including ://), domain name (or IP address) [and port number]
|
|
42
|
+
* For example:
|
|
43
|
+
* https://www.datakit.com;
|
|
44
|
+
* http://100.20.34.3:8088.
|
|
43
45
|
*/
|
|
44
46
|
datakitOrigin: string
|
|
45
47
|
}
|
|
46
48
|
export interface InitConfiguration {
|
|
47
49
|
/**
|
|
48
|
-
*
|
|
49
|
-
* @param event
|
|
50
|
-
* @param context
|
|
50
|
+
* Interceptor before sending data
|
|
51
|
+
* @param event Event content
|
|
52
|
+
* @param context Additional event properties
|
|
51
53
|
* @returns
|
|
52
54
|
*/
|
|
53
55
|
beforeSend?: (event: any, context?: any) => unknown | undefined
|
|
54
56
|
/**
|
|
55
|
-
*
|
|
57
|
+
* Data reporting sample rate, 100 means collect all; 0 means do not collect. Default is 100
|
|
56
58
|
*/
|
|
57
59
|
sessionSampleRate?: number | undefined
|
|
58
60
|
telemetrySampleRate?: number | undefined
|
|
59
61
|
silentMultipleInit?: boolean | undefined
|
|
60
62
|
|
|
61
63
|
service?: string | undefined
|
|
62
|
-
/**
|
|
64
|
+
/** Current environment of the web application, such as prod: production; gray: gray environment; pre: pre-release; common: daily; local: local environment. */
|
|
63
65
|
env?: string | undefined
|
|
64
|
-
/**
|
|
66
|
+
/** Version number of the web application. */
|
|
65
67
|
version?: string | undefined
|
|
66
|
-
/**
|
|
68
|
+
/** Trace data sampling percentage: 100 means collect all; 0 means do not collect. */
|
|
67
69
|
tracingSampleRate?: number | undefined
|
|
68
70
|
/**
|
|
69
71
|
* @deprecated use usePartitionedCrossSiteSessionCookie instead
|
|
70
72
|
*/
|
|
71
73
|
useCrossSiteSessionCookie?: boolean | undefined
|
|
72
74
|
/**
|
|
73
|
-
*
|
|
75
|
+
* Whether to use cross-site cookies, enabling third-party cookie partitioning. By default, cross-site is not allowed, such as nested cross-domain iframes.
|
|
74
76
|
*/
|
|
75
77
|
usePartitionedCrossSiteSessionCookie?: boolean | undefined
|
|
76
78
|
useSecureSessionCookie?: boolean | undefined
|
|
77
79
|
trackSessionAcrossSubdomains?: boolean | undefined
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* Whether to store public data in localStorage, default is not to store
|
|
80
82
|
*/
|
|
81
83
|
storeContextsToLocal?: boolean | undefined
|
|
82
84
|
/**
|
|
83
|
-
*
|
|
85
|
+
* Define the key for storing in localStorage. If not filled, it is automatically generated. This parameter is mainly to distinguish the problem of sharing store under different subpaths of the same domain.
|
|
84
86
|
*/
|
|
85
87
|
storeContextsKey?: string | undefined
|
|
86
88
|
/**
|
|
87
|
-
*
|
|
89
|
+
* Send data as application/json, default is text
|
|
88
90
|
*/
|
|
89
91
|
sendContentTypeByJson?: boolean | undefined
|
|
90
92
|
/**
|
|
91
|
-
*
|
|
93
|
+
* When cookies are not available, you can enable this option to store data in localStorage
|
|
92
94
|
*/
|
|
93
95
|
allowFallbackToLocalStorage?: boolean | undefined
|
|
96
|
+
/**
|
|
97
|
+
* Which storage strategy to use for persisting sessions. Can be either 'cookie' or 'local-storage'.
|
|
98
|
+
*
|
|
99
|
+
* Important: If you are using the RUM and Logs Browser SDKs, this option must be configured with identical values
|
|
100
|
+
* @default "cookie"
|
|
101
|
+
*/
|
|
102
|
+
sessionPersistence?: SessionPersistence | undefined
|
|
94
103
|
}
|
|
95
104
|
export enum TraceType {
|
|
96
105
|
DDTRACE = 'ddtrace',
|
|
@@ -118,7 +127,7 @@ export const NodePrivacyLevel = {
|
|
|
118
127
|
} as const
|
|
119
128
|
export type NodePrivacyLevel =
|
|
120
129
|
(typeof NodePrivacyLevel)[keyof typeof NodePrivacyLevel]
|
|
121
|
-
|
|
130
|
+
export type OriginMatchOption = string | RegExp
|
|
122
131
|
export type MatchOption = string | RegExp | ((value: string) => boolean)
|
|
123
132
|
export type TracingOption = {
|
|
124
133
|
match: MatchOption
|
|
@@ -138,93 +147,98 @@ export declare function matchList(
|
|
|
138
147
|
): boolean
|
|
139
148
|
|
|
140
149
|
export interface RumBaseInitConfiguration extends InitConfiguration {
|
|
141
|
-
|
|
150
|
+
/** Application ID created from TrueWatch Cloud */
|
|
142
151
|
applicationId: string
|
|
143
152
|
/**
|
|
144
|
-
*
|
|
145
|
-
* https://docs.
|
|
153
|
+
* Exclude some URLs that affect the accuracy of loadingtime indicators. See the following documentation for details:
|
|
154
|
+
* https://docs.truewatch.com/security/page-performance/#_3
|
|
146
155
|
*/
|
|
147
156
|
excludedActivityUrls?: MatchOption[] | undefined
|
|
148
157
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
158
|
+
* List of all requests allowed to inject trace collector required headers. For example:
|
|
159
|
+
["https://api.example.com/test", /https:\\/\\/.*\\.my-api-domain\\.com/, (url) => { return true }].
|
|
160
|
+
*/
|
|
152
161
|
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined
|
|
162
|
+
/**
|
|
163
|
+
* List of all requests allowed to inject trace collector required headers. Can be the request origin or a regex. Origin: protocol (including ://), domain name (or IP address) [and port number]. For example:
|
|
164
|
+
["https://api.example.com", /https:\\/\\/.*\\.my-api-domain\\.com/].
|
|
165
|
+
*/
|
|
166
|
+
allowedTracingOrigins?: Array<OriginMatchOption> | undefined
|
|
153
167
|
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined
|
|
154
168
|
/**
|
|
155
|
-
*
|
|
156
|
-
* -
|
|
157
|
-
*
|
|
158
|
-
* -
|
|
169
|
+
* Error session compensation sample rate:
|
|
170
|
+
* - When the session is not sampled by `sessionSampleRate`, if an error occurs during the session, it will be collected according to this ratio.
|
|
171
|
+
* Such sessions will start recording events when an error occurs and continue until the session ends.
|
|
172
|
+
* - Value range 0-100, 100 means collect all error sessions, 0 means ignore error sessions
|
|
159
173
|
*/
|
|
160
174
|
sessionOnErrorSampleRate?: number | undefined
|
|
161
175
|
|
|
162
176
|
/**
|
|
163
|
-
* Session Replay
|
|
164
|
-
* -
|
|
165
|
-
* -
|
|
177
|
+
* Session Replay full collection sample rate:
|
|
178
|
+
* - Used to control the proportion of full data collection for all session replays
|
|
179
|
+
* - Value range 0-100, 100 means full collection, 0 means no collection
|
|
166
180
|
**/
|
|
167
181
|
sessionReplaySampleRate?: number | undefined
|
|
168
182
|
|
|
169
|
-
/**
|
|
170
|
-
* -
|
|
171
|
-
*
|
|
172
|
-
100
|
|
173
|
-
|
|
183
|
+
/** Error session replay compensation sample rate:
|
|
184
|
+
* - When the session is not sampled by `sessionReplaySampleRate`, if an error occurs during the session, it will be collected according to this ratio.
|
|
185
|
+
* Such replays will record up to one minute of events before the error occurs and continue recording until the session ends.
|
|
186
|
+
* 100 means collect all; 0 means do not collect.
|
|
187
|
+
*/
|
|
174
188
|
sessionReplayOnErrorSampleRate?: number | undefined
|
|
175
189
|
/**
|
|
176
|
-
*
|
|
190
|
+
* Whether to enable user interaction collection.
|
|
177
191
|
*/
|
|
178
192
|
trackUserInteractions?: boolean | undefined
|
|
179
193
|
/**
|
|
180
|
-
*
|
|
194
|
+
* Specify how to get the action data name. By default, it is obtained automatically. You can specify the element's specific attribute name, such as alt, name, title, aria-labelledby, aria-label, data-truewatch-action-name, etc.
|
|
181
195
|
*/
|
|
182
196
|
actionNameAttribute?: string | undefined
|
|
183
197
|
trackViewsManually?: boolean | undefined
|
|
184
198
|
/**
|
|
185
|
-
* sessionReplay
|
|
199
|
+
* sessionReplay and compressIntakeRequests data compression are both done in the web worker thread, so by default, you need to allow worker-src blob: under CSP security access, or use workerUrl to host the worker address yourself
|
|
186
200
|
*/
|
|
187
201
|
workerUrl?: string
|
|
188
202
|
/**
|
|
189
|
-
*
|
|
203
|
+
* Compress RUM data request content to reduce bandwidth usage when sending large amounts of data. Compression is done in the Worker thread.
|
|
190
204
|
*/
|
|
191
205
|
compressIntakeRequests?: boolean | undefined
|
|
192
206
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
207
|
+
* Whether to enable remote configuration for data collection. Disabled by default.
|
|
208
|
+
* The remote configuration feature allows you to dynamically modify data collection configuration items without releasing a new version.
|
|
209
|
+
* For example: you can modify the sampling rate, whether to enable user interaction collection, etc. in the remote configuration.
|
|
210
|
+
* The remote configuration feature needs to be enabled in the TrueWatch Cloud console.
|
|
197
211
|
*
|
|
198
212
|
*/
|
|
199
213
|
remoteConfiguration?: boolean | undefined
|
|
200
214
|
/**
|
|
201
|
-
*
|
|
215
|
+
* Configure the type of trace tool. If not configured, ddtrace is used by default. Currently supports 6 types: ddtrace, zipkin, skywalking_v3, jaeger, zipkin_single_header, w3c_traceparent.
|
|
202
216
|
*/
|
|
203
217
|
traceType?: TraceType
|
|
204
218
|
/**
|
|
205
|
-
*
|
|
219
|
+
* Whether to generate traceID in 128-bit mode, corresponding to traceType. Currently supported types: zipkin, jaeger.
|
|
206
220
|
*/
|
|
207
221
|
traceId128Bit?: boolean | undefined
|
|
208
222
|
/**
|
|
209
|
-
* Fetch/Xhr
|
|
210
|
-
* @param context
|
|
211
|
-
* @returns
|
|
223
|
+
* After Fetch/Xhr interception, add extra header-keys to the request header, affected by allowedTracingUrls
|
|
224
|
+
* @param context Additional information attached to the request, including traceid, spanid, url, etc.
|
|
225
|
+
* @returns Returns a key: value object, the extra keys to be added to the request
|
|
212
226
|
*/
|
|
213
227
|
injectTraceHeader?: (content: any) => { [key: string]: string } | undefined
|
|
214
228
|
/**
|
|
215
|
-
* traceId
|
|
216
|
-
* @returns
|
|
229
|
+
* traceId generator, overrides the SDK's internal traceId implementation. Default is not configured.
|
|
230
|
+
* @returns Returns the traceId corresponding to the traceType type.
|
|
217
231
|
*/
|
|
218
232
|
generateTraceId?: () => string
|
|
219
233
|
/**
|
|
220
|
-
*
|
|
234
|
+
* Whether to enable longAnimationFrame collection, overriding longtask collection. Currently in debugging stage.
|
|
221
235
|
*/
|
|
222
236
|
enableLongAnimationFrame?: boolean | undefined
|
|
223
237
|
/**
|
|
224
|
-
* session replay
|
|
225
|
-
* @param node
|
|
226
|
-
* @param privacyLevel
|
|
227
|
-
* @returns true
|
|
238
|
+
* Whether to mask a node's data in session replay, can be used to implement masking for specific nodes
|
|
239
|
+
* @param node Node object
|
|
240
|
+
* @param privacyLevel Current privacy level
|
|
241
|
+
* @returns true means mask the node, false means do not mask and continue privacyLevel logic
|
|
228
242
|
*/
|
|
229
243
|
shouldMaskNode?: (node: Node, privacyLevel: NodePrivacyLevel) => boolean
|
|
230
244
|
}
|