@dynatrace/rum-javascript-sdk 1.333.15 → 1.335.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.
- package/dist/api/interactions.d.ts +22 -0
- package/dist/api/interactions.js +48 -0
- package/dist/api/promises/interactions.d.ts +15 -0
- package/dist/api/promises/interactions.js +19 -0
- package/dist/api/promises/wait-for-interactions.d.ts +9 -0
- package/dist/api/promises/wait-for-interactions.js +18 -0
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/install.js +1 -1
- package/dist/testing/test.d.ts +1 -119
- package/dist/testing/test.js +12 -11
- package/dist/testing/types/dynatrace-config.d.ts +36 -0
- package/dist/testing/types/dynatrace-config.js +2 -0
- package/dist/testing/types/dynatrace-testing-fixtures.d.ts +24 -0
- package/dist/testing/types/dynatrace-testing-fixtures.js +2 -0
- package/dist/testing/types/dynatrace-testing.d.ts +66 -0
- package/dist/testing/types/dynatrace-testing.js +2 -0
- package/dist/types/api/dynatrace-api-types.d.ts +91 -1
- package/dist/types/api/dynatrace-api-types.js +1 -1
- package/dist/types/rum-events/json-event.d.ts +1 -1
- package/dist/types/rum-events/json-event.js +1 -1
- package/dist/types/rum-events/rum-internal-selfmonitoring-event.d.ts +4 -0
- package/dist/types/rum-events/rum-internal-selfmonitoring-event.js +5 -1
- package/dist/types/rum-events/rum-user-interaction-event.d.ts +17 -0
- package/dist/types/rum-events/rum-user-interaction-event.js +19 -1
- package/docs/1-overview.md +41 -0
- package/docs/2-testing.md +3 -3
- package/docs/3-types.md +1 -0
- package/docs/4-useractions.md +1 -1
- package/docs/5-interactions.md +60 -0
- package/package.json +19 -3
package/docs/1-overview.md
CHANGED
|
@@ -18,6 +18,7 @@ This package provides two main API approaches for interacting with the Dynatrace
|
|
|
18
18
|
- **Synchronous API**: Safe wrapper functions that gracefully handle cases where the RUM JavaScript is not available
|
|
19
19
|
- **Asynchronous API**: Promise-based functions that wait for the RUM JavaScript to become available
|
|
20
20
|
- **User Actions API**: Manual control over user action creation and lifecycle (see [User Actions API](./4-useractions.md))
|
|
21
|
+
- **Interactions API**: Report custom user interaction events (see [Interactions API](./5-interactions.md))
|
|
21
22
|
- **TypeScript Support**: Comprehensive type definitions for all RUM API functions
|
|
22
23
|
- **Testing Framework**: Playwright-based utilities for testing RUM integration
|
|
23
24
|
|
|
@@ -195,6 +196,32 @@ const yourError = new Error("Your Error Message");
|
|
|
195
196
|
sendExceptionEvent(yourError, { "event_properties.component": "myExampleComponent" });
|
|
196
197
|
```
|
|
197
198
|
|
|
199
|
+
### Interactions API (`@dynatrace/rum-javascript-sdk/api/interactions`)
|
|
200
|
+
|
|
201
|
+
#### `sendKeyPressEvent(fields, elementOrEvent?): void`
|
|
202
|
+
|
|
203
|
+
Sends a user interaction event to report custom keyboard shortcuts or key combinations.
|
|
204
|
+
Only available if the User Interaction module is enabled.
|
|
205
|
+
|
|
206
|
+
**Parameters:**
|
|
207
|
+
|
|
208
|
+
- `fields: SendUserInteractionFields` - Must be a JSON-serializable object with a `keys` array (at least one key).
|
|
209
|
+
Optional `ui_element.custom_name` and `event_properties.*` entries are allowed.
|
|
210
|
+
- `elementOrEvent?: Element | KeyboardEvent` - Optional Element or KeyboardEvent to auto-capture UI element fields.
|
|
211
|
+
|
|
212
|
+
**Example:**
|
|
213
|
+
```typescript
|
|
214
|
+
import * as interactions from '@dynatrace/rum-javascript-sdk/api/interactions';
|
|
215
|
+
import { UserInteractionSpecialKey } from '@dynatrace/rum-javascript-sdk/types/rum-events';
|
|
216
|
+
|
|
217
|
+
interactions.sendKeyPressEvent({
|
|
218
|
+
keys: [UserInteractionSpecialKey.CTRL, "S"],
|
|
219
|
+
"event_properties.context": "editor"
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
For detailed documentation and examples, see [Interactions API](./5-interactions.md).
|
|
224
|
+
|
|
198
225
|
### Asynchronous API (`@dynatrace/rum-javascript-sdk/promises`)
|
|
199
226
|
|
|
200
227
|
The asynchronous API provides Promise-based functions that wait for the Dynatrace RUM JavaScript to become available. These functions will throw a `DynatraceError` if the RUM JavaScript is not available within the specified timeout. This is useful for scenarios where you don't want to
|
|
@@ -285,6 +312,20 @@ Only available if the Errors module is enabled.
|
|
|
285
312
|
- `error: Error` - The error object to report. Must be an instance of the standard JavaScript `Error` class.
|
|
286
313
|
- `fields: ApiCreatedEventPropertiesEvent` - Optional Event properties object. Must be serializable JSON with properties prefixed with `event_properties.`, plus optional `duration` and `start_time` properties.
|
|
287
314
|
|
|
315
|
+
### Interactions API (`@dynatrace/rum-javascript-sdk/api/promises/interactions`)
|
|
316
|
+
|
|
317
|
+
#### `sendKeyPressEvent(fields, elementOrEvent?, timeout?): Promise<void>`
|
|
318
|
+
|
|
319
|
+
Async wrapper for sending a user interaction event, with automatic waiting for RUM JavaScript availability.
|
|
320
|
+
Only available if the User Interaction module is enabled.
|
|
321
|
+
|
|
322
|
+
**Parameters:**
|
|
323
|
+
|
|
324
|
+
- `fields: SendUserInteractionFields` - Must be a JSON-serializable object with a `keys` array (at least one key).
|
|
325
|
+
Optional `ui_element.custom_name` and `event_properties.*` entries are allowed.
|
|
326
|
+
- `elementOrEvent?: Element | KeyboardEvent` - Optional Element or KeyboardEvent to auto-capture UI element fields.
|
|
327
|
+
- `timeout?: number` - Timeout in milliseconds to wait for RUM JavaScript (default: 10,000)
|
|
328
|
+
|
|
288
329
|
### User Actions API
|
|
289
330
|
|
|
290
331
|
Both synchronous and asynchronous wrappers are available for the User Actions API. For detailed documentation and examples, see [User Actions API](./4-useractions.md).
|
package/docs/2-testing.md
CHANGED
|
@@ -372,10 +372,10 @@ The snapshot files contain JSON-formatted event data with ignored fields replace
|
|
|
372
372
|
|
|
373
373
|
#### Updating Snapshots
|
|
374
374
|
|
|
375
|
-
To update snapshots when event structures change intentionally, run Playwright with the `--update-snapshots` flag:
|
|
375
|
+
To update snapshots when event structures change intentionally, run Playwright with the `--update-snapshots=all` flag:
|
|
376
376
|
|
|
377
377
|
```bash
|
|
378
|
-
npx playwright test --update-snapshots
|
|
378
|
+
npx playwright test --update-snapshots=all
|
|
379
379
|
```
|
|
380
380
|
|
|
381
381
|
#### Default Ignored Fields
|
|
@@ -417,7 +417,7 @@ When a snapshot comparison fails, the error message includes:
|
|
|
417
417
|
3. Instructions for updating the snapshot
|
|
418
418
|
|
|
419
419
|
Common causes of snapshot failures:
|
|
420
|
-
- **New fields added to events**: Update the snapshot with `--update-snapshots`
|
|
420
|
+
- **New fields added to events**: Update the snapshot with `--update-snapshots=all`
|
|
421
421
|
- **Volatile field values**: Add the field to `ignoredFields` to replace values with `[IGNORED]`
|
|
422
422
|
- **Varying field presence**: Add the field to `removedFields` (use `fieldname.*` wildcard to remove all fields with that prefix)
|
|
423
423
|
- **Unwanted events**: Add an event pattern to `ignoreEvents` to filter them out
|
package/docs/3-types.md
CHANGED
package/docs/4-useractions.md
CHANGED
|
@@ -136,7 +136,7 @@ By default, user actions are automatically closed when Dynatrace detects that th
|
|
|
136
136
|
:::caution
|
|
137
137
|
Calling `finish()` is reliable in this case because `performSomeWork()` is synchronous. If it was awaited, there is no
|
|
138
138
|
guarantee that the action would still be open when `finish()` is called, leading to unreliable action durations. See
|
|
139
|
-
|
|
139
|
+
[User action with manual control](#user-action-with-manual-control) below.
|
|
140
140
|
:::
|
|
141
141
|
|
|
142
142
|
### User action with manual control
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Interactions API
|
|
3
|
+
---
|
|
4
|
+
# Interactions API
|
|
5
|
+
|
|
6
|
+
This guide explains how to report custom interaction events that are not automatically detected.
|
|
7
|
+
|
|
8
|
+
## What you can do
|
|
9
|
+
|
|
10
|
+
- Report custom keyboard shortcuts or key combinations via `sendKeyPressEvent`
|
|
11
|
+
- Attach `ui_element.custom_name` and `event_properties.*` fields
|
|
12
|
+
- Provide an `Element` or `KeyboardEvent` to capture UI element fields
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- New RUM Experience is enabled for your application
|
|
17
|
+
|
|
18
|
+
## API approaches
|
|
19
|
+
|
|
20
|
+
You can use the Interactions API directly, or via its synchronous or asynchronous SDK functions, matching the pattern established in the [RUM JavaScript SDK Overview](./1-overview.md):
|
|
21
|
+
|
|
22
|
+
### Direct API (via `dynatrace.interactions`)
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
dynatrace?.interactions?.sendKeyPressEvent({
|
|
26
|
+
keys: ["A"]
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Safe Wrapper API (recommended)
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import * as interactions from "@dynatrace/rum-javascript-sdk/api/interactions";
|
|
34
|
+
import { UserInteractionSpecialKey } from "@dynatrace/rum-javascript-sdk/types/rum-events";
|
|
35
|
+
|
|
36
|
+
interactions.sendKeyPressEvent({
|
|
37
|
+
keys: [UserInteractionSpecialKey.CTRL, "S"],
|
|
38
|
+
"event_properties.context": "editor"
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Async API
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { sendKeyPressEvent } from "@dynatrace/rum-javascript-sdk/api/promises/interactions";
|
|
46
|
+
import { UserInteractionSpecialKey } from "@dynatrace/rum-javascript-sdk/types/rum-events";
|
|
47
|
+
|
|
48
|
+
await sendKeyPressEvent({
|
|
49
|
+
keys: [UserInteractionSpecialKey.CTRL, "S"]
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## sendKeyPressEvent
|
|
54
|
+
|
|
55
|
+
`sendKeyPressEvent(fields, elementOrEvent?)` reports a custom key_press interaction.
|
|
56
|
+
|
|
57
|
+
- `fields` must be a JSON-serializable object with a non-empty `keys` array.
|
|
58
|
+
- Use `UserInteractionSpecialKey` enum values for modifier and special keys (ctrl, cmd, shift, alt, esc, enter, tab, space).
|
|
59
|
+
- Optional `ui_element.custom_name` and `event_properties.*` entries are allowed.
|
|
60
|
+
- `elementOrEvent` may be an [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element) or [`KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) to derive UI element fields. If omitted, no UI element fields are added.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynatrace/rum-javascript-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.335.1",
|
|
4
4
|
"description": "JavaScript API for Real User Monitoring (RUM)",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -13,12 +13,18 @@
|
|
|
13
13
|
"api/user-actions": [
|
|
14
14
|
"./dist/api/user-actions.d.ts"
|
|
15
15
|
],
|
|
16
|
+
"api/interactions": [
|
|
17
|
+
"./dist/api/interactions.d.ts"
|
|
18
|
+
],
|
|
16
19
|
"api/promises": [
|
|
17
20
|
"./dist/api/promises/index.d.ts"
|
|
18
21
|
],
|
|
19
22
|
"api/promises/user-actions": [
|
|
20
23
|
"./dist/api/promises/user-actions.d.ts"
|
|
21
24
|
],
|
|
25
|
+
"api/promises/interactions": [
|
|
26
|
+
"./dist/api/promises/interactions.d.ts"
|
|
27
|
+
],
|
|
22
28
|
"test": [
|
|
23
29
|
"./dist/testing/index.d.ts"
|
|
24
30
|
],
|
|
@@ -63,11 +69,21 @@
|
|
|
63
69
|
"import": "./dist/api/user-actions.js",
|
|
64
70
|
"default": "./dist/api/user-actions.js"
|
|
65
71
|
},
|
|
72
|
+
"./api/interactions": {
|
|
73
|
+
"types": "./dist/api/interactions.d.ts",
|
|
74
|
+
"import": "./dist/api/interactions.js",
|
|
75
|
+
"default": "./dist/api/interactions.js"
|
|
76
|
+
},
|
|
66
77
|
"./api/promises/user-actions": {
|
|
67
78
|
"types": "./dist/api/promises/user-actions.d.ts",
|
|
68
79
|
"import": "./dist/api/promises/user-actions.js",
|
|
69
80
|
"default": "./dist/api/promises/user-actions.js"
|
|
70
81
|
},
|
|
82
|
+
"./api/promises/interactions": {
|
|
83
|
+
"types": "./dist/api/promises/interactions.d.ts",
|
|
84
|
+
"import": "./dist/api/promises/interactions.js",
|
|
85
|
+
"default": "./dist/api/promises/interactions.js"
|
|
86
|
+
},
|
|
71
87
|
"./api/promises": {
|
|
72
88
|
"types": "./dist/api/promises/index.d.ts",
|
|
73
89
|
"import": "./dist/api/promises/index.js",
|
|
@@ -134,8 +150,8 @@
|
|
|
134
150
|
"@vitest/coverage-v8": "4.1.0-beta.1",
|
|
135
151
|
"@vitest/ui": "4.1.0-beta.1",
|
|
136
152
|
"eslint": "9.38.0",
|
|
137
|
-
"jsdom": "
|
|
138
|
-
"knip": "5.
|
|
153
|
+
"jsdom": "28.0.0",
|
|
154
|
+
"knip": "5.85.0",
|
|
139
155
|
"typedoc": "0.28.10",
|
|
140
156
|
"typedoc-plugin-mdn-links": "5.0.3",
|
|
141
157
|
"typescript": "5.8.2",
|