@unproducts/nuxt-posthog 2.0.3 → 2.0.4
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/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -3
- package/dist/runtime/plugins/posthog.client.js +1 -1
- package/dist/runtime/plugins/posthog.server.js +1 -1
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/utils/nitro.js +1 -1
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ const module$1 = defineNuxtModule({
|
|
|
7
7
|
configKey: "posthog"
|
|
8
8
|
},
|
|
9
9
|
defaults: {
|
|
10
|
-
|
|
10
|
+
key: process.env.POSTHOG_API_KEY,
|
|
11
11
|
host: process.env.POSTHOG_API_HOST,
|
|
12
12
|
capturePageViews: true,
|
|
13
13
|
capturePageLeaves: true,
|
|
@@ -18,13 +18,13 @@ const module$1 = defineNuxtModule({
|
|
|
18
18
|
},
|
|
19
19
|
setup(options, nuxt) {
|
|
20
20
|
const { resolve } = createResolver(import.meta.url);
|
|
21
|
-
if (!options.
|
|
21
|
+
if (!options.key || !options.host) {
|
|
22
22
|
options.disabled = true;
|
|
23
23
|
} else if (!options.disabled) {
|
|
24
24
|
nuxt.options.runtimeConfig.public.posthog = defu(
|
|
25
25
|
nuxt.options.runtimeConfig.public.posthog,
|
|
26
26
|
{
|
|
27
|
-
|
|
27
|
+
key: options.key,
|
|
28
28
|
host: options.host,
|
|
29
29
|
capturePageViews: options.capturePageViews,
|
|
30
30
|
capturePageLeaves: options.capturePageLeaves,
|
|
@@ -32,7 +32,7 @@ export default defineNuxtPlugin({
|
|
|
32
32
|
clientOptions.ui_host = `https://${region}.posthog.com`;
|
|
33
33
|
clientOptions.api_host = `${window.location.origin}/ingest/ph`;
|
|
34
34
|
}
|
|
35
|
-
const posthogClient = posthog.init(config.
|
|
35
|
+
const posthogClient = posthog.init(config.key, clientOptions);
|
|
36
36
|
const identity = useCookie("ph-identify");
|
|
37
37
|
identity.value = posthog.get_distinct_id();
|
|
38
38
|
if (config.capturePageViews) {
|
|
@@ -12,7 +12,7 @@ export default defineNuxtPlugin({
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
const PostHog = (await import("posthog-node")).PostHog;
|
|
15
|
-
const posthog = new PostHog(config.
|
|
15
|
+
const posthog = new PostHog(config.key, { host: config.host });
|
|
16
16
|
await posthog.reloadFeatureFlags();
|
|
17
17
|
const identity = useCookie("ph-identify", { default: () => "" });
|
|
18
18
|
const { featureFlags, featureFlagPayloads } = await posthog.getAllFlagsAndPayloads(identity.value);
|
|
@@ -7,7 +7,7 @@ declare module '@nuxt/schema' {
|
|
|
7
7
|
interface PublicRuntimeConfig {
|
|
8
8
|
posthog?: Pick<
|
|
9
9
|
ModuleOptions,
|
|
10
|
-
'
|
|
10
|
+
'key' | 'host' | 'capturePageViews' | 'capturePageLeaves' | 'clientOptions' | 'proxy'
|
|
11
11
|
>;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -6,7 +6,7 @@ export const usePostHog = async () => {
|
|
|
6
6
|
if (!config || !runtimeConfig.server) return;
|
|
7
7
|
if (!posthog) {
|
|
8
8
|
const PostHog = (await import("posthog-node")).PostHog;
|
|
9
|
-
posthog = new PostHog(config.
|
|
9
|
+
posthog = new PostHog(config.key, { host: config.host });
|
|
10
10
|
}
|
|
11
11
|
return posthog;
|
|
12
12
|
};
|