@dev-2-dev/websdk-plugin-session-tracker 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -0
- package/dist/browser.js +4893 -0
- package/dist/browser.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.esm.js +4886 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +4891 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Session Tracker Plugin for DevToDev WebSDK
|
|
2
|
+
|
|
3
|
+
A powerful session recording plugin that automatically captures user interactions on your website using advanced screen recording technology. This plugin integrates seamlessly with the DevToDev WebSDK to provide comprehensive session replay capabilities.
|
|
4
|
+
|
|
5
|
+
## What is Session Recording?
|
|
6
|
+
|
|
7
|
+
Session recording captures everything a user does on your website - clicks, scrolls, form inputs, and page navigation - allowing you to replay their exact session later. This helps you:
|
|
8
|
+
|
|
9
|
+
- **Debug Issues**: See exactly what users experienced when they encountered errors
|
|
10
|
+
- **Improve UX**: Understand how users interact with your product
|
|
11
|
+
- **Optimize Conversion**: Identify friction points in user journeys
|
|
12
|
+
- **Support Users**: Reproduce and resolve support tickets more effectively
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Automatic Recording**: Records user sessions automatically with minimal configuration
|
|
17
|
+
- **Privacy Controls**: Built-in options to mask sensitive data like passwords
|
|
18
|
+
- **Reliable Delivery**: Ensures session data is sent even when users close the browser
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### Using NPM
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @dev-2-dev/websdk-plugin-session-tracker
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Using Yarn
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn add @dev-2-dev/websdk-plugin-session-tracker
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
The plugin integrates automatically with the DevToDev WebSDK. Simply enable it in your WebSDK configuration:
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { DTDAnalytics } from '@dev-2-dev/websdk';
|
|
40
|
+
import { D2DWebSessionTracker } from '@dev-2-dev/websdk-plugin-session-tracker';
|
|
41
|
+
|
|
42
|
+
const sessionTracker = new D2DWebSessionTracker();
|
|
43
|
+
const sdk = new DTDAnalytics();
|
|
44
|
+
|
|
45
|
+
sdk.initialize('your-app-id');
|
|
46
|
+
sdk.registerPlugin(sessionTracker);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
That's it! Session recording will start automatically for eligible sessions based on your DevToDev dashboard configuration.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
You can customize the session recording behavior in two ways:
|
|
54
|
+
|
|
55
|
+
### 1. Recording Options (Constructor Config)
|
|
56
|
+
|
|
57
|
+
Configure privacy and recording behavior when creating the tracker instance:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { D2DWebSessionTracker } from '@dev-2-dev/websdk-plugin-session-tracker';
|
|
61
|
+
|
|
62
|
+
const sessionRecordingConfig = {
|
|
63
|
+
recordCanvas: true, // Record canvas elements
|
|
64
|
+
maskAllInputs: false, // Mask all input fields
|
|
65
|
+
maskInputOptions: {
|
|
66
|
+
password: true, // Always mask password fields (default: true)
|
|
67
|
+
email: true, // Mask email fields (default: true)
|
|
68
|
+
text: false, // Don't mask text inputs (default: false)
|
|
69
|
+
},
|
|
70
|
+
blockClass: 'sensitive-field', // Block elements with this class
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const sessionTracker = new D2DWebSessionTracker(sessionRecordingConfig);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 2. Disabling from SDK Config
|
|
77
|
+
|
|
78
|
+
You can disable session recording through the SDK's `webSessions` configuration:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { DTDAnalytics } from '@dev-2-dev/websdk';
|
|
82
|
+
|
|
83
|
+
const sdk = new DTDAnalytics({
|
|
84
|
+
appId: 'your-app-id',
|
|
85
|
+
webSessions: {
|
|
86
|
+
enabled: false, // Disable session recording
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Configuration Options
|
|
92
|
+
|
|
93
|
+
These options are passed to the `D2DWebSessionTracker` constructor:
|
|
94
|
+
|
|
95
|
+
| Option | Type | Default | Description |
|
|
96
|
+
|--------|------|---------|-------------|
|
|
97
|
+
| `recordCanvas` | boolean | `true` | Record canvas elements |
|
|
98
|
+
| `maskAllInputs` | boolean | `false` | Mask all input fields |
|
|
99
|
+
| `maskInputOptions` | object | See below | Selective input masking options |
|
|
100
|
+
| `blockClass` | string | `'sensitive-field'` | CSS class name to block elements from recording |
|
|
101
|
+
|
|
102
|
+
**Mask Input Options:**
|
|
103
|
+
|
|
104
|
+
| Option | Type | Default | Description |
|
|
105
|
+
|--------|------|---------|-------------|
|
|
106
|
+
| `password` | boolean | `true` | Always mask password fields |
|
|
107
|
+
| `email` | boolean | `true` | Mask email fields |
|
|
108
|
+
| `text` | boolean | `false` | Mask text inputs |
|
|
109
|
+
|
|
110
|
+
**Example: Privacy Configuration**
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Option 1: Mask all inputs
|
|
114
|
+
const sessionTracker = new D2DWebSessionTracker({
|
|
115
|
+
maskAllInputs: true,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Option 2: Selective masking
|
|
119
|
+
const sessionTracker = new D2DWebSessionTracker({
|
|
120
|
+
maskAllInputs: false,
|
|
121
|
+
maskInputOptions: {
|
|
122
|
+
password: true, // Mask passwords
|
|
123
|
+
email: true, // Mask emails
|
|
124
|
+
text: false, // Don't mask text inputs
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Option 3: Block specific elements
|
|
129
|
+
// Add the 'sensitive-field' class to exclude elements from recording
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<!-- Add the 'sensitive-field' class to exclude elements from recording -->
|
|
134
|
+
<div class="sensitive-field">
|
|
135
|
+
<p>This content will not be recorded</p>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<input type="password" class="sensitive-field" />
|
|
139
|
+
<input type="email" class="sensitive-field" />
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## How It Works
|
|
143
|
+
|
|
144
|
+
1. **Automatic Recording**: When enabled, the plugin automatically starts recording user sessions based on your DevToDev dashboard settings (recording chance, daily/monthly limits).
|
|
145
|
+
|
|
146
|
+
2. **Event Collection**: The plugin captures user interactions, DOM changes, and page events in real-time.
|
|
147
|
+
|
|
148
|
+
3. **Batch Upload**: Session data is automatically sent to DevToDev servers in batches when:
|
|
149
|
+
- A batch size limit is reached (default: 50 events)
|
|
150
|
+
- A time interval passes (default: 30 seconds)
|
|
151
|
+
- A maximum batch size is reached (default: 1MB)
|
|
152
|
+
- The session ends (user closes tab/window)
|
|
153
|
+
|
|
154
|
+
4. **Storage**: Session data is securely stored in DevToDev's infrastructure and can be accessed through your dashboard.
|
|
155
|
+
|
|
156
|
+
## Session Recording Controls
|
|
157
|
+
|
|
158
|
+
The plugin respects configuration settings from your DevToDev dashboard:
|
|
159
|
+
|
|
160
|
+
- **Recording Chance**: Percentage of sessions to record (e.g., 10% of all sessions)
|
|
161
|
+
- **Daily Limit**: Maximum number of sessions to record per day
|
|
162
|
+
- **Monthly Limit**: Maximum number of sessions to record per month
|
|
163
|
+
- **Active/Blocked**: Global enable/disable toggle
|
|
164
|
+
|
|
165
|
+
These settings help you control costs and ensure you're only recording the sessions you need.
|
|
166
|
+
|
|
167
|
+
## Performance Impact
|
|
168
|
+
|
|
169
|
+
The session tracker plugin is designed to have minimal impact on your website's performance:
|
|
170
|
+
|
|
171
|
+
- Lightweight recording engine
|
|
172
|
+
- Efficient event batching reduces network requests
|
|
173
|
+
- Automatic session limits prevent memory issues
|
|
174
|
+
- Non-blocking uploads don't affect user experience
|
|
175
|
+
- Optimized DOM observation for minimal overhead
|
|
176
|
+
|
|
177
|
+
## Support
|
|
178
|
+
|
|
179
|
+
For issues, questions, or feature requests, please contact DevToDev support or visit our [documentation](https://docs.devtodev.com/).
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|