swish-recorder 0.1.2 → 0.1.3
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 +19 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,11 +29,15 @@ npm install swish-recorder
|
|
|
29
29
|
pnpm add swish-recorder
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
`posthog-js` must already be installed in your project. `swish-recorder` has no dependencies of its own.
|
|
33
|
+
|
|
32
34
|
---
|
|
33
35
|
|
|
34
36
|
## Usage
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
### Vanilla JS
|
|
39
|
+
|
|
40
|
+
Call `SwishRecorder.init` right after `posthog.init`. The project token is read automatically from the PostHog instance — no extra credentials needed.
|
|
37
41
|
|
|
38
42
|
```ts
|
|
39
43
|
import posthog from 'posthog-js'
|
|
@@ -49,26 +53,35 @@ SwishRecorder.init({ posthog })
|
|
|
49
53
|
|
|
50
54
|
### React
|
|
51
55
|
|
|
56
|
+
Initialize PostHog before mounting your app, then pass the instance to `PostHogProvider` via `client=`. Call `SwishRecorder.init` in between — before `createRoot`.
|
|
57
|
+
|
|
52
58
|
```tsx
|
|
53
59
|
// src/main.tsx
|
|
60
|
+
import { StrictMode } from 'react'
|
|
61
|
+
import { createRoot } from 'react-dom/client'
|
|
54
62
|
import posthog from 'posthog-js'
|
|
55
63
|
import { PostHogProvider } from 'posthog-js/react'
|
|
56
64
|
import { SwishRecorder } from 'swish-recorder'
|
|
65
|
+
import App from './App'
|
|
57
66
|
|
|
58
|
-
posthog.init(
|
|
59
|
-
api_host:
|
|
67
|
+
posthog.init(import.meta.env.VITE_PUBLIC_POSTHOG_TOKEN, {
|
|
68
|
+
api_host: import.meta.env.VITE_PUBLIC_POSTHOG_HOST,
|
|
60
69
|
defaults: '2026-01-30',
|
|
61
70
|
})
|
|
62
71
|
|
|
63
72
|
SwishRecorder.init({ posthog })
|
|
64
73
|
|
|
65
74
|
createRoot(document.getElementById('root')!).render(
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
|
|
75
|
+
<StrictMode>
|
|
76
|
+
<PostHogProvider client={posthog}>
|
|
77
|
+
<App />
|
|
78
|
+
</PostHogProvider>
|
|
79
|
+
</StrictMode>
|
|
69
80
|
)
|
|
70
81
|
```
|
|
71
82
|
|
|
83
|
+
> If you use `@posthog/react` instead of `posthog-js/react`, replace the import accordingly — the API is identical.
|
|
84
|
+
|
|
72
85
|
---
|
|
73
86
|
|
|
74
87
|
## API
|