@dash0/sdk-web 0.6.2
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/LICENSE +202 -0
- package/README.md +496 -0
- package/dist/dash0.iife.js +2 -0
- package/dist/dash0.iife.js.map +1 -0
- package/dist/dash0.js +2 -0
- package/dist/dash0.js.map +1 -0
- package/dist/dash0.umd.cjs +2 -0
- package/dist/dash0.umd.cjs.map +1 -0
- package/dist/modules/api/attributes.js +16 -0
- package/dist/modules/api/debug.js +5 -0
- package/dist/modules/api/events.js +30 -0
- package/dist/modules/api/identify.js +29 -0
- package/dist/modules/api/init.js +130 -0
- package/dist/modules/api/report-error.js +4 -0
- package/dist/modules/api/session.js +88 -0
- package/dist/modules/attributes/common.js +26 -0
- package/dist/modules/attributes/index.js +2 -0
- package/dist/modules/attributes/url.js +25 -0
- package/dist/modules/entrypoint/npm-package.js +12 -0
- package/dist/modules/entrypoint/script.js +60 -0
- package/dist/modules/instrumentations/errors/async-function-wrapping.js +105 -0
- package/dist/modules/instrumentations/errors/event-handlers.js +52 -0
- package/dist/modules/instrumentations/errors/index.js +10 -0
- package/dist/modules/instrumentations/errors/timers.js +46 -0
- package/dist/modules/instrumentations/errors/unhandled-error.js +137 -0
- package/dist/modules/instrumentations/errors/unhandled-promise-rejection.js +29 -0
- package/dist/modules/instrumentations/http/fetch.js +164 -0
- package/dist/modules/instrumentations/http/utils.js +35 -0
- package/dist/modules/instrumentations/navigation/event.js +44 -0
- package/dist/modules/instrumentations/navigation/index.js +6 -0
- package/dist/modules/instrumentations/navigation/page-load.js +83 -0
- package/dist/modules/instrumentations/navigation/page-transition.js +72 -0
- package/dist/modules/instrumentations/web-vitals.js +32 -0
- package/dist/modules/semantic-conventions.js +79 -0
- package/dist/modules/transport/batcher.js +48 -0
- package/dist/modules/transport/fetch.js +58 -0
- package/dist/modules/transport/index.js +66 -0
- package/dist/modules/utils/constants.js +2 -0
- package/dist/modules/utils/debug.js +19 -0
- package/dist/modules/utils/fn.js +3 -0
- package/dist/modules/utils/globals.js +36 -0
- package/dist/modules/utils/id.js +16 -0
- package/dist/modules/utils/id_test.js +33 -0
- package/dist/modules/utils/ignore-rules.js +48 -0
- package/dist/modules/utils/index.js +16 -0
- package/dist/modules/utils/listeners.js +18 -0
- package/dist/modules/utils/local-storage.js +19 -0
- package/dist/modules/utils/math.js +3 -0
- package/dist/modules/utils/obj.js +10 -0
- package/dist/modules/utils/on-last-chance.js +31 -0
- package/dist/modules/utils/origin.js +14 -0
- package/dist/modules/utils/otel/attributes.js +55 -0
- package/dist/modules/utils/otel/attributes_test.js +158 -0
- package/dist/modules/utils/otel/error.js +30 -0
- package/dist/modules/utils/otel/http.js +7 -0
- package/dist/modules/utils/otel/index.js +4 -0
- package/dist/modules/utils/otel/span.js +56 -0
- package/dist/modules/utils/otel/trace-context.js +60 -0
- package/dist/modules/utils/performance.js +162 -0
- package/dist/modules/utils/pick.js +17 -0
- package/dist/modules/utils/pick_test.js +104 -0
- package/dist/modules/utils/rate-limit.js +20 -0
- package/dist/modules/utils/session-storage.js +21 -0
- package/dist/modules/utils/tab-id.js +29 -0
- package/dist/modules/utils/time.js +28 -0
- package/dist/modules/utils/timers.js +62 -0
- package/dist/modules/utils/url.js +11 -0
- package/dist/modules/utils/wrap.js +22 -0
- package/dist/modules/vars.js +25 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/api/attributes.d.ts +12 -0
- package/dist/types/api/debug.d.ts +1 -0
- package/dist/types/api/events.d.ts +36 -0
- package/dist/types/api/identify.d.ts +9 -0
- package/dist/types/api/init.d.ts +31 -0
- package/dist/types/api/report-error.d.ts +2 -0
- package/dist/types/api/session.d.ts +3 -0
- package/dist/types/attributes/common.d.ts +6 -0
- package/dist/types/attributes/index.d.ts +2 -0
- package/dist/types/attributes/url.d.ts +2 -0
- package/dist/types/entrypoint/npm-package.d.ts +8 -0
- package/dist/types/entrypoint/script.d.ts +1 -0
- package/dist/types/instrumentations/errors/async-function-wrapping.d.ts +8 -0
- package/dist/types/instrumentations/errors/event-handlers.d.ts +1 -0
- package/dist/types/instrumentations/errors/index.d.ts +1 -0
- package/dist/types/instrumentations/errors/timers.d.ts +1 -0
- package/dist/types/instrumentations/errors/unhandled-error.d.ts +5 -0
- package/dist/types/instrumentations/errors/unhandled-promise-rejection.d.ts +2 -0
- package/dist/types/instrumentations/http/fetch.d.ts +1 -0
- package/dist/types/instrumentations/http/utils.d.ts +5 -0
- package/dist/types/instrumentations/navigation/event.d.ts +1 -0
- package/dist/types/instrumentations/navigation/index.d.ts +1 -0
- package/dist/types/instrumentations/navigation/page-load.d.ts +7 -0
- package/dist/types/instrumentations/navigation/page-transition.d.ts +7 -0
- package/dist/types/instrumentations/web-vitals.d.ts +1 -0
- package/dist/types/semantic-conventions.d.ts +68 -0
- package/dist/types/transport/batcher.d.ts +4 -0
- package/dist/types/transport/fetch.d.ts +1 -0
- package/dist/types/transport/index.d.ts +3 -0
- package/dist/types/utils/constants.d.ts +2 -0
- package/dist/types/utils/debug.d.ts +7 -0
- package/dist/types/utils/fn.d.ts +1 -0
- package/dist/types/utils/globals.d.ts +14 -0
- package/dist/types/utils/id.d.ts +6 -0
- package/dist/types/utils/id_test.d.ts +1 -0
- package/dist/types/utils/ignore-rules.d.ts +3 -0
- package/dist/types/utils/index.d.ts +16 -0
- package/dist/types/utils/listeners.d.ts +2 -0
- package/dist/types/utils/local-storage.d.ts +4 -0
- package/dist/types/utils/math.d.ts +1 -0
- package/dist/types/utils/obj.d.ts +5 -0
- package/dist/types/utils/on-last-chance.d.ts +5 -0
- package/dist/types/utils/origin.d.ts +1 -0
- package/dist/types/utils/otel/attributes.d.ts +9 -0
- package/dist/types/utils/otel/attributes_test.d.ts +1 -0
- package/dist/types/utils/otel/error.d.ts +24 -0
- package/dist/types/utils/otel/http.d.ts +2 -0
- package/dist/types/utils/otel/index.d.ts +4 -0
- package/dist/types/utils/otel/span.d.ts +10 -0
- package/dist/types/utils/otel/trace-context.d.ts +8 -0
- package/dist/types/utils/performance.d.ts +45 -0
- package/dist/types/utils/pick.d.ts +9 -0
- package/dist/types/utils/pick_test.d.ts +1 -0
- package/dist/types/utils/rate-limit.d.ts +5 -0
- package/dist/types/utils/session-storage.d.ts +4 -0
- package/dist/types/utils/tab-id.d.ts +8 -0
- package/dist/types/utils/time.d.ts +6 -0
- package/dist/types/utils/timers.d.ts +6 -0
- package/dist/types/utils/url.d.ts +6 -0
- package/dist/types/utils/wrap.d.ts +1 -0
- package/dist/types/vars.d.ts +123 -0
- package/package.json +124 -0
- package/src/api/attributes.ts +19 -0
- package/src/api/debug.ts +6 -0
- package/src/api/events.ts +67 -0
- package/src/api/identify.ts +43 -0
- package/src/api/init.ts +221 -0
- package/src/api/report-error.ts +6 -0
- package/src/api/session.ts +113 -0
- package/src/attributes/common.ts +42 -0
- package/src/attributes/index.ts +2 -0
- package/src/attributes/url.ts +25 -0
- package/src/entrypoint/npm-package.ts +14 -0
- package/src/entrypoint/script-tag.html +23 -0
- package/src/entrypoint/script.ts +82 -0
- package/src/instrumentations/errors/async-function-wrapping.ts +157 -0
- package/src/instrumentations/errors/event-handlers.ts +77 -0
- package/src/instrumentations/errors/index.ts +11 -0
- package/src/instrumentations/errors/timers.ts +52 -0
- package/src/instrumentations/errors/unhandled-error.ts +187 -0
- package/src/instrumentations/errors/unhandled-promise-rejection.ts +30 -0
- package/src/instrumentations/http/fetch.ts +194 -0
- package/src/instrumentations/http/utils.ts +49 -0
- package/src/instrumentations/navigation/event.ts +66 -0
- package/src/instrumentations/navigation/index.ts +7 -0
- package/src/instrumentations/navigation/page-load.ts +96 -0
- package/src/instrumentations/navigation/page-transition.ts +100 -0
- package/src/instrumentations/web-vitals.ts +37 -0
- package/src/semantic-conventions.ts +91 -0
- package/src/transport/batcher.ts +59 -0
- package/src/transport/fetch.ts +72 -0
- package/src/transport/index.ts +77 -0
- package/src/utils/constants.ts +3 -0
- package/src/utils/debug.ts +25 -0
- package/src/utils/fn.ts +3 -0
- package/src/utils/globals.ts +42 -0
- package/src/utils/id.ts +17 -0
- package/src/utils/id_test.ts +41 -0
- package/src/utils/ignore-rules.ts +59 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/listeners.ts +18 -0
- package/src/utils/local-storage.ts +25 -0
- package/src/utils/math.ts +3 -0
- package/src/utils/obj.ts +12 -0
- package/src/utils/on-last-chance.ts +36 -0
- package/src/utils/origin.ts +15 -0
- package/src/utils/otel/attributes.ts +67 -0
- package/src/utils/otel/attributes_test.ts +181 -0
- package/src/utils/otel/error.ts +63 -0
- package/src/utils/otel/http.ts +9 -0
- package/src/utils/otel/index.ts +4 -0
- package/src/utils/otel/span.ts +70 -0
- package/src/utils/otel/trace-context.ts +84 -0
- package/src/utils/performance.ts +203 -0
- package/src/utils/pick.ts +19 -0
- package/src/utils/pick_test.ts +134 -0
- package/src/utils/rate-limit.ts +34 -0
- package/src/utils/session-storage.ts +27 -0
- package/src/utils/tab-id.ts +33 -0
- package/src/utils/time.ts +37 -0
- package/src/utils/timers.ts +79 -0
- package/src/utils/url.ts +12 -0
- package/src/utils/wrap.ts +33 -0
- package/src/vars.ts +169 -0
package/src/vars.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// TODO use OTel types here?
|
|
2
|
+
|
|
3
|
+
import { AnyValue, InstrumentationScope, KeyValue, Resource } from "../types/otlp";
|
|
4
|
+
import { AttributeValueType } from "./utils/otel";
|
|
5
|
+
|
|
6
|
+
export type Endpoint = {
|
|
7
|
+
/**
|
|
8
|
+
* OTLP HTTP URL excluding the /v1/* prefix
|
|
9
|
+
*/
|
|
10
|
+
url: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Will be placed into `Authorization: Bearer {auth_token}` header. Has the form
|
|
14
|
+
* `auth_abc123`.
|
|
15
|
+
*/
|
|
16
|
+
authToken: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Optionally specify what dataset should be placed into. Can also be configured within Dash0
|
|
20
|
+
* through the auth token.
|
|
21
|
+
*/
|
|
22
|
+
dataset?: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type PageViewMeta = {
|
|
26
|
+
/**
|
|
27
|
+
* Defaults to document.title
|
|
28
|
+
*/
|
|
29
|
+
title?: string;
|
|
30
|
+
attributes?: Record<string, AttributeValueType | AnyValue>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type PageViewInstrumentationSettings = {
|
|
34
|
+
/**
|
|
35
|
+
* Allows the selection of custom page metadata, falls back to default behaviour if undefined is returned.
|
|
36
|
+
*/
|
|
37
|
+
generateMetadata?: (url: URL) => PageViewMeta | undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether the sdk should track virtual page views by instrumenting the history api.
|
|
41
|
+
* Only relevant for websites utilizing virtual navigation.
|
|
42
|
+
* Defaults to true.
|
|
43
|
+
*/
|
|
44
|
+
trackVirtualPageViews?: boolean;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Additionally generate virtual page views when these url parts change.
|
|
48
|
+
* - "HASH" include changes to the urls hash / fragment
|
|
49
|
+
* - "SEARCH" include changes to the urls search / query parameters
|
|
50
|
+
*/
|
|
51
|
+
includeParts?: Array<"HASH" | "SEARCH">;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type Vars = {
|
|
55
|
+
/**
|
|
56
|
+
* Telemetry endpoints to which the generated telemetry should be sent
|
|
57
|
+
*/
|
|
58
|
+
endpoints: Endpoint[];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* OpenTelemetry resource used for all the telemetry we emit.
|
|
62
|
+
*/
|
|
63
|
+
resource: Resource;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* OpenTelemetry scope used for all the telemetry we emit.
|
|
67
|
+
*/
|
|
68
|
+
scope: InstrumentationScope;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Attributes that are supposed to be added to all outgoing signals
|
|
72
|
+
* at the time they are **added** to the transport layer.
|
|
73
|
+
*/
|
|
74
|
+
signalAttributes: KeyValue[];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* An array of URL regular expression for which no data should be
|
|
78
|
+
* collected. These regular expressions are evaluated against
|
|
79
|
+
* the document, XMLHttpRequest, fetch and resource URLs.
|
|
80
|
+
*/
|
|
81
|
+
ignoreUrls: RegExp[];
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* An array of error message regular expressions for which no data
|
|
85
|
+
* should be collected.
|
|
86
|
+
*/
|
|
87
|
+
ignoreErrorMessages: RegExp[];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Whether we should automatically wrap DOM event handlers
|
|
91
|
+
* added via addEventlistener for improved uncaught error tracking.
|
|
92
|
+
* This results in improved uncaught error tracking for cross-origin
|
|
93
|
+
* errors, but may have adverse effects on website performance and
|
|
94
|
+
* stability.
|
|
95
|
+
*
|
|
96
|
+
* @default true
|
|
97
|
+
*/
|
|
98
|
+
wrapEventHandlers: boolean;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Whether we should automatically wrap timers
|
|
102
|
+
* added via setTimeout / setInterval for improved uncaught error tracking.
|
|
103
|
+
* This results in improved uncaught error tracking for cross-origin
|
|
104
|
+
* errors, but may have adverse effects on website performance and
|
|
105
|
+
* stability.
|
|
106
|
+
*
|
|
107
|
+
* @default true
|
|
108
|
+
*/
|
|
109
|
+
wrapTimers: boolean;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* An array of URL regular expressions
|
|
113
|
+
* for which trace context headers should be sent across origins by http client instrumentations.
|
|
114
|
+
*/
|
|
115
|
+
propagateTraceHeadersCorsURLs: RegExp[];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* How long to wait after an XMLHttpRequest or fetch request has finished
|
|
119
|
+
* for the retrieval of resource timing data. Performance timeline events
|
|
120
|
+
* are placed on the low priority task queue and therefore high values
|
|
121
|
+
* might be necessary.
|
|
122
|
+
*
|
|
123
|
+
* @default 10000
|
|
124
|
+
*/
|
|
125
|
+
maxWaitForResourceTimingsMillis: number;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The number of milliseconds of tolerance between resolution of a http request promise and the end time of performanceEntries
|
|
129
|
+
* applied when matching a request to its respective performance entry. A higher value might increase match frequency at
|
|
130
|
+
* the cost of potential incorrect matches. Matching is performed based on request timing and url.
|
|
131
|
+
*
|
|
132
|
+
* @default 3000
|
|
133
|
+
*/
|
|
134
|
+
maxToleranceForResourceTimingsMillis: number;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A set of regular expressions that will be matched against HTTP request headers to be
|
|
138
|
+
* captured in `XMLHttpRequest` and `fetch` Instrumentations.
|
|
139
|
+
* These headers will be transferred as span attributes
|
|
140
|
+
*/
|
|
141
|
+
headersToCapture: RegExp[];
|
|
142
|
+
|
|
143
|
+
pageViewInstrumentation: PageViewInstrumentationSettings;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const vars: Vars = {
|
|
147
|
+
endpoints: [],
|
|
148
|
+
resource: {
|
|
149
|
+
attributes: [],
|
|
150
|
+
},
|
|
151
|
+
scope: {
|
|
152
|
+
name: "dash0-web-sdk",
|
|
153
|
+
version: __sdkVersion,
|
|
154
|
+
attributes: [],
|
|
155
|
+
},
|
|
156
|
+
signalAttributes: [],
|
|
157
|
+
ignoreUrls: [],
|
|
158
|
+
ignoreErrorMessages: [],
|
|
159
|
+
wrapEventHandlers: true,
|
|
160
|
+
wrapTimers: true,
|
|
161
|
+
propagateTraceHeadersCorsURLs: [],
|
|
162
|
+
maxWaitForResourceTimingsMillis: 10000,
|
|
163
|
+
maxToleranceForResourceTimingsMillis: 3000,
|
|
164
|
+
headersToCapture: [],
|
|
165
|
+
pageViewInstrumentation: {
|
|
166
|
+
trackVirtualPageViews: true,
|
|
167
|
+
includeParts: [],
|
|
168
|
+
},
|
|
169
|
+
};
|