@dash0/sdk-web 0.15.0 → 0.16.1

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 (54) hide show
  1. package/README.md +35 -515
  2. package/dist/dash0.iife.js +1 -1
  3. package/dist/dash0.iife.js.map +1 -1
  4. package/dist/dash0.js +1 -1
  5. package/dist/dash0.js.map +1 -1
  6. package/dist/dash0.umd.cjs +1 -1
  7. package/dist/dash0.umd.cjs.map +1 -1
  8. package/dist/modules/api/init.js +30 -0
  9. package/dist/modules/api/init_test.js +102 -6
  10. package/dist/modules/api/report-error.js +1 -1
  11. package/dist/modules/instrumentations/errors/event-handlers.js +2 -2
  12. package/dist/modules/instrumentations/errors/unhandled-error.js +1 -1
  13. package/dist/modules/instrumentations/errors/unhandled-promise-rejection.js +4 -4
  14. package/dist/modules/instrumentations/http/fetch.js +125 -28
  15. package/dist/modules/instrumentations/http/fetch_test.js +170 -0
  16. package/dist/modules/instrumentations/http/propagator-integration_test.js +77 -0
  17. package/dist/modules/transport/index.js +2 -0
  18. package/dist/modules/utils/index.js +1 -0
  19. package/dist/modules/utils/otel/span.js +9 -0
  20. package/dist/modules/utils/otel/trace-context.js +24 -1
  21. package/dist/modules/utils/otel/trace-context_test.js +40 -0
  22. package/dist/modules/utils/performance.js +16 -3
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/types/entrypoint/npm-package.d.ts +1 -1
  25. package/dist/types/instrumentations/errors/unhandled-error.d.ts +1 -1
  26. package/dist/types/instrumentations/http/fetch_test.d.ts +1 -0
  27. package/dist/types/instrumentations/http/propagator-integration_test.d.ts +1 -0
  28. package/dist/types/transport/index.d.ts +1 -1
  29. package/dist/types/types/options.d.ts +6 -1
  30. package/dist/types/utils/index.d.ts +1 -0
  31. package/dist/types/utils/otel/span.d.ts +5 -1
  32. package/dist/types/utils/otel/trace-context.d.ts +2 -1
  33. package/dist/types/utils/otel/trace-context_test.d.ts +1 -0
  34. package/dist/types/utils/performance.d.ts +5 -1
  35. package/dist/types/vars.d.ts +11 -0
  36. package/package.json +1 -1
  37. package/src/api/init.ts +34 -0
  38. package/src/api/init_test.ts +130 -9
  39. package/src/api/report-error.ts +1 -1
  40. package/src/entrypoint/npm-package.ts +1 -1
  41. package/src/instrumentations/errors/event-handlers.ts +2 -2
  42. package/src/instrumentations/errors/unhandled-error.ts +1 -1
  43. package/src/instrumentations/errors/unhandled-promise-rejection.ts +4 -4
  44. package/src/instrumentations/http/fetch.ts +148 -30
  45. package/src/instrumentations/http/fetch_test.ts +191 -0
  46. package/src/instrumentations/http/propagator-integration_test.ts +93 -0
  47. package/src/transport/index.ts +3 -1
  48. package/src/types/options.ts +7 -1
  49. package/src/utils/index.ts +1 -0
  50. package/src/utils/otel/span.ts +16 -1
  51. package/src/utils/otel/trace-context.ts +30 -1
  52. package/src/utils/otel/trace-context_test.ts +59 -0
  53. package/src/utils/performance.ts +21 -4
  54. package/src/vars.ts +14 -0
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Dash0 Web SDK
2
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.
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
5
 
6
6
  Features include:
7
7
 
@@ -10,522 +10,42 @@ Features include:
10
10
  - HTTP request instrumentation
11
11
  - Error tracking
12
12
 
