@posthog/plugin-utils 1.1.0 → 1.1.2

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 CHANGED
@@ -219,8 +219,8 @@ limitations under the License.
219
219
 
220
220
  ---
221
221
 
222
- Some files in this codebase contain code from getsentry/sentry-javascript or getsentry/sentry-react-native by Software, Inc. dba Sentry.
223
- In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
222
+ Some files in this codebase contain code from getsentry/sentry-javascript.
223
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
224
224
 
225
225
  MIT License
226
226
 
@@ -246,6 +246,33 @@ SOFTWARE.
246
246
 
247
247
  ---
248
248
 
249
+ Some files in this codebase contain code from getsentry/sentry-react-native.
250
+ In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
251
+
252
+ The MIT License (MIT)
253
+
254
+ Copyright (c) 2017 Sentry
255
+
256
+ Permission is hereby granted, free of charge, to any person obtaining a copy
257
+ of this software and associated documentation files (the "Software"), to deal
258
+ in the Software without restriction, including without limitation the rights
259
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
260
+ copies of the Software, and to permit persons to whom the Software is
261
+ furnished to do so, subject to the following conditions:
262
+
263
+ The above copyright notice and this permission notice shall be included in all
264
+ copies or substantial portions of the Software.
265
+
266
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
267
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
268
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
269
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
270
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
271
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
272
+ SOFTWARE.
273
+
274
+ ---
275
+
249
276
  Some files in this codebase contain code from facebook/metro by Meta Platforms, Inc. and affiliates.
250
277
  In such cases it is explicitly stated in the file header. This license only applies to the relevant code in such cases.
251
278
 
