@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.
Files changed (194) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +496 -0
  3. package/dist/dash0.iife.js +2 -0
  4. package/dist/dash0.iife.js.map +1 -0
  5. package/dist/dash0.js +2 -0
  6. package/dist/dash0.js.map +1 -0
  7. package/dist/dash0.umd.cjs +2 -0
  8. package/dist/dash0.umd.cjs.map +1 -0
  9. package/dist/modules/api/attributes.js +16 -0
  10. package/dist/modules/api/debug.js +5 -0
  11. package/dist/modules/api/events.js +30 -0
  12. package/dist/modules/api/identify.js +29 -0
  13. package/dist/modules/api/init.js +130 -0
  14. package/dist/modules/api/report-error.js +4 -0
  15. package/dist/modules/api/session.js +88 -0
  16. package/dist/modules/attributes/common.js +26 -0
  17. package/dist/modules/attributes/index.js +2 -0
  18. package/dist/modules/attributes/url.js +25 -0
  19. package/dist/modules/entrypoint/npm-package.js +12 -0
  20. package/dist/modules/entrypoint/script.js +60 -0
  21. package/dist/modules/instrumentations/errors/async-function-wrapping.js +105 -0
  22. package/dist/modules/instrumentations/errors/event-handlers.js +52 -0
  23. package/dist/modules/instrumentations/errors/index.js +10 -0
  24. package/dist/modules/instrumentations/errors/timers.js +46 -0
  25. package/dist/modules/instrumentations/errors/unhandled-error.js +137 -0
  26. package/dist/modules/instrumentations/errors/unhandled-promise-rejection.js +29 -0
  27. package/dist/modules/instrumentations/http/fetch.js +164 -0
  28. package/dist/modules/instrumentations/http/utils.js +35 -0
  29. package/dist/modules/instrumentations/navigation/event.js +44 -0
  30. package/dist/modules/instrumentations/navigation/index.js +6 -0
  31. package/dist/modules/instrumentations/navigation/page-load.js +83 -0
  32. package/dist/modules/instrumentations/navigation/page-transition.js +72 -0
  33. package/dist/modules/instrumentations/web-vitals.js +32 -0
  34. package/dist/modules/semantic-conventions.js +79 -0
  35. package/dist/modules/transport/batcher.js +48 -0
  36. package/dist/modules/transport/fetch.js +58 -0
  37. package/dist/modules/transport/index.js +66 -0
  38. package/dist/modules/utils/constants.js +2 -0
  39. package/dist/modules/utils/debug.js +19 -0
  40. package/dist/modules/utils/fn.js +3 -0
  41. package/dist/modules/utils/globals.js +36 -0
  42. package/dist/modules/utils/id.js +16 -0
  43. package/dist/modules/utils/id_test.js +33 -0
  44. package/dist/modules/utils/ignore-rules.js +48 -0
  45. package/dist/modules/utils/index.js +16 -0
  46. package/dist/modules/utils/listeners.js +18 -0
  47. package/dist/modules/utils/local-storage.js +19 -0
  48. package/dist/modules/utils/math.js +3 -0
  49. package/dist/modules/utils/obj.js +10 -0
  50. package/dist/modules/utils/on-last-chance.js +31 -0
  51. package/dist/modules/utils/origin.js +14 -0
  52. package/dist/modules/utils/otel/attributes.js +55 -0
  53. package/dist/modules/utils/otel/attributes_test.js +158 -0
  54. package/dist/modules/utils/otel/error.js +30 -0
  55. package/dist/modules/utils/otel/http.js +7 -0
  56. package/dist/modules/utils/otel/index.js +4 -0
  57. package/dist/modules/utils/otel/span.js +56 -0
  58. package/dist/modules/utils/otel/trace-context.js +60 -0
  59. package/dist/modules/utils/performance.js +162 -0
  60. package/dist/modules/utils/pick.js +17 -0
  61. package/dist/modules/utils/pick_test.js +104 -0
  62. package/dist/modules/utils/rate-limit.js +20 -0
  63. package/dist/modules/utils/session-storage.js +21 -0
  64. package/dist/modules/utils/tab-id.js +29 -0
  65. package/dist/modules/utils/time.js +28 -0
  66. package/dist/modules/utils/timers.js +62 -0
  67. package/dist/modules/utils/url.js +11 -0
  68. package/dist/modules/utils/wrap.js +22 -0
  69. package/dist/modules/vars.js +25 -0
  70. package/dist/tsconfig.tsbuildinfo +1 -0
  71. package/dist/types/api/attributes.d.ts +12 -0
  72. package/dist/types/api/debug.d.ts +1 -0
  73. package/dist/types/api/events.d.ts +36 -0
  74. package/dist/types/api/identify.d.ts +9 -0
  75. package/dist/types/api/init.d.ts +31 -0
  76. package/dist/types/api/report-error.d.ts +2 -0
  77. package/dist/types/api/session.d.ts +3 -0
  78. package/dist/types/attributes/common.d.ts +6 -0
  79. package/dist/types/attributes/index.d.ts +2 -0
  80. package/dist/types/attributes/url.d.ts +2 -0
  81. package/dist/types/entrypoint/npm-package.d.ts +8 -0
  82. package/dist/types/entrypoint/script.d.ts +1 -0
  83. package/dist/types/instrumentations/errors/async-function-wrapping.d.ts +8 -0
  84. package/dist/types/instrumentations/errors/event-handlers.d.ts +1 -0
  85. package/dist/types/instrumentations/errors/index.d.ts +1 -0
  86. package/dist/types/instrumentations/errors/timers.d.ts +1 -0
  87. package/dist/types/instrumentations/errors/unhandled-error.d.ts +5 -0
  88. package/dist/types/instrumentations/errors/unhandled-promise-rejection.d.ts +2 -0
  89. package/dist/types/instrumentations/http/fetch.d.ts +1 -0
  90. package/dist/types/instrumentations/http/utils.d.ts +5 -0
  91. package/dist/types/instrumentations/navigation/event.d.ts +1 -0
  92. package/dist/types/instrumentations/navigation/index.d.ts +1 -0
  93. package/dist/types/instrumentations/navigation/page-load.d.ts +7 -0
  94. package/dist/types/instrumentations/navigation/page-transition.d.ts +7 -0
  95. package/dist/types/instrumentations/web-vitals.d.ts +1 -0
  96. package/dist/types/semantic-conventions.d.ts +68 -0
  97. package/dist/types/transport/batcher.d.ts +4 -0
  98. package/dist/types/transport/fetch.d.ts +1 -0
  99. package/dist/types/transport/index.d.ts +3 -0
  100. package/dist/types/utils/constants.d.ts +2 -0
  101. package/dist/types/utils/debug.d.ts +7 -0
  102. package/dist/types/utils/fn.d.ts +1 -0
  103. package/dist/types/utils/globals.d.ts +14 -0
  104. package/dist/types/utils/id.d.ts +6 -0
  105. package/dist/types/utils/id_test.d.ts +1 -0
  106. package/dist/types/utils/ignore-rules.d.ts +3 -0
  107. package/dist/types/utils/index.d.ts +16 -0
  108. package/dist/types/utils/listeners.d.ts +2 -0
  109. package/dist/types/utils/local-storage.d.ts +4 -0
  110. package/dist/types/utils/math.d.ts +1 -0
  111. package/dist/types/utils/obj.d.ts +5 -0
  112. package/dist/types/utils/on-last-chance.d.ts +5 -0
  113. package/dist/types/utils/origin.d.ts +1 -0
  114. package/dist/types/utils/otel/attributes.d.ts +9 -0
  115. package/dist/types/utils/otel/attributes_test.d.ts +1 -0
  116. package/dist/types/utils/otel/error.d.ts +24 -0
  117. package/dist/types/utils/otel/http.d.ts +2 -0
  118. package/dist/types/utils/otel/index.d.ts +4 -0
  119. package/dist/types/utils/otel/span.d.ts +10 -0
  120. package/dist/types/utils/otel/trace-context.d.ts +8 -0
  121. package/dist/types/utils/performance.d.ts +45 -0
  122. package/dist/types/utils/pick.d.ts +9 -0
  123. package/dist/types/utils/pick_test.d.ts +1 -0
  124. package/dist/types/utils/rate-limit.d.ts +5 -0
  125. package/dist/types/utils/session-storage.d.ts +4 -0
  126. package/dist/types/utils/tab-id.d.ts +8 -0
  127. package/dist/types/utils/time.d.ts +6 -0
  128. package/dist/types/utils/timers.d.ts +6 -0
  129. package/dist/types/utils/url.d.ts +6 -0
  130. package/dist/types/utils/wrap.d.ts +1 -0
  131. package/dist/types/vars.d.ts +123 -0
  132. package/package.json +124 -0
  133. package/src/api/attributes.ts +19 -0
  134. package/src/api/debug.ts +6 -0
  135. package/src/api/events.ts +67 -0
  136. package/src/api/identify.ts +43 -0
  137. package/src/api/init.ts +221 -0
  138. package/src/api/report-error.ts +6 -0
  139. package/src/api/session.ts +113 -0
  140. package/src/attributes/common.ts +42 -0
  141. package/src/attributes/index.ts +2 -0
  142. package/src/attributes/url.ts +25 -0
  143. package/src/entrypoint/npm-package.ts +14 -0
  144. package/src/entrypoint/script-tag.html +23 -0
  145. package/src/entrypoint/script.ts +82 -0
  146. package/src/instrumentations/errors/async-function-wrapping.ts +157 -0
  147. package/src/instrumentations/errors/event-handlers.ts +77 -0
  148. package/src/instrumentations/errors/index.ts +11 -0
  149. package/src/instrumentations/errors/timers.ts +52 -0
  150. package/src/instrumentations/errors/unhandled-error.ts +187 -0
  151. package/src/instrumentations/errors/unhandled-promise-rejection.ts +30 -0
  152. package/src/instrumentations/http/fetch.ts +194 -0
  153. package/src/instrumentations/http/utils.ts +49 -0
  154. package/src/instrumentations/navigation/event.ts +66 -0
  155. package/src/instrumentations/navigation/index.ts +7 -0
  156. package/src/instrumentations/navigation/page-load.ts +96 -0
  157. package/src/instrumentations/navigation/page-transition.ts +100 -0
  158. package/src/instrumentations/web-vitals.ts +37 -0
  159. package/src/semantic-conventions.ts +91 -0
  160. package/src/transport/batcher.ts +59 -0
  161. package/src/transport/fetch.ts +72 -0
  162. package/src/transport/index.ts +77 -0
  163. package/src/utils/constants.ts +3 -0
  164. package/src/utils/debug.ts +25 -0
  165. package/src/utils/fn.ts +3 -0
  166. package/src/utils/globals.ts +42 -0
  167. package/src/utils/id.ts +17 -0
  168. package/src/utils/id_test.ts +41 -0
  169. package/src/utils/ignore-rules.ts +59 -0
  170. package/src/utils/index.ts +16 -0
  171. package/src/utils/listeners.ts +18 -0
  172. package/src/utils/local-storage.ts +25 -0
  173. package/src/utils/math.ts +3 -0
  174. package/src/utils/obj.ts +12 -0
  175. package/src/utils/on-last-chance.ts +36 -0
  176. package/src/utils/origin.ts +15 -0
  177. package/src/utils/otel/attributes.ts +67 -0
  178. package/src/utils/otel/attributes_test.ts +181 -0
  179. package/src/utils/otel/error.ts +63 -0
  180. package/src/utils/otel/http.ts +9 -0
  181. package/src/utils/otel/index.ts +4 -0
  182. package/src/utils/otel/span.ts +70 -0
  183. package/src/utils/otel/trace-context.ts +84 -0
  184. package/src/utils/performance.ts +203 -0
  185. package/src/utils/pick.ts +19 -0
  186. package/src/utils/pick_test.ts +134 -0
  187. package/src/utils/rate-limit.ts +34 -0
  188. package/src/utils/session-storage.ts +27 -0
  189. package/src/utils/tab-id.ts +33 -0
  190. package/src/utils/time.ts +37 -0
  191. package/src/utils/timers.ts +79 -0
  192. package/src/utils/url.ts +12 -0
  193. package/src/utils/wrap.ts +33 -0
  194. package/src/vars.ts +169 -0
