@dash0/sdk-web 0.13.4 → 0.14.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.
- package/README.md +21 -0
- 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 +19 -4
- package/dist/modules/api/init_test.js +86 -0
- package/dist/modules/attributes/url.js +22 -12
- package/dist/modules/attributes/url_test.js +326 -0
- package/dist/modules/types/errors.js +1 -0
- package/dist/modules/types/globals.js +1 -0
- package/dist/modules/types/options.js +1 -0
- package/dist/modules/types/otlp.js +1 -0
- package/dist/modules/utils/fn.js +3 -0
- package/dist/modules/vars.js +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/api/attributes.d.ts +1 -1
- package/dist/types/api/events.d.ts +1 -1
- package/dist/types/api/init.d.ts +1 -30
- package/dist/types/api/init_test.d.ts +1 -0
- package/dist/types/api/report-error.d.ts +1 -1
- package/dist/types/attributes/common.d.ts +1 -1
- package/dist/types/attributes/url.d.ts +11 -1
- package/dist/types/attributes/url_test.d.ts +1 -0
- package/dist/types/entrypoint/npm-package.d.ts +1 -1
- package/dist/types/instrumentations/errors/unhandled-error.d.ts +1 -1
- package/dist/types/transport/index.d.ts +1 -1
- package/dist/types/types/errors.d.ts +8 -0
- package/dist/types/types/globals.d.ts +12 -0
- package/dist/types/types/options.d.ts +35 -0
- package/dist/types/types/otlp.d.ts +104 -0
- package/dist/types/utils/fn.d.ts +1 -0
- package/dist/types/utils/otel/attributes.d.ts +1 -1
- package/dist/types/utils/otel/error.d.ts +1 -1
- package/dist/types/utils/otel/span.d.ts +1 -1
- package/dist/types/vars.d.ts +11 -1
- package/package.json +1 -1
- package/src/api/attributes.ts +1 -1
- package/src/api/events.ts +1 -1
- package/src/api/init.ts +25 -52
- package/src/api/init_test.ts +108 -0
- package/src/api/report-error.ts +1 -1
- package/src/attributes/common.ts +1 -1
- package/src/attributes/common_test.ts +1 -1
- package/src/attributes/url.ts +35 -13
- package/src/attributes/url_test.ts +417 -0
- package/src/entrypoint/npm-package.ts +2 -1
- package/src/instrumentations/errors/unhandled-error.ts +2 -2
- package/src/instrumentations/navigation/event.ts +1 -1
- package/src/instrumentations/navigation/page-load.ts +1 -1
- package/src/instrumentations/web-vitals.ts +1 -1
- package/src/transport/index.ts +1 -1
- package/src/types/errors.ts +9 -0
- package/src/types/globals.ts +19 -0
- package/src/types/options.ts +56 -0
- package/src/types/otlp.ts +121 -0
- package/src/utils/fn.ts +4 -0
- package/src/utils/otel/attributes.ts +1 -1
- package/src/utils/otel/attributes_test.ts +1 -1
- package/src/utils/otel/error.ts +1 -1
- package/src/utils/otel/span.ts +1 -1
- package/src/vars.ts +14 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { LOG_SEVERITY_NUMBER, LOG_SEVERITY_TEXT } from "../semantic-conventions";
|
|
2
|
+
|
|
3
|
+
export type AnyValue = {
|
|
4
|
+
["stringValue"]?: string;
|
|
5
|
+
["boolValue"]?: boolean;
|
|
6
|
+
/** Format: int64 */
|
|
7
|
+
["intValue"]?: string;
|
|
8
|
+
/** Format: double */
|
|
9
|
+
["doubleValue"]?: number;
|
|
10
|
+
["arrayValue"]?: ArrayValue;
|
|
11
|
+
["kvlistValue"]?: KeyValueList;
|
|
12
|
+
/** Format: byte */
|
|
13
|
+
["bytesValue"]?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ArrayValue = {
|
|
17
|
+
["values"]: AnyValue[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type KeyValue = {
|
|
21
|
+
["key"]: string;
|
|
22
|
+
["value"]: AnyValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type KeyValueList = {
|
|
26
|
+
["values"]: KeyValue[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type Resource = {
|
|
30
|
+
["attributes"]: KeyValue[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type InstrumentationScope = {
|
|
34
|
+
["name"]?: string;
|
|
35
|
+
["version"]?: string;
|
|
36
|
+
["attributes"]: KeyValue[];
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type ExportLogsServiceRequest = {
|
|
40
|
+
resourceLogs: ResourceLogs[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ResourceLogs = {
|
|
44
|
+
resource: Resource;
|
|
45
|
+
scopeLogs: ScopeLogs[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ScopeLogs = {
|
|
49
|
+
scope?: InstrumentationScope;
|
|
50
|
+
logRecords: LogRecord[];
|
|
51
|
+
schemaUrl?: string;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type LogRecord = {
|
|
55
|
+
/** Format: uint64 */
|
|
56
|
+
timeUnixNano: string;
|
|
57
|
+
severityNumber?: LOG_SEVERITY_NUMBER;
|
|
58
|
+
severityText?: LOG_SEVERITY_TEXT;
|
|
59
|
+
body?: AnyValue;
|
|
60
|
+
attributes: KeyValue[];
|
|
61
|
+
/** Format: byte */
|
|
62
|
+
traceId?: string;
|
|
63
|
+
/** Format: byte */
|
|
64
|
+
spanId?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type ExportTraceServiceRequest = {
|
|
68
|
+
resourceSpans: ResourceSpans[];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type ResourceSpans = {
|
|
72
|
+
resource: Resource;
|
|
73
|
+
scopeSpans: ScopeSpans[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type ScopeSpans = {
|
|
77
|
+
scope?: InstrumentationScope;
|
|
78
|
+
spans: Span[];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type SpanStatus = {
|
|
82
|
+
message?: string;
|
|
83
|
+
code: 0 | 1 | 2;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type SpanEvent = {
|
|
87
|
+
timeUnixNano: string;
|
|
88
|
+
name: string;
|
|
89
|
+
attributes: KeyValue[];
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type SpanLink = {
|
|
93
|
+
/** Format: byte */
|
|
94
|
+
traceId: string;
|
|
95
|
+
/** Format: byte */
|
|
96
|
+
spanId: string;
|
|
97
|
+
traceState?: string;
|
|
98
|
+
attributes: KeyValue[];
|
|
99
|
+
droppedAttributesCount: number;
|
|
100
|
+
flags?: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type Span = {
|
|
104
|
+
/** Format: byte */
|
|
105
|
+
traceId: string;
|
|
106
|
+
/** Format: byte */
|
|
107
|
+
spanId: string;
|
|
108
|
+
traceState?: string;
|
|
109
|
+
/** Format: byte */
|
|
110
|
+
parentSpanId?: string;
|
|
111
|
+
name: string;
|
|
112
|
+
kind: number;
|
|
113
|
+
startTimeUnixNano: string;
|
|
114
|
+
endTimeUnixNano: string;
|
|
115
|
+
attributes: KeyValue[];
|
|
116
|
+
events: SpanEvent[];
|
|
117
|
+
/** Format: int64 */
|
|
118
|
+
droppedEventsCount?: number;
|
|
119
|
+
links: SpanLink[];
|
|
120
|
+
status: SpanStatus;
|
|
121
|
+
};
|
package/src/utils/fn.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect, describe, it } from "vitest";
|
|
2
2
|
import { addAttribute, toAnyValue } from "./attributes";
|
|
3
|
-
import { AnyValue, KeyValue } from "
|
|
3
|
+
import { AnyValue, KeyValue } from "../../types/otlp";
|
|
4
4
|
|
|
5
5
|
describe("toAnyValue", () => {
|
|
6
6
|
describe("primitive values", () => {
|
package/src/utils/otel/error.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { addSpanEvent, InProgressSpan } from "./span";
|
|
2
|
-
import { KeyValue, SpanStatus } from "../../../types/otlp";
|
|
3
2
|
import { addAttribute } from "./attributes";
|
|
4
3
|
import {
|
|
5
4
|
SPAN_EVENT_NAME_EXCEPTION,
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
EXCEPTION_TYPE,
|
|
9
8
|
SPAN_STATUS_ERROR,
|
|
10
9
|
} from "../../semantic-conventions";
|
|
10
|
+
import { KeyValue, SpanStatus } from "../../types/otlp";
|
|
11
11
|
|
|
12
12
|
interface ExceptionWithCode {
|
|
13
13
|
code: string | number;
|
package/src/utils/otel/span.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { KeyValue, Span, SpanStatus } from "../../../types/otlp";
|
|
2
1
|
import { nowNanos } from "../time";
|
|
3
2
|
import { SPAN_KIND_CLIENT, SPAN_STATUS_UNSET, WEB_EVENT_ID } from "../../semantic-conventions";
|
|
4
3
|
import { sessionId } from "../../api/session";
|
|
5
4
|
import { generateTraceId } from "../trace-id";
|
|
6
5
|
import { generateSpanId } from "../span-id";
|
|
7
6
|
import { addAttribute } from "./attributes";
|
|
7
|
+
import { KeyValue, Span, SpanStatus } from "../../types/otlp";
|
|
8
8
|
|
|
9
9
|
export type InProgressSpan = Omit<Span, "endTimeUnixNano">;
|
|
10
10
|
|
package/src/vars.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// TODO use OTel types here?
|
|
2
|
-
|
|
3
|
-
import { AnyValue, InstrumentationScope, KeyValue, Resource } from "../types/otlp";
|
|
4
1
|
import { AttributeValueType } from "./utils/otel";
|
|
2
|
+
import { AnyValue, InstrumentationScope, KeyValue, Resource } from "./types/otlp";
|
|
3
|
+
import { UrlAttributeScrubber } from "./attributes";
|
|
4
|
+
import { identity } from "./utils";
|
|
5
5
|
|
|
6
6
|
export type Endpoint = {
|
|
7
7
|
/**
|
|
@@ -140,6 +140,16 @@ export type Vars = {
|
|
|
140
140
|
*/
|
|
141
141
|
headersToCapture: RegExp[];
|
|
142
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Allows the application of a custom scrubbing function to url attributes before they are applied to signals.
|
|
145
|
+
* This is invoked for each url processed for inclusion in signal attributes. For example this applies both to `page.url.*`
|
|
146
|
+
* and `url.*` attribute namespaces.
|
|
147
|
+
* Sensitive parts of the url attributes should be replaced with `REDACTED`,
|
|
148
|
+
* avoid partially or fully dropping attributes to preserve telemetry quality.
|
|
149
|
+
* Note: basic auth credentials in urls are automatically redacted before this is invoked.
|
|
150
|
+
*/
|
|
151
|
+
urlAttributeScrubber: UrlAttributeScrubber;
|
|
152
|
+
|
|
143
153
|
pageViewInstrumentation: PageViewInstrumentationSettings;
|
|
144
154
|
};
|
|
145
155
|
|
|
@@ -162,6 +172,7 @@ export const vars: Vars = {
|
|
|
162
172
|
maxWaitForResourceTimingsMillis: 10000,
|
|
163
173
|
maxToleranceForResourceTimingsMillis: 50,
|
|
164
174
|
headersToCapture: [],
|
|
175
|
+
urlAttributeScrubber: identity,
|
|
165
176
|
pageViewInstrumentation: {
|
|
166
177
|
trackVirtualPageViews: true,
|
|
167
178
|
includeParts: [],
|