@posthog/webpack-plugin 1.2.21 → 1.2.23

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 CHANGED
@@ -22,11 +22,11 @@ export default {
22
22
  plugins: [
23
23
  new PosthogWebpackPlugin({
24
24
  personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
25
- envId: process.env.POSTHOG_PROJECT_ID,
25
+ projectId: process.env.POSTHOG_PROJECT_ID,
26
26
  sourcemaps: {
27
27
  enabled: true,
28
- project: 'my-app',
29
- version: '1.0.0',
28
+ releaseName: 'my-app',
29
+ releaseVersion: '1.0.0',
30
30
  },
31
31
  }),
32
32
  ],
@@ -38,13 +38,14 @@ export default {
38
38
  | Option | Type | Required | Default | Description |
39
39
  | ------------------------------ | ---------------------------------------------------- | -------- | -------------------------- | ------------------------------------------- |
40
40
  | `personalApiKey` | `string` | Yes | - | Your PostHog personal API key |
41
- | `envId` | `string` | Yes | - | Your PostHog project/environment ID |
41
+ | `projectId` | `string` | Yes | - | Your PostHog project/environment ID |
42
+ | `envId` | `string` | No | - | Deprecated alias for `projectId` |
42
43
  | `host` | `string` | No | `https://us.i.posthog.com` | PostHog instance host |
43
44
  | `logLevel` | `'debug' \| 'info' \| 'warn' \| 'error' \| 'silent'` | No | `'info'` | Logging verbosity |
44
45
  | `cliBinaryPath` | `string` | No | Auto-detected | Path to the PostHog CLI binary |
45
46
  | `sourcemaps.enabled` | `boolean` | No | `true` in production | Enable source map processing |
46
- | `sourcemaps.project` | `string` | No | - | Project name for source map grouping |
47
- | `sourcemaps.version` | `string` | No | - | Version identifier for the release |
47
+ | `sourcemaps.releaseName` | `string` | No | - | Release name for source map grouping |
48
+ | `sourcemaps.releaseVersion` | `string` | No | - | Version identifier for the release |
48
49
  | `sourcemaps.deleteAfterUpload` | `boolean` | No | `true` | Delete source maps after upload |
49
50
  | `sourcemaps.batchSize` | `number` | No | - | Number of source maps to upload in parallel |
50
51
 
@@ -66,13 +67,13 @@ const config: webpack.Configuration = {
66
67
  plugins: [
67
68
  new PosthogWebpackPlugin({
68
69
  personalApiKey: process.env.POSTHOG_PERSONAL_API_KEY,
69
- envId: process.env.POSTHOG_PROJECT_ID,
70
+ projectId: process.env.POSTHOG_PROJECT_ID,
70
71
  host: process.env.POSTHOG_API_HOST,
71
72
  logLevel: 'error',
72
73
  sourcemaps: {
73
74
  enabled: true,
74
- project: packageJson.name,
75
- version: packageJson.version,
75
+ releaseName: packageJson.name,
76
+ releaseVersion: packageJson.version,
76
77
  deleteAfterUpload: true,
77
78
  },
78
79
  }),
package/dist/config.d.ts CHANGED
@@ -1,26 +1,33 @@
1
1
  type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
2
2
  export interface PluginConfig {
3
3
  personalApiKey: string;
4
- envId: string;
4
+ /** @deprecated Use projectId instead */
5
+ envId?: string;
6
+ projectId?: string;
5
7
  host?: string;
6
8
  logLevel?: LogLevel;
7
9
  cliBinaryPath?: string;
8
10
  sourcemaps?: {
9
11
  enabled?: boolean;
12
+ /** @deprecated Use releaseName instead */
10
13
  project?: string;
14
+ releaseName?: string;
15
+ /** @deprecated Use releaseVersion instead */
11
16
  version?: string;
17
+ releaseVersion?: string;
12
18
  deleteAfterUpload?: boolean;
13
19
  batchSize?: number;
14
20
  };
15
21
  }
16
- export interface ResolvedPluginConfig extends PluginConfig {
22
+ export interface ResolvedPluginConfig extends Omit<PluginConfig, 'envId' | 'projectId'> {
23
+ projectId: string;
17
24
  host: string;
18
25
  logLevel: LogLevel;
19
26
  cliBinaryPath: string;
20
27
  sourcemaps: {
21
28
  enabled: boolean;
22
- project?: string;
23
- version?: string;
29
+ releaseName?: string;
30
+ releaseVersion?: string;
24
31
  deleteAfterUpload: boolean;
25
32
  batchSize?: number;
26
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GAAG,OAAO,GAAG,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,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,UAAU,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,0CAA0C;QAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,6CAA6C;QAC7C,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,iBAAiB,CAAC,EAAE,OAAO,CAAA;QAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACJ;AAED,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,WAAW,CAAC;IACnF,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE;QACR,OAAO,EAAE,OAAO,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,iBAAiB,EAAE,OAAO,CAAA;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACJ;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,oBAAoB,CA+BzE"}
package/dist/config.js CHANGED
@@ -28,6 +28,9 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  });
29
29
  const process_namespaceObject = require("@posthog/core/process");
30
30
  function resolveConfig(options) {
31
+ var _options_projectId;
32
+ const projectId = null != (_options_projectId = options.projectId) ? _options_projectId : options.envId;
33
+ if (!projectId) throw new Error('projectId is required (envId is deprecated)');
31
34
  var _options_host;
32
35
  const host = null != (_options_host = options.host) ? _options_host : 'https://us.i.posthog.com';
33
36
  var _options_logLevel;
@@ -39,17 +42,17 @@ function resolveConfig(options) {
39
42
  });
40
43
  var _options_sourcemaps;
41
44
  const sourcemaps = null != (_options_sourcemaps = options.sourcemaps) ? _options_sourcemaps : {};
42
- var _sourcemaps_enabled, _sourcemaps_deleteAfterUpload;
45
+ var _sourcemaps_enabled, _sourcemaps_releaseName, _sourcemaps_releaseVersion, _sourcemaps_deleteAfterUpload;
43
46
  return {
44
47
  personalApiKey: options.personalApiKey,
45
- envId: options.envId,
48
+ projectId,
46
49
  host,
47
50
  logLevel,
48
51
  cliBinaryPath,
49
52
  sourcemaps: {
50
53
  enabled: null != (_sourcemaps_enabled = sourcemaps.enabled) ? _sourcemaps_enabled : 'production' === process.env.NODE_ENV,
51
- project: sourcemaps.project,
52
- version: sourcemaps.version,
54
+ releaseName: null != (_sourcemaps_releaseName = sourcemaps.releaseName) ? _sourcemaps_releaseName : sourcemaps.project,
55
+ releaseVersion: null != (_sourcemaps_releaseVersion = sourcemaps.releaseVersion) ? _sourcemaps_releaseVersion : sourcemaps.version,
53
56
  deleteAfterUpload: null != (_sourcemaps_deleteAfterUpload = sourcemaps.deleteAfterUpload) ? _sourcemaps_deleteAfterUpload : true,
54
57
  batchSize: sourcemaps.batchSize
55
58
  }
package/dist/config.mjs CHANGED
@@ -3,6 +3,9 @@ import { dirname as __webpack_dirname__ } from "node:path";
3
3
  import { resolveBinaryPath } from "@posthog/core/process";
4
4
  var config_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
5
5
  function resolveConfig(options) {
6
+ var _options_projectId;
7
+ const projectId = null != (_options_projectId = options.projectId) ? _options_projectId : options.envId;
8
+ if (!projectId) throw new Error('projectId is required (envId is deprecated)');
6
9
  var _options_host;
7
10
  const host = null != (_options_host = options.host) ? _options_host : 'https://us.i.posthog.com';
8
11
  var _options_logLevel;
@@ -14,17 +17,17 @@ function resolveConfig(options) {
14
17
  });
15
18
  var _options_sourcemaps;
16
19
  const sourcemaps = null != (_options_sourcemaps = options.sourcemaps) ? _options_sourcemaps : {};
17
- var _sourcemaps_enabled, _sourcemaps_deleteAfterUpload;
20
+ var _sourcemaps_enabled, _sourcemaps_releaseName, _sourcemaps_releaseVersion, _sourcemaps_deleteAfterUpload;
18
21
  return {
19
22
  personalApiKey: options.personalApiKey,
20
- envId: options.envId,
23
+ projectId,
21
24
  host,
22
25
  logLevel,
23
26
  cliBinaryPath,
24
27
  sourcemaps: {
25
28
  enabled: null != (_sourcemaps_enabled = sourcemaps.enabled) ? _sourcemaps_enabled : 'production' === process.env.NODE_ENV,
26
- project: sourcemaps.project,
27
- version: sourcemaps.version,
29
+ releaseName: null != (_sourcemaps_releaseName = sourcemaps.releaseName) ? _sourcemaps_releaseName : sourcemaps.project,
30
+ releaseVersion: null != (_sourcemaps_releaseVersion = sourcemaps.releaseVersion) ? _sourcemaps_releaseVersion : sourcemaps.version,
28
31
  deleteAfterUpload: null != (_sourcemaps_deleteAfterUpload = sourcemaps.deleteAfterUpload) ? _sourcemaps_deleteAfterUpload : true,
29
32
  batchSize: sourcemaps.batchSize
30
33
  }
package/dist/index.js CHANGED
@@ -103,8 +103,8 @@ var __webpack_exports__ = {};
103
103
  const chunkPath = path__WEBPACK_IMPORTED_MODULE_3___default().resolve(outputDirectory, file);
104
104
  args.push('--file', chunkPath);
105
105
  }));
106
- if (config.sourcemaps.project) args.push('--project', config.sourcemaps.project);
107
- if (config.sourcemaps.version) args.push('--version', config.sourcemaps.version);
106
+ if (config.sourcemaps.releaseName) args.push('--release-name', config.sourcemaps.releaseName);
107
+ if (config.sourcemaps.releaseVersion) args.push('--release-version', config.sourcemaps.releaseVersion);
108
108
  if (config.sourcemaps.deleteAfterUpload) args.push('--delete-after');
109
109
  if (config.sourcemaps.batchSize) args.push('--batch-size', config.sourcemaps.batchSize.toString());
110
110
  await (0, _posthog_core_process__WEBPACK_IMPORTED_MODULE_2__.spawnLocal)(config.cliBinaryPath, args, {
@@ -113,8 +113,8 @@ var __webpack_exports__ = {};
113
113
  RUST_LOG: `posthog_cli=${config.logLevel}`,
114
114
  ...process.env,
115
115
  POSTHOG_CLI_HOST: config.host,
116
- POSTHOG_CLI_TOKEN: config.personalApiKey,
117
- POSTHOG_CLI_ENV_ID: config.envId
116
+ POSTHOG_CLI_API_KEY: config.personalApiKey,
117
+ POSTHOG_CLI_PROJECT_ID: config.projectId
118
118
  },
119
119
  stdio: 'inherit'
120
120
  });
@@ -123,7 +123,7 @@ var __webpack_exports__ = {};
123
123
  this.logger = (0, _posthog_core__WEBPACK_IMPORTED_MODULE_0__.createLogger)('[PostHog Webpack]');
124
124
  this.resolvedConfig = (0, _config__WEBPACK_IMPORTED_MODULE_1__.resolveConfig)(pluginConfig);
125
125
  assertValue(this.resolvedConfig.personalApiKey, "Personal API key not provided. If you are using turbo, make sure to add env variables to your turbo config");
126
- assertValue(this.resolvedConfig.envId, "Environment ID not provided. If you are using turbo, make sure to add env variables to your turbo config");
126
+ assertValue(this.resolvedConfig.projectId, "projectId (or deprecated envId) not provided. If you are using turbo, make sure to add env variables to your turbo config");
127
127
  }
128
128
  }
129
129
  function assertValue(value, message) {
package/dist/index.mjs CHANGED
@@ -34,8 +34,8 @@ class PosthogWebpackPlugin {
34
34
  const chunkPath = path.resolve(outputDirectory, file);
35
35
  args.push('--file', chunkPath);
36
36
  }));
37
- if (config.sourcemaps.project) args.push('--project', config.sourcemaps.project);
38
- if (config.sourcemaps.version) args.push('--version', config.sourcemaps.version);
37
+ if (config.sourcemaps.releaseName) args.push('--release-name', config.sourcemaps.releaseName);
38
+ if (config.sourcemaps.releaseVersion) args.push('--release-version', config.sourcemaps.releaseVersion);
39
39
  if (config.sourcemaps.deleteAfterUpload) args.push('--delete-after');
40
40
  if (config.sourcemaps.batchSize) args.push('--batch-size', config.sourcemaps.batchSize.toString());
41
41
  await spawnLocal(config.cliBinaryPath, args, {
@@ -44,8 +44,8 @@ class PosthogWebpackPlugin {
44
44
  RUST_LOG: `posthog_cli=${config.logLevel}`,
45
45
  ...process.env,
46
46
  POSTHOG_CLI_HOST: config.host,
47
- POSTHOG_CLI_TOKEN: config.personalApiKey,
48
- POSTHOG_CLI_ENV_ID: config.envId
47
+ POSTHOG_CLI_API_KEY: config.personalApiKey,
48
+ POSTHOG_CLI_PROJECT_ID: config.projectId
49
49
  },
50
50
  stdio: 'inherit'
51
51
  });
@@ -54,7 +54,7 @@ class PosthogWebpackPlugin {
54
54
  this.logger = createLogger('[PostHog Webpack]');
55
55
  this.resolvedConfig = resolveConfig(pluginConfig);
56
56
  assertValue(this.resolvedConfig.personalApiKey, "Personal API key not provided. If you are using turbo, make sure to add env variables to your turbo config");
57
- assertValue(this.resolvedConfig.envId, "Environment ID not provided. If you are using turbo, make sure to add env variables to your turbo config");
57
+ assertValue(this.resolvedConfig.projectId, "projectId (or deprecated envId) not provided. If you are using turbo, make sure to add env variables to your turbo config");
58
58
  }
59
59
  }
60
60
  function assertValue(value, message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/webpack-plugin",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "Webpack plugin for Posthog 🦔",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,8 +16,8 @@
16
16
  "module": "./dist/index.mjs",
17
17
  "types": "./dist/index.d.ts",
18
18
  "dependencies": {
19
- "@posthog/cli": "~0.5.26",
20
- "@posthog/core": "1.22.0"
19
+ "@posthog/cli": "~0.5.29",
20
+ "@posthog/core": "1.23.0"
21
21
  },
22
22
  "files": [
23
23
  "dist",
package/src/config.ts CHANGED
@@ -4,33 +4,45 @@ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'
4
4
 
5
5
  export interface PluginConfig {
6
6
  personalApiKey: string
7
- envId: string
7
+ /** @deprecated Use projectId instead */
8
+ envId?: string
9
+ projectId?: string
8
10
  host?: string
9
11
  logLevel?: LogLevel
10
12
  cliBinaryPath?: string
11
13
  sourcemaps?: {
12
14
  enabled?: boolean
15
+ /** @deprecated Use releaseName instead */
13
16
  project?: string
17
+ releaseName?: string
18
+ /** @deprecated Use releaseVersion instead */
14
19
  version?: string
20
+ releaseVersion?: string
15
21
  deleteAfterUpload?: boolean
16
22
  batchSize?: number
17
23
  }
18
24
  }
19
25
 
20
- export interface ResolvedPluginConfig extends PluginConfig {
26
+ export interface ResolvedPluginConfig extends Omit<PluginConfig, 'envId' | 'projectId'> {
27
+ projectId: string
21
28
  host: string
22
29
  logLevel: LogLevel
23
30
  cliBinaryPath: string
24
31
  sourcemaps: {
25
32
  enabled: boolean
26
- project?: string
27
- version?: string
33
+ releaseName?: string
34
+ releaseVersion?: string
28
35
  deleteAfterUpload: boolean
29
36
  batchSize?: number
30
37
  }
31
38
  }
32
39
 
33
40
  export function resolveConfig(options: PluginConfig): ResolvedPluginConfig {
41
+ const projectId = options.projectId ?? options.envId
42
+ if (!projectId) {
43
+ throw new Error('projectId is required (envId is deprecated)')
44
+ }
45
+
34
46
  const host = options.host ?? 'https://us.i.posthog.com'
35
47
  const logLevel = options.logLevel ?? 'info'
36
48
  const cliBinaryPath =
@@ -44,14 +56,14 @@ export function resolveConfig(options: PluginConfig): ResolvedPluginConfig {
44
56
 
45
57
  return {
46
58
  personalApiKey: options.personalApiKey,
47
- envId: options.envId,
59
+ projectId,
48
60
  host,
49
61
  logLevel,
50
62
  cliBinaryPath,
51
63
  sourcemaps: {
52
64
  enabled: sourcemaps.enabled ?? process.env.NODE_ENV === 'production',
53
- project: sourcemaps.project,
54
- version: sourcemaps.version,
65
+ releaseName: sourcemaps.releaseName ?? sourcemaps.project,
66
+ releaseVersion: sourcemaps.releaseVersion ?? sourcemaps.version,
55
67
  deleteAfterUpload: sourcemaps.deleteAfterUpload ?? true,
56
68
  batchSize: sourcemaps.batchSize,
57
69
  },
package/src/index.ts CHANGED
@@ -18,8 +18,8 @@ export class PosthogWebpackPlugin {
18
18
  `Personal API key not provided. If you are using turbo, make sure to add env variables to your turbo config`
19
19
  )
20
20
  assertValue(
21
- this.resolvedConfig.envId,
22
- `Environment ID not provided. If you are using turbo, make sure to add env variables to your turbo config`
21
+ this.resolvedConfig.projectId,
22
+ `projectId (or deprecated envId) not provided. If you are using turbo, make sure to add env variables to your turbo config`
23
23
  )
24
24
  }
25
25
 
@@ -70,12 +70,12 @@ export class PosthogWebpackPlugin {
70
70
  })
71
71
  )
72
72
 
73
- if (config.sourcemaps.project) {
74
- args.push('--project', config.sourcemaps.project)
73
+ if (config.sourcemaps.releaseName) {
74
+ args.push('--release-name', config.sourcemaps.releaseName)
75
75
  }
76
76
 
77
- if (config.sourcemaps.version) {
78
- args.push('--version', config.sourcemaps.version)
77
+ if (config.sourcemaps.releaseVersion) {
78
+ args.push('--release-version', config.sourcemaps.releaseVersion)
79
79
  }
80
80
 
81
81
  if (config.sourcemaps.deleteAfterUpload) {
@@ -92,8 +92,8 @@ export class PosthogWebpackPlugin {
92
92
  RUST_LOG: `posthog_cli=${config.logLevel}`,
93
93
  ...process.env,
94
94
  POSTHOG_CLI_HOST: config.host,
95
- POSTHOG_CLI_TOKEN: config.personalApiKey,
96
- POSTHOG_CLI_ENV_ID: config.envId,
95
+ POSTHOG_CLI_API_KEY: config.personalApiKey,
96
+ POSTHOG_CLI_PROJECT_ID: config.projectId,
97
97
  },
98
98
  stdio: 'inherit',
99
99
  })