@dash0/sdk-web 0.16.2 → 0.17.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.
@@ -1,4 +1,14 @@
1
- import { debug, observeResourcePerformance, perf, win, setTimeout, isSameOrigin, wrap, parseUrl } from "../../utils";
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);
@@ -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;
@@ -1,3 +1,5 @@
1
+ import { KeyValue } from "./otlp";
2
+
1
3
  export type ErrorLike = {
2
4
  message: string;
3
5
  name?: string;
@@ -6,4 +8,8 @@ export type ErrorLike = {
6
8
 
7
9
  export type ReportErrorOpts = {
8
10
  componentStack: string | null | undefined;
11
+ /**
12
+ * Additional attributes to add to the error span
13
+ */
14
+ attributes?: KeyValue[];
9
15
  };
@@ -58,5 +58,6 @@ export type InitOptions = {
58
58
  | "headersToCapture"
59
59
  | "urlAttributeScrubber"
60
60
  | "pageViewInstrumentation"
61
+ | "enableTransportCompression"
61
62
  >
62
63
  >;
package/src/utils/wrap.ts CHANGED
@@ -26,6 +26,7 @@ export function wrap<ModuleType extends object, TargetNameType extends keyof Mod
26
26
 
27
27
  if (isAlreadyInstrumented(original)) {
28
28
  debug(`${String(target)} has already been instrumented, skipping`);
29
+ return;
29
30
  }
30
31
 
31
32
  markAsInstrumented(original);
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
  };