@posthog/nuxt 1.7.74 → 1.7.76
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/LICENSE +27 -0
- package/README.md +5 -129
- package/dist/module.json +1 -1
- package/package.json +8 -5
package/LICENSE
CHANGED
|
@@ -324,3 +324,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
324
324
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
325
325
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
326
326
|
SOFTWARE.
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
Some files in this codebase contain code from MCPCat/mcpcat-typescript-sdk.
|
|
331
|
+
In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
|
|
332
|
+
|
|
333
|
+
MIT License
|
|
334
|
+
|
|
335
|
+
Copyright (c) 2025 MCPcat
|
|
336
|
+
|
|
337
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
338
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
339
|
+
in the Software without restriction, including without limitation the rights
|
|
340
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
341
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
342
|
+
furnished to do so, subject to the following conditions:
|
|
343
|
+
|
|
344
|
+
The above copyright notice and this permission notice shall be included in all
|
|
345
|
+
copies or substantial portions of the Software.
|
|
346
|
+
|
|
347
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
348
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
349
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
350
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
351
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
352
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
353
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,136 +1,12 @@
|
|
|
1
|
-
# PostHog Nuxt
|
|
1
|
+
# PostHog Nuxt package
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
- Provides posthog client and auto exception capture for Vue and Nitro
|
|
3
|
+
Please see the main [PostHog docs](https://posthog.com/docs).
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
SDK usage examples and code snippets live in the official documentation so they stay up to date.
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Documentation
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
```
|
|
13
|
-
pnpm add @posthog/nuxt
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
2. Configure posthog module
|
|
17
|
-
|
|
18
|
-
```typescript
|
|
19
|
-
// nuxt.config.ts
|
|
20
|
-
export default defineNuxtConfig({
|
|
21
|
-
modules: ['@posthog/nuxt'], // Add module reference
|
|
22
|
-
|
|
23
|
-
sourcemap: { client: 'hidden' }, // Make sure to set it (otherwise client sourcemaps will not be generated)
|
|
24
|
-
|
|
25
|
-
nitro: {
|
|
26
|
-
rollupConfig: {
|
|
27
|
-
output: {
|
|
28
|
-
sourcemapExcludeSources: false, // Make sure to set it (otherwise server sourcemaps will not be generated)
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
posthogConfig: {
|
|
34
|
-
host: 'http://localhost:8010', // (optional) Host URL, defaults to https://us.posthog.com
|
|
35
|
-
publicKey: 'public api key', // Your public web snippet key. You can find it in settings
|
|
36
|
-
clientConfig?: Partial<PostHogConfig> // (optional) It will be passed to the posthog-js client on init in vue
|
|
37
|
-
serverConfig?: PostHogOptions // (optional) It will be passed to the posthog-node client on init in nitro. Please note that this client instance is intended for error-tracking purposes only
|
|
38
|
-
sourcemaps: {
|
|
39
|
-
enabled: true, // Enables sourcemaps generation and upload
|
|
40
|
-
projectId: '2', // Project ID, see https://app.posthog.com/settings/project#variables
|
|
41
|
-
releaseName: 'my-application', // (optional) Release name, defaults to git repository name
|
|
42
|
-
releaseVersion: '1.0.0', // (optional) Release version, defaults to current git commit
|
|
43
|
-
personalApiKey: 'personal api key', // Your personal API key. You can generate it in settings -> Personal API keys
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
3. You can access your vue posthog client inside vue using
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
// some-file.vue
|
|
53
|
-
const { $posthog } = useNuxtApp()
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Composables
|
|
57
|
-
|
|
58
|
-
The module provides auto-imported composables for working with feature flags:
|
|
59
|
-
|
|
60
|
-
### `usePostHog()`
|
|
61
|
-
|
|
62
|
-
Returns the PostHog client instance.
|
|
63
|
-
|
|
64
|
-
```vue
|
|
65
|
-
<script setup>
|
|
66
|
-
const posthog = usePostHog()
|
|
67
|
-
|
|
68
|
-
posthog.capture('event_name')
|
|
69
|
-
</script>
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### `useFeatureFlagEnabled(flag: string)`
|
|
73
|
-
|
|
74
|
-
Returns a reactive ref that checks if a feature flag is enabled (returns `true`/`false`/`undefined`).
|
|
75
|
-
|
|
76
|
-
```vue
|
|
77
|
-
<script setup>
|
|
78
|
-
const isEnabled = useFeatureFlagEnabled('my-flag')
|
|
79
|
-
</script>
|
|
80
|
-
|
|
81
|
-
<template>
|
|
82
|
-
<div v-if="isEnabled">Feature is enabled!</div>
|
|
83
|
-
</template>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### `useFeatureFlagVariantKey(flag: string)`
|
|
87
|
-
|
|
88
|
-
Returns a reactive ref containing the feature flag value/variant (returns the variant string, `true`/`false`, or `undefined`).
|
|
89
|
-
|
|
90
|
-
```vue
|
|
91
|
-
<script setup>
|
|
92
|
-
const variant = useFeatureFlagVariantKey('my-flag')
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
|
-
<template>
|
|
96
|
-
<div v-if="variant === 'variant-a'">Show variant A</div>
|
|
97
|
-
<div v-else-if="variant === 'variant-b'">Show variant B</div>
|
|
98
|
-
</template>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### `useFeatureFlagPayload(flag: string)`
|
|
102
|
-
|
|
103
|
-
Returns a reactive ref containing the feature flag payload (returns any JSON value or `undefined`).
|
|
104
|
-
|
|
105
|
-
```vue
|
|
106
|
-
<script setup>
|
|
107
|
-
const payload = useFeatureFlagPayload('config-flag')
|
|
108
|
-
</script>
|
|
109
|
-
|
|
110
|
-
<template>
|
|
111
|
-
<div v-if="payload">Config value: {{ payload.value }}</div>
|
|
112
|
-
</template>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
All these composables automatically update when feature flags are loaded or changed.
|
|
116
|
-
|
|
117
|
-
4. On the server side, the PostHog client instance initialized by the plugin is intended exclusively for error tracking. If you require additional PostHog client functionality for other purposes, please instantiate a separate client within your application as needed.
|
|
118
|
-
|
|
119
|
-
## FAQ
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
Q: I see typescript errors in the posthog config after adding this module
|
|
123
|
-
A: It is possible that after adding a new module to `modules` typescript will complain about types. Solution is to remove `.nuxt` directory and regenerate it by running `build` command you are using. This will properly regenerate config types.
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
Q: I see stack traces but I do not see line context in the error tracking tab
|
|
128
|
-
A: Double check whether you enabled sourcemaps generation in the nuxt config both for vue and nitro. It is covered in the docs.
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Contributing
|
|
132
|
-
|
|
133
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for package-specific development instructions.
|
|
9
|
+
- [Nuxt library docs](https://posthog.com/docs/libraries/nuxt-js)
|
|
134
10
|
|
|
135
11
|
## Questions?
|
|
136
12
|
|
package/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/nuxt",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.76",
|
|
4
|
+
"bugs": {
|
|
5
|
+
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
|
+
},
|
|
4
7
|
"description": "Nuxt module for Posthog 🦔",
|
|
5
8
|
"repository": {
|
|
6
9
|
"type": "git",
|
|
@@ -25,10 +28,10 @@
|
|
|
25
28
|
"dependencies": {
|
|
26
29
|
"@posthog/cli": "~0.7.21",
|
|
27
30
|
"@nuxt/kit": ">=3.7.0",
|
|
28
|
-
"posthog
|
|
29
|
-
"@posthog/plugin-utils": "1.1.
|
|
30
|
-
"
|
|
31
|
-
"posthog-js": "1.386.
|
|
31
|
+
"@posthog/core": "^1.32.4",
|
|
32
|
+
"@posthog/plugin-utils": "^1.1.2",
|
|
33
|
+
"posthog-node": "^5.37.1",
|
|
34
|
+
"posthog-js": "^1.386.7"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
34
37
|
"@types/node": "^20.0.0",
|