@posthog/plugin-utils 1.1.0 → 1.1.1
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/config.d.ts.map +1 -1
- package/dist/config.js +12 -3
- package/dist/config.mjs +12 -3
- package/package.json +1 -1
- package/src/config.ts +15 -3
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAErE,MAAM,WAAW,YAAY;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,QAAQ,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,KAAK,CAAC,EAAE,MAAM,GAAG,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,CAAC,EAAE,MAAM,CAAA;IAClB,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,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
|
|
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 (!
|
|
53
|
+
if (!personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
|
|
45
54
|
}
|
|
46
55
|
return {
|
|
47
|
-
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
|
|
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 (!
|
|
25
|
+
if (!personalApiKey) throw new Error('personalApiKey is required when sourcemaps are enabled');
|
|
17
26
|
}
|
|
18
27
|
return {
|
|
19
|
-
personalApiKey
|
|
28
|
+
personalApiKey,
|
|
20
29
|
projectId,
|
|
21
30
|
host,
|
|
22
31
|
logLevel,
|
package/package.json
CHANGED
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
|
|
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 (!
|
|
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
|
|
87
|
+
personalApiKey,
|
|
76
88
|
projectId,
|
|
77
89
|
host,
|
|
78
90
|
logLevel,
|