@cloudcare/browser-core 3.2.28 → 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/dataMap.js +1 -0
- package/cjs/dataMap.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 +3 -1
- 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/dataMap.js +1 -0
- package/esm/dataMap.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 +3 -1
- 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 +2 -2
- package/src/dataMap.js +1 -0
- 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 +3 -1
- package/src/transport/httpRequest.js +53 -14
- package/types/index.d.ts +16 -2
|
@@ -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'
|
|
@@ -91,6 +93,13 @@ export interface InitConfiguration {
|
|
|
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
|
|
@@ -145,11 +154,16 @@ export interface RumBaseInitConfiguration extends InitConfiguration {
|
|
|
145
154
|
* https://docs.truewatch.com/security/page-performance/#_3
|
|
146
155
|
*/
|
|
147
156
|
excludedActivityUrls?: MatchOption[] | undefined
|
|
157
|
+
/**
|
|
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
|
+
*/
|
|
161
|
+
allowedTracingUrls?: Array<MatchOption | TracingOption> | undefined
|
|
148
162
|
/**
|
|
149
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:
|
|
150
164
|
["https://api.example.com", /https:\\/\\/.*\\.my-api-domain\\.com/].
|
|
151
165
|
*/
|
|
152
|
-
|
|
166
|
+
allowedTracingOrigins?: Array<OriginMatchOption> | undefined
|
|
153
167
|
defaultPrivacyLevel?: DefaultPrivacyLevel | undefined
|
|
154
168
|
/**
|
|
155
169
|
* Error session compensation sample rate:
|