@multiplayer-app/session-recorder-react 1.2.24 → 1.2.25
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 +34 -57
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -51,18 +51,18 @@ To get full‑stack session recording working, set up one of our backend SDKs/CL
|
|
|
51
51
|
|
|
52
52
|
## Quick start
|
|
53
53
|
|
|
54
|
-
1.
|
|
55
|
-
2.
|
|
54
|
+
1. Recommended: Call `SessionRecorder.init(options)` before you mount your React app to avoid losing any data.
|
|
55
|
+
2. Wrap your application with the `SessionRecorderProvider`.
|
|
56
56
|
3. Start or stop sessions using the widget or the provided hooks.
|
|
57
57
|
|
|
58
|
-
### Minimal setup with manual initialization
|
|
58
|
+
### Minimal setup with manual initialization (Recommended)
|
|
59
59
|
|
|
60
60
|
```tsx
|
|
61
61
|
// src/main.tsx or src/index.tsx app root
|
|
62
62
|
import React from 'react'
|
|
63
63
|
import ReactDOM from 'react-dom/client'
|
|
64
64
|
import App from './App'
|
|
65
|
-
import { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
65
|
+
import SessionRecorder, { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
66
66
|
|
|
67
67
|
const sessionRecorderConfig = {
|
|
68
68
|
version: '1.0.0',
|
|
@@ -77,8 +77,8 @@ const sessionRecorderConfig = {
|
|
|
77
77
|
propagateTraceHeaderCorsUrls: [new RegExp('https://api.example.com', 'i')]
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
// Initialize the session recorder
|
|
81
|
-
|
|
80
|
+
// Initialize the session recorder before mounting (Recommended)
|
|
81
|
+
SessionRecorder.init(sessionRecorderConfig)
|
|
82
82
|
|
|
83
83
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
84
84
|
<SessionRecorderProvider>
|
|
@@ -87,30 +87,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
87
87
|
)
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
// src/main.tsx or src/index.tsx app root
|
|
94
|
-
import React from 'react'
|
|
95
|
-
import ReactDOM from 'react-dom/client'
|
|
96
|
-
import App from './App'
|
|
97
|
-
import { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
98
|
-
|
|
99
|
-
const sessionRecorderConfig = {
|
|
100
|
-
version: '1.0.0',
|
|
101
|
-
environment: 'production',
|
|
102
|
-
application: 'my-react-app',
|
|
103
|
-
apiKey: 'YOUR_MULTIPLAYER_API_KEY'
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
107
|
-
<SessionRecorderProvider options={sessionRecorderConfig}>
|
|
108
|
-
<App />
|
|
109
|
-
</SessionRecorderProvider>
|
|
110
|
-
)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Behind the scenes, the provider initializes the shared Browser SDK (if you pass the configuration as options to the provider) — or you can initialize it manually as shown in the example above. It then sets up listeners and exposes helper APIs through React context and selectors.
|
|
90
|
+
Behind the scenes, the provider sets up listeners and exposes helper APIs through React context and selectors.
|
|
114
91
|
|
|
115
92
|
### Set session attributes to provide context for the session
|
|
116
93
|
|
|
@@ -140,16 +117,19 @@ const MyComponent = () => {
|
|
|
140
117
|
If you prefer not to render our floating widget, disable it and rely purely on the imperative hooks. Use the context hook when you need imperative control (for example, to bind to buttons or QA tooling) as shown in the example below:
|
|
141
118
|
|
|
142
119
|
```tsx
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
120
|
+
import SessionRecorder, { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
121
|
+
|
|
122
|
+
// Initialize without the built‑in widget
|
|
123
|
+
SessionRecorder.init({
|
|
124
|
+
application: 'my-react-app',
|
|
125
|
+
version: '1.0.0',
|
|
126
|
+
environment: 'production',
|
|
127
|
+
apiKey: 'YOUR_MULTIPLAYER_API_KEY',
|
|
128
|
+
showWidget: false // hide the built-in widget
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
// Wrap your app with the provider to enable hooks/context
|
|
132
|
+
<SessionRecorderProvider>
|
|
153
133
|
<App />
|
|
154
134
|
</SessionRecorderProvider>
|
|
155
135
|
```
|
|
@@ -279,7 +259,7 @@ export function NavigationTrackerLegacy() {
|
|
|
279
259
|
|
|
280
260
|
## Configuration reference
|
|
281
261
|
|
|
282
|
-
The
|
|
262
|
+
The options passed to `SessionRecorder.init(...)` are forwarded to the underlying browser SDK. Refer to the [browser README](../session-recorder-browser/README.md#initialize) for the full option list, including:
|
|
283
263
|
|
|
284
264
|
- `application`, `version`, `environment`, `apiKey`
|
|
285
265
|
- `showWidget`, `showContinuousRecording`
|
|
@@ -300,27 +280,24 @@ Any time `recordNavigation` is enabled, the browser SDK will emit OpenTelemetry
|
|
|
300
280
|
|
|
301
281
|
An official Next.js-specific wrapper is coming soon. Until then, you can use this package safely in Next.js by:
|
|
302
282
|
|
|
303
|
-
1. Initializing in a Client Component
|
|
283
|
+
1. Initializing in a Client Component (Recommended)
|
|
304
284
|
|
|
305
285
|
```tsx
|
|
306
286
|
'use client'
|
|
307
287
|
import React from 'react'
|
|
308
|
-
import { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
288
|
+
import SessionRecorder, { SessionRecorderProvider } from '@multiplayer-app/session-recorder-react'
|
|
289
|
+
|
|
290
|
+
// Initialize before mount to avoid losing any data
|
|
291
|
+
SessionRecorder.init({
|
|
292
|
+
application: 'my-next-app',
|
|
293
|
+
version: '1.0.0',
|
|
294
|
+
environment: 'production',
|
|
295
|
+
apiKey: 'YOUR_MULTIPLAYER_API_KEY',
|
|
296
|
+
showWidget: true
|
|
297
|
+
})
|
|
309
298
|
|
|
310
299
|
export function Providers({ children }: { children: React.ReactNode }) {
|
|
311
|
-
return
|
|
312
|
-
<SessionRecorderProvider
|
|
313
|
-
options={{
|
|
314
|
-
application: 'my-next-app',
|
|
315
|
-
version: '1.0.0',
|
|
316
|
-
environment: 'production',
|
|
317
|
-
apiKey: 'YOUR_MULTIPLAYER_API_KEY',
|
|
318
|
-
showWidget: true
|
|
319
|
-
}}
|
|
320
|
-
>
|
|
321
|
-
{children}
|
|
322
|
-
</SessionRecorderProvider>
|
|
323
|
-
)
|
|
300
|
+
return <SessionRecorderProvider>{children}</SessionRecorderProvider>
|
|
324
301
|
}
|
|
325
302
|
```
|
|
326
303
|
|
|
@@ -377,7 +354,7 @@ All hooks and helpers ship with TypeScript types. To extend the navigation metad
|
|
|
377
354
|
## Troubleshooting
|
|
378
355
|
|
|
379
356
|
- Ensure the provider wraps your entire component tree so context hooks resolve.
|
|
380
|
-
- Confirm `SessionRecorder.init` runs only once
|
|
357
|
+
- Confirm `SessionRecorder.init` runs only once and before your app mounts.
|
|
381
358
|
- Ensure the session recorder required options are passed and the API key is valid.
|
|
382
359
|
- For SSR environments, guard any direct `document` or `window` usage behind `typeof window !== 'undefined'` checks (the helper hooks already do this).
|
|
383
360
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplayer-app/session-recorder-react",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.25",
|
|
4
4
|
"description": "Multiplayer Fullstack Session Recorder for React (browser wrapper)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Multiplayer Software, Inc.",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@opentelemetry/api": "^1.9.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@multiplayer-app/session-recorder-browser": "1.2.
|
|
39
|
-
"@multiplayer-app/session-recorder-common": "1.2.
|
|
38
|
+
"@multiplayer-app/session-recorder-browser": "1.2.25",
|
|
39
|
+
"@multiplayer-app/session-recorder-common": "1.2.25"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"eslint": "8.48.0",
|