swish-recorder 0.1.5 → 0.1.6

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 (2) hide show
  1. package/README.md +33 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -51,7 +51,7 @@ posthog.init('phc_your_project_token', {
51
51
  SwishRecorder.init({ posthog })
52
52
  ```
53
53
 
54
- ### React
54
+ ### React (manual init)
55
55
 
56
56
  Initialize PostHog before mounting your app, then pass the instance to `PostHogProvider` via `client=`. Call `SwishRecorder.init` in between — before `createRoot`.
57
57
 
@@ -82,6 +82,38 @@ createRoot(document.getElementById('root')!).render(
82
82
 
83
83
  > If you use `@posthog/react` instead of `posthog-js/react`, replace the import accordingly — the API is identical.
84
84
 
85
+ ### React (PostHogProvider only)
86
+
87
+ If you let `PostHogProvider` handle initialization (passing `apiKey` + `options` directly), PostHog isn't available until after it loads. Use the `loaded` callback to init SwishRecorder at that point:
88
+
89
+ ```tsx
90
+ // src/main.tsx
91
+ import { StrictMode } from 'react'
92
+ import { createRoot } from 'react-dom/client'
93
+ import { PostHogProvider } from 'posthog-js/react'
94
+ import { SwishRecorder } from 'swish-recorder'
95
+ import App from './App'
96
+
97
+ createRoot(document.getElementById('root')!).render(
98
+ <StrictMode>
99
+ <PostHogProvider
100
+ apiKey={import.meta.env.VITE_PUBLIC_POSTHOG_TOKEN}
101
+ options={{
102
+ api_host: import.meta.env.VITE_PUBLIC_POSTHOG_HOST,
103
+ defaults: '2026-01-30',
104
+ loaded: (posthog) => {
105
+ SwishRecorder.init({ posthog })
106
+ },
107
+ }}
108
+ >
109
+ <App />
110
+ </PostHogProvider>
111
+ </StrictMode>
112
+ )
113
+ ```
114
+
115
+ No separate `posthog.init` call needed — `PostHogProvider` takes care of it.
116
+
85
117
  ---
86
118
 
87
119
  ## API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swish-recorder",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "First-party session recording SDK for Swish",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",