@posthog/nuxt 1.1.1 → 1.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/dist/module.json +1 -1
- package/dist/module.mjs +13 -14
- package/dist/runtime/vue-plugin.d.ts +2 -2
- package/package.json +3 -3
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addPlugin, addServerPlugin } from '@nuxt/kit';
|
|
2
2
|
import { resolveBinaryPath, spawnLocal } from '@posthog/core/process';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
5
|
|
|
6
6
|
const filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const resolvedDirname = dirname(filename);
|
|
@@ -38,6 +38,14 @@ const module = defineNuxtModule({
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const sourcemapsConfig = options.sourcemaps;
|
|
41
|
+
let outputDir;
|
|
42
|
+
let publicDir;
|
|
43
|
+
let serverDir;
|
|
44
|
+
nuxt.hook("nitro:init", (nitro) => {
|
|
45
|
+
publicDir = nitro.options.output?.publicDir;
|
|
46
|
+
serverDir = nitro.options.output?.serverDir;
|
|
47
|
+
outputDir = nitro.options.output?.dir;
|
|
48
|
+
});
|
|
41
49
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
42
50
|
nitroConfig.rollupConfig = {
|
|
43
51
|
...nitroConfig.rollupConfig || {},
|
|
@@ -54,7 +62,6 @@ const module = defineNuxtModule({
|
|
|
54
62
|
server: "hidden"
|
|
55
63
|
};
|
|
56
64
|
});
|
|
57
|
-
const outputDir = getOutputDir(nuxt.options.nitro);
|
|
58
65
|
let isBuildProcess = false;
|
|
59
66
|
const posthogCliRunner = () => {
|
|
60
67
|
const cliBinaryPath = options.cliBinaryPath || resolveBinaryPath("posthog-cli", {
|
|
@@ -80,16 +87,17 @@ const module = defineNuxtModule({
|
|
|
80
87
|
const cliRunner = posthogCliRunner();
|
|
81
88
|
nuxt.hook("nitro:build:public-assets", async () => {
|
|
82
89
|
isBuildProcess = true;
|
|
90
|
+
if (!publicDir) return;
|
|
83
91
|
try {
|
|
84
|
-
await cliRunner(getInjectArgs(
|
|
92
|
+
await cliRunner(getInjectArgs(publicDir, sourcemapsConfig));
|
|
85
93
|
} catch (error) {
|
|
86
94
|
console.error("Failed to process public sourcemaps:", error);
|
|
87
95
|
}
|
|
88
96
|
});
|
|
89
97
|
nuxt.hook("close", async () => {
|
|
90
|
-
if (!isBuildProcess) return;
|
|
98
|
+
if (!isBuildProcess || !serverDir || !outputDir) return;
|
|
91
99
|
try {
|
|
92
|
-
await cliRunner(getInjectArgs(
|
|
100
|
+
await cliRunner(getInjectArgs(serverDir, sourcemapsConfig));
|
|
93
101
|
await cliRunner(getUploadArgs(outputDir, sourcemapsConfig));
|
|
94
102
|
} catch (error) {
|
|
95
103
|
console.error("Failed to process server sourcemaps:", error);
|
|
@@ -114,14 +122,5 @@ function getUploadArgs(directory, sourcemapsConfig) {
|
|
|
114
122
|
}
|
|
115
123
|
return processOptions;
|
|
116
124
|
}
|
|
117
|
-
function getOutputDir(nitroConfig) {
|
|
118
|
-
if (nitroConfig.preset && nitroConfig.preset.includes("vercel")) {
|
|
119
|
-
return ".vercel/output";
|
|
120
|
-
}
|
|
121
|
-
if (nitroConfig.output && nitroConfig.output.dir) {
|
|
122
|
-
return nitroConfig.output.dir;
|
|
123
|
-
}
|
|
124
|
-
return ".output";
|
|
125
|
-
}
|
|
126
125
|
|
|
127
126
|
export { module as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare const _default: import("
|
|
1
|
+
declare const _default: import("#app").Plugin<{
|
|
2
2
|
posthog: () => import("posthog-js").PostHog;
|
|
3
|
-
}> & import("
|
|
3
|
+
}> & import("#app").ObjectPlugin<{
|
|
4
4
|
posthog: () => import("posthog-js").PostHog;
|
|
5
5
|
}>;
|
|
6
6
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/nuxt",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Nuxt module for Posthog 🦔",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@posthog/cli": "~0.5.9",
|
|
24
24
|
"@nuxt/kit": ">=3.7.0",
|
|
25
25
|
"posthog-node": "5.11.2",
|
|
26
|
-
"posthog
|
|
27
|
-
"
|
|
26
|
+
"@posthog/core": "1.5.2",
|
|
27
|
+
"posthog-js": "1.290.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^20.0.0",
|