@posthog/nuxt 1.1.2 → 1.1.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.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.7.0"
6
6
  },
7
- "version": "1.1.2",
7
+ "version": "1.1.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "unknown"
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 path, { dirname } from 'node:path';
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(path.join(outputDir, "public"), sourcemapsConfig));
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(path.join(outputDir, "server"), sourcemapsConfig));
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("nuxt/app").Plugin<{
1
+ declare const _default: import("#app").Plugin<{
2
2
  posthog: () => import("posthog-js").PostHog;
3
- }> & import("nuxt/app").ObjectPlugin<{
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.2",
3
+ "version": "1.1.4",
4
4
  "description": "Nuxt module for Posthog 🦔",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@posthog/cli": "~0.5.9",
24
24
  "@nuxt/kit": ">=3.7.0",
25
+ "posthog-js": "1.291.0",
25
26
  "@posthog/core": "1.5.2",
26
- "posthog-js": "1.290.0",
27
27
  "posthog-node": "5.11.2"
28
28
  },
29
29
  "devDependencies": {