@dash0/sdk-web 0.16.1 → 0.16.3
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/dist/dash0.iife.js +1 -1
- package/dist/dash0.iife.js.map +1 -1
- package/dist/dash0.js +1 -1
- package/dist/dash0.js.map +1 -1
- package/dist/dash0.umd.cjs +1 -1
- package/dist/dash0.umd.cjs.map +1 -1
- package/dist/modules/api/init.js +1 -0
- package/dist/modules/instrumentations/http/fetch.js +9 -2
- package/dist/modules/transport/fetch.js +1 -1
- package/dist/modules/utils/wrap.js +1 -0
- package/dist/modules/vars.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/types/options.d.ts +1 -1
- package/dist/types/vars.d.ts +5 -0
- package/package.json +1 -1
- package/src/api/init.ts +1 -0
- package/src/instrumentations/http/fetch.ts +20 -2
- package/src/transport/fetch.ts +1 -1
- package/src/types/options.ts +1 -0
- package/src/utils/wrap.ts +1 -0
- package/src/vars.ts +7 -0
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
debug,
|
|
3
|
+
observeResourcePerformance,
|
|
4
|
+
perf,
|
|
5
|
+
win,
|
|
6
|
+
setTimeout,
|
|
7
|
+
isSameOrigin,
|
|
8
|
+
wrap,
|
|
9
|
+
parseUrl,
|
|
10
|
+
clearTimeout,
|
|
11
|
+
} from "../../utils";
|
|
2
12
|
import { isUrlIgnored, matchesAny } from "../../utils/ignore-rules";
|
|
3
13
|
import {
|
|
4
14
|
addAttribute,
|
|
@@ -156,6 +166,8 @@ function isGraphQLQuery(input: RequestInfo | URL, init?: RequestInit) {
|
|
|
156
166
|
|
|
157
167
|
function tryCaptureHttpHeaders(headers: Headers, span: InProgressSpan, getAttributeKey: (headerKey: string) => string) {
|
|
158
168
|
try {
|
|
169
|
+
if (!vars.headersToCapture.length) return;
|
|
170
|
+
|
|
159
171
|
headers.forEach((value, key) => {
|
|
160
172
|
if (vars.headersToCapture.some((rxp) => rxp.test(key))) {
|
|
161
173
|
addAttribute(span.attributes, getAttributeKey(key), value);
|
|
@@ -194,7 +206,8 @@ function wrapResponse(
|
|
|
194
206
|
let fallbackTs: number = perf.now();
|
|
195
207
|
const body = originalResponse.body;
|
|
196
208
|
|
|
197
|
-
|
|
209
|
+
// For some reason browsers return a response body on responses that can't be constructed with one. In that case we can't wrap the body stream
|
|
210
|
+
if (!body || !responseCanHaveBody(originalResponse)) {
|
|
198
211
|
onDone();
|
|
199
212
|
return originalResponse;
|
|
200
213
|
}
|
|
@@ -314,3 +327,8 @@ function addTraceContextHttpHeaders(
|
|
|
314
327
|
}
|
|
315
328
|
}
|
|
316
329
|
}
|
|
330
|
+
|
|
331
|
+
function responseCanHaveBody(response: Response) {
|
|
332
|
+
const status = response.status;
|
|
333
|
+
return status >= 200 && status != 204 && status != 205 && status != 304;
|
|
334
|
+
}
|
package/src/transport/fetch.ts
CHANGED
|
@@ -12,7 +12,7 @@ export async function send(path: string, body: unknown): Promise<void> {
|
|
|
12
12
|
let isCompressed = false;
|
|
13
13
|
|
|
14
14
|
// Try to compress if supported
|
|
15
|
-
if (typeof CompressionStream !== "undefined") {
|
|
15
|
+
if (typeof CompressionStream !== "undefined" && vars.enableTransportCompression) {
|
|
16
16
|
requestBody = await compressWithGzip(jsonString);
|
|
17
17
|
byteLength = requestBody.byteLength;
|
|
18
18
|
isCompressed = true;
|
package/src/types/options.ts
CHANGED
package/src/utils/wrap.ts
CHANGED
package/src/vars.ts
CHANGED
|
@@ -165,6 +165,12 @@ export type Vars = {
|
|
|
165
165
|
urlAttributeScrubber: UrlAttributeScrubber;
|
|
166
166
|
|
|
167
167
|
pageViewInstrumentation: PageViewInstrumentationSettings;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Enables telemetry transport compression using gzip.
|
|
171
|
+
* experimental - in rare cases causes Chrome to crash to use at your own risk.
|
|
172
|
+
*/
|
|
173
|
+
enableTransportCompression: boolean;
|
|
168
174
|
};
|
|
169
175
|
|
|
170
176
|
export const vars: Vars = {
|
|
@@ -191,4 +197,5 @@ export const vars: Vars = {
|
|
|
191
197
|
trackVirtualPageViews: true,
|
|
192
198
|
includeParts: [],
|
|
193
199
|
},
|
|
200
|
+
enableTransportCompression: false,
|
|
194
201
|
};
|