@posthog/wizard 1.13.2 → 1.15.0

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.
Files changed (66) hide show
  1. package/dist/bin.js +17 -4
  2. package/dist/bin.js.map +1 -1
  3. package/dist/src/astro/astro-wizard.js +5 -3
  4. package/dist/src/astro/astro-wizard.js.map +1 -1
  5. package/dist/src/lib/api.d.ts +75 -0
  6. package/dist/src/lib/api.js +102 -0
  7. package/dist/src/lib/api.js.map +1 -0
  8. package/dist/src/lib/constants.d.ts +4 -0
  9. package/dist/src/lib/constants.js +5 -1
  10. package/dist/src/lib/constants.js.map +1 -1
  11. package/dist/src/mcp.d.ts +4 -1
  12. package/dist/src/mcp.js +6 -3
  13. package/dist/src/mcp.js.map +1 -1
  14. package/dist/src/nextjs/event-setup.js +5 -3
  15. package/dist/src/nextjs/event-setup.js.map +1 -1
  16. package/dist/src/nextjs/nextjs-wizard.js +5 -3
  17. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  18. package/dist/src/react/react-wizard.js +5 -3
  19. package/dist/src/react/react-wizard.js.map +1 -1
  20. package/dist/src/react-native/react-native-wizard.js +5 -3
  21. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  22. package/dist/src/run.js +7 -1
  23. package/dist/src/run.js.map +1 -1
  24. package/dist/src/steps/add-mcp-server-to-clients/MCPClient.d.ts +8 -8
  25. package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js +16 -13
  26. package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js.map +1 -1
  27. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.js +1 -1
  28. package/dist/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.js.map +1 -1
  29. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +3 -3
  30. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js +12 -8
  31. package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js.map +1 -1
  32. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +1 -1
  33. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js +2 -2
  34. package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js.map +1 -1
  35. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +1 -1
  36. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js +2 -2
  37. package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js.map +1 -1
  38. package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +19 -1
  39. package/dist/src/steps/add-mcp-server-to-clients/defaults.js +70 -13
  40. package/dist/src/steps/add-mcp-server-to-clients/defaults.js.map +1 -1
  41. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +7 -5
  42. package/dist/src/steps/add-mcp-server-to-clients/index.js +24 -14
  43. package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
  44. package/dist/src/svelte/svelte-wizard.js +5 -3
  45. package/dist/src/svelte/svelte-wizard.js.map +1 -1
  46. package/dist/src/utils/clack-utils.d.ts +2 -1
  47. package/dist/src/utils/clack-utils.js +31 -60
  48. package/dist/src/utils/clack-utils.js.map +1 -1
  49. package/dist/src/utils/errors.d.ts +3 -0
  50. package/dist/src/utils/errors.js +11 -0
  51. package/dist/src/utils/errors.js.map +1 -0
  52. package/dist/src/utils/file-utils.d.ts +9 -6
  53. package/dist/src/utils/file-utils.js +9 -6
  54. package/dist/src/utils/file-utils.js.map +1 -1
  55. package/dist/src/utils/oauth.d.ts +35 -0
  56. package/dist/src/utils/oauth.js +212 -0
  57. package/dist/src/utils/oauth.js.map +1 -0
  58. package/dist/src/utils/query.d.ts +3 -2
  59. package/dist/src/utils/query.js +48 -3
  60. package/dist/src/utils/query.js.map +1 -1
  61. package/dist/src/utils/types.d.ts +1 -1
  62. package/dist/src/utils/types.js.map +1 -1
  63. package/dist/src/utils/urls.d.ts +2 -0
  64. package/dist/src/utils/urls.js +24 -4
  65. package/dist/src/utils/urls.js.map +1 -1
  66. package/package.json +3 -3
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.performOAuthFlow = performOAuthFlow;
40
+ const crypto = __importStar(require("node:crypto"));
41
+ const http = __importStar(require("node:http"));
42
+ const axios_1 = __importDefault(require("axios"));
43
+ const chalk_1 = __importDefault(require("chalk"));
44
+ const opn_1 = __importDefault(require("opn"));
45
+ const zod_1 = require("zod");
46
+ const clack_1 = __importDefault(require("./clack"));
47
+ const constants_1 = require("../lib/constants");
48
+ const clack_utils_1 = require("./clack-utils");
49
+ const analytics_1 = require("./analytics");
50
+ const urls_1 = require("./urls");
51
+ const OAuthTokenResponseSchema = zod_1.z.object({
52
+ access_token: zod_1.z.string(),
53
+ expires_in: zod_1.z.number(),
54
+ token_type: zod_1.z.string(),
55
+ scope: zod_1.z.string(),
56
+ refresh_token: zod_1.z.string(),
57
+ scoped_teams: zod_1.z.array(zod_1.z.number()).optional(),
58
+ scoped_organizations: zod_1.z.array(zod_1.z.string()).optional(),
59
+ });
60
+ function generateCodeVerifier() {
61
+ return crypto.randomBytes(32).toString('base64url');
62
+ }
63
+ function generateCodeChallenge(verifier) {
64
+ return crypto.createHash('sha256').update(verifier).digest('base64url');
65
+ }
66
+ async function startCallbackServer(authUrl, signupUrl) {
67
+ return new Promise((resolve, reject) => {
68
+ let callbackResolve;
69
+ let callbackReject;
70
+ const waitForCallback = () => new Promise((res, rej) => {
71
+ callbackResolve = res;
72
+ callbackReject = rej;
73
+ });
74
+ const server = http.createServer((req, res) => {
75
+ if (!req.url) {
76
+ res.writeHead(400);
77
+ res.end();
78
+ return;
79
+ }
80
+ const url = new URL(req.url, `http://localhost:${constants_1.OAUTH_PORT}`);
81
+ if (url.pathname === '/authorize') {
82
+ const isSignup = url.searchParams.get('signup') === 'true';
83
+ const redirectUrl = isSignup ? signupUrl : authUrl;
84
+ res.writeHead(302, { Location: redirectUrl });
85
+ res.end();
86
+ return;
87
+ }
88
+ const code = url.searchParams.get('code');
89
+ const error = url.searchParams.get('error');
90
+ if (error) {
91
+ const isAccessDenied = error === 'access_denied';
92
+ res.writeHead(isAccessDenied ? 200 : 400, {
93
+ 'Content-Type': 'text/html',
94
+ });
95
+ res.end(`
96
+ <html>
97
+ <body>
98
+ <p>${isAccessDenied
99
+ ? 'Authorization cancelled.'
100
+ : `Authorization failed.`}</p>
101
+ <p>Return to your terminal. This window will close automatically.</p>
102
+ <script>window.close();</script>
103
+ </body>
104
+ </html>
105
+ `);
106
+ callbackReject(new Error(`OAuth error: ${error}`));
107
+ return;
108
+ }
109
+ if (code) {
110
+ res.writeHead(200, { 'Content-Type': 'text/html' });
111
+ res.end(`
112
+ <html>
113
+ <body>
114
+ <p>Authorization successful! Return to your terminal.</p>
115
+ <script>window.close();</script>
116
+ </body>
117
+ </html>
118
+ `);
119
+ callbackResolve(code);
120
+ }
121
+ else {
122
+ res.writeHead(400, { 'Content-Type': 'text/html' });
123
+ res.end(`
124
+ <html>
125
+ <body>
126
+ <p>Invalid request - no authorization code received.</p>
127
+ <p>You can close this window.</p>
128
+ </body>
129
+ </html>
130
+ `);
131
+ }
132
+ });
133
+ server.listen(constants_1.OAUTH_PORT, () => {
134
+ resolve({ server, waitForCallback });
135
+ });
136
+ server.on('error', reject);
137
+ });
138
+ }
139
+ async function exchangeCodeForToken(code, codeVerifier, config) {
140
+ const cloudUrl = (0, urls_1.getCloudUrlFromRegion)(config.cloudRegion);
141
+ const response = await axios_1.default.post(`${cloudUrl}/oauth/token`, {
142
+ grant_type: 'authorization_code',
143
+ code,
144
+ redirect_uri: `http://localhost:${constants_1.OAUTH_PORT}/callback`,
145
+ client_id: (0, urls_1.getOauthClientIdFromRegion)(config.cloudRegion),
146
+ code_verifier: codeVerifier,
147
+ }, {
148
+ headers: {
149
+ 'Content-Type': 'application/json',
150
+ },
151
+ });
152
+ return OAuthTokenResponseSchema.parse(response.data);
153
+ }
154
+ async function performOAuthFlow(config) {
155
+ const cloudUrl = (0, urls_1.getCloudUrlFromRegion)(config.cloudRegion);
156
+ const codeVerifier = generateCodeVerifier();
157
+ const codeChallenge = generateCodeChallenge(codeVerifier);
158
+ const authUrl = new URL(`${cloudUrl}/oauth/authorize`);
159
+ authUrl.searchParams.set('client_id', (0, urls_1.getOauthClientIdFromRegion)(config.cloudRegion));
160
+ authUrl.searchParams.set('redirect_uri', `http://localhost:${constants_1.OAUTH_PORT}/callback`);
161
+ authUrl.searchParams.set('response_type', 'code');
162
+ authUrl.searchParams.set('code_challenge', codeChallenge);
163
+ authUrl.searchParams.set('code_challenge_method', 'S256');
164
+ authUrl.searchParams.set('scope', config.scopes.join(' '));
165
+ authUrl.searchParams.set('required_access_level', 'project');
166
+ const signupUrl = new URL(`${cloudUrl}/signup?next=${encodeURIComponent(authUrl.toString())}`);
167
+ const localSignupUrl = `http://localhost:${constants_1.OAUTH_PORT}/authorize?signup=true`;
168
+ const localLoginUrl = `http://localhost:${constants_1.OAUTH_PORT}/authorize`;
169
+ const urlToOpen = config.signup ? localSignupUrl : localLoginUrl;
170
+ const { server, waitForCallback } = await startCallbackServer(authUrl.toString(), signupUrl.toString());
171
+ clack_1.default.log.info(`${chalk_1.default.bold("If the browser window didn't open automatically, please open the following link to be redirected to PostHog:")}\n\n${chalk_1.default.cyan(urlToOpen)}${config.signup
172
+ ? `\n\nIf you already have an account, you can use this link:\n\n${chalk_1.default.cyan(localLoginUrl)}`
173
+ : ``}`);
174
+ if (process.env.NODE_ENV !== 'test') {
175
+ (0, opn_1.default)(urlToOpen, { wait: false }).catch(() => {
176
+ // opn throws in environments without a browser
177
+ });
178
+ }
179
+ const loginSpinner = clack_1.default.spinner();
180
+ loginSpinner.start('Waiting for authorization...');
181
+ try {
182
+ const code = await Promise.race([
183
+ waitForCallback(),
184
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Authorization timed out')), 60_000)),
185
+ ]);
186
+ const token = await exchangeCodeForToken(code, codeVerifier, config);
187
+ server.close();
188
+ loginSpinner.stop('Authorization complete!');
189
+ return token;
190
+ }
191
+ catch (e) {
192
+ loginSpinner.stop('Authorization failed.');
193
+ server.close();
194
+ const error = e instanceof Error ? e : new Error('Unknown error');
195
+ if (error.message.includes('timeout')) {
196
+ clack_1.default.log.error('Authorization timed out. Please try again.');
197
+ }
198
+ else if (error.message.includes('access_denied')) {
199
+ clack_1.default.log.info(`${chalk_1.default.yellow('Authorization was cancelled.')}\n\nYou denied access to PostHog. To use the wizard, you need to authorize access to your PostHog account.\n\n${chalk_1.default.dim('You can try again by re-running the wizard.')}`);
200
+ }
201
+ else {
202
+ clack_1.default.log.error(`${chalk_1.default.red('Authorization failed:')}\n\n${error.message}\n\n${chalk_1.default.dim(`If you think this is a bug in the PostHog wizard, please create an issue:\n${constants_1.ISSUES_URL}`)}`);
203
+ }
204
+ analytics_1.analytics.captureException(error, {
205
+ step: 'oauth_flow',
206
+ cloud_region: config.cloudRegion,
207
+ });
208
+ await (0, clack_utils_1.abort)();
209
+ throw error;
210
+ }
211
+ }
212
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/utils/oauth.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JA,4CAyGC;AApQD,oDAAsC;AACtC,gDAAkC;AAClC,kDAA0B;AAC1B,kDAA0B;AAC1B,8CAAsB;AACtB,6BAAwB;AACxB,oDAA4B;AAC5B,gDAA0D;AAC1D,+CAAsC;AACtC,2CAAwC;AAExC,iCAA2E;AAE3E,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;IACxB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;IACtB,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE;IACzB,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC5C,oBAAoB,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrD,CAAC,CAAC;AAUH,SAAS,oBAAoB;IAC3B,OAAO,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACtD,C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,eAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,OACnC,KAAK,CAAC,OACR,OAAO,eAAK,CAAC,GAAG,CACd,8EAA8E,sBAAU,EAAE,CAC3F,EAAE,CACJ,CAAC;QACJ,CAAC;QAED,qBAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE;YAChC,IAAI,EAAE,YAAY;YAClB,YAAY,EAAE,MAAM,CAAC,WAAW;SACjC,CAAC,CAAC;QAEH,MAAM,IAAA,mBAAK,GAAE,CAAC;QACd,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import * as crypto from 'node:crypto';\nimport * as http from 'node:http';\nimport axios from 'axios';\nimport chalk from 'chalk';\nimport opn from 'opn';\nimport { z } from 'zod';\nimport clack from './clack';\nimport { ISSUES_URL, OAUTH_PORT } from '../lib/constants';\nimport { abort } from './clack-utils';\nimport { analytics } from './analytics';\nimport type { CloudRegion } from './types';\nimport { getCloudUrlFromRegion, getOauthClientIdFromRegion } from './urls';\n\nconst OAuthTokenResponseSchema = z.object({\n access_token: z.string(),\n expires_in: z.number(),\n token_type: z.string(),\n scope: z.string(),\n refresh_token: z.string(),\n scoped_teams: z.array(z.number()).optional(),\n scoped_organizations: z.array(z.string()).optional(),\n});\n\nexport type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;\n\ninterface OAuthConfig {\n scopes: string[];\n cloudRegion: CloudRegion;\n signup?: boolean;\n}\n\nfunction generateCodeVerifier(): string {\n return crypto.randomBytes(32).toString('base64url');\n}\n\nfunction generateCodeChallenge(verifier: string): string {\n return crypto.createHash('sha256').update(verifier).digest('base64url');\n}\n\nasync function startCallbackServer(\n authUrl: string,\n signupUrl: string,\n): Promise<{\n server: http.Server;\n waitForCallback: () => Promise<string>;\n}> {\n return new Promise((resolve, reject) => {\n let callbackResolve: (code: string) => void;\n let callbackReject: (error: Error) => void;\n\n const waitForCallback = () =>\n new Promise<string>((res, rej) => {\n callbackResolve = res;\n callbackReject = rej;\n });\n\n const server = http.createServer((req, res) => {\n if (!req.url) {\n res.writeHead(400);\n res.end();\n return;\n }\n const url = new URL(req.url, `http://localhost:${OAUTH_PORT}`);\n\n if (url.pathname === '/authorize') {\n const isSignup = url.searchParams.get('signup') === 'true';\n const redirectUrl = isSignup ? signupUrl : authUrl;\n res.writeHead(302, { Location: redirectUrl });\n res.end();\n return;\n }\n\n const code = url.searchParams.get('code');\n const error = url.searchParams.get('error');\n\n if (error) {\n const isAccessDenied = error === 'access_denied';\n res.writeHead(isAccessDenied ? 200 : 400, {\n 'Content-Type': 'text/html',\n });\n res.end(`\n <html>\n <body>\n <p>${\n isAccessDenied\n ? 'Authorization cancelled.'\n : `Authorization failed.`\n }</p>\n <p>Return to your terminal. This window will close automatically.</p>\n <script>window.close();</script>\n </body>\n </html>\n `);\n callbackReject(new Error(`OAuth error: ${error}`));\n return;\n }\n\n if (code) {\n res.writeHead(200, { 'Content-Type': 'text/html' });\n res.end(`\n <html>\n <body>\n <p>Authorization successful! Return to your terminal.</p>\n <script>window.close();</script>\n </body>\n </html>\n `);\n callbackResolve(code);\n } else {\n res.writeHead(400, { 'Content-Type': 'text/html' });\n res.end(`\n <html>\n <body>\n <p>Invalid request - no authorization code received.</p>\n <p>You can close this window.</p>\n </body>\n </html>\n `);\n }\n });\n\n server.listen(OAUTH_PORT, () => {\n resolve({ server, waitForCallback });\n });\n\n server.on('error', reject);\n });\n}\n\nasync function exchangeCodeForToken(\n code: string,\n codeVerifier: string,\n config: OAuthConfig,\n): Promise<OAuthTokenResponse> {\n const cloudUrl = getCloudUrlFromRegion(config.cloudRegion);\n\n const response = await axios.post(\n `${cloudUrl}/oauth/token`,\n {\n grant_type: 'authorization_code',\n code,\n redirect_uri: `http://localhost:${OAUTH_PORT}/callback`,\n client_id: getOauthClientIdFromRegion(config.cloudRegion),\n code_verifier: codeVerifier,\n },\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n },\n );\n\n return OAuthTokenResponseSchema.parse(response.data);\n}\n\nexport async function performOAuthFlow(\n config: OAuthConfig,\n): Promise<OAuthTokenResponse> {\n const cloudUrl = getCloudUrlFromRegion(config.cloudRegion);\n const codeVerifier = generateCodeVerifier();\n const codeChallenge = generateCodeChallenge(codeVerifier);\n\n const authUrl = new URL(`${cloudUrl}/oauth/authorize`);\n authUrl.searchParams.set(\n 'client_id',\n getOauthClientIdFromRegion(config.cloudRegion),\n );\n authUrl.searchParams.set(\n 'redirect_uri',\n `http://localhost:${OAUTH_PORT}/callback`,\n );\n authUrl.searchParams.set('response_type', 'code');\n authUrl.searchParams.set('code_challenge', codeChallenge);\n authUrl.searchParams.set('code_challenge_method', 'S256');\n authUrl.searchParams.set('scope', config.scopes.join(' '));\n authUrl.searchParams.set('required_access_level', 'project');\n\n const signupUrl = new URL(\n `${cloudUrl}/signup?next=${encodeURIComponent(authUrl.toString())}`,\n );\n\n const localSignupUrl = `http://localhost:${OAUTH_PORT}/authorize?signup=true`;\n const localLoginUrl = `http://localhost:${OAUTH_PORT}/authorize`;\n\n const urlToOpen = config.signup ? localSignupUrl : localLoginUrl;\n\n const { server, waitForCallback } = await startCallbackServer(\n authUrl.toString(),\n signupUrl.toString(),\n );\n\n clack.log.info(\n `${chalk.bold(\n \"If the browser window didn't open automatically, please open the following link to be redirected to PostHog:\",\n )}\\n\\n${chalk.cyan(urlToOpen)}${\n config.signup\n ? `\\n\\nIf you already have an account, you can use this link:\\n\\n${chalk.cyan(\n localLoginUrl,\n )}`\n : ``\n }`,\n );\n\n if (process.env.NODE_ENV !== 'test') {\n opn(urlToOpen, { wait: false }).catch(() => {\n // opn throws in environments without a browser\n });\n }\n\n const loginSpinner = clack.spinner();\n loginSpinner.start('Waiting for authorization...');\n\n try {\n const code = await Promise.race([\n waitForCallback(),\n new Promise<never>((_, reject) =>\n setTimeout(() => reject(new Error('Authorization timed out')), 60_000),\n ),\n ]);\n\n const token = await exchangeCodeForToken(code, codeVerifier, config);\n\n server.close();\n loginSpinner.stop('Authorization complete!');\n\n return token;\n } catch (e) {\n loginSpinner.stop('Authorization failed.');\n server.close();\n\n const error = e instanceof Error ? e : new Error('Unknown error');\n\n if (error.message.includes('timeout')) {\n clack.log.error('Authorization timed out. Please try again.');\n } else if (error.message.includes('access_denied')) {\n clack.log.info(\n `${chalk.yellow(\n 'Authorization was cancelled.',\n )}\\n\\nYou denied access to PostHog. To use the wizard, you need to authorize access to your PostHog account.\\n\\n${chalk.dim(\n 'You can try again by re-running the wizard.',\n )}`,\n );\n } else {\n clack.log.error(\n `${chalk.red('Authorization failed:')}\\n\\n${\n error.message\n }\\n\\n${chalk.dim(\n `If you think this is a bug in the PostHog wizard, please create an issue:\\n${ISSUES_URL}`,\n )}`,\n );\n }\n\n analytics.captureException(error, {\n step: 'oauth_flow',\n cloud_region: config.cloudRegion,\n });\n\n await abort();\n throw error;\n }\n}\n"]}
@@ -5,6 +5,7 @@ export interface QueryOptions<S> {
5
5
  model?: AIModel;
6
6
  region: CloudRegion;
7
7
  schema: ZodSchema<S>;
8
- wizardHash: string;
8
+ accessToken: string;
9
+ projectId: number;
9
10
  }
10
- export declare const query: <S>({ message, model, region, schema, wizardHash, }: QueryOptions<S>) => Promise<S>;
11
+ export declare const query: <S>({ message, model, region, schema, accessToken, projectId: _, }: QueryOptions<S>) => Promise<S>;
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -10,13 +43,21 @@ const urls_1 = require("./urls");
10
43
  const analytics_1 = require("./analytics");
11
44
  const axios_2 = require("axios");
12
45
  const debug_1 = require("./debug");
13
- const query = async ({ message, model = 'o4-mini', region, schema, wizardHash, }) => {
46
+ const errors_1 = require("./errors");
47
+ const crypto = __importStar(require("node:crypto"));
48
+ const generateTraceId = () => {
49
+ const randomBytes = crypto.randomBytes(32);
50
+ return crypto.createHash('sha256').update(randomBytes).digest('hex');
51
+ };
52
+ const TRACE_ID = generateTraceId();
53
+ const query = async ({ message, model = 'o4-mini', region, schema, accessToken, projectId: _, // TODO: Use this to switch the wizard query endpoint over to the new LLM Gateway
54
+ }) => {
14
55
  const fullSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(schema, 'schema');
15
56
  const jsonSchema = fullSchema.definitions;
16
57
  (0, debug_1.debug)('Full schema:', JSON.stringify(fullSchema, null, 2));
17
58
  (0, debug_1.debug)('Query request:', {
18
59
  url: `${(0, urls_1.getCloudUrlFromRegion)(region)}/api/wizard/query`,
19
- wizardHash,
60
+ accessToken,
20
61
  message: message.substring(0, 100) + '...',
21
62
  json_schema: { ...jsonSchema, name: 'schema', strict: true },
22
63
  });
@@ -27,7 +68,8 @@ const query = async ({ message, model = 'o4-mini', region, schema, wizardHash, }
27
68
  json_schema: { ...jsonSchema, name: 'schema', strict: true },
28
69
  }, {
29
70
  headers: {
30
- 'X-PostHog-Wizard-Hash': wizardHash,
71
+ Authorization: `Bearer ${accessToken}`,
72
+ 'X-PostHog-Trace-Id': TRACE_ID,
31
73
  ...(process.env.RECORD_FIXTURES === 'true'
32
74
  ? { 'X-PostHog-Wizard-Fixture-Generation': true }
33
75
  : {}),
@@ -43,6 +85,9 @@ const query = async ({ message, model = 'o4-mini', region, schema, wizardHash, }
43
85
  json_schema: jsonSchema,
44
86
  type: 'wizard_query_error',
45
87
  });
88
+ if (error.response?.status === 429) {
89
+ throw new errors_1.RateLimitError();
90
+ }
46
91
  }
47
92
  throw error;
48
93
  });
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utils/query.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,2DAAqD;AAErD,iCAA+C;AAC/C,2CAAwC;AACxC,iCAAmC;AACnC,mCAAgC;AAUzB,MAAM,KAAK,GAAG,KAAK,EAAK,EAC7B,OAAO,EACP,KAAK,GAAG,SAAS,EACjB,MAAM,EACN,MAAM,EACN,UAAU,GACM,EAAc,EAAE;IAChC,MAAM,UAAU,GAAG,IAAA,oCAAe,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,UAAU,CAAC,WAAW,CAAC;IAE1C,IAAA,aAAK,EAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3D,IAAA,aAAK,EAAC,gBAAgB,EAAE;QACtB,GAAG,EAAE,GAAG,IAAA,4BAAqB,EAAC,MAAM,CAAC,mBAAmB;QACxD,UAAU;QACV,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK;QAC1C,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AE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC7C,MAAM,IAAI,KAAK,CACb,iCAAiC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAC5D,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;QACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CACrC,0CAA0C,CAC3C,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC;YACjC,OAAO;YACP,KAAK;YACL,WAAW,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;SAC7D,CAAC,CAAC;QAEH,cAAc,CAAC,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC,CAAC;AAhFW,QAAA,KAAK,SAgFhB","sourcesContent":["import axios from 'axios';\nimport type { ZodSchema } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport type { AIModel, CloudRegion } from './types';\nimport { getCloudUrlFromRegion } from './urls';\nimport { analytics } from './analytics';\nimport { AxiosError } from 'axios';\nimport { debug } from './debug';\n\nexport interface QueryOptions<S> {\n message: string;\n model?: AIModel;\n region: CloudRegion;\n schema: ZodSchema<S>;\n wizardHash: string;\n}\n\nexport const query = async <S>({\n message,\n model = 'o4-mini',\n region,\n schema,\n wizardHash,\n}: QueryOptions<S>): Promise<S> => {\n const fullSchema = zodToJsonSchema(schema, 'schema');\n const jsonSchema = fullSchema.definitions;\n\n debug('Full schema:', JSON.stringify(fullSchema, null, 2));\n debug('Query request:', {\n url: `${getCloudUrlFromRegion(region)}/api/wizard/query`,\n wizardHash,\n message: message.substring(0, 100) + '...',\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n });\n\n const response = await axios\n .post<{ data: unknown }>(\n `${getCloudUrlFromRegion(region)}/api/wizard/query`,\n {\n message,\n model,\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n },\n {\n headers: {\n 'X-PostHog-Wizard-Hash': wizardHash,\n ...(process.env.RECORD_FIXTURES === 'true'\n ? { 'X-PostHog-Wizard-Fixture-Generation': true }\n : {}),\n },\n },\n )\n .catch((error) => {\n debug('Query error:', error);\n\n if (error instanceof AxiosError) {\n analytics.captureException(error, {\n response_status_code: error.response?.status,\n message,\n model,\n json_schema: jsonSchema,\n type: 'wizard_query_error',\n });\n }\n\n throw error;\n });\n\n debug('Query response:', {\n status: response.status,\n data: response.data,\n });\n\n const validation = schema.safeParse(response.data.data);\n\n if (!validation.success) {\n debug('Validation error:', validation.error);\n throw new Error(\n `Invalid response from wizard: ${validation.error.message}`,\n );\n }\n\n if (process.env.NODE_ENV === 'test') {\n const { fixtureTracker } = await import(\n '../../e2e-tests/mocks/fixture-tracker.js'\n );\n\n const requestBody = JSON.stringify({\n message,\n model,\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n });\n\n fixtureTracker.saveQueryFixture(requestBody, validation.data);\n }\n\n return validation.data;\n};\n"]}
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/utils/query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,2DAAqD;AAErD,iCAA+C;AAC/C,2CAAwC;AACxC,iCAAmC;AACnC,mCAAgC;AAChC,qCAA0C;AAC1C,oDAAsC;AAEtC,MAAM,eAAe,GAAG,GAAG,EAAE;IAC3B,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;AA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B,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC,CAAC;AAtFW,QAAA,KAAK,SAsFhB","sourcesContent":["import axios from 'axios';\nimport type { ZodSchema } from 'zod';\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport type { AIModel, CloudRegion } from './types';\nimport { getCloudUrlFromRegion } from './urls';\nimport { analytics } from './analytics';\nimport { AxiosError } from 'axios';\nimport { debug } from './debug';\nimport { RateLimitError } from './errors';\nimport * as crypto from 'node:crypto';\n\nconst generateTraceId = () => {\n const randomBytes = crypto.randomBytes(32);\n return crypto.createHash('sha256').update(randomBytes).digest('hex');\n};\n\nconst TRACE_ID = generateTraceId();\n\nexport interface QueryOptions<S> {\n message: string;\n model?: AIModel;\n region: CloudRegion;\n schema: ZodSchema<S>;\n accessToken: string;\n projectId: number;\n}\n\nexport const query = async <S>({\n message,\n model = 'o4-mini',\n region,\n schema,\n accessToken,\n projectId: _, // TODO: Use this to switch the wizard query endpoint over to the new LLM Gateway\n}: QueryOptions<S>): Promise<S> => {\n const fullSchema = zodToJsonSchema(schema, 'schema');\n const jsonSchema = fullSchema.definitions;\n\n debug('Full schema:', JSON.stringify(fullSchema, null, 2));\n debug('Query request:', {\n url: `${getCloudUrlFromRegion(region)}/api/wizard/query`,\n accessToken,\n message: message.substring(0, 100) + '...',\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n });\n\n const response = await axios\n .post<{ data: unknown }>(\n `${getCloudUrlFromRegion(region)}/api/wizard/query`,\n {\n message,\n model,\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n },\n {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'X-PostHog-Trace-Id': TRACE_ID,\n ...(process.env.RECORD_FIXTURES === 'true'\n ? { 'X-PostHog-Wizard-Fixture-Generation': true }\n : {}),\n },\n },\n )\n .catch((error) => {\n debug('Query error:', error);\n\n if (error instanceof AxiosError) {\n analytics.captureException(error, {\n response_status_code: error.response?.status,\n message,\n model,\n json_schema: jsonSchema,\n type: 'wizard_query_error',\n });\n\n if (error.response?.status === 429) {\n throw new RateLimitError();\n }\n }\n\n throw error;\n });\n\n debug('Query response:', {\n status: response.status,\n data: response.data,\n });\n\n const validation = schema.safeParse(response.data.data);\n\n if (!validation.success) {\n debug('Validation error:', validation.error);\n throw new Error(\n `Invalid response from wizard: ${validation.error.message}`,\n );\n }\n\n if (process.env.NODE_ENV === 'test') {\n const { fixtureTracker } = await import(\n '../../e2e-tests/mocks/fixture-tracker.js'\n );\n\n const requestBody = JSON.stringify({\n message,\n model,\n json_schema: { ...jsonSchema, name: 'schema', strict: true },\n });\n\n fixtureTracker.saveQueryFixture(requestBody, validation.data);\n }\n\n return validation.data;\n};\n"]}
@@ -46,4 +46,4 @@ export type FileChange = {
46
46
  newContent: string;
47
47
  };
48
48
  export type CloudRegion = 'us' | 'eu';
49
- export type AIModel = 'o4-mini' | 'gemini-2.5-flash' | 'gemini-2.5-pro';
49
+ export type AIModel = 'gpt-5-mini' | 'o4-mini' | 'gemini-2.5-flash' | 'gemini-2.5-pro';
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PostHogProjectData = Record<string, unknown>;\n\nexport type PreselectedProject = {\n project: PostHogProjectData;\n authToken: string;\n};\n\nexport type WizardOptions = {\n /**\n * Whether to enable debug mode.\n */\n debug: boolean;\n\n /**\n * Whether to force install the SDK package to continue with the installation in case\n * any package manager checks are failing (e.g. peer dependency versions).\n *\n * Use with caution and only if you know what you're doing.\n *\n * Does not apply to all wizard flows (currently NPM only)\n */\n forceInstall: boolean;\n\n /**\n * The directory to run the wizard in.\n */\n installDir: string;\n\n /**\n * The cloud region to use.\n */\n cloudRegion?: CloudRegion;\n\n /**\n * Whether to select the default option for all questions automatically.\n */\n default: boolean;\n\n /**\n * Whether to create a new PostHog account during setup.\n */\n signup: boolean;\n};\n\nexport interface Feature {\n id: string;\n prompt: string;\n enabledHint?: string;\n disabledHint?: string;\n}\n\nexport type FileChange = {\n filePath: string;\n oldContent?: string;\n newContent: string;\n};\n\nexport type CloudRegion = 'us' | 'eu';\n\nexport type AIModel = 'o4-mini' | 'gemini-2.5-flash' | 'gemini-2.5-pro';\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["export type PostHogProjectData = Record<string, unknown>;\n\nexport type PreselectedProject = {\n project: PostHogProjectData;\n authToken: string;\n};\n\nexport type WizardOptions = {\n /**\n * Whether to enable debug mode.\n */\n debug: boolean;\n\n /**\n * Whether to force install the SDK package to continue with the installation in case\n * any package manager checks are failing (e.g. peer dependency versions).\n *\n * Use with caution and only if you know what you're doing.\n *\n * Does not apply to all wizard flows (currently NPM only)\n */\n forceInstall: boolean;\n\n /**\n * The directory to run the wizard in.\n */\n installDir: string;\n\n /**\n * The cloud region to use.\n */\n cloudRegion?: CloudRegion;\n\n /**\n * Whether to select the default option for all questions automatically.\n */\n default: boolean;\n\n /**\n * Whether to create a new PostHog account during setup.\n */\n signup: boolean;\n};\n\nexport interface Feature {\n id: string;\n prompt: string;\n enabledHint?: string;\n disabledHint?: string;\n}\n\nexport type FileChange = {\n filePath: string;\n oldContent?: string;\n newContent: string;\n};\n\nexport type CloudRegion = 'us' | 'eu';\n\nexport type AIModel =\n | 'gpt-5-mini'\n | 'o4-mini'\n | 'gemini-2.5-flash'\n | 'gemini-2.5-pro';\n"]}
@@ -1,4 +1,6 @@
1
1
  import type { CloudRegion } from './types';
2
2
  export declare const getAssetHostFromHost: (host: string) => string;
3
3
  export declare const getUiHostFromHost: (host: string) => string;
4
+ export declare const getHostFromRegion: (region: CloudRegion) => "http://localhost:8010" | "https://us.i.posthog.com" | "https://eu.i.posthog.com";
4
5
  export declare const getCloudUrlFromRegion: (region: CloudRegion) => "http://localhost:8010" | "https://us.posthog.com" | "https://eu.posthog.com";
6
+ export declare const getOauthClientIdFromRegion: (region: CloudRegion) => "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM" | "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy" | "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCloudUrlFromRegion = exports.getUiHostFromHost = exports.getAssetHostFromHost = void 0;
3
+ exports.getOauthClientIdFromRegion = exports.getCloudUrlFromRegion = exports.getHostFromRegion = exports.getUiHostFromHost = exports.getAssetHostFromHost = void 0;
4
4
  const constants_1 = require("../lib/constants");
5
5
  const getAssetHostFromHost = (host) => {
6
6
  if (host.includes('us.i.posthog.com')) {
@@ -22,14 +22,34 @@ const getUiHostFromHost = (host) => {
22
22
  return host;
23
23
  };
24
24
  exports.getUiHostFromHost = getUiHostFromHost;
25
+ const getHostFromRegion = (region) => {
26
+ if (constants_1.IS_DEV) {
27
+ return 'http://localhost:8010';
28
+ }
29
+ if (region === 'eu') {
30
+ return 'https://eu.i.posthog.com';
31
+ }
32
+ return 'https://us.i.posthog.com';
33
+ };
34
+ exports.getHostFromRegion = getHostFromRegion;
25
35
  const getCloudUrlFromRegion = (region) => {
26
36
  if (constants_1.IS_DEV) {
27
37
  return 'http://localhost:8010';
28
38
  }
29
- if (region === 'us') {
30
- return 'https://us.posthog.com';
39
+ if (region === 'eu') {
40
+ return 'https://eu.posthog.com';
31
41
  }
32
- return 'https://eu.posthog.com';
42
+ return 'https://us.posthog.com';
33
43
  };
34
44
  exports.getCloudUrlFromRegion = getCloudUrlFromRegion;
45
+ const getOauthClientIdFromRegion = (region) => {
46
+ if (constants_1.IS_DEV) {
47
+ return constants_1.POSTHOG_DEV_CLIENT_ID;
48
+ }
49
+ if (region === 'us') {
50
+ return constants_1.POSTHOG_US_CLIENT_ID;
51
+ }
52
+ return constants_1.POSTHOG_EU_CLIENT_ID;
53
+ };
54
+ exports.getOauthClientIdFromRegion = getOauthClientIdFromRegion;
35
55
  //# sourceMappingURL=urls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../src/utils/urls.ts"],"names":[],"mappings":";;;AAAA,gDAA0C;AAGnC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE;IACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,oBAAoB,wBAU/B;AAEK,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,qBAAqB,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC3D,IAAI,kBAAM,EAAE,CAAC;QACX,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,wBAAwB,CAAC;IAClC,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AATW,QAAA,qBAAqB,yBAShC","sourcesContent":["import { IS_DEV } from '../lib/constants';\nimport type { CloudRegion } from './types';\n\nexport const getAssetHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us-assets.i.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu-assets.i.posthog.com';\n }\n\n return host;\n};\n\nexport const getUiHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu.posthog.com';\n }\n\n return host;\n};\n\nexport const getCloudUrlFromRegion = (region: CloudRegion) => {\n if (IS_DEV) {\n return 'http://localhost:8010';\n }\n\n if (region === 'us') {\n return 'https://us.posthog.com';\n }\n return 'https://eu.posthog.com';\n};\n"]}
1
+ {"version":3,"file":"urls.js","sourceRoot":"","sources":["../../../src/utils/urls.ts"],"names":[],"mappings":";;;AAAA,gDAK0B;AAGnB,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE;IACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,iCAAiC,CAAC;IAC3C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,oBAAoB,wBAU/B;AAEK,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtC,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,iBAAiB,GAAG,CAAC,MAAmB,EAAE,EAAE;IACvD,IAAI,kBAAM,EAAE,CAAC;QACX,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,0BAA0B,CAAC;IACpC,CAAC;IAED,OAAO,0BAA0B,CAAC;AACpC,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B;AAEK,MAAM,qBAAqB,GAAG,CAAC,MAAmB,EAAE,EAAE;IAC3D,IAAI,kBAAM,EAAE,CAAC;QACX,OAAO,uBAAuB,CAAC;IACjC,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,wBAAwB,CAAC;IAClC,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAEK,MAAM,0BAA0B,GAAG,CAAC,MAAmB,EAAE,EAAE;IAChE,IAAI,kBAAM,EAAE,CAAC;QACX,OAAO,iCAAqB,CAAC;IAC/B,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,gCAAoB,CAAC;IAC9B,CAAC;IACD,OAAO,gCAAoB,CAAC;AAC9B,CAAC,CAAC;AATW,QAAA,0BAA0B,8BASrC","sourcesContent":["import {\n IS_DEV,\n POSTHOG_DEV_CLIENT_ID,\n POSTHOG_EU_CLIENT_ID,\n POSTHOG_US_CLIENT_ID,\n} from '../lib/constants';\nimport type { CloudRegion } from './types';\n\nexport const getAssetHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us-assets.i.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu-assets.i.posthog.com';\n }\n\n return host;\n};\n\nexport const getUiHostFromHost = (host: string) => {\n if (host.includes('us.i.posthog.com')) {\n return 'https://us.posthog.com';\n }\n\n if (host.includes('eu.i.posthog.com')) {\n return 'https://eu.posthog.com';\n }\n\n return host;\n};\n\nexport const getHostFromRegion = (region: CloudRegion) => {\n if (IS_DEV) {\n return 'http://localhost:8010';\n }\n\n if (region === 'eu') {\n return 'https://eu.i.posthog.com';\n }\n\n return 'https://us.i.posthog.com';\n};\n\nexport const getCloudUrlFromRegion = (region: CloudRegion) => {\n if (IS_DEV) {\n return 'http://localhost:8010';\n }\n\n if (region === 'eu') {\n return 'https://eu.posthog.com';\n }\n\n return 'https://us.posthog.com';\n};\n\nexport const getOauthClientIdFromRegion = (region: CloudRegion) => {\n if (IS_DEV) {\n return POSTHOG_DEV_CLIENT_ID;\n }\n\n if (region === 'us') {\n return POSTHOG_US_CLIENT_ID;\n }\n return POSTHOG_EU_CLIENT_ID;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/wizard",
3
- "version": "1.13.2",
3
+ "version": "1.15.0",
4
4
  "homepage": "https://github.com/posthog/wizard",
5
5
  "repository": "https://github.com/posthog/wizard",
6
6
  "description": "The PostHog wizard helps you to configure your project",
@@ -85,7 +85,7 @@
85
85
  "typescript": "^5.0.4"
86
86
  },
87
87
  "engines": {
88
- "node": "18.x || 20.x",
88
+ "node": ">=18",
89
89
  "npm": ">=3.10.7"
90
90
  },
91
91
  "jest": {
@@ -122,7 +122,7 @@
122
122
  "author": "PostHog",
123
123
  "license": "MIT",
124
124
  "volta": {
125
- "node": "18.20.8",
125
+ "node": "20.18.2",
126
126
  "pnpm": "9.15.5"
127
127
  },
128
128
  "scripts": {