package/README.md ADDED
@@ -0,0 +1,496 @@
1
+ # Dash0 Web SDK
2
+
3
+ This SDK enables users of dash0's web monitoring features to instrument a website or single-page-application to capture
4
+ and transmit telemetry to dash0.
5
+
6
+ Features include:
7
+
8
+ - Page view instrumentation
9
+ - Navigation timing instrumentation
10
+ - HTTP request instrumentation
11
+ - Error tracking
12
+
13
+ ## Getting Started
14
+
15
+ The SDK is currently only distributed as an npm package, additional distribution formats will be added in the future.
16
+ Should you need a currently unavailable format, let us know by creating a github issue or via [support@dash0.com](mailto:support@dash0.com).
17
+
18
+ ### Before you begin
19
+
20
+ You'll need a couple of prequesites before you can start:
21
+
22
+ - An active dash0 account. [Sign Up](https://www.dash0.com/sign-up)
23
+ - An [Auth Token](https://www.dash0.com/documentation/dash0/key-concepts/auth-tokens)
24
+ Auth tokens for client monitoring will be public as part of your website, please make sure to:
25
+ - Use a separate token, exclusively for web monitoring
26
+ - Limit the dataset to the dataset you want to ingest to
27
+ - Limit permissions to `Ingesting`
28
+ - The [Endpoint](https://www.dash0.com/documentation/dash0/key-concepts/endpoints) url for your dash0 region. You can find it via `Organization Settings > Endpoints > OTLP via HTTP`.
29
+
30
+ ### Installation
31
+
32
+ #### Via package
33
+
34
+ - Add the SDK to your dependencies
35
+ ```
36
+ # npm
37
+ npm install @dash0/sdk-web
38
+ # yarn
39
+ yarn add @dash0/sdk-web
40
+ ```
41
+ - Initialize the sdk
42
+ In order to initialize the sdk you'll need to call the `init` function at a convenient time in your applications lifecycle.
43
+ Ideally this should happen as early as possible, as most instrumentations can only observe events after init has been called.
44
+
45
+ ```js
46
+ import { init } from "@dash0/sdk-web";
47
+
48
+ init({
49
+ serviceName: "my-website",
50
+ endpoint: {
51
+ // Replace this with the endpoint url identified during preparation
52
+ url: "http://example.com",
53
+ // Replace this with your auth token you created earlier
54
+ // Ideally inject the value at build time to not commit the token to git, even if its effectively public
55
+ authToken: "you-auth-token-goes-here",
56
+ },
57
+ });
58
+ ```
59
+
60
+ ## Configuration
61
+
62
+ The following configuration options are available, in order to customize the behaviour of the sdk.
63
+ These can all be passed via the sdk's `init` call.
64
+
65
+ ### Backend Correlation
66
+
67
+ Backend Correlation for HTTP requests is by default only enabled for endpoints that share the same origin as the website.
68
+
69
+ > [!NOTE]
70
+ > Misconfiguration of cross origin trace correlation can lead to request failures. Please make sure to carefully validate
71
+ > the configuration provided in the next steps
72
+
73
+ If you want to enable correlation for cross-origin requests you have to follow these steps:
74
+
75
+ - Make sure the endpoints respond to `OPTIONS` requests and include `traceparent` in their `Access-Control-Allow-Headers`
76
+ response header.
77
+ - Include a regex matching the endpoint you want to enable in the [propagateTraceHeadersCorsURLs](#http-request-instrumentation) configuration option.
78
+
79
+ ### Configuration auto detection
80
+
81
+ Certain configuration values can be auto-detected if using the module version of the SDK in combination with certain cloud providers.
82
+
83
+ #### Vercel
84
+
85
+ This currently also requires the use of Next.js
86
+
87
+ | Configuration Key | Source |
88
+ | :---------------- | :------------------------------------------------------------------------------------------------------------------------------------------- |
89
+ | environment | [NEXT_PUBLIC_VERCEL_ENV](https://vercel.com/docs/environment-variables/framework-environment-variables#NEXT_PUBLIC_VERCEL_ENV) |
90
+ | deploymentName | [NEXT_PUBLIC_VERCEL_TARGET_ENV](https://vercel.com/docs/environment-variables/framework-environment-variables#NEXT_PUBLIC_VERCEL_TARGET_ENV) |
91
+ | deploymentId | [NEXT_PUBLIC_VERCEL_BRANCH_URL](https://vercel.com/docs/environment-variables/framework-environment-variables#NEXT_PUBLIC_VERCEL_BRANCH_URL) |
92
+
93
+ ### Configuration Overview
94
+
95
+ #### General
96
+
97
+ - **Ignore URLs**<br>
98
+ key: `ignoreUrls`<br>
99
+ type: `Array<RegExp>`<br>
100
+ optional: `true`<br>
101
+ default: `undefined`<br>
102
+ An array of URL regular expression for which no data should be collected.
103
+ These regular expressions are evaluated against the document, XMLHttpRequest, fetch and resource URLs.
104
+
105
+ #### Website Details and Attributes
106
+
107
+ - **Service Name**<br>
108
+ key: `serviceName`<br>
109
+ type: `string`<br>
110
+ optional: `false`<br>
111
+ The logical name or your website, maps to the [service.name](https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-name) otel attribute.
112
+ - **Service Version**<br>
113
+ key: `serviceVersion`<br>
114
+ type: `string`<br>
115
+ optional: `true`<br>
116
+ default: `undefined`<br>
117
+ The current version of your website, maps to the [service.version](https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-version) otel attribute.
118
+ - **Environment**<br>
119
+ key: `environment`<br>
120
+ type: `string`<br>
121
+ optional: `true`<br>
122
+ default: `undefined`<br>
123
+ Name of the deployment environment, for example `staging`, or `production`. Maps to the [deployment.environment.name](https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-environment-name) otel attribute.
124
+ This value is [auto detected](#configuration-auto-detection) in certain build environments.
125
+ - **Deployment Name**<br>
126
+ key: `deploymentName`<br>
127
+ type: `string`<br>
128
+ optional: `true`<br>
129
+ default: `undefined`<br>
130
+ Name of the deployment, maps to the [deployment.name](https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-name) otel attribute.
131
+ This value is [auto detected](#configuration-auto-detection) in certain build environments.
132
+ - **Deployment Id**<br>
133
+ key: `deploymentId`<br>
134
+ type: `string`<br>
135
+ optional: `true`<br>
136
+ default: `undefined`<br>
137
+ Id of the deployment, aps to the [deployment.id](https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-id) otel attribute.
138
+ This value is [auto detected](#configuration-auto-detection) in certain build environments.
139
+ - **Additional Signal Attributes**<br>
140
+ key: `additionalSignalAttributes`<br>
141
+ type: `Record<string, AttributeValueType | AnyValue>`<br>
142
+ optional: `true`<br>
143
+ default: `undefined`<br>
144
+ Allows the configuration of additional attributes to be included with any transmitted event.
145
+ See [AttributeValueType](https://github.com/dash0hq/dash0-sdk-web/blob/main/src/utils/otel/attributes.ts#L4) and [AnyValue](https://github.com/dash0hq/dash0-sdk-web/blob/main/types/otlp.d.ts#L3) for detailed types.
146
+
147
+ #### OTLP Endpoint
148
+
149
+ - **Endpoint**<br>
150
+ key: `endpoint`<br>
151
+ type: `Endpoint | Endpoint[]`<br>
152
+ optional: `false`<br>
153
+ The OTLP to which the generated telemtetry should be sent. Supports multiple endpoints in parallel if an array is provided.
154
+ - **Endpoint URL**<br>
155
+ key: `endpoint.url`<br>
156
+ type: `string`<br>
157
+ optional: `false`<br>
158
+ The OTLP HTTP URL of the endpoint, not including the `/v1/*` part of the path
159
+ - **Endpoint Auth Token**<br>
160
+ key: `endpoint.authToken`<br>
161
+ type: `string`<br>
162
+ optional: `false`<br>
163
+ The auth token used for the endpoint. Will be placed into `Authorization: Bearer {auth_token}` header.
164
+ - **Endpoint Dataset**<br>
165
+ key: `endpoint.dataset`<br>
166
+ type: `string`<br>
167
+ optional: `true`<br>
168
+ Optionally specify what dataset should be placed into. Can also be configured within Dash0 through the auth token.
169
+
170
+ #### Session Tracking
171
+
172
+ - **Session Inactivity Timeout**<br>
173
+ key: `sessionInactivityTimeoutMillis`<br>
174
+ type: `number`<br>
175
+ optional: `true`<br>
176
+ default: `10800000` (3 hours)<br>
177
+ The session inactivity timeout. Session inactivity is the maximum allowed time to pass between two page loads before
178
+ the session is considered to be expired. The maximum value is the maximum session duration of 24 hours.
179
+ - **Session Termination Timeout**<br>
180
+ key: `sessionTerminationTimeoutMillis`<br>
181
+ type: `number`<br>
182
+ optional: `true`<br>
183
+ default: `21600000` (6 hours)<br>
184
+ The default session termination timeout. Session termination is the maximum allowed time to pass since session start
185
+ before the session is considered to be expired.
186
+
187
+ #### Error tracking
188
+
189
+ - **Ignore Error Messages**<br>
190
+ key: `ignoreErrorMessages`<br>
191
+ type: `Array<RegExp>`<br>
192
+ optional: `true`<br>
193
+ default: `undefined`<br>
194
+ An array of error message regular expressions for which no data should be collected.
195
+ - **Wrap Event Handlers**<br>
196
+ key: `wrapEventHandlers`<br>
197
+ type: `boolean`<br>
198
+ optional: `true`<br>
199
+ default: `true`<br>
200
+ Whether we should automatically wrap DOM event handlers added via addEventlistener for improved uncaught error tracking.
201
+ This results in improved uncaught error tracking for cross-origin errors,
202
+ but may have adverse effects on website performance and stability.
203
+ - **Wrap Timers**<br>
204
+ key: `wrapTimers`<br>
205
+ type: `boolean`<br>
206
+ optional: `true`<br>
207
+ default: `true`<br>
208
+ Whether we should automatically wrap timers added via setTimeout / setInterval for improved uncaught error tracking.
209
+ This results in improved uncaught error tracking for cross-origin errors,
210
+ but may have adverse effects on website performance and stability.
211
+
212
+ #### HTTP request instrumentation
213
+
214
+ - **Propagate Trace Header Cors URLs**<br>
215
+ key: `propagateTraceHeadersCorsURLs`<br>
216
+ type: `Array<RegExp>`<br>
217
+ optional: `true`<br>
218
+ default: `undefined`<br>
219
+ An array of URL regular expressions for which trace context headers should be sent across origins by http client instrumentations.
220
+ NOTE: Any cross origin endpoints allowed via this option need to include `traceparent` in the `Access-Control-Allow-Headers`
221
+ response header. Misconfiguration will cause request failures!
222
+ - **Max Wait For Resource Timings**<br>
223
+ key: `maxWaitForResourceTimingsMillis`<br>
224
+ type: `number`<br>
225
+ optional: `true`<br>
226
+ default: `10000`<br>
227
+ How long to wait after an XMLHttpRequest or fetch request has finished for the retrieval of resource timing data.
228
+ Performance timeline events are placed on the low priority task queue and therefore high values might be necessary.
229
+ - **Max Tolerance For Resource Timings**<br>
230
+ key: `maxToleranceForResourceTimingsMillis`<br>
231
+ type: `number`<br>
232
+ optional: `true`<br>
233
+ default: `3000`<br>
234
+ The number of milliseconds of tolerance between resolution of a http request promise and the end time of performanceEntries
235
+ applied when matching a request to its respective performance entry. A higher value might increase match frequency at
236
+ the cost of potential incorrect matches. Matching is performed based on request timing and url.
237
+ - **Headers to Capture**<br>
238
+ key: `headersToCapture`<br>
239
+ type: `Array<RegExp>`<br>
240
+ optional: `true`<br>
241
+ default: `undefined`<br>
242
+ A set of regular expressions that will be matched against HTTP request headers,
243
+ to be captured in `XMLHttpRequest` and `fetch` Instrumentations. These headers will be transferred as span attributes.
244
+
245
+ #### Page view instrumentation
246
+
247
+ - **Provide Page Metadata**<br>
248
+ key: `pageViewInstrumentation.generateMetadata`<br>
249
+ type: `(url: URL) => PageViewMeta | undefined`<br>
250
+ optional: `true`<br>
251
+ default: `undefined`<br>
252
+ Allows websites to dynamically provide page metadata based on the current url. Metadata may include the page title
253
+ and a set of attributes. See [PageViewMeta](https://github.com/dash0hq/dash0-sdk-web/blob/main/src/vars.ts#L25) for
254
+ detailed type information.
255
+ - **Track Virtual Page Views**<br>
256
+ key: `pageViewInstrumentation.trackVirtualPageViews`<br>
257
+ type: `boolean`<br>
258
+ optional: `true`<br>
259
+ default: `true`<br>
260
+ Whether the sdk should track virtual page views by instrumenting the history api.
261
+ Only relevant for websites utilizing virtual navigation.
262
+ - **Track Url Part Changes**<br>
263
+ key: `pageViewInstrumentation.includeParts`<br>
264
+ type: `Array<"HASH" | "SEARCH">`<br>
265
+ optional: `true`<br>
266
+ default: `[]`<br>
267
+ Additionally generate virtual page views when these url parts change.
268
+ - "HASH" changes to the urls hash / fragment
269
+ - "SEARCH" changes to the urls search / query parameters
270
+
271
+ ## API
272
+
273
+ The SDK provides several API functions to help you customize telemetry collection and add contextual information to your signals.
274
+
275
+ ### Signal attributes
276
+
277
+ Functions for managing custom attributes that are included with all signals.
278
+
279
+ #### `addSignalAttribute(name, value)`
280
+
281
+ Adds a signal attribute to be transmitted with every signal.
282
+
283
+ **Parameters:**
284
+
285
+ - `name` (string): The attribute name
286
+ - `value` (AttributeValueType | AnyValue): The attribute value
287
+
288
+ **Example:**
289
+
290
+ ```js
291
+ import { addSignalAttribute } from "@dash0/sdk-web";
292
+
293
+ addSignalAttribute("environment", "production");
294
+ addSignalAttribute("version", "1.2.3");
295
+ ```
296
+
297
+ **Note:** If you need to ensure attributes are included with signals transmitted on initial page load, use the `additionalSignalAttributes` property in the `init()` call instead.
298
+
299
+ #### `removeSignalAttribute(name)`
300
+
301
+ Removes a previously added signal attribute.
302
+
303
+ **Parameters:**
304
+
305
+ - `name` (string): The attribute name to remove
306
+
307
+ **Example:**
308
+
309
+ ```js
310
+ import { removeSignalAttribute } from "@dash0/sdk-web";
311
+
312
+ removeSignalAttribute("environment");
313
+ ```
314
+
315
+ ### User identification
316
+
317
+ #### `identify(id, opts)`
318
+
319
+ Associates user information with telemetry signals.
320
+ See [OTEL User Attributes](https://opentelemetry.io/docs/specs/semconv/registry/attributes/user/) for the matching attributes
321
+
322
+ **Parameters:**
323
+
324
+ - `id` (string, optional): User identifier
325
+ - `opts` (object, optional): Additional user information
326
+ - `name` (string, optional): Short name or login/username of the user
327
+ - `fullName` (string, optional): User's full name
328
+ - `email` (string, optional): User email address
329
+ - `hash` (string, optional): Unique user hash to correlate information for a user in anonymized form.
330
+ - `roles` (string[], optional): User roles
331
+
332
+ **Example:**
333
+
334
+ ```js
335
+ import { identify } from "@dash0/sdk-web";
336
+
337
+ identify("user123", {
338
+ name: "johndoe",
339
+ fullName: "John Doe",
340
+ email: "john@example.com",
341
+ roles: ["admin", "user"],
342
+ });
343
+ ```
344
+
345
+ ### Custom Events
346
+
347
+ #### `sendEvent(name, opts)`
348
+
349
+ Sends a custom event with optional data and attributes.
350
+ Event name cannot be one of the event names internally used by the SDK. See [Event Names](https://github.com/dash0hq/dash0-sdk-web/blob/main/src/semantic-conventions.ts#L50)
351
+
352
+ **Parameters:**
353
+
354
+ - `name` (string): Event name
355
+ - `opts` (object, optional): Event options
356
+ - `title` (string, optional): Human readable title for the event. Should summarize the event in a single short sentence.
357
+ - `timestamp` (number | Date, optional): Event timestamp
358
+ - `data` (AttributeValueType | AnyValue, optional): Event data
359
+ - `attributes` (Record<string, AttributeValueType | AnyValue>, optional): Event attributes
360
+ - `severity` (LOG_SEVERITY_TEXT, optional): Log severity level
361
+
362
+ **Example:**
363
+
364
+ ```js
365
+ import { sendEvent } from "@dash0/sdk-web";
366
+
367
+ sendEvent("user_action", {
368
+ data: "button_clicked",
369
+ attributes: {
370
+ buttonId: "submit-form",
371
+ page: "/checkout",
372
+ },
373
+ severity: "INFO",
374
+ });
375
+ ```
376
+
377
+ ### Error Reporting
378
+
379
+ #### `reportError(error, opts)`
380
+
381
+ Manually reports an error to be tracked in telemetry.
382
+
383
+ **Parameters:**
384
+
385
+ - `error` (string | ErrorLike): Error message or error object
386
+ - `opts` (object, optional): Error reporting options
387
+ - `componentStack` (string | null | undefined): Component stack trace for React errors
388
+
389
+ **Example:**
390
+
391
+ ```js
392
+ import { reportError } from "@dash0/sdk-web";
393
+
394
+ // Report a string error
395
+ reportError("Something went wrong in user flow");
396
+
397
+ // Report an Error object
398
+ try {
399
+ // Some operation
400
+ } catch (error) {
401
+ reportError(error);
402
+ }
403
+
404
+ // Report with component stack (useful for React)
405
+ reportError(error, {
406
+ componentStack: getComponentStack(),
407
+ });
408
+ ```
409
+
410
+ ### Session Management
411
+
412
+ #### `terminateSession()`
413
+
414
+ Manually terminates the current user session.
415
+
416
+ **Example:**
417
+
418
+ ```js
419
+ import { terminateSession } from "@dash0/sdk-web";
420
+
421
+ // Terminate session on user logout
422
+ function handleLogout() {
423
+ terminateSession();
424
+ // Additional logout logic
425
+ }
426
+ ```
427
+
428
+ **Note:** Sessions are automatically managed by the SDK based on inactivity and termination timeouts configured during initialization. Manual termination is typically only needed for explicit user logout scenarios.
429
+
430
+ ## Development
431
+
432
+ ### Releases
433
+
434
+ This project follows the [Semantic Versioning](https://semver.org/) scheme `MAJOR.MINOR.PATH`.
435
+ In this means:
436
+
437
+ - `MAJOR` versions are released for significant changes in operation or backward incompatible API changes.
438
+ - `MINOR` versions add functionality in a backward compatible manner.
439
+ - `PATCH` versions include bug and security fixes which do not break backward compatibility.
440
+
441
+ We automatically release new versions of this package whenever a PR is merged to main and the ci is able to detect a
442
+ valid version increase from the merge commit. It uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
443
+ to calculate the version increase and to generate additional messaging such as changelogs.
444
+ Please make sure PR merge commits are formatted accordingly, not matching messages will create a PATCH release, but no
445
+ changelog entry.
446
+ Examples:
447
+
448
+ - A `PATCH` release:
449
+ ```
450
+ fix: Include missing user.name attribute
451
+ ```
452
+ - A `MINOR` release:
453
+
454
+ ```
455
+ feat: Add instrumentation for fetch()
456
+
457
+ The sdk now supports automatic instrumentation of the fetch api
458
+ ```
459
+
460
+ - A `MAJOR` release:
461
+
462
+ ```
463
+ feat: Add version two of page-load instrumentation
464
+
465
+ BREAKING CHANGE: This adds a new updated instrumentation for page-loads, it is no longer
466
+ compatible with the previous version. For instructions on how to update see: https://example.com
467
+ ```
468
+
469
+ or:
470
+
471
+ ```
472
+ feat!: Add version two of page-load instrumentation
473
+
474
+ This adds a new updated instrumentation for page-loads, it is no longer
475
+ compatible with the previous version. For instructions on how to update see: https://example.com
476
+ ```
477
+
478
+ - NO changelog entry, PATCH release:
479
+ ```
480
+ chore: Improve spelling of README
481
+ ```
482
+
483
+ ### E2E Tests
484
+
485
+ We run e2e tests via webdriverIO and lambda test.
486
+ They currently don't have a fully local setup, but tests can be executed locally targeting chrome headless via `pnpm run test:e2e:local`.
487
+
488
+ #### Setup
489
+
490
+ - Get a labmda test account
491
+ - Create a `.env` file based on `.env.example` and provide your lambda test credentials.
492
+ - Run the tests via `pnpm run test:e2e`
493
+
494
+ #### Why do tests run on ports 8010, 8011 and 8012?
495
+
496
+ We need multiple ports to properly test cors behaviour.
@@ -0,0 +1,2 @@
1
+ !function(){"use strict";function t(){}o("log");var e=o("info"),n=o("warn"),r=o("error"),i=o("debug");function o(e){return"undefined"==typeof console||"function"!=typeof console.log||"function"!=typeof console.log.apply?t:console[e]&&"function"==typeof console[e].apply?function(){console[e].apply(console,arguments)}:function(){console.log.apply(console,arguments)}}var a=Object.prototype.hasOwnProperty;function u(t,e){return a.call(t,e)}var s="undefined"!=typeof window?window:void 0,c=null==s?void 0:s.document,l=null==s?void 0:s.navigator,f="undefined"!=typeof location?location:void 0,d=(null==s?void 0:s.performance)||(null==s?void 0:s.webkitPerformance)||(null==s?void 0:s.msPerformance)||(null==s?void 0:s.mozPerformance);null==s||s.encodeURIComponent;var v=null==s?void 0:s.fetch,p=function(){try{var t;return null!==(t=null==s?void 0:s.localStorage)&&void 0!==t?t:null}catch(t){return null}}(),h=function(){try{var t;return null!==(t=null==s?void 0:s.sessionStorage)&&void 0!==t?t:null}catch(t){return null}}(),m=Array(32);function y(t){for(var e=0;e<2*t;e++)m[e]=Math.floor(16*Math.random())+48,m[e]>=58&&(m[e]+=39);return String.fromCharCode.apply(null,m.slice(0,2*t))}function g(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent&&t.attachEvent("on"+e,n)}var b=null!=p&&"function"==typeof p.getItem&&"function"==typeof p.setItem;function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function T(t,e,n,r,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void n(t)}u.done?e(s):Promise.resolve(s).then(r,i)}function w(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function a(t){T(o,r,i,a,u,"next",t)}function u(t){T(o,r,i,a,u,"throw",t)}a(void 0)}))}}function S(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=_(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw o}}}}function A(){A=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",u=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,n){return t[e]=n}}function l(t,e,n,r){var o=e&&e.prototype instanceof y?e:y,a=Object.create(o.prototype),u=new R(r||[]);return i(a,"_invoke",{value:O(t,n,u)}),a}function f(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var d="suspendedStart",v="suspendedYield",p="executing",h="completed",m={};function y(){}function g(){}function b(){}var E={};c(E,a,(function(){return this}));var T=Object.getPrototypeOf,w=T&&T(T(x([])));w&&w!==n&&r.call(w,a)&&(E=w);var S=b.prototype=y.prototype=Object.create(E);function I(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function N(t,e){function n(i,o,a,u){var s=f(t[i],t,o);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,u)}),(function(t){n("throw",t,a,u)})):e.resolve(l).then((function(t){c.value=t,a(c)}),(function(t){return n("throw",t,a,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,i){n(t,r,e,i)}))}return o=o?o.then(i,i):i()}})}function O(e,n,r){var i=d;return function(o,a){if(i===p)throw Error("Generator is already running");if(i===h){if("throw"===o)throw a;return{value:t,done:!0}}for(r.method=o,r.arg=a;;){var u=r.delegate;if(u){var s=_(u,r);if(s){if(s===m)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===d)throw i=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=p;var c=f(e,n,r);if("normal"===c.type){if(i=r.done?h:v,c.arg===m)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=h,r.method="throw",r.arg=c.arg)}}}function _(e,n){var r=n.method,i=e.iterator[r];if(i===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,_(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var o=f(i,e.iterator,n.arg);if("throw"===o.type)return n.method="throw",n.arg=o.arg,n.delegate=null,m;var a=o.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function x(e){if(e||""===e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(r.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(S,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=c(b,s,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,c(t,s,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},I(N.prototype),c(N.prototype,u,(function(){return this})),e.AsyncIterator=N,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new N(l(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},I(S),c(S,s,"Generator"),c(S,a,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=x,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(r,i){return u.type="throw",u.arg=e,n.next=r,i&&(n.method="next",n.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],u=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),C(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;C(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:x(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function I(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,a,u=[],s=!0,c=!1;try{if(o=(n=n.call(t)).next,0===e);else for(;!(s=(r=o.call(n)).done)&&(u.push(r.value),u.length!==e);s=!0);}catch(t){c=!0,i=t}finally{try{if(!s&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return u}}(t,e)||_(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function N(t){return function(t){if(Array.isArray(t))return E(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||_(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(t){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(t)}function _(t,e){if(t){if("string"==typeof t)return E(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?E(t,e):void 0}}function L(){return(new Date).getTime()}function C(){var t=x();return t?String(1e6*(d.now()+t)):R(new Date)}function R(t){return"object"===O(t)?R(t.getTime()):String(t)+"000000"}function x(){var t,e=null==d?void 0:d.timeOrigin;"number"!=typeof e&&(e=null==d||null===(t=d.timing)||void 0===t?void 0:t.fetchStart);return e}var D={setTimeout:null==s?void 0:s.setTimeout,clearTimeout:null==s?void 0:s.clearTimeout,setInterval:null==s?void 0:s.setInterval,clearInterval:null==s?void 0:s.clearInterval},k=null!=s&&null!=s.Zone&&null!=s.Zone.root&&"function"==typeof s.Zone.root.run;function P(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.apply("setTimeout",arguments)}function j(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return M.apply("setInterval",arguments)}function M(){var t,e=this;if(k)try{var r=Array.prototype.slice.apply(arguments);return s.Zone.root.run(D[e],s,r)}catch(t){n("Failed to execute %s inside of zone (via Zone.js). Falling back to execution inside currently active zone.",e,t)}return null===(t=D[e])||void 0===t?void 0:t.apply(s,arguments)}k&&i("Discovered Zone.js globals. Will attempt to register all timers inside the root Zone.");d&&d.getEntriesByType;var U=d&&"function"==typeof s.PerformanceObserver&&"function"==typeof d.now,F=Object.freeze({CONNECT_END:"connectEnd",CONNECT_START:"connectStart",DECODED_BODY_SIZE:"decodedBodySize",DOM_COMPLETE:"domComplete",DOM_CONTENT_LOADED_EVENT_END:"domContentLoadedEventEnd",DOM_CONTENT_LOADED_EVENT_START:"domContentLoadedEventStart",DOM_INTERACTIVE:"domInteractive",DOMAIN_LOOKUP_END:"domainLookupEnd",DOMAIN_LOOKUP_START:"domainLookupStart",ENCODED_BODY_SIZE:"encodedBodySize",FETCH_START:"fetchStart",LOAD_EVENT_END:"loadEventEnd",LOAD_EVENT_START:"loadEventStart",NAVIGATION_START:"navigationStart",REDIRECT_END:"redirectEnd",REDIRECT_START:"redirectStart",REQUEST_START:"requestStart",RESPONSE_END:"responseEnd",RESPONSE_START:"responseStart",SECURE_CONNECTION_START:"secureConnectionStart",START_TIME:"startTime",UNLOAD_EVENT_END:"unloadEventEnd",UNLOAD_EVENT_START:"unloadEventStart"});function V(e){return U?{start:function(){n=d.now();try{var t,e=null==s?void 0:s.PerformanceObserver;if(e)null===(t=o=new e(f))||void 0===t||t.observe({type:"resource"})}catch(t){}u=P(p,6e5)},end:function(){r=d.now(),h(),i||!B()?l():(g(c,"visibilitychange",v),a=P(l,e.maxWaitForResourceMillis))},cancel:p}:function(e){var n=0;return{start:function(){n=L()},end:function(){return e({duration:L()-n})},cancel:t}}(e.onEnd);var n,r,i,o,a,u;function l(){var t;p(),null!==(t=i)&&void 0!==t&&t.duration&&i.duration<864e5?e.onEnd({resource:i,duration:Math.round(i.duration)}):e.onEnd({resource:i,duration:Math.round(r-n)})}function f(t){var o=t.getEntriesByType("resource").find((function(t){var i=t;return i.startTime>=n&&(!r||r+e.maxToleranceForResourceTimingsMillis>=i.responseEnd)&&e.resourceMatcher(i)}));o&&(i=o,r&&l())}function v(){B()||l()}function p(){!function(){if(o){try{var t;null===(t=o)||void 0===t||t.disconnect()}catch(t){}o=void 0}}(),a&&(clearTimeout(a),a=void 0),h(),function(){if(!c)return;t=c,e="visibilitychange",n=v,t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent&&t.detachEvent("on"+e,n);var t,e,n}()}function h(){u&&(clearTimeout(u),u=void 0)}}function B(){return"visible"===(null==c?void 0:c.visibilityState)||"prerender"===(null==c?void 0:c.visibilityState)}var W="undefined";function q(t){return Math.round(100*t)/100}function H(t){var e;return"string"!=typeof t?t:new URL(t,null!==(e=null==c?void 0:c.baseURI)&&void 0!==e?e:null==f?void 0:f.href)}function z(t){try{return H(t).origin===("undefined"!=typeof location?location.origin:void 0)}catch(t){return!1}}var G=Symbol.for("INSTRUMENTED_BY_DASH0");function K(t,e,n){var r=t[e];r?(!0===r[G]&&i("".concat(String(e)," has already been instrumented, skipping")),function(t){t[G]=!0}(r),t[e]=n(r)):i("".concat(String(e)," is not defined, unable to instrument"))}var Z={endpoints:[],resource:{attributes:[]},scope:{name:"dash0-web-sdk",version:"0.6.2",attributes:[]},signalAttributes:[],ignoreUrls:[],ignoreErrorMessages:[],wrapEventHandlers:!0,wrapTimers:!0,propagateTraceHeadersCorsURLs:[],maxWaitForResourceTimingsMillis:1e4,maxToleranceForResourceTimingsMillis:3e3,headersToCapture:[],pageViewInstrumentation:{trackVirtualPageViews:!0,includeParts:[]}};function Y(t,e){for(var n=0,r=t.length;n<r;n++)if(t[n].test(e))return!0;return!1}var Q="data:";function X(t){return!t||(!(t=String(t))||(null==t.substring||t.substring(0,5).toLowerCase()===Q||(!!function(t){for(var e=t.toLowerCase(),n=0,r=Z.endpoints.length;n<r;n++){var i=Z.endpoints[n];if(e.startsWith(i.url))return!0}return!1}(t)||Y(Z.ignoreUrls,t))))}var $=!1;function J(t){var e,n,r=[];return n=i,$&&n(),c&&s&&(g(c,"visibilitychange",(function(){"visible"!==c.visibilityState&&n()})),g(s,"pagehide",(function(){$=!0,n()})),g(s,"beforeunload",(function(){$=!0,n()}))),{send:function(n){"visible"===(null==c?void 0:c.visibilityState)?(r.push(n),r.length>=15?i():null==e&&(e=P(i,1e3))):t([n])}};function i(){null!=e&&(clearTimeout(e),e=null),r.length>0&&(t(r.slice()),r.length=0)}}function tt(t,e){return et.apply(this,arguments)}function et(){return et=w(A().mark((function e(r,i){var o,a,u,s;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=JSON.stringify(i),a=o,u=o.length,s=!1,"undefined"==typeof CompressionStream){e.next=10;break}return e.next=7,nt(o);case 7:a=e.sent,u=a.byteLength,s=!0;case 10:return e.next=12,Promise.all(Z.endpoints.map(function(){var e=w(A().mark((function e(i){var o,c,l;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,(o=new URL(i.url)).pathname=o.pathname+(o.pathname.endsWith("/")?r.substring(1):r),c={"Content-Type":"application/json",Authorization:"Bearer ".concat(i.authToken)},i.dataset&&(c["Dash0-Dataset"]=i.dataset),s&&(c["Content-Encoding"]="gzip"),v){e.next=9;break}return n("Unable to send telemetry, fetch is not defined"),e.abrupt("return");case 9:return e.next=11,v(o,{method:"POST",headers:c,body:a,keepalive:u<=6e4});case 11:(l=e.sent).text().catch(t),l.ok||n("Failed to send telemetry to ".concat(o,": ").concat(l.status," ").concat(l.statusText)),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(0),n("Error sending telemetry to ".concat(i.url).concat(r,":"),e.t0);case 19:case"end":return e.stop()}}),e,null,[[0,16]])})));return function(t){return e.apply(this,arguments)}}()));case 12:case"end":return e.stop()}}),e)}))),et.apply(this,arguments)}function nt(t){return rt.apply(this,arguments)}function rt(){return(rt=w(A().mark((function t(e){var n,r,i;return A().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new Blob([e]),r=n.stream(),i=r.pipeThrough(new CompressionStream("gzip")),t.abrupt("return",new Response(i).arrayBuffer());case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}var it,ot=J((function(t){tt("/v1/logs",{resourceLogs:[{resource:Z.resource,scopeLogs:[{scope:Z.scope,logRecords:t}]}]}).catch((function(t){r("Failed to transmit logs",t)}))})),at=J((function(t){tt("/v1/traces",{resourceSpans:[{resource:Z.resource,scopeSpans:[{scope:Z.scope,spans:t}]}]}).catch((function(t){r("Failed to transmit spans",t)}))}));function ut(){var t,e,n,r,i,o,a;return it||(e=(t={maxCalls:8096,maxCallsPerTenMinutes:4096,maxCallsPerTenSeconds:128}).maxCalls,n=t.maxCallsPerTenMinutes,r=t.maxCallsPerTenSeconds,i=0,o=0,a=0,j((function(){o=0}),6e5),j((function(){a=0}),1e4),it=function(){return++i>e||++o>n||++a>r}),it()}function st(t){ut()?i("Transport rate limit. Will not send item.",t):ot.send(t)}function ct(t){ut()?i("Transport rate limit. Will not send item.",t):at.send(t)}var lt="service.name",ft="service.version",dt="deployment.environment.name",vt="deployment.name",pt="deployment.id",ht="event.name",mt="page.load.id",yt="user_agent.original",gt="user.id",bt="user.name",Et="user.full_name",Tt="user.email",wt="user.hash",St="user.roles",At="exception.message",It="exception.type",Nt="exception.stacktrace",Ot="url.full",_t={PAGE_VIEW:"browser.page_view",NAVIGATION_TIMING:"browser.navigation_timing",WEB_VITAL:"browser.web_vital",ERROR:"browser.error"},Lt={UNSPECIFIED:0,TRACE:1,DEBUG:5,INFO:9,WARN:13,ERROR:17,FATAL:21},Ct=0,Rt=1,xt="pushState",Dt="replaceState",kt=["stringValue","boolValue","intValue","doubleValue","arrayValue","kvlistValue","bytesValue"];function Pt(t){if(null!=t){var e={};return Array.isArray(t)?e.arrayValue={values:t.map((function(t){return Pt(t)}))}:"string"==typeof t?e.stringValue=t:"number"==typeof t?e.doubleValue=t:"boolean"==typeof t?e.boolValue=t:!function(t){if(null==t||"object"!==O(t))return!1;var e=Object.keys(t);return 1===e.length&&kt.includes(e[0])}(t)?"object"===O(t)&&(e.kvlistValue={values:Object.entries(t).map((function(t){var e=I(t,2);return jt(e[0],e[1])}))}):e=t,e}}function jt(t,e){return{key:t,value:Pt(e)}}function Mt(t,e,n){t.push(jt(e,n))}function Ut(t,e){var n=t.findIndex((function(t){return t.key===e}));-1!==n&&t.splice(n,1)}var Ft="traceparent",Vt=/^00-([a-f0-9]{32})-([a-f0-9]{16})-[0-9]{1,2}$/;function Bt(){var t,e,n=((null===(t=Array.from(null!==(e=null==c?void 0:c.getElementsByTagName("meta"))&&void 0!==e?e:[]).find((function(t){var e;return(null===(e=t.getAttribute("name"))||void 0===e?void 0:e.toLowerCase())===Ft})))||void 0===t?void 0:t.content.trim())||"").match(Vt)||function(){var t=d.getEntriesByType("navigation")[0];if(!t)return"";if(!t.serverTiming)return"";return function(t){var e,n=S(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;if(r.name===Ft)return r.description.trim()}}catch(t){n.e(t)}finally{n.f()}return""}(t.serverTiming)}().match(Vt);if(n)return{traceId:n[1],spanId:n[2]}}function Wt(t,e,n){t.call(e,"traceparent","00-".concat(n.traceId,"-").concat(n.spanId,"-03"))}function qt(t,e,n){var r=t;return e&&(r.status=e),r.endTimeUnixNano=null!=n?String(Math.round(parseInt(r.startTimeUnixNano)+n)):C(),r}function Ht(t,e,n,r){var i=void 0,o=void 0;"string"==typeof n?i=n:Array.isArray(n)&&(o=n),t.events.push({name:e,timeUnixNano:null!=i?i:C(),attributes:null!=o?o:[]})}var zt="d0_session",Gt="#",Kt=864e5,Zt=null;function Yt(t,e){if(b){t||(t=108e5),e||(e=216e5),t=Math.min(t,Kt),e=Math.min(e,Kt);try{var r=function(t){return b&&p?p.getItem(t):null}(zt),o=function(t){if(!t)return null;var e=t.split(Gt);if(e.length<3)return null;var n=e[0],r=parseInt(e[1],10),i=parseInt(e[2],10);if(!n||isNaN(r)||isNaN(i))return null;return{id:n,startTime:r,lastActivityTime:i}}(r);o&&!function(t,e,n){var r=L()-e;if(t.lastActivityTime<r)return!1;var i=L()-n;return t.startTime>=i}(o,t,e)&&(o=null),o?o.lastActivityTime=L():o={id:y(16),startTime:L(),lastActivityTime:L()},function(t,e){b&&p&&p.setItem(t,e)}(zt,function(t){return t.id+Gt+t.startTime+Gt+t.lastActivityTime}(o)),Zt=o.id}catch(t){n("Failed to record session information",t)}}else i("Storage API is not available and session tracking is therefore not supported.")}var Qt=null!=h&&"function"==typeof h.getItem&&"function"==typeof h.setItem;var Xt="d0_tab",$t=null;function Jt(){if(Qt)try{var t=function(t){return Qt&&h?h.getItem(t):null}(Xt);if(t)return void($t=t);$t=y(8),function(t,e){Qt&&h&&h.setItem(t,e)}(Xt,$t)}catch(t){n("Failed to record tab ID information",t)}else i("Storage API is not available and tab tracking is therefore not supported.")}function te(t,e){for(var n,r,i,o,a,u=0;u<Z.signalAttributes.length;u++)t.push(Z.signalAttributes[u]);!function(t,e){try{var n=H(e);n.username&&(n.username="REDACTED"),n.password&&(n.password="REDACTED"),Mt(t,Ot,n.href),Mt(t,"url.path",n.pathname),Mt(t,"url.domain",n.hostname),Mt(t,"url.scheme",n.protocol.replace(":","")),n.hash&&Mt(t,"url.fragment",n.hash.replace("#","")),n.search&&Mt(t,"url.query",n.search.replace("?",""))}catch(n){Mt(t,Ot,String(e))}}(t,null!==(n=null!==(r=null==e?void 0:e.url)&&void 0!==r?r:null==s?void 0:s.location.href)&&void 0!==n?n:W),Zt&&Mt(t,"session.id",Zt),$t&&Mt(t,"browser.tab.id",$t),Mt(t,"browser.window.width",null!==(i=null==s?void 0:s.innerWidth)&&void 0!==i?i:W),Mt(t,"browser.window.height",null!==(o=null==s?void 0:s.innerHeight)&&void 0!==o?o:W);var c=null==l||null===(a=l.connection)||void 0===a?void 0:a.effectiveType;c&&Mt(t,"network.connection.subtype",c)}var ee,ne=0,re=0,ie={},oe=!1;function ae(){oe=!0}function ue(t,e){t&&se("string"==typeof t?{message:t,opts:e}:{message:t.message,type:t.name,stack:t.stack,opts:e})}function se(t){var e=t.message,n=t.type,r=t.stack,i=t.opts;if(e&&!(ne>100)&&!function(t){return!t||Y(Z.ignoreErrorMessages,t)}(e)){re>=20&&(ie={},re=0);var o=(e=String(e).substring(0,300))+(r=function(t){return String(t||"").split("\n").slice(0,30).join("\n")}(r))+(null==s?void 0:s.location.href),a=ie[o];if(a)a.seenCount++;else{var u=[];Mt(u,ht,_t.ERROR),Mt(u,At,e),n&&Mt(u,It,n),r&&Mt(u,Nt,r),null!=i&&i.componentStack&&Mt(u,"exception.component_stack",null==i?void 0:i.componentStack.substring(0,2048)),te(u),a={seenCount:1,transmittedCount:0,log:{timeUnixNano:C(),attributes:u,severityNumber:Lt.ERROR,severityText:"ERROR",body:{stringValue:e}}},ie[o]=a,re++}!function(){if(ee)return;ee=setTimeout(ce,1e3)}()}}function ce(){for(var t in ee&&(clearTimeout(ee),ee=null),ie)if(u(ie,t)){var e=ie[t];e.seenCount>e.transmittedCount&&(st(e.log),ne++)}ie={},re=0}var le,fe=-1,de=function(t){addEventListener("pageshow",(function(e){e.persisted&&(fe=e.timeStamp,t(e))}),!0)},ve=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},pe=function(){var t=ve();return t&&t.activationStart||0},he=function(t,e){var n=ve(),r="navigate";return fe>=0?r="back-forward-cache":n&&(document.prerendering||pe()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:t,value:void 0===e?-1:e,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r}},me=function(t,e,n){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var r=new PerformanceObserver((function(t){Promise.resolve().then((function(){e(t.getEntries())}))}));return r.observe(Object.assign({type:t,buffered:!0},n||{})),r}}catch(t){}},ye=function(t,e,n,r){var i,o;return function(a){e.value>=0&&(a||r)&&((o=e.value-(i||0))||void 0===i)&&(i=e.value,e.delta=o,e.rating=function(t,e){return t>e[1]?"poor":t>e[0]?"needs-improvement":"good"}(e.value,n),t(e))}},ge=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},be=function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))},Ee=function(t){var e=!1;return function(){e||(t(),e=!0)}},Te=-1,we=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},Se=function(t){"hidden"===document.visibilityState&&Te>-1&&(Te="visibilitychange"===t.type?t.timeStamp:0,Ie())},Ae=function(){addEventListener("visibilitychange",Se,!0),addEventListener("prerenderingchange",Se,!0)},Ie=function(){removeEventListener("visibilitychange",Se,!0),removeEventListener("prerenderingchange",Se,!0)},Ne=function(){return Te<0&&(Te=we(),Ae(),de((function(){setTimeout((function(){Te=we(),Ae()}),0)}))),{get firstHiddenTime(){return Te}}},Oe=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},_e=[1800,3e3],Le=[.1,.25],Ce=function(t,e){e=e||{},function(t,e){e=e||{},Oe((function(){var n,r=Ne(),i=he("FCP"),o=me("paint",(function(t){t.forEach((function(t){"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-pe(),0),i.entries.push(t),n(!0)))}))}));o&&(n=ye(t,i,_e,e.reportAllChanges),de((function(r){i=he("FCP"),n=ye(t,i,_e,e.reportAllChanges),ge((function(){i.value=performance.now()-r.timeStamp,n(!0)}))})))}))}(Ee((function(){var n,r=he("CLS",0),i=0,o=[],a=function(t){t.forEach((function(t){if(!t.hadRecentInput){var e=o[0],n=o[o.length-1];i&&t.startTime-n.startTime<1e3&&t.startTime-e.startTime<5e3?(i+=t.value,o.push(t)):(i=t.value,o=[t])}})),i>r.value&&(r.value=i,r.entries=o,n())},u=me("layout-shift",a);u&&(n=ye(t,r,Le,e.reportAllChanges),be((function(){a(u.takeRecords()),n(!0)})),de((function(){i=0,r=he("CLS",0),n=ye(t,r,Le,e.reportAllChanges),ge((function(){return n()}))})),setTimeout(n,0))})))},Re=0,xe=1/0,De=0,ke=function(t){t.forEach((function(t){t.interactionId&&(xe=Math.min(xe,t.interactionId),De=Math.max(De,t.interactionId),Re=De?(De-xe)/7+1:0)}))},Pe=function(){return le?Re:performance.interactionCount||0},je=function(){"interactionCount"in performance||le||(le=me("event",ke,{type:"event",buffered:!0,durationThreshold:0}))},Me=[],Ue=new Map,Fe=0,Ve=[],Be=function(t){if(Ve.forEach((function(e){return e(t)})),t.interactionId||"first-input"===t.entryType){var e=Me[Me.length-1],n=Ue.get(t.interactionId);if(n||Me.length<10||t.duration>e.latency){if(n)t.duration>n.latency?(n.entries=[t],n.latency=t.duration):t.duration===n.latency&&t.startTime===n.entries[0].startTime&&n.entries.push(t);else{var r={id:t.interactionId,latency:t.duration,entries:[t]};Ue.set(r.id,r),Me.push(r)}Me.sort((function(t,e){return e.latency-t.latency})),Me.length>10&&Me.splice(10).forEach((function(t){return Ue.delete(t.id)}))}}},We=function(t){var e=self.requestIdleCallback||self.setTimeout,n=-1;return t=Ee(t),"hidden"===document.visibilityState?t():(n=e(t),be(t)),n},qe=[200,500],He=function(t,e){"PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype&&(e=e||{},Oe((function(){var n;je();var r,i=he("INP"),o=function(t){We((function(){t.forEach(Be);var e=function(){var t=Math.min(Me.length-1,Math.floor((Pe()-Fe)/50));return Me[t]}();e&&e.latency!==i.value&&(i.value=e.latency,i.entries=e.entries,r())}))},a=me("event",o,{durationThreshold:null!==(n=e.durationThreshold)&&void 0!==n?n:40});r=ye(t,i,qe,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),be((function(){o(a.takeRecords()),r(!0)})),de((function(){Fe=Pe(),Me.length=0,Ue.clear(),i=he("INP"),r=ye(t,i,qe,e.reportAllChanges)})))})))},ze=[2500,4e3],Ge={};function Ke(){!function(t,e){e=e||{},Oe((function(){var n,r=Ne(),i=he("LCP"),o=function(t){e.reportAllChanges||(t=t.slice(-1)),t.forEach((function(t){t.startTime<r.firstHiddenTime&&(i.value=Math.max(t.startTime-pe(),0),i.entries=[t],n())}))},a=me("largest-contentful-paint",o);if(a){n=ye(t,i,ze,e.reportAllChanges);var u=Ee((function(){Ge[i.id]||(o(a.takeRecords()),a.disconnect(),Ge[i.id]=!0,n(!0))}));["keydown","click"].forEach((function(t){addEventListener(t,(function(){return We(u)}),{once:!0,capture:!0})})),be(u),de((function(r){i=he("LCP"),n=ye(t,i,ze,e.reportAllChanges),ge((function(){i.value=performance.now()-r.timeStamp,Ge[i.id]=!0,n(!0)}))}))}}))}(Ze),He(Ze),Ce(Ze)}function Ze(t){var e=[];Mt(e,ht,_t.WEB_VITAL);var n=[];Mt(n,"name",t.name),Mt(n,"value",q(t.value)),Mt(n,"delta",q(t.delta));var r={timeUnixNano:C(),attributes:e,severityNumber:Lt.INFO,severityText:"INFO",body:{kvlistValue:{values:n}}};te(r.attributes),st(r)}var Ye="Unhandled promise rejection: ",Qe="<unavailable because Promise wasn't rejected with an Error object>";function Xe(t){null==t.reason?ue({message:Ye+"<no reason defined>",stack:Qe}):"string"==typeof t.reason.message?ue({message:Ye+t.reason.message,stack:"string"==typeof t.reason.stack?t.reason.stack:Qe}):"object"!==O(t.reason)&&ue({message:Ye+t.reason,stack:Qe})}var $e="__dash0OriginalFunctions";function Je(t,e){for(var n=t[$e],r=0;r<n.length;r++){if(tn(n[r].valuesForEqualityCheck,e))return r}return-1}function tn(t,e){if(t.length!==e.length)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function en(t,e,n,r,i){return function(t,e,n){if(!t)return e;var r=t[$e]=t[$e]||[],i=Je(t,n);return-1!==i?r[i].wrappedFunction:(r.push({wrappedFunction:e,valuesForEqualityCheck:n}),e)}(t,e,nn(n,r,i))}function nn(t,e,n){return[t,e,rn(n)]}function rn(t){return null!=t&&("object"===O(t)?Boolean(t.capture):Boolean(t))}function on(t,e,n,r,i){return function(t,e,n){var r=null==t?void 0:t[$e];if(null==r)return n;var i=Je(t,e);if(-1===i)return n;var o=r[i];return r.splice(i,1),o.wrappedFunction}(t,nn(e,n,r),i)}function an(){Z.wrapEventHandlers&&function(t){if(!t||"function"!=typeof t.prototype.addEventListener||"function"!=typeof t.prototype.removeEventListener)return;var e=t.prototype.addEventListener,n=t.prototype.removeEventListener;t.prototype.addEventListener=function(t,n,r){if("function"!=typeof n)return e.apply(this,arguments);for(var i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=arguments[o];return i[1]=function(){try{return n.apply(this,arguments)}catch(t){throw reportError(t),ae(),t}},i[1]=en(this,i[1],t,n,r),e.apply(this,i)},t.prototype.removeEventListener=function(t,e,r){if("function"!=typeof e)return n.apply(this,arguments);for(var i=new Array(arguments.length),o=0;o<arguments.length;o++)i[o]=arguments[o];return i[1]=on(this,t,e,r,e),n.apply(this,i)}}(null==s?void 0:s.EventTarget)}function un(t){var e=null==s?void 0:s[t];"function"==typeof e&&(s[t]=function(t){for(var n=new Array(arguments.length),r=0;r<arguments.length;r++)n[r]=arguments[r];return n[0]=function(t){if("function"!=typeof t)return t;return function(){try{return t.apply(this,arguments)}catch(t){throw reportError(t),ae(),t}}}(t),e.apply(this,n)})}function sn(){!function(){if(s){var t=s.onerror;s.onerror=function(e,n,r,i,o){if(oe)return oe=!1,"function"==typeof t?t.apply(this,arguments):void 0;var a=o&&o.stack;return a||(a="at "+n+" "+r,null!=i&&(a+=":"+i)),se({message:String(e),stack:a}),"function"==typeof t?t.apply(this,arguments):void 0}}}(),"function"==typeof(null==s?void 0:s.addEventListener)&&s.addEventListener("unhandledrejection",Xe),an(),function(){if(Z.wrapTimers){if(k)return void n("We discovered a usage of Zone.js. In order to avoid any incompatibility issues timer wrapping is not going to be enabled.");un("setTimeout"),un("setInterval")}}()}var cn=["GET","HEAD","POST","PUT","DELETE","CONNECT","OPTIONS","TRACE","PATCH"];function ln(t){return cn.includes(t)}function fn(t,e){var n=0!==e.startTime;dn(t,F.FETCH_START,e,n),dn(t,F.DOMAIN_LOOKUP_START,e,n),dn(t,F.DOMAIN_LOOKUP_END,e,n),dn(t,F.CONNECT_START,e,n),dn(t,F.SECURE_CONNECTION_START,e,n),dn(t,F.CONNECT_END,e,n),dn(t,F.REQUEST_START,e,n),dn(t,F.RESPONSE_START,e,n),dn(t,F.RESPONSE_END,e,n)}function dn(t,e,n){var r,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];!(e in n)||"number"!=typeof n[e]||i&&0===n[e]||Ht(t,e,(r=n[e],String(Math.round(1e6*(r+x())))))}function vn(t,e){var n=e.encodedBodySize;null!=n&&Mt(t.attributes,"http.response.body.size",n)}function pn(t){return function(){var e=w(A().mark((function e(n,r){var o,a,u,s,c,l,f,d,v,p,h,m,g,b;return A().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(u=r?Object.assign({},r):r,s=null,null!==(o=u)&&void 0!==o&&o.body&&(s=u.body,u.body=void 0),c=new Request(n,u),s&&u&&(u.body=s),!X(l=c.url)){e.next=9;break}return i("Not creating span for fetch call because the url is ignored, URL: ".concat(l)),e.abrupt("return",t(n instanceof Request?c:n,r));case 9:return f=null!==(a=c.method)&&void 0!==a?a:"GET",d=ln(f),v=ln(f.toUpperCase()),p=v?f.toUpperCase():"_OTHER",E="HTTP ".concat(p),te((h={traceId:y(16),spanId:y(8),name:E,kind:3,startTimeUnixNano:C(),attributes:[],events:[],links:[],status:{code:0}}).attributes,{url:l}),hn(n,r),Mt(h.attributes,"http.request.method",p),d||Mt(h.attributes,"http.request.method_original",f),(z(l)||Y(Z.propagateTraceHeadersCorsURLs,l))&&(null!==(m=u)&&void 0!==m&&m.headers?(u.headers=new Headers(u.headers),Wt(u.headers.append,u.headers,h)):n instanceof Request?Wt(c.headers.append,c.headers,h):(u||(u={}),u.headers=new Headers,Wt(u.headers.append,u.headers,h))),mn(c.headers,h,(function(t){return e=t,"".concat("http.request.header",".").concat(e.toLowerCase());var e})),g=V({resourceMatcher:function(t){var e=t.initiatorType,n=t.name;return("fetch"===e||"xmlhttprequest"===e)&&n===H(l).href},maxWaitForResourceMillis:Z.maxWaitForResourceTimingsMillis,maxToleranceForResourceTimingsMillis:Z.maxToleranceForResourceTimingsMillis,onEnd:function(t){var e=t.duration,n=t.resource;n&&(fn(h,n),vn(h,n)),ct(qt(h,void 0,1e6*e))}}),g.start(),e.prev=23,e.next=26,t(n instanceof Request?c:n,u);case 26:return b=e.sent,yn(h,b),gn(b).then((function(){return g.end()})).catch((function(t){g.cancel(),bn(h,t)})),e.abrupt("return",b);case 32:throw e.prev=32,e.t0=e.catch(23),g.cancel(),bn(h,e.t0),e.t0;case 37:case"end":return e.stop()}var E}),e,null,[[23,32]])})));return function(t,n){return e.apply(this,arguments)}}()}function hn(t,e,n){try{return void 0}catch(n){i("failed to analyze request for GraphQL insights",n,t,e)}}function mn(t,e,n){try{t.forEach((function(t,r){Z.headersToCapture.some((function(t){return t.test(r)}))&&Mt(e.attributes,n(r),t)}))}catch(t){i("unable to capture http headers due to CORS policy")}}function yn(t,e){var n=e.status;!function(t,e,n){t.status={code:e,message:n}}(t,n>=200&&n<400?0:2,e.statusText),Mt(t.attributes,"http.response.status_code",String(n)),mn(e.headers,t,(function(t){return e=t,"".concat("http.response.header",".").concat(e.toLowerCase());var e}))}function gn(t){return new Promise((function(e){var n=t.clone().body;if(!n)return e();var r=n.getReader(),i=function(){var t=w(A().mark((function t(){var n;return A().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,r.read();case 2:if(n=t.sent,!n.done){t.next=6;break}return t.abrupt("return",e());case 6:return t.abrupt("return",i());case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return i()}))}function bn(t,e){!function(t,e){var n=[];"string"==typeof e?Mt(n,At,e):e&&(e.code?Mt(n,It,e.code.toString()):e.name&&Mt(n,It,e.name),e.message&&Mt(n,At,e.message),e.stack&&Mt(n,Nt,e.stack),Ht(t,"exception",n))}(t,e),ct(qt(t,function(t){return{code:2,message:t&&"object"===O(t)&&"message"in t?t.message:String(t)}}(e),void 0))}function En(t,e,n,r){var i,o,a=function(t){var e,n,r;return t&&null!==(e=null===(n=(r=Z.pageViewInstrumentation).generateMetadata)||void 0===n?void 0:n.call(r,t))&&void 0!==e?e:{}}(e),u=[];Mt(u,ht,_t.PAGE_VIEW),a.attributes&&Object.entries(a.attributes).forEach((function(t){var e=I(t,2),n=e[0],r=e[1];return Mt(u,n,r)})),te(u,{url:e});var s=[];Mt(s,"title",null!==(i=null!==(o=a.title)&&void 0!==o?o:null==c?void 0:c.title)&&void 0!==i?i:W),null!=c&&c.referrer&&Mt(s,"referrer",c.referrer),Mt(s,"type",n?Rt:Ct),Mt(s,"change_state",r?Dt:xt);var l={timeUnixNano:t,attributes:u,severityNumber:Lt.INFO,severityText:"INFO",body:{kvlistValue:{values:s}}},f=Bt();f&&(l.traceId=f.traceId,l.spanId=f.spanId),st(l)}function Tn(){var t=null==s?void 0:s.performance.getEntriesByType("navigation")[0];if(t){var e=[];Mt(e,ht,_t.NAVIGATION_TIMING);var n=[];Mt(n,"name",t.name),wn(n,t,"responseStatus"),wn(n,t,"fetchStart"),wn(n,t,"requestStart"),wn(n,t,"responseStart"),wn(n,t,"domInteractive"),wn(n,t,"domContentLoadedEventEnd"),wn(n,t,"domComplete"),wn(n,t,"loadEventEnd"),wn(n,t,"transferSize"),wn(n,t,"encodedBodySize"),wn(n,t,"decodedBodySize");var r={timeUnixNano:Sn(),attributes:e,severityNumber:Lt.INFO,severityText:"INFO",body:{kvlistValue:{values:n}}};te(r.attributes);var o=Bt();o&&(r.traceId=o.traceId,r.spanId=o.spanId),st(r)}else i("Navigation timings not available. Cannot emit navigation timing log")}function wn(t,e,n){var r=e[n];"number"!=typeof r||isNaN(r)||Mt(t,n,Number.isInteger(r)?r:q(r))}function Sn(){return R(Math.round(x()))}var An={},In=!1,Nn=!1;function On(){Ln(null==s?void 0:s.location.href)}function _n(t){Ln(t.newURL)}function Ln(t,e){var n;if(t)try{var r=new URL(t,null==s?void 0:s.location.href);((n=r).pathname!==An.path||Nn&&n.search!==An.search||In&&n.hash!==An.hash)&&(Cn(r),En(C(),r,!0,Boolean(e)))}catch(t){i("Failed to handle url change",t)}}function Cn(t){An.path=t.pathname,An.search=t.search,An.hash=t.hash}function Rn(){!function(){try{En(Sn(),null!=s&&s.location.href?new URL(null==s?void 0:s.location.href):void 0)}catch(t){r("Failed to transmit initial page view event",t)}if("complete"===(null==c?void 0:c.readyState))return Tn();s&&g(s,"load",(function(){setTimeout(Tn,0)}))}(),function(){var t,e,n,r;if(s&&s.history){if(Z.pageViewInstrumentation.trackVirtualPageViews){Nn=null!==(t=null===(e=Z.pageViewInstrumentation.includeParts)||void 0===e?void 0:e.includes("SEARCH"))&&void 0!==t&&t,In=null!==(n=null===(r=Z.pageViewInstrumentation.includeParts)||void 0===r?void 0:r.includes("HASH"))&&void 0!==n&&n,K(s.history,"replaceState",(function(t){return function(e,n,r){return Ln(r?String(r):void 0,!0),t.apply(this,[e,n,r])}})),K(s.history,"pushState",(function(t){return function(e,n,r){return Ln(r?String(r):void 0),t.apply(this,[e,n,r])}})),s.addEventListener("hashchange",_n),s.addEventListener("popstate",On);try{Cn(new URL(s.location.href))}catch(t){}}}else i("Browser does not support history API, skipping instrumentation")}()}var xn=function(t){if("object"===O(t)&&null!==t){if("function"==typeof Object.getPrototypeOf){var e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1},Dn=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.reduce((function(t,e){if(void 0===e)return t;if(Array.isArray(e))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(e).forEach((function(n){["__proto__","constructor","prototype"].includes(n)||(Array.isArray(t[n])&&Array.isArray(e[n])?t[n]=Dn.options.mergeArrays?Dn.options.uniqueArrayItems?Array.from(new Set(t[n].concat(e[n]))):[].concat(N(t[n]),N(e[n])):e[n]:xn(t[n])&&xn(e[n])?t[n]=Dn(t[n],e[n]):!xn(t[n])&&xn(e[n])?t[n]=Dn(e[n],void 0):t[n]=void 0===e[n]?Dn.options.allowUndefinedOverrides?e[n]:t[n]:e[n])})),t}),{})},kn={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};Dn.options=kn,Dn.withOptions=function(t){Dn.options=Object.assign(Object.assign({},kn),t);for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var i=Dn.apply(void 0,n);return Dn.options=kn,i};var Pn=!1;var jn={init:function(t){Pn?i("Dash0 SDK is being reinitialized, skipping ..."):null!=s?"function"==typeof v&&d&&d.getEntriesByType?(Z.endpoints=t.endpoint instanceof Array?t.endpoint:[t.endpoint],0!==Z.endpoints.length?(Object.assign(Z,Dn(Z,function(t,e){var n,r={},i=S(e);try{for(i.s();!(n=i.n()).done;){var o=n.value;o in t&&(r[o]=t[o])}}catch(t){i.e(t)}finally{i.f()}return r}(t,["ignoreUrls","ignoreErrorMessages","wrapEventHandlers","wrapTimers","propagateTraceHeadersCorsURLs","maxWaitForResourceTimingsMillis","maxToleranceForResourceTimingsMillis","headersToCapture","pageViewInstrumentation"]))),function(t){Mt(Z.resource.attributes,lt,t.serviceName),t.serviceVersion&&Mt(Z.resource.attributes,ft,t.serviceVersion);var e=function(t){if(t.environment)return t.environment;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_ENV}catch(t){return}}(t);e&&Mt(Z.resource.attributes,dt,e);var n=function(t){if(t.deploymentName)return t.deploymentName;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_TARGET_ENV}catch(t){return}}(t);n&&Mt(Z.resource.attributes,vt,n);var r=function(t){if(t.deploymentId)return t.deploymentId;try{var e;return null===(e=process)||void 0===e||null===(e=e.env)||void 0===e?void 0:e.NEXT_PUBLIC_VERCEL_BRANCH_URL}catch(t){return}}(t);r&&Mt(Z.resource.attributes,pt,r)}(t),function(t){var e;Mt(Z.signalAttributes,mt,y(16)),Mt(Z.signalAttributes,yt,null!==(e=null==l?void 0:l.userAgent)&&void 0!==e?e:W),t.additionalSignalAttributes&&Object.entries(t.additionalSignalAttributes).forEach((function(t){var e=I(t,2),n=e[0],r=e[1];Mt(Z.signalAttributes,n,r)}))}(t),Jt(),Yt(t.sessionInactivityTimeoutMillis,t.sessionTerminationTimeoutMillis),Rn(),Ke(),sn(),s&&s.fetch&&s.Request?K(s,"fetch",pn):i("Browser does not support the Fetch API, skipping instrumentation"),Pn=!0):n("No telemetry endpoint configured. Aborting Dash0 Web SDK initialization process.")):i("Stopping Dash0 Web SDK initialization. This browser does not support the necessary APIs"):i("Looks like we are not running in a browser context. Stopping Dash0 Web SDK initialization.")},debug:function(){i("Dash0 Web SDK configuration state:",Z)},identify:function(t,e){Ut(Z.signalAttributes,gt),null!=t&&Mt(Z.signalAttributes,gt,t),Ut(Z.signalAttributes,bt),null!=(null==e?void 0:e.name)&&Mt(Z.signalAttributes,bt,e.name),Ut(Z.signalAttributes,Et),null!=(null==e?void 0:e.fullName)&&Mt(Z.signalAttributes,Et,e.fullName),Ut(Z.signalAttributes,Tt),null!=(null==e?void 0:e.email)&&Mt(Z.signalAttributes,Tt,e.email),Ut(Z.signalAttributes,wt),null!=(null==e?void 0:e.hash)&&Mt(Z.signalAttributes,wt,e.hash),Ut(Z.signalAttributes,St),null!=(null==e?void 0:e.roles)&&Mt(Z.signalAttributes,St,e.roles)},terminateSession:function(){if(Zt=null,b)try{!function(t){b&&p&&p.removeItem(t)}(zt)}catch(t){e("Failed to terminate session",t)}},reportError:function(t,e){ue(t,e)},addSignalAttribute:function(t,e){Mt(Z.signalAttributes,t,e)},removeSignalAttribute:function(t){Ut(Z.signalAttributes,t)},sendEvent:function(t,e){var r;if(Object.values(_t).includes(t))n("Unable to send custom event ".concat(t,". You are not allowed to use an internal event name while sending a custom event. Dropping event..."));else{var i=[];te(i),Object.entries(null!==(r=null==e?void 0:e.attributes)&&void 0!==r?r:{}).forEach((function(t){var e=I(t,2),n=e[0],r=e[1];return Mt(i,n,r)})),Mt(i,ht,t),null!=e&&e.title&&Mt(i,"dash0.event.title",e.title),st({timeUnixNano:null!=(null==e?void 0:e.timestamp)?R(e.timestamp):C(),attributes:i,body:Pt(null==e?void 0:e.data),severityText:null==e?void 0:e.severity,severityNumber:null!=e&&e.severity?Lt[e.severity]:void 0})}}};function Mn(t){var e=t[0],r=jn[e];if(r){for(var i=[],o=1;o<t.length;o++)i.push(t[o]);r.apply(null,i)}else n("Unsupported Dash0 Web SDK api: ",t[0])}!function(){i("".concat("Initializing Dash0 Web SDK"," (via Script)"));var t=s.dash0;if(!t)return void n("global 'dash0' not found. Did you use the correct Dash0 Web SDK initializer?");if(!t._q)return void n("Dash0 Web SDK command queue not defined. Did you add the script tag multiple times to your website?");(function(t){for(var e=0,n=t.length;e<n;e++)Mn(t[e])})(t._q),s.dash0=function(){return Mn(arguments)}}()}();
2
+ //# sourceMappingURL=dash0.iife.js.map