@cloudcare/browser-core 3.2.19 → 3.2.24
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/addEventListener.js +4 -2
- package/cjs/browser/addEventListener.js.map +1 -1
- package/cjs/browser/asyncClocks.js +68 -0
- package/cjs/browser/asyncClocks.js.map +1 -0
- package/cjs/browser/pageExitObservable.js +1 -2
- package/cjs/browser/pageExitObservable.js.map +1 -1
- package/cjs/configuration/configuration.js +1 -2
- package/cjs/configuration/configuration.js.map +1 -1
- package/cjs/configuration/remoteConfiguration.js +214 -0
- package/cjs/configuration/remoteConfiguration.js.map +1 -0
- package/cjs/configuration/transportConfiguration.js +1 -0
- package/cjs/configuration/transportConfiguration.js.map +1 -1
- package/cjs/dataMap.js +4 -7
- package/cjs/dataMap.js.map +1 -1
- package/cjs/helper/byteUtils.js +2 -4
- package/cjs/helper/byteUtils.js.map +1 -1
- package/cjs/helper/createEventRateLimiter.js.map +1 -1
- package/cjs/helper/deviceInfo.js +11 -7
- package/cjs/helper/deviceInfo.js.map +1 -1
- package/cjs/helper/display.js +4 -8
- package/cjs/helper/display.js.map +1 -1
- package/cjs/helper/encoder.js.map +1 -1
- package/cjs/helper/enums.js +11 -22
- package/cjs/helper/enums.js.map +1 -1
- package/cjs/helper/errorTools.js +2 -4
- package/cjs/helper/errorTools.js.map +1 -1
- package/cjs/helper/eventEmitter.js +1 -2
- package/cjs/helper/eventEmitter.js.map +1 -1
- package/cjs/helper/getZoneJsOriginalValue.js +2 -1
- package/cjs/helper/getZoneJsOriginalValue.js.map +1 -1
- package/cjs/helper/instrumentMethod.js.map +1 -1
- package/cjs/helper/lifeCycle.js +1 -2
- package/cjs/helper/lifeCycle.js.map +1 -1
- package/cjs/helper/limitModification.js +7 -7
- package/cjs/helper/limitModification.js.map +1 -1
- package/cjs/helper/mobileUtil.js +5 -10
- package/cjs/helper/mobileUtil.js.map +1 -1
- package/cjs/helper/observable.js +1 -2
- package/cjs/helper/observable.js.map +1 -1
- package/cjs/helper/requestIdleCallback.js +1 -2
- package/cjs/helper/requestIdleCallback.js.map +1 -1
- package/cjs/helper/sanitize.js +1 -1
- package/cjs/helper/sanitize.js.map +1 -1
- package/cjs/helper/serialisation/const.js +1 -2
- package/cjs/helper/serialisation/const.js.map +1 -1
- package/cjs/helper/serialisation/contextManager.js +15 -15
- package/cjs/helper/serialisation/contextManager.js.map +1 -1
- package/cjs/helper/serialisation/customerDataTracker.js +4 -8
- package/cjs/helper/serialisation/customerDataTracker.js.map +1 -1
- package/cjs/helper/serialisation/jsonStringify.js +1 -1
- package/cjs/helper/serialisation/jsonStringify.js.map +1 -1
- package/cjs/helper/serialisation/rowData.js +1 -1
- package/cjs/helper/serialisation/rowData.js.map +1 -1
- package/cjs/helper/taskQueue.js +1 -2
- package/cjs/helper/taskQueue.js.map +1 -1
- package/cjs/helper/tools.js +74 -145
- package/cjs/helper/tools.js.map +1 -1
- package/cjs/helper/valueHistory.js +20 -8
- package/cjs/helper/valueHistory.js.map +1 -1
- package/cjs/index.js +12 -0
- package/cjs/index.js.map +1 -1
- package/cjs/init.js +1 -1
- package/cjs/init.js.map +1 -1
- package/cjs/report/reportObservable.js +1 -2
- package/cjs/report/reportObservable.js.map +1 -1
- package/cjs/session/sessionConstants.js +3 -6
- package/cjs/session/sessionConstants.js.map +1 -1
- package/cjs/session/sessionInCookie.js.map +1 -1
- package/cjs/session/sessionManagement.js +1 -2
- package/cjs/session/sessionManagement.js.map +1 -1
- package/cjs/session/sessionState.js +6 -7
- package/cjs/session/sessionState.js.map +1 -1
- package/cjs/session/sessionStore.js +2 -3
- package/cjs/session/sessionStore.js.map +1 -1
- package/cjs/session/sessionStoreOperations.js +6 -8
- package/cjs/session/sessionStoreOperations.js.map +1 -1
- package/cjs/synthetics/syntheticsWorkerValues.js +3 -6
- package/cjs/synthetics/syntheticsWorkerValues.js.map +1 -1
- package/cjs/telemetry/telemetry.js +1 -2
- package/cjs/telemetry/telemetry.js.map +1 -1
- package/cjs/telemetry/types.js +2 -4
- package/cjs/telemetry/types.js.map +1 -1
- package/cjs/tracekit/computeStackTrace.js +2 -4
- package/cjs/tracekit/computeStackTrace.js.map +1 -1
- package/cjs/tracekit/tracekit.js.map +1 -1
- package/cjs/transport/batch.js +1 -3
- package/cjs/transport/batch.js.map +1 -1
- package/cjs/transport/eventBridge.js +36 -3
- package/cjs/transport/eventBridge.js.map +1 -1
- package/cjs/transport/flushController.js.map +1 -1
- package/cjs/transport/httpRequest.js.map +1 -1
- package/cjs/transport/index.js +12 -0
- package/cjs/transport/index.js.map +1 -1
- package/cjs/transport/sendWithRetryStrategy.js +5 -10
- package/cjs/transport/sendWithRetryStrategy.js.map +1 -1
- package/cjs/transport/startBatchWithReplica.js.map +1 -1
- package/esm/browser/addEventListener.js +4 -2
- package/esm/browser/addEventListener.js.map +1 -1
- package/esm/browser/asyncClocks.js +60 -0
- package/esm/browser/asyncClocks.js.map +1 -0
- package/esm/configuration/remoteConfiguration.js +205 -0
- package/esm/configuration/remoteConfiguration.js.map +1 -0
- package/esm/configuration/transportConfiguration.js +1 -1
- package/esm/configuration/transportConfiguration.js.map +1 -1
- package/esm/dataMap.js +1 -1
- package/esm/dataMap.js.map +1 -1
- package/esm/helper/createEventRateLimiter.js.map +1 -1
- package/esm/helper/deviceInfo.js +10 -5
- package/esm/helper/deviceInfo.js.map +1 -1
- package/esm/helper/encoder.js.map +1 -1
- package/esm/helper/eventEmitter.js.map +1 -1
- package/esm/helper/getZoneJsOriginalValue.js +2 -1
- package/esm/helper/getZoneJsOriginalValue.js.map +1 -1
- package/esm/helper/instrumentMethod.js.map +1 -1
- package/esm/helper/lifeCycle.js.map +1 -1
- package/esm/helper/limitModification.js +7 -7
- package/esm/helper/mobileUtil.js.map +1 -1
- package/esm/helper/observable.js.map +1 -1
- package/esm/helper/requestIdleCallback.js.map +1 -1
- package/esm/helper/sanitize.js +1 -1
- package/esm/helper/serialisation/contextManager.js +15 -15
- package/esm/helper/serialisation/contextManager.js.map +1 -1
- package/esm/helper/serialisation/customerDataTracker.js.map +1 -1
- package/esm/helper/serialisation/jsonStringify.js +1 -1
- package/esm/helper/serialisation/rowData.js +1 -1
- package/esm/helper/taskQueue.js.map +1 -1
- package/esm/helper/tools.js +10 -8
- package/esm/helper/tools.js.map +1 -1
- package/esm/helper/valueHistory.js +19 -6
- package/esm/helper/valueHistory.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/init.js +1 -1
- package/esm/init.js.map +1 -1
- package/esm/session/sessionInCookie.js.map +1 -1
- package/esm/session/sessionManagement.js.map +1 -1
- package/esm/session/sessionState.js +5 -5
- package/esm/session/sessionStore.js +1 -1
- package/esm/session/sessionStore.js.map +1 -1
- package/esm/session/sessionStoreOperations.js +4 -4
- package/esm/session/sessionStoreOperations.js.map +1 -1
- package/esm/telemetry/telemetry.js.map +1 -1
- package/esm/tracekit/computeStackTrace.js +2 -4
- package/esm/tracekit/computeStackTrace.js.map +1 -1
- package/esm/tracekit/tracekit.js.map +1 -1
- package/esm/transport/batch.js +0 -1
- package/esm/transport/batch.js.map +1 -1
- package/esm/transport/eventBridge.js +34 -3
- package/esm/transport/eventBridge.js.map +1 -1
- package/esm/transport/flushController.js.map +1 -1
- package/esm/transport/httpRequest.js.map +1 -1
- package/esm/transport/index.js +1 -1
- package/esm/transport/index.js.map +1 -1
- package/esm/transport/sendWithRetryStrategy.js.map +1 -1
- package/esm/transport/startBatchWithReplica.js.map +1 -1
- package/package.json +24 -24
- package/src/browser/addEventListener.js +7 -2
- package/src/browser/asyncClocks.js +69 -0
- package/src/configuration/remoteConfiguration.js +213 -0
- package/src/configuration/transportConfiguration.js +1 -1
- package/src/dataMap.js +1 -0
- package/src/helper/deviceInfo.js +6 -1
- package/src/helper/getZoneJsOriginalValue.js +2 -1
- package/src/helper/valueHistory.js +18 -6
- package/src/index.js +1 -0
- package/src/session/sessionStore.js +1 -1
- package/src/session/sessionStoreOperations.js +4 -16
- package/src/tracekit/computeStackTrace.js +2 -1
- package/src/transport/eventBridge.js +56 -4
- package/src/transport/index.js +6 -1
- package/types/index.d.ts +8 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { addEventListener } from '../browser/addEventListener'
|
|
2
|
+
import { display } from '../helper/display'
|
|
3
|
+
import { trim } from './transportConfiguration'
|
|
4
|
+
import { objectEntries, getType } from '../helper/tools'
|
|
5
|
+
export function fetchAndApplyRemoteConfiguration(initConfiguration, callback) {
|
|
6
|
+
fetchRemoteConfiguration(initConfiguration, (remoteInitConfiguration) => {
|
|
7
|
+
callback(
|
|
8
|
+
applyRemoteConfiguration(initConfiguration, remoteInitConfiguration)
|
|
9
|
+
)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 数据上报采样率,100 表示全收集;0 表示不收集。默认 100
|
|
14
|
+
*/
|
|
15
|
+
// sessionSampleRate?: number | undefined
|
|
16
|
+
// telemetrySampleRate?: number | undefined
|
|
17
|
+
// silentMultipleInit?: boolean | undefined
|
|
18
|
+
|
|
19
|
+
// service?: string | undefined
|
|
20
|
+
// /** Web 应用当前环境,如 prod:线上环境;gray:灰度环境;pre:预发布环境;common:日常环境;local:本地环境。 */
|
|
21
|
+
// env?: string | undefined
|
|
22
|
+
// /** Web 应用的版本号。 */
|
|
23
|
+
// version?: string | undefined
|
|
24
|
+
// /** 链路数据采样百分比:100 表示全收集;0 表示不收集。 */
|
|
25
|
+
// tracingSampleRate?: number | undefined
|
|
26
|
+
// /**
|
|
27
|
+
// * @deprecated use usePartitionedCrossSiteSessionCookie instead
|
|
28
|
+
// */
|
|
29
|
+
// useCrossSiteSessionCookie?: boolean | undefined
|
|
30
|
+
// /**
|
|
31
|
+
// * 是否使用跨域 cookie,开启第三方 cookie 跨分区实现。默认不允许跨域,例如嵌套跨域 iframe 的情况。
|
|
32
|
+
// */
|
|
33
|
+
// usePartitionedCrossSiteSessionCookie?: boolean | undefined
|
|
34
|
+
// useSecureSessionCookie?: boolean | undefined
|
|
35
|
+
// trackSessionAcrossSubdomains?: boolean | undefined
|
|
36
|
+
// /**
|
|
37
|
+
// * 是否把公共数据存储到localstorage,默认不存储
|
|
38
|
+
// */
|
|
39
|
+
// storeContextsToLocal?: boolean | undefined
|
|
40
|
+
// /**
|
|
41
|
+
// * 定义存储到 localstorage 的 key ,默认不填,自动生成, 该参数主要是为了区分在同一个域名下,不同子路径共用store 的问题
|
|
42
|
+
// */
|
|
43
|
+
// storeContextsKey?: string | undefined
|
|
44
|
+
// /**
|
|
45
|
+
// * 数据以 application/json 的发送方式,默认text
|
|
46
|
+
// */
|
|
47
|
+
// sendContentTypeByJson?: boolean | undefined
|
|
48
|
+
// /**
|
|
49
|
+
// * 在 cookie 不可用的情况下,可以开启该选项,把数据储存到 localstorage
|
|
50
|
+
// */
|
|
51
|
+
// allowFallbackToLocalStorage ?: boolean | undefined
|
|
52
|
+
// /**
|
|
53
|
+
// * 错误会话补偿采样率:
|
|
54
|
+
// * - 当会话未被 `sessionSampleRate` 采样时,若会话期间发生错误,则按此比例采集
|
|
55
|
+
// * 此类会话将在错误发生时开始记录事件,并持续记录直到会话结束。
|
|
56
|
+
// * - 取值范围 0-100,100 表示全采错误会话,0 表示忽略错误会话
|
|
57
|
+
// */
|
|
58
|
+
// sessionOnErrorSampleRate?: number | undefined
|
|
59
|
+
|
|
60
|
+
// /**
|
|
61
|
+
// * Session Replay 全量采集采样率:
|
|
62
|
+
// * - 用于控制所有会话重放的全量数据采集比例
|
|
63
|
+
// * - 取值范围 0-100,100 表示全量采集,0 表示不采集
|
|
64
|
+
// **/
|
|
65
|
+
// sessionReplaySampleRate?: number | undefined
|
|
66
|
+
|
|
67
|
+
// /** 错误会话重放补偿采样率:
|
|
68
|
+
// * - 当会话未被 `sessionReplaySampleRate` 采样时,若会话期间发生错误,则按此比例采集
|
|
69
|
+
// * 此类回放将记录错误发生前最多一分钟的事件,并持续记录直到会话结束。
|
|
70
|
+
// 100 表示全收集;0 表示不收集。
|
|
71
|
+
// */
|
|
72
|
+
// sessionReplayOnErrorSampleRate?: number | undefined
|
|
73
|
+
// /**
|
|
74
|
+
// * 是否开启用户行为采集。
|
|
75
|
+
// */
|
|
76
|
+
// trackUserInteractions?: boolean | undefined
|
|
77
|
+
// /**
|
|
78
|
+
// * 指定 action 数据 name 获取方式,默认自动获取,可以指定元素特定属性名称,alt,name,title,aria-labelledby,aria-label,data-guance-action-name 这些属性
|
|
79
|
+
// */
|
|
80
|
+
// actionNameAttribute?: string | undefined
|
|
81
|
+
// trackViewsManually?: boolean | undefined
|
|
82
|
+
// /**
|
|
83
|
+
// * sessionReplay 和 compressIntakeRequests数据压缩都是在 webwork 线程中完成,所以默认情况下,需要在开启csp 安全访问的情况下,允许 worker-src blob:; workerUrl 配置允许自行托管 worker 地址
|
|
84
|
+
// */
|
|
85
|
+
// workerUrl?: string
|
|
86
|
+
// /**
|
|
87
|
+
// * 压缩 RUM 数据请求内容,以减少发送大量数据时的带宽使用量。压缩在 Worker 线程中完成。
|
|
88
|
+
// */
|
|
89
|
+
// compressIntakeRequests ?: boolean | undefined
|
|
90
|
+
// /**
|
|
91
|
+
// * 配置链路追踪工具类型,如果不配置默认为 ddtrace。目前支持 ddtrace、zipkin、skywalking_v3、jaeger、zipkin_single_header、w3c_traceparent 6 种数据类型。
|
|
92
|
+
// */
|
|
93
|
+
// traceType?: TraceType
|
|
94
|
+
|
|
95
|
+
const modifiableFieldPaths = {
|
|
96
|
+
sessionSampleRate: 'number',
|
|
97
|
+
telemetrySampleRate: 'number',
|
|
98
|
+
silentMultipleInit: 'boolean',
|
|
99
|
+
service: 'string',
|
|
100
|
+
env: 'string',
|
|
101
|
+
version: 'string',
|
|
102
|
+
tracingSampleRate: 'number',
|
|
103
|
+
useCrossSiteSessionCookie: 'boolean',
|
|
104
|
+
usePartitionedCrossSiteSessionCookie: 'boolean',
|
|
105
|
+
useSecureSessionCookie: 'boolean',
|
|
106
|
+
trackSessionAcrossSubdomains: 'boolean',
|
|
107
|
+
storeContextsToLocal: 'boolean',
|
|
108
|
+
storeContextsKey: 'string',
|
|
109
|
+
sendContentTypeByJson: 'boolean',
|
|
110
|
+
allowFallbackToLocalStorage: 'boolean',
|
|
111
|
+
sessionOnErrorSampleRate: 'number',
|
|
112
|
+
sessionReplaySampleRate: 'number',
|
|
113
|
+
sessionReplayOnErrorSampleRate: 'number',
|
|
114
|
+
trackUserInteractions: 'boolean',
|
|
115
|
+
trackInteractions: 'boolean',
|
|
116
|
+
actionNameAttribute: 'string',
|
|
117
|
+
trackViewsManually: 'boolean',
|
|
118
|
+
workerUrl: 'string',
|
|
119
|
+
compressIntakeRequests: 'boolean',
|
|
120
|
+
traceType: 'string'
|
|
121
|
+
}
|
|
122
|
+
function modificationByFieldsPath(remoteConfiguration, modifiableFieldPaths) {
|
|
123
|
+
const result = {}
|
|
124
|
+
objectEntries(modifiableFieldPaths).forEach(([fieldPath, fieldType]) => {
|
|
125
|
+
// const sourceValue = sourceConfiguration[fieldPath]
|
|
126
|
+
const remoteValue = remoteConfiguration[fieldPath]
|
|
127
|
+
if (getType(remoteValue) === fieldType) {
|
|
128
|
+
result[fieldPath] = remoteValue
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
return result
|
|
132
|
+
}
|
|
133
|
+
export function applyRemoteConfiguration(
|
|
134
|
+
initConfiguration,
|
|
135
|
+
remoteInitConfiguration
|
|
136
|
+
) {
|
|
137
|
+
const simpleRemoteInitConfiguration = {}
|
|
138
|
+
for (const key in remoteInitConfiguration) {
|
|
139
|
+
if (remoteInitConfiguration[key] !== undefined) {
|
|
140
|
+
// ex
|
|
141
|
+
// {
|
|
142
|
+
// "R.d1b454d0_22eb_11ef_9b66_95ca11aa2c6c.sessionSampleRate": 80
|
|
143
|
+
// }
|
|
144
|
+
// transform to
|
|
145
|
+
// {
|
|
146
|
+
// "sessionSampleRate": 80
|
|
147
|
+
// }
|
|
148
|
+
const simpleKey = key.replace(
|
|
149
|
+
'R.' + initConfiguration.applicationId + '.',
|
|
150
|
+
''
|
|
151
|
+
)
|
|
152
|
+
simpleRemoteInitConfiguration[simpleKey] = remoteInitConfiguration[key]
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
...initConfiguration,
|
|
157
|
+
...modificationByFieldsPath(
|
|
158
|
+
simpleRemoteInitConfiguration,
|
|
159
|
+
modifiableFieldPaths
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function fetchRemoteConfiguration(configuration, callback) {
|
|
165
|
+
const xhr = new XMLHttpRequest()
|
|
166
|
+
|
|
167
|
+
addEventListener(xhr, 'load', function () {
|
|
168
|
+
if (xhr.status === 200) {
|
|
169
|
+
const remoteConfiguration = JSON.parse(xhr.responseText)
|
|
170
|
+
callback(remoteConfiguration.content)
|
|
171
|
+
} else {
|
|
172
|
+
callback({})
|
|
173
|
+
displayRemoteConfigurationFetchingError()
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
addEventListener(xhr, 'error', function () {
|
|
178
|
+
callback({})
|
|
179
|
+
displayRemoteConfigurationFetchingError()
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
xhr.open('GET', buildEndpoint(configuration))
|
|
183
|
+
xhr.send()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function buildEndpoint(configuration) {
|
|
187
|
+
var url =
|
|
188
|
+
configuration.datakitOrigin ||
|
|
189
|
+
configuration.datakitUrl ||
|
|
190
|
+
configuration.site
|
|
191
|
+
if (url.indexOf('/') === 0) {
|
|
192
|
+
// 绝对路径这种 /xxx
|
|
193
|
+
url = location.origin + trim(url)
|
|
194
|
+
}
|
|
195
|
+
var endpoint = url
|
|
196
|
+
if (url.lastIndexOf('/') === url.length - 1) {
|
|
197
|
+
endpoint = trim(url) + 'v1/env_variable'
|
|
198
|
+
} else {
|
|
199
|
+
endpoint = trim(url) + '/v1/env_variable'
|
|
200
|
+
}
|
|
201
|
+
// 这里需要加上token和app_id
|
|
202
|
+
endpoint += '?app_id=' + configuration.applicationId
|
|
203
|
+
//testing-openway.dataflux.cn/v1/env_variable?token=a47fb0cdddaa4561a90d941317cdbc0b&app_id=d1b454d0_22eb_11ef_9b66_95ca11aa2c6c&to_headless=true
|
|
204
|
+
if (configuration.site && configuration.clientToken) {
|
|
205
|
+
endpoint =
|
|
206
|
+
endpoint + '&token=' + configuration.clientToken + '&to_headless=true'
|
|
207
|
+
}
|
|
208
|
+
return endpoint
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function displayRemoteConfigurationFetchingError() {
|
|
212
|
+
display.error('Error fetching the remote configuration.')
|
|
213
|
+
}
|
package/src/dataMap.js
CHANGED
|
@@ -22,6 +22,7 @@ export var commonTags = {
|
|
|
22
22
|
browser_version_major: 'device.browser_version_major',
|
|
23
23
|
screen_size: 'device.screen_size',
|
|
24
24
|
network_type: 'device.network_type',
|
|
25
|
+
time_zone: 'device.time_zone',
|
|
25
26
|
device: 'device.device',
|
|
26
27
|
view_id: 'view.id',
|
|
27
28
|
view_referrer: 'view.referrer',
|
package/src/helper/deviceInfo.js
CHANGED
|
@@ -307,6 +307,10 @@ var MethodLibrary = {
|
|
|
307
307
|
})()
|
|
308
308
|
return _this.language
|
|
309
309
|
}),
|
|
310
|
+
getTimeZone: monitor(function () {
|
|
311
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
312
|
+
return timeZone
|
|
313
|
+
}),
|
|
310
314
|
// 浏览器信息
|
|
311
315
|
getBrowserInfo: monitor(function () {
|
|
312
316
|
var _this = this
|
|
@@ -619,7 +623,8 @@ if (typeof window !== 'undefined') {
|
|
|
619
623
|
browserVersionMajor: MethodLibrary.getBrowserInfo().browserMajor,
|
|
620
624
|
screenSize: window.screen.width + '*' + window.screen.height,
|
|
621
625
|
networkType: MethodLibrary.getNetwork(),
|
|
622
|
-
device: MethodLibrary.getDeviceType()
|
|
626
|
+
device: MethodLibrary.getDeviceType(),
|
|
627
|
+
timeZone: MethodLibrary.getTimeZone()
|
|
623
628
|
}
|
|
624
629
|
}
|
|
625
630
|
export var deviceInfo = _deviceInfo
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getGlobalObject } from '../init'
|
|
1
2
|
/**
|
|
2
3
|
* Gets the original value for a DOM API that was potentially patched by Zone.js.
|
|
3
4
|
*
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
* [1]: https://github.com/angular/angular/tree/main/packages/zone.js
|
|
13
14
|
*/
|
|
14
15
|
export function getZoneJsOriginalValue(target, name) {
|
|
15
|
-
var browserWindow =
|
|
16
|
+
var browserWindow = getGlobalObject()
|
|
16
17
|
var original
|
|
17
18
|
if (
|
|
18
19
|
browserWindow.Zone &&
|
|
@@ -3,7 +3,13 @@ import { setInterval, clearInterval } from './timer'
|
|
|
3
3
|
var END_OF_TIMES = Infinity
|
|
4
4
|
|
|
5
5
|
export var CLEAR_OLD_VALUES_INTERVAL = ONE_MINUTE
|
|
6
|
+
let cleanupHistoriesInterval = null
|
|
6
7
|
|
|
8
|
+
const cleanupTasks = new Set()
|
|
9
|
+
|
|
10
|
+
function cleanupHistories() {
|
|
11
|
+
cleanupTasks.forEach((task) => task())
|
|
12
|
+
}
|
|
7
13
|
/**
|
|
8
14
|
*
|
|
9
15
|
* @param {expireDelay,maxEntries } params
|
|
@@ -14,11 +20,13 @@ export function createValueHistory(params) {
|
|
|
14
20
|
var maxEntries = params.maxEntries
|
|
15
21
|
|
|
16
22
|
var entries = []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
if (cleanupHistoriesInterval) {
|
|
24
|
+
cleanupHistoriesInterval = setInterval(function () {
|
|
25
|
+
return clearExpiredValues()
|
|
26
|
+
}, CLEAR_OLD_VALUES_INTERVAL)
|
|
27
|
+
}
|
|
20
28
|
|
|
21
|
-
function
|
|
29
|
+
function clearExpiredValues() {
|
|
22
30
|
var oldTimeThreshold = relativeNow() - expireDelay
|
|
23
31
|
while (
|
|
24
32
|
entries.length > 0 &&
|
|
@@ -27,7 +35,7 @@ export function createValueHistory(params) {
|
|
|
27
35
|
entries.pop()
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
|
-
|
|
38
|
+
cleanupTasks.add(clearExpiredValues)
|
|
31
39
|
function add(value, startTime) {
|
|
32
40
|
var entry = {
|
|
33
41
|
value: value,
|
|
@@ -103,7 +111,11 @@ export function createValueHistory(params) {
|
|
|
103
111
|
* Stop internal garbage collection of past entries.
|
|
104
112
|
*/
|
|
105
113
|
function stop() {
|
|
106
|
-
|
|
114
|
+
cleanupTasks.delete(clearExpiredValues)
|
|
115
|
+
if (cleanupTasks.size === 0 && cleanupHistoriesInterval) {
|
|
116
|
+
clearInterval(cleanupHistoriesInterval)
|
|
117
|
+
cleanupHistoriesInterval = null
|
|
118
|
+
}
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
return {
|
package/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export * from './helper/taskQueue'
|
|
|
27
27
|
export * from './tracekit'
|
|
28
28
|
export * from './configuration/configuration'
|
|
29
29
|
export * from './configuration/transportConfiguration'
|
|
30
|
+
export * from './configuration/remoteConfiguration'
|
|
30
31
|
export * from './browser/cookie'
|
|
31
32
|
export * from './browser/fetchObservable'
|
|
32
33
|
export * from './browser/xhrObservable'
|
|
@@ -48,10 +48,7 @@ export function processSessionStoreOperations(
|
|
|
48
48
|
let currentStore = retrieveStore()
|
|
49
49
|
if (isLockEnabled) {
|
|
50
50
|
// if someone has lock, retry later
|
|
51
|
-
if (
|
|
52
|
-
currentStore.lock &&
|
|
53
|
-
!isSessionInNotStartedState(currentStore.session)
|
|
54
|
-
) {
|
|
51
|
+
if (currentStore.lock) {
|
|
55
52
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
56
53
|
return
|
|
57
54
|
}
|
|
@@ -60,10 +57,7 @@ export function processSessionStoreOperations(
|
|
|
60
57
|
persistWithLock(currentStore.session)
|
|
61
58
|
// if lock is not acquired, retry later
|
|
62
59
|
currentStore = retrieveStore()
|
|
63
|
-
if (
|
|
64
|
-
currentStore.lock !== currentLock &&
|
|
65
|
-
!isSessionInNotStartedState(currentStore.session)
|
|
66
|
-
) {
|
|
60
|
+
if (currentStore.lock !== currentLock) {
|
|
67
61
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
68
62
|
return
|
|
69
63
|
}
|
|
@@ -72,10 +66,7 @@ export function processSessionStoreOperations(
|
|
|
72
66
|
if (isLockEnabled) {
|
|
73
67
|
// if lock corrupted after process, retry later
|
|
74
68
|
currentStore = retrieveStore()
|
|
75
|
-
if (
|
|
76
|
-
currentStore.lock !== currentLock &&
|
|
77
|
-
!isSessionInNotStartedState(currentStore.session)
|
|
78
|
-
) {
|
|
69
|
+
if (currentStore.lock !== currentLock) {
|
|
79
70
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
80
71
|
return
|
|
81
72
|
}
|
|
@@ -96,10 +87,7 @@ export function processSessionStoreOperations(
|
|
|
96
87
|
if (!(processedSession && isSessionInExpiredState(processedSession))) {
|
|
97
88
|
// if lock corrupted after persist, retry later
|
|
98
89
|
currentStore = retrieveStore()
|
|
99
|
-
if (
|
|
100
|
-
currentStore.lock !== currentLock &&
|
|
101
|
-
!isSessionInNotStartedState(currentStore.session)
|
|
102
|
-
) {
|
|
90
|
+
if (currentStore.lock !== currentLock) {
|
|
103
91
|
retryLater(operations, sessionStoreStrategy, numberOfRetries)
|
|
104
92
|
return
|
|
105
93
|
}
|
|
@@ -36,6 +36,7 @@ export function computeStackTrace(ex) {
|
|
|
36
36
|
}
|
|
37
37
|
var fileUrl =
|
|
38
38
|
'((?:file|https?|blob|chrome-extension|electron|native|eval|webpack|<anonymous>|\\w+\\.|\\/).*?)'
|
|
39
|
+
|
|
39
40
|
var filePosition = '(?::(\\d+))'
|
|
40
41
|
var CHROME_LINE_RE = new RegExp(
|
|
41
42
|
'^\\s*at (.*?) ?\\(' +
|
|
@@ -117,7 +118,7 @@ function parseWinLine(line) {
|
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
var GECKO_LINE_RE =
|
|
120
|
-
/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i
|
|
121
|
+
/^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|capacitor|\[native).*?|[^@]*bundle|\[wasm code\])(?::(\d+))?(?::(\d+))?\s*$/i
|
|
121
122
|
var GECKO_EVAL_RE = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i
|
|
122
123
|
|
|
123
124
|
function parseGeckoLine(line) {
|
|
@@ -11,14 +11,66 @@ export function getEventBridge() {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
|
-
|
|
14
|
+
getCapabilities() {
|
|
15
|
+
return JSON.parse(
|
|
16
|
+
(eventBridgeGlobal.getCapabilities &&
|
|
17
|
+
eventBridgeGlobal.getCapabilities()) ||
|
|
18
|
+
'[]'
|
|
19
|
+
)
|
|
20
|
+
},
|
|
21
|
+
getPrivacyLevel() {
|
|
22
|
+
return (
|
|
23
|
+
eventBridgeGlobal.getPrivacyLevel && eventBridgeGlobal.getPrivacyLevel()
|
|
24
|
+
)
|
|
25
|
+
},
|
|
26
|
+
getAllowedWebViewHosts() {
|
|
27
|
+
return JSON.parse(
|
|
28
|
+
(eventBridgeGlobal.getAllowedWebViewHosts &&
|
|
29
|
+
eventBridgeGlobal.getAllowedWebViewHosts()) ||
|
|
30
|
+
'[]'
|
|
31
|
+
)
|
|
32
|
+
},
|
|
33
|
+
send(eventType, event, viewId) {
|
|
34
|
+
const view = viewId ? { id: viewId } : undefined
|
|
15
35
|
eventBridgeGlobal.sendEvent(
|
|
16
|
-
JSON.stringify({ name: eventType, data: event })
|
|
36
|
+
JSON.stringify({ name: eventType, data: event, view })
|
|
17
37
|
)
|
|
18
38
|
}
|
|
19
39
|
}
|
|
20
40
|
}
|
|
21
|
-
export
|
|
41
|
+
export const BridgeCapability = {
|
|
42
|
+
RECORDS: 'records'
|
|
43
|
+
}
|
|
44
|
+
export function bridgeSupports(capability) {
|
|
45
|
+
const bridge = getEventBridge()
|
|
46
|
+
|
|
47
|
+
return !!bridge && bridge.getCapabilities().includes(capability)
|
|
48
|
+
}
|
|
49
|
+
export function canUseEventBridge(
|
|
50
|
+
currentHost = getGlobalObject().location?.hostname
|
|
51
|
+
) {
|
|
52
|
+
const eventBridgeGlobal = getEventBridgeGlobal()
|
|
53
|
+
if (
|
|
54
|
+
eventBridgeGlobal &&
|
|
55
|
+
eventBridgeGlobal.getAllowedWebViewHosts === undefined
|
|
56
|
+
) {
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
eventBridgeGlobal &&
|
|
61
|
+
eventBridgeGlobal.getAllowedWebViewHosts &&
|
|
62
|
+
eventBridgeGlobal.getAllowedWebViewHosts() === null
|
|
63
|
+
) {
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
22
66
|
var bridge = getEventBridge()
|
|
23
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
!!bridge &&
|
|
69
|
+
bridge
|
|
70
|
+
.getAllowedWebViewHosts()
|
|
71
|
+
.some(
|
|
72
|
+
(allowedHost) =>
|
|
73
|
+
currentHost === allowedHost || currentHost.endsWith(`.${allowedHost}`)
|
|
74
|
+
)
|
|
75
|
+
)
|
|
24
76
|
}
|
package/src/transport/index.js
CHANGED
|
@@ -2,4 +2,9 @@ export { createHttpRequest } from './httpRequest'
|
|
|
2
2
|
export { createBatch, processedMessageByDataMap } from './batch'
|
|
3
3
|
export { startBatchWithReplica } from './startBatchWithReplica'
|
|
4
4
|
export { createFlushController } from './flushController'
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
getEventBridge,
|
|
7
|
+
canUseEventBridge,
|
|
8
|
+
bridgeSupports,
|
|
9
|
+
BridgeCapability
|
|
10
|
+
} from './eventBridge'
|
package/types/index.d.ts
CHANGED
|
@@ -189,6 +189,14 @@ export interface RumBaseInitConfiguration extends InitConfiguration {
|
|
|
189
189
|
* 压缩 RUM 数据请求内容,以减少发送大量数据时的带宽使用量。压缩在 Worker 线程中完成。
|
|
190
190
|
*/
|
|
191
191
|
compressIntakeRequests?: boolean | undefined
|
|
192
|
+
/**
|
|
193
|
+
* 是否开启数据采集的远程配置功能,默认不开启
|
|
194
|
+
* 远程配置功能可以在不发布新版本的情况下,动态修改数据采集的配置项
|
|
195
|
+
* 例如:可以在远程配置中修改采样率、是否开启用户行为采集等
|
|
196
|
+
* 远程配置功能需要在观测云控制台中开启
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
remoteConfiguration?: boolean | undefined
|
|
192
200
|
/**
|
|
193
201
|
* 配置链路追踪工具类型,如果不配置默认为 ddtrace。目前支持 ddtrace、zipkin、skywalking_v3、jaeger、zipkin_single_header、w3c_traceparent 6 种数据类型。
|
|
194
202
|
*/
|