13
- ## Getting Started
13
+ ## Getting started
14
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).
15
+ 1. Get an active Dash0 account. [Sign Up](https://www.Dash0.com/sign-up)
16
+ 1. Prepare an [Auth Token](https://www.Dash0.com/documentation/Dash0/key-concepts/auth-tokens); auth tokens for client monitoring will be public as part of your website, please make sure to:
17
17
 
18
- ### Before you begin
18
+ - Use a separate token, exclusively for website monitoring; if you want to monitor multiple websites, it is best to use a dedicated token for each
19
+ - Limit the dataset permissions on the auth token to the dataset you want to ingest Website Monitoring data with
20
+ - Limit permissions on the auth token to `Ingesting`
19
21
 
20
- You'll need a couple of prerequisites before you can start:
22
+ 1. Get 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`.
23
+ 1. Add the SDK to your dependencies
21
24
 
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: "your-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
- - **Enabled Instrumentations**<br>
98
- key: `enabledInstrumentations`<br>
99
- type: `InstrumentationName[]`<br>
100
- optional: `true`<br>
101
- default: `undefined`<br>
102
- List of instrumentations to enable. Defaults to `undefined`, enabling all instrumentations.
103
- Supported values: `'navigation' | 'web-vitals' | 'error' | 'fetch'`
104
- Please note that some dash0 features might not work as expected if instrumentations are disabled.
105
-
106
- - **Ignore URLs**<br>
107
- key: `ignoreUrls`<br>
108
- type: `Array<RegExp>`<br>
109
- optional: `true`<br>
110
- default: `undefined`<br>
111
- An array of URL regular expression for which no data should be collected.
112
- These regular expressions are evaluated against the document, XMLHttpRequest, fetch and resource URLs.
113
-
114
- - ** URL Attribute Scrubber**<br>
115
- key: `urlAttributeScrubber`<br>
116
- type: `UrlAttributeScrubber`<br>
117
- optional: `true`<br>
118
- default: `(attributes) => attributes`
119
- Allows the application of a custom scrubbing function to url attributes before they are applied to signals.
120
- This is invoked for each url processed for inclusion in signal attributes. For example this applies both to `page.url.*`
121
- and `url.*` attribute namespaces.
122
- Sensitive parts of the url attributes should be replaced with `REDACTED`,
123
- avoid partially or fully dropping attributes to preserve telemetry quality.
124
- Note: basic auth credentials in urls are automatically redacted before this is invoked.
125
-
126
- #### Website Details and Attributes
127
-
128
- - **Service Name**<br>
129
- key: `serviceName`<br>
130
- type: `string`<br>
131
- optional: `false`<br>
132
- The logical name or your website, maps to the [service.name](https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-name) otel attribute.
133
- - **Service Version**<br>
134
- key: `serviceVersion`<br>
135
- type: `string`<br>
136
- optional: `true`<br>
137
- default: `undefined`<br>
138
- The current version of your website, maps to the [service.version](https://opentelemetry.io/docs/specs/semconv/registry/attributes/service/#service-version) otel attribute.
139
- - **Environment**<br>
140
- key: `environment`<br>
141
- type: `string`<br>
142
- optional: `true`<br>
143
- default: `undefined`<br>
144
- 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.
145
- This value is [auto detected](#configuration-auto-detection) in certain build environments.
146
- - **Deployment Name**<br>
147
- key: `deploymentName`<br>
148
- type: `string`<br>
149
- optional: `true`<br>
150
- default: `undefined`<br>
151
- Name of the deployment, maps to the [deployment.name](https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-name) otel attribute.
152
- This value is [auto detected](#configuration-auto-detection) in certain build environments.
153
- - **Deployment Id**<br>
154
- key: `deploymentId`<br>
155
- type: `string`<br>
156
- optional: `true`<br>
157
- default: `undefined`<br>
158
- Id of the deployment, maps to the [deployment.id](https://opentelemetry.io/docs/specs/semconv/registry/attributes/deployment/#deployment-id) otel attribute.
159
- This value is [auto detected](#configuration-auto-detection) in certain build environments.
160
- - **Additional Signal Attributes**<br>
161
- key: `additionalSignalAttributes`<br>
162
- type: `Record<string, AttributeValueType | AnyValue>`<br>
163
- optional: `true`<br>
164
- default: `undefined`<br>
165
- Allows the configuration of additional attributes to be included with any transmitted event.
166
- 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.
167
-
168
- #### OTLP Endpoint
169
-
170
- - **Endpoint**<br>
171
- key: `endpoint`<br>
172
- type: `Endpoint | Endpoint[]`<br>
173
- optional: `false`<br>
174
- The OTLP to which the generated telemetry should be sent. Supports multiple endpoints in parallel if an array is provided.
175
- - **Endpoint URL**<br>
176
- key: `endpoint.url`<br>
177
- type: `string`<br>
178
- optional: `false`<br>
179
- The OTLP HTTP URL of the endpoint, not including the `/v1/*` part of the path
180
- - **Endpoint Auth Token**<br>
181
- key: `endpoint.authToken`<br>
182
- type: `string`<br>
183
- optional: `false`<br>
184
- The auth token used for the endpoint. Will be placed into `Authorization: Bearer {auth_token}` header.
185
- - **Endpoint Dataset**<br>
186
- key: `endpoint.dataset`<br>
187
- type: `string`<br>
188
- optional: `true`<br>
189
- Optionally specify what dataset should be placed into. Can also be configured within Dash0 through the auth token.
190
-
191
- #### Session Tracking
192
-
193
- - **Session Inactivity Timeout**<br>
194
- key: `sessionInactivityTimeoutMillis`<br>
195
- type: `number`<br>
196
- optional: `true`<br>
197
- default: `10800000` (3 hours)<br>
198
- The session inactivity timeout. Session inactivity is the maximum allowed time to pass between two page loads before
199
- the session is considered to be expired. The maximum value is the maximum session duration of 24 hours.
200
- - **Session Termination Timeout**<br>
201
- key: `sessionTerminationTimeoutMillis`<br>
202
- type: `number`<br>
203
- optional: `true`<br>
204
- default: `21600000` (6 hours)<br>
205
- The default session termination timeout. Session termination is the maximum allowed time to pass since session start
206
- before the session is considered to be expired.
207
-
208
- #### Error tracking
209
-
210
- - **Ignore Error Messages**<br>
211
- key: `ignoreErrorMessages`<br>
212
- type: `Array<RegExp>`<br>
213
- optional: `true`<br>
214
- default: `undefined`<br>
215
- An array of error message regular expressions for which no data should be collected.
216
- - **Wrap Event Handlers**<br>
217
- key: `wrapEventHandlers`<br>
218
- type: `boolean`<br>
219
- optional: `true`<br>
220
- default: `true`<br>
221
- Whether we should automatically wrap DOM event handlers added via addEventListener for improved uncaught error tracking.
222
- This results in improved uncaught error tracking for cross-origin errors,
223
- but may have adverse effects on website performance and stability.
224
- - **Wrap Timers**<br>
225
- key: `wrapTimers`<br>
226
- type: `boolean`<br>
227
- optional: `true`<br>
228
- default: `true`<br>
229
- Whether we should automatically wrap timers added via setTimeout / setInterval for improved uncaught error tracking.
230
- This results in improved uncaught error tracking for cross-origin errors,
231
- but may have adverse effects on website performance and stability.
232
-
233
- #### HTTP request instrumentation
234
-
235
- - **Propagate Trace Header Cors URLs**<br>
236
- key: `propagateTraceHeadersCorsURLs`<br>
237
- type: `Array<RegExp>`<br>
238
- optional: `true`<br>
239
- default: `undefined`<br>
240
- An array of URL regular expressions for which trace context headers should be sent across origins by http client instrumentations.
241
- NOTE: Any cross origin endpoints allowed via this option need to include `traceparent` in the `Access-Control-Allow-Headers`
242
- response header. Misconfiguration will cause request failures!
243
- - **Max Wait For Resource Timings**<br>
244
- key: `maxWaitForResourceTimingsMillis`<br>
245
- type: `number`<br>
246
- optional: `true`<br>
247
- default: `10000`<br>
248
- How long to wait after an XMLHttpRequest or fetch request has finished for the retrieval of resource timing data.
249
- Performance timeline events are placed on the low priority task queue and therefore high values might be necessary.
250
- - **Max Tolerance For Resource Timings**<br>
251
- key: `maxToleranceForResourceTimingsMillis`<br>
252
- type: `number`<br>
253
- optional: `true`<br>
254
- default: `50`<br>
255
- The number of milliseconds of tolerance between resolution of a http request promise and the end time of performanceEntries
256
- applied when matching a request to its respective performance entry. A higher value might increase match frequency at
257
- the cost of potential incorrect matches. Matching is performed based on request timing and url.
258
- - **Headers to Capture**<br>
259
- key: `headersToCapture`<br>
260
- type: `Array<RegExp>`<br>
261
- optional: `true`<br>
262
- default: `undefined`<br>
263
- A set of regular expressions that will be matched against HTTP request headers,
264
- to be captured in `XMLHttpRequest` and `fetch` Instrumentations. These headers will be transferred as span attributes.
265
-
266
- #### Page view instrumentation
267
-
268
- - **Provide Page Metadata**<br>
269
- key: `pageViewInstrumentation.generateMetadata`<br>
270
- type: `(url: URL) => PageViewMeta | undefined`<br>
271
- optional: `true`<br>
272
- default: `undefined`<br>
273
- Allows websites to dynamically provide page metadata based on the current url. Metadata may include the page title
274
- and a set of attributes. See [PageViewMeta](https://github.com/dash0hq/dash0-sdk-web/blob/main/src/vars.ts#L25) for
275
- detailed type information.
276
- - **Track Virtual Page Views**<br>
277
- key: `pageViewInstrumentation.trackVirtualPageViews`<br>
278
- type: `boolean`<br>
279
- optional: `true`<br>
280
- default: `true`<br>
281
- Whether the sdk should track virtual page views by instrumenting the history api.
282
- Only relevant for websites utilizing virtual navigation.
283
- - **Track Url Part Changes**<br>
284
- key: `pageViewInstrumentation.includeParts`<br>
285
- type: `Array<"HASH" | "SEARCH">`<br>
286
- optional: `true`<br>
287
- default: `[]`<br>
288
- Additionally generate virtual page views when these url parts change.
289
- - "HASH" changes to the urls hash / fragment
290
- - "SEARCH" changes to the urls search / query parameters
291
-
292
- ## API
293
-
294
- The SDK provides several API functions to help you customize telemetry collection and add contextual information to your signals.
295
-
296
- ### Signal attributes
297
-
298
- Functions for managing custom attributes that are included with all signals.
299
-
300
- #### `addSignalAttribute(name, value)`
301
-
302
- Adds a signal attribute to be transmitted with every signal.
303
-
304
- **Parameters:**
305
-
306
- - `name` (string): The attribute name
307
- - `value` (AttributeValueType | AnyValue): The attribute value
308
-
309
- **Example:**
310
-
311
- ```js
312
- import { addSignalAttribute } from "@dash0/sdk-web";
313
-
314
- addSignalAttribute("environment", "production");
315
- addSignalAttribute("version", "1.2.3");
316
- ```
317
-
318
- **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.
319
-
320
- #### `removeSignalAttribute(name)`
321
-
322
- Removes a previously added signal attribute.
323
-
324
- **Parameters:**
325
-
326
- - `name` (string): The attribute name to remove
327
-
328
- **Example:**
329
-
330
- ```js
331
- import { removeSignalAttribute } from "@dash0/sdk-web";
332
-
333
- removeSignalAttribute("environment");
334
- ```
335
-
336
- ### User identification
337
-
338
- #### `identify(id, opts)`
339
-
340
- Associates user information with telemetry signals.
341
- See [OTEL User Attributes](https://opentelemetry.io/docs/specs/semconv/registry/attributes/user/) for the matching attributes
342
-
343
- **Parameters:**
344
-
345
- - `id` (string, optional): User identifier
346
- - `opts` (object, optional): Additional user information
347
- - `name` (string, optional): Short name or login/username of the user
348
- - `fullName` (string, optional): User's full name
349
- - `email` (string, optional): User email address
350
- - `hash` (string, optional): Unique user hash to correlate information for a user in anonymized form.
351
- - `roles` (string[], optional): User roles
352
-
353
- **Example:**
354
-
355
- ```js
356
- import { identify } from "@dash0/sdk-web";
357
-
358
- identify("user123", {
359
- name: "johndoe",
360
- fullName: "John Doe",
361
- email: "john@example.com",
362
- roles: ["admin", "user"],
363
- });
364
- ```
365
-
366
- ### Custom Events
367
-
368
- #### `sendEvent(name, opts)`
369
-
370
- Sends a custom event with optional data and attributes.
371
- 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)
372
-
373
- **Parameters:**
374
-
375
- - `name` (string): Event name
376
- - `opts` (object, optional): Event options
377
- - `title` (string, optional): Human readable title for the event. Should summarize the event in a single short sentence.
378
- - `timestamp` (number | Date, optional): Event timestamp
379
- - `data` (AttributeValueType | AnyValue, optional): Event data
380
- - `attributes` (Record<string, AttributeValueType | AnyValue>, optional): Event attributes
381
- - `severity` (LOG_SEVERITY_TEXT, optional): Log severity level
382
-
383
- **Example:**
384
-
385
- ```js
386
- import { sendEvent } from "@dash0/sdk-web";
387
-
388
- sendEvent("user_action", {
389
- data: "button_clicked",
390
- attributes: {
391
- buttonId: "submit-form",
392
- page: "/checkout",
393
- },
394
- severity: "INFO",
395
- });
396
- ```
397
-
398
- ### Error Reporting
399
-
400
- #### `reportError(error, opts)`
401
-
402
- Manually reports an error to be tracked in telemetry.
403
-
404
- **Parameters:**
405
-
406
- - `error` (string | ErrorLike): Error message or error object
407
- - `opts` (object, optional): Error reporting options
408
- - `componentStack` (string | null | undefined): Component stack trace for React errors
409
-
410
- **Example:**
411
-
412
- ```js
413
- import { reportError } from "@dash0/sdk-web";
414
-
415
- // Report a string error
416
- reportError("Something went wrong in user flow");
417
-
418
- // Report an Error object
419
- try {
420
- // Some operation
421
- } catch (error) {
422
- reportError(error);
423
- }
424
-
425
- // Report with component stack (useful for React)
426
- reportError(error, {
427
- componentStack: getComponentStack(),
428
- });
25
+ ```sh
26
+ # npm
27
+ npm install @Dash0/sdk-web
28
+ # yarn
29
+ yarn add @Dash0/sdk-web
429
30
  ```
430
31
 
431
- ### Session Management
432
-
433
- #### `terminateSession()`
434
-
435
- Manually terminates the current user session.
436
-
437
- **Example:**
438
-
439
- ```js
440
- import { terminateSession } from "@dash0/sdk-web";
441
-
442
- // Terminate session on user logout
443
- function handleLogout() {
444
- terminateSession();
445
- // Additional logout logic
446
- }
447
- ```
448
-
449
- **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.
450
-
451
- ### Internal Telemetry
452
-
453
- #### `setActiveLogLevel(logLevel)`
454
-
455
- Changes the active log level of this SDK. Defaults to `warn`.
456
-
457
- **Example:**
458
-
459
- ```js
460
- import { setActiveLogLevel } from "@dash0/sdk-web";
461
-
462
- setActiveLogLevel("debug");
463
- ```
464
-
465
- ## Development
466
-
467
- ### Releases
468
-
469
- This project follows the [Semantic Versioning](https://semver.org/) scheme `MAJOR.MINOR.PATH`.
470
- In this means:
471
-
472
- - `MAJOR` versions are released for significant changes in operation or backward incompatible API changes.
473
- - `MINOR` versions add functionality in a backward compatible manner.
474
- - `PATCH` versions include bug and security fixes which do not break backward compatibility.
475
-
476
- We automatically release new versions of this package whenever a PR is merged to main and the CI is able to detect a
477
- valid version increase from the merge commit. It uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
478
- to calculate the version increase and to generate additional messaging such as changelogs.
479
- Please make sure PR merge commits are formatted accordingly, non matching messages will create a PATCH release, but no
480
- changelog entry.
481
- Examples:
482
-
483
- - A `PATCH` release:
484
- ```
485
- fix: Include missing user.name attribute
486
- ```
487
- - A `MINOR` release:
488
-
489
- ```
490
- feat: Add instrumentation for fetch()
491
-
492
- The sdk now supports automatic instrumentation of the fetch api
493
- ```
494
-
495
- - A `MAJOR` release:
496
-
497
- ```
498
- feat: Add version two of page-load instrumentation
499
-
500
- BREAKING CHANGE: This adds a new updated instrumentation for page-loads, it is no longer
501
- compatible with the previous version. For instructions on how to update see: https://example.com
502
- ```
503
-
504
- or:
505
-
506
- ```
507
- feat!: Add version two of page-load instrumentation
508
-
509
- This adds a new updated instrumentation for page-loads, it is no longer
510
- compatible with the previous version. For instructions on how to update see: https://example.com
511
- ```
512
-
513
- - NO changelog entry, PATCH release:
514
- ```
515
- chore: Improve spelling of README
516
- ```
517
-
518
- ### E2E Tests
519
-
520
- We run e2e tests via webdriverIO and lambda test.
521
- They currently don't have a fully local setup, but tests can be executed locally targeting chrome headless via `pnpm run test:e2e:local`.
522
-
523
- #### Setup
524
-
525
- - Get a lambda test account
526
- - Create a `.env` file based on `.env.example` and provide your lambda test credentials.
527
- - Run the tests via `pnpm run test:e2e`
528
-
529
- #### Why do tests run on ports 8010, 8011 and 8012?
530
-
531
- We need multiple ports to properly test cors behaviour.
32
+ 2. Initialize the SDK in your code: you'll need to call the `init` function at a convenient time in your applications lifecycle.
33
+ Ideally this should happen as early as possible in the web page intialization, as most instrumentations shipped by the SDK can only observe events after init has been called.
34
+
35
+ ```js
36
+ import { init } from "@Dash0/sdk-web";
37
+
38
+ init({
39
+ serviceName: "my-website",
40
+ endpoint: {
41
+ // Replace this with the endpoint URL identified during preparation
42
+ url: REPLACE THIS,
43
+ // Replace this with your auth token you created earlier
44
+ // Ideally, you will inject the value at build time in order not commit the token to git,
45
+ // even if its effectively public in the HTML you ship to the end user's browser
46
+ authToken: REPLACE THIS
47
+ },
48
+ });
49
+ ```
50
+
51
+ For more detailed instructions, refer to [`INSTALL.md`](./INSTALL.md).