@@ -297,3 +324,30 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
297
324
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
298
325
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
299
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.
@@ -1 +1 @@
1
- {"version":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E;QACR,OAAO,EAAE,OAAO,CAAA;QAChB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,iBAAiB,EAAE,OAAO,CAAA;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;KACrB,CAAA;CACJ;AAED,MAAM,WAAW,oBAAoB;IACjC,sFAAsF;IACtF,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iFAAiF;IACjF,GAAG,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,EAAE,oBAAoB,GAAG,oBAAoB,CAyChH"}
package/dist/config.js CHANGED
@@ -27,9 +27,18 @@ __webpack_require__.d(__webpack_exports__, {
27
27
  resolveConfig: ()=>resolveConfig
28
28
  });
29
29
  const external_utils_js_namespaceObject = require("./utils.js");
30
+ const DEFAULT_PLUGIN_HOST = 'https://us.i.posthog.com';
31
+ function normalizeApiKey(value) {
32
+ return 'string' == typeof value ? value.trim() : '';
33
+ }
34
+ function normalizeHost(value) {
35
+ const normalizedHost = 'string' == typeof value ? value.trim() : '';
36
+ return normalizedHost || DEFAULT_PLUGIN_HOST;
37
+ }
30
38
  function resolveConfig(options, resolveOptions) {
31
39
  const projectId = options.projectId ?? options.envId;
32
- const host = options.host ?? 'https://us.i.posthog.com';
40
+ const personalApiKey = normalizeApiKey(options.personalApiKey);
41
+ const host = normalizeHost(options.host);
33
42
  const logLevel = options.logLevel ?? 'info';
34
43
  const cwd = resolveOptions?.cwd ?? process.cwd();
35
44
  const cliBinaryPath = options.cliBinaryPath ?? (0, external_utils_js_namespaceObject.resolveBinaryPath)('posthog-cli', {
@@ -41,10 +50,10 @@ function resolveConfig(options, resolveOptions) {
41
50
  const enabled = userSourcemaps.enabled ?? defaultEnabled;
42
51
  if (enabled) {
43
52
  if (!projectId) throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)');
44
- if (!options.personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
53
+ if (!personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
45
54
  }
46
55
  return {
47
- personalApiKey: options.personalApiKey,
56
+ personalApiKey,
48
57
  projectId,
49
58
  host,
50
59
  logLevel,
package/dist/config.mjs CHANGED
@@ -1,7 +1,16 @@
1
1
  import { resolveBinaryPath } from "./utils.mjs";
2
+ const DEFAULT_PLUGIN_HOST = 'https://us.i.posthog.com';
3
+ function normalizeApiKey(value) {
4
+ return 'string' == typeof value ? value.trim() : '';
5
+ }
6
+ function normalizeHost(value) {
7
+ const normalizedHost = 'string' == typeof value ? value.trim() : '';
8
+ return normalizedHost || DEFAULT_PLUGIN_HOST;
9
+ }
2
10
  function resolveConfig(options, resolveOptions) {
3
11
  const projectId = options.projectId ?? options.envId;
4
- const host = options.host ?? 'https://us.i.posthog.com';
12
+ const personalApiKey = normalizeApiKey(options.personalApiKey);
13
+ const host = normalizeHost(options.host);
5
14
  const logLevel = options.logLevel ?? 'info';
6
15
  const cwd = resolveOptions?.cwd ?? process.cwd();
7
16
  const cliBinaryPath = options.cliBinaryPath ?? resolveBinaryPath('posthog-cli', {
@@ -13,10 +22,10 @@ function resolveConfig(options, resolveOptions) {
13
22
  const enabled = userSourcemaps.enabled ?? defaultEnabled;
14
23
  if (enabled) {
15
24
  if (!projectId) throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)');
16
- if (!options.personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
25
+ if (!personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
17
26
  }
18
27
  return {
19
- personalApiKey: options.personalApiKey,
28
+ personalApiKey,
20
29
  projectId,
21
30
  host,
22
31
  logLevel,
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@posthog/plugin-utils",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
+ "bugs": {
5
+ "url": "https://github.com/PostHog/posthog-js/issues"
6
+ },
4
7
  "description": "Shared CLI and sourcemap utilities for PostHog build plugins",
5
8
  "license": "MIT",
6
9
  "repository": {
package/src/config.ts CHANGED
@@ -1,5 +1,16 @@
1
1
  import { resolveBinaryPath } from './utils'
2
2
 
3
+ const DEFAULT_PLUGIN_HOST = 'https://us.i.posthog.com'
4
+
5
+ function normalizeApiKey(value?: unknown): string {
6
+ return typeof value === 'string' ? value.trim() : ''
7
+ }
8
+
9
+ function normalizeHost(value?: unknown): string {
10
+ const normalizedHost = typeof value === 'string' ? value.trim() : ''
11
+ return normalizedHost || DEFAULT_PLUGIN_HOST
12
+ }
13
+
3
14
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'
4
15
 
5
16
  export interface PluginConfig {
@@ -48,7 +59,8 @@ export interface ResolveConfigOptions {
48
59
 
49
60
  export function resolveConfig(options: PluginConfig, resolveOptions?: ResolveConfigOptions): ResolvedPluginConfig {
50
61
  const projectId = options.projectId ?? options.envId
51
- const host = options.host ?? 'https://us.i.posthog.com'
62
+ const personalApiKey = normalizeApiKey(options.personalApiKey)
63
+ const host = normalizeHost(options.host)
52
64
  const logLevel = options.logLevel ?? 'info'
53
65
  const cwd = resolveOptions?.cwd ?? process.cwd()
54
66
  const cliBinaryPath =
@@ -66,13 +78,13 @@ export function resolveConfig(options: PluginConfig, resolveOptions?: ResolveCon
66
78
  if (!projectId) {
67
79
  throw new Error('projectId is required when sourcemaps are enabled (envId is deprecated)')
68
80
  }
69
- if (!options.personalApiKey) {
81
+ if (!personalApiKey) {
70
82
  throw new Error('personalApiKey is required when sourcemaps are enabled')
71
83
  }
72
84
  }
73
85
 
74
86
  return {
75
- personalApiKey: options.personalApiKey,
87
+ personalApiKey,
76
88
  projectId,
77
89
  host,
78
90
  logLevel,