@posthog/wizard 1.22.0 → 1.24.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 (51) hide show
  1. package/README.md +37 -0
  2. package/dist/bin.js +35 -41
  3. package/dist/bin.js.map +1 -1
  4. package/dist/src/__tests__/cli.test.js +91 -0
  5. package/dist/src/__tests__/cli.test.js.map +1 -1
  6. package/dist/src/__tests__/run.test.js +4 -5
  7. package/dist/src/__tests__/run.test.js.map +1 -1
  8. package/dist/src/astro/astro-wizard.js +1 -0
  9. package/dist/src/astro/astro-wizard.js.map +1 -1
  10. package/dist/src/lib/agent-interface.d.ts +0 -1
  11. package/dist/src/lib/agent-interface.js +2 -1
  12. package/dist/src/lib/agent-interface.js.map +1 -1
  13. package/dist/src/lib/agent-runner.js +2 -2
  14. package/dist/src/lib/agent-runner.js.map +1 -1
  15. package/dist/src/lib/constants.d.ts +0 -7
  16. package/dist/src/lib/constants.js +1 -10
  17. package/dist/src/lib/constants.js.map +1 -1
  18. package/dist/src/lib/framework-config.d.ts +5 -0
  19. package/dist/src/lib/framework-config.js.map +1 -1
  20. package/dist/src/nextjs/nextjs-wizard-agent.js +56 -0
  21. package/dist/src/nextjs/nextjs-wizard-agent.js.map +1 -1
  22. package/dist/src/react/react-wizard.js +1 -0
  23. package/dist/src/react/react-wizard.js.map +1 -1
  24. package/dist/src/react-native/react-native-wizard.js +2 -3
  25. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  26. package/dist/src/run.d.ts +2 -0
  27. package/dist/src/run.js +6 -62
  28. package/dist/src/run.js.map +1 -1
  29. package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +2 -1
  30. package/dist/src/steps/add-mcp-server-to-clients/index.js +6 -1
  31. package/dist/src/steps/add-mcp-server-to-clients/index.js.map +1 -1
  32. package/dist/src/svelte/svelte-wizard.js +1 -0
  33. package/dist/src/svelte/svelte-wizard.js.map +1 -1
  34. package/dist/src/utils/clack-utils.d.ts +6 -4
  35. package/dist/src/utils/clack-utils.js +52 -7
  36. package/dist/src/utils/clack-utils.js.map +1 -1
  37. package/dist/src/utils/types.d.ts +8 -0
  38. package/dist/src/utils/types.js.map +1 -1
  39. package/dist/src/utils/urls.d.ts +1 -0
  40. package/dist/src/utils/urls.js +11 -1
  41. package/dist/src/utils/urls.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/src/nextjs/docs.d.ts +0 -12
  44. package/dist/src/nextjs/docs.js +0 -272
  45. package/dist/src/nextjs/docs.js.map +0 -1
  46. package/dist/src/nextjs/event-setup.d.ts +0 -2
  47. package/dist/src/nextjs/event-setup.js +0 -390
  48. package/dist/src/nextjs/event-setup.js.map +0 -1
  49. package/dist/src/nextjs/nextjs-wizard.d.ts +0 -2
  50. package/dist/src/nextjs/nextjs-wizard.js +0 -190
  51. package/dist/src/nextjs/nextjs-wizard.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"clack-utils.js","sourceRoot":"","sources":["../../../src/utils/clack-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,sBAKC;AAED,4CAyBC;AAED,oCAaC;AAED,8EA6CC;AAED,kCASC;AAED,wEAmBC;AAED,kDAmBC;AAED,kGAkDC;AAED,gDAmBC;AAQD,wCAgHC;AAYD,4DAuBC;AAED,8CA4BC;AAED,oDAmBC;AAED,8CAoCC;AAED,8CAQC;AASD,wDAwCC;AAwED,oDAkCC;AAwBD,8DAwBC;AAgCD,0CASC;AAmBD,kDA+BC;AAED,wDA+BC;AAED,0DAUC;AAED,kEAaC;AAED,0CAyBC;AAED,8CAsBC;AA36BD,iEAAmD;AACnD,4CAA8B;AAC9B,4CAA8B;AAC9B,yCAAiE;AAEjE,kDAA0B;AAC1B,4CAAyC;AACzC,mCAAgC;AAChC,iDAA0E;AAC1E,uDAI2B;AAC3B,qCAAgD;AAEhD,iDAAmD;AACnD,gDAK0B;AAC1B,2CAAwC;AACxC,oDAA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,gBAAgB,CACrD,eAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,kCAAkC;YAC3C,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,oCAAoC;iBAC3C;gBACD;oBACE,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,oCAAoC;iBAC3C;aACF;SACF,CAAC,CACH,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as childProcess from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport { basename, isAbsolute, join, relative } from 'node:path';\n\nimport chalk from 'chalk';\nimport { traceStep } from '../telemetry';\nimport { debug } from './debug';\nimport { type PackageDotJson, hasPackageInstalled } from './package-json';\nimport {\n type PackageManager,\n detectAllPackageManagers,\n packageManagers,\n} from './package-manager';\nimport { fulfillsVersionRange } from './semver';\nimport type { CloudRegion, Feature, WizardOptions } from './types';\nimport { getPackageVersion } from './package-json';\nimport {\n DEFAULT_HOST_URL,\n DUMMY_PROJECT_API_KEY,\n ISSUES_URL,\n type Integration,\n} from '../lib/constants';\nimport { analytics } from './analytics';\nimport clack from './clack';\nimport { getCloudUrlFromRegion, getHostFromRegion } from './urls';\nimport { INTEGRATION_CONFIG } from '../lib/config';\nimport { performOAuthFlow } from './oauth';\nimport { fetchUserData, fetchProjectData } from '../lib/api';\n\ninterface ProjectData {\n projectApiKey: string;\n accessToken: string;\n host: string;\n distinctId: string;\n projectId: number;\n}\n\nexport interface CliSetupConfig {\n filename: string;\n name: string;\n gitignore: boolean;\n\n likelyAlreadyHasAuthToken(contents: string): boolean;\n tokenContent(authToken: string): string;\n\n likelyAlreadyHasOrgAndProject(contents: string): boolean;\n orgAndProjContent(org: string, project: string): string;\n\n likelyAlreadyHasUrl?(contents: string): boolean;\n urlContent?(url: string): string;\n}\n\nexport interface CliSetupConfigContent {\n authToken: string;\n org?: string;\n project?: string;\n url?: string;\n}\n\nexport async function abort(message?: string, status?: number): Promise<never> {\n await analytics.shutdown('cancelled');\n\n clack.outro(message ?? 'Wizard setup cancelled.');\n return process.exit(status ?? 1);\n}\n\nexport async function abortIfCancelled<T>(\n input: T | Promise<T>,\n integration?: Integration,\n): Promise<Exclude<T, symbol>> {\n await analytics.shutdown('cancelled');\n const resolvedInput = await input;\n\n if (\n clack.isCancel(resolvedInput) ||\n (typeof resolvedInput === 'symbol' &&\n resolvedInput.description === 'clack:cancel')\n ) {\n const docsUrl = integration\n ? INTEGRATION_CONFIG[integration].docsUrl\n : 'https://posthog.com/docs';\n\n clack.cancel(\n `Wizard setup cancelled. You can read the documentation for ${\n integration ?? 'PostHog'\n } at ${chalk.cyan(docsUrl)} to continue with the setup manually.`,\n );\n process.exit(0);\n } else {\n return input as Exclude<T, symbol>;\n }\n}\n\nexport function printWelcome(options: {\n wizardName: string;\n message?: string;\n}): void {\n // eslint-disable-next-line no-console\n console.log('');\n clack.intro(chalk.inverse(` ${options.wizardName} `));\n\n const welcomeText =\n options.message ||\n `The ${options.wizardName} will help you set up PostHog for your application.\\nThank you for using PostHog :)`;\n\n clack.note(welcomeText);\n}\n\nexport async function confirmContinueIfNoOrDirtyGitRepo(\n options: Pick<WizardOptions, 'default'>,\n): Promise<void> {\n return traceStep('check-git-status', async () => {\n if (!isInGitRepo()) {\n const continueWithoutGit = options.default\n ? true\n : await abortIfCancelled(\n clack.confirm({\n message:\n 'You are not inside a git repository. The wizard will create and update files. Do you want to continue anyway?',\n }),\n );\n\n analytics.setTag('continue-without-git', continueWithoutGit);\n\n if (!continueWithoutGit) {\n await abort(undefined, 0);\n }\n // return early to avoid checking for uncommitted files\n return;\n }\n\n const uncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles();\n if (uncommittedOrUntrackedFiles.length) {\n clack.log.warn(\n `You have uncommitted or untracked files in your repo:\n\n${uncommittedOrUntrackedFiles.join('\\n')}\n\nThe wizard will create and update files.`,\n );\n const continueWithDirtyRepo = await abortIfCancelled(\n clack.confirm({\n message: 'Do you want to continue anyway?',\n }),\n );\n\n analytics.setTag('continue-with-dirty-repo', continueWithDirtyRepo);\n\n if (!continueWithDirtyRepo) {\n await abort(undefined, 0);\n }\n }\n });\n}\n\nexport function isInGitRepo() {\n try {\n childProcess.execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n });\n return true;\n } catch {\n return false;\n }\n}\n\nexport function getUncommittedOrUntrackedFiles(): string[] {\n try {\n const gitStatus = childProcess\n .execSync('git status --porcelain=v1', {\n // we only care about stdout\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n .toString();\n\n const files = gitStatus\n .split(os.EOL)\n .map((line) => line.trim())\n .filter(Boolean)\n .map((f) => `- ${f.split(/\\s+/)[1]}`);\n\n return files;\n } catch {\n return [];\n }\n}\n\nexport async function askForItemSelection(\n items: string[],\n message: string,\n): Promise<{ value: string; index: number }> {\n const selection: { value: string; index: number } | symbol =\n await abortIfCancelled(\n clack.select({\n maxItems: 12,\n message: message,\n options: items.map((item, index) => {\n return {\n value: { value: item, index: index },\n label: item,\n };\n }),\n }),\n );\n\n return selection;\n}\n\nexport async function confirmContinueIfPackageVersionNotSupported({\n packageId,\n packageName,\n packageVersion,\n acceptableVersions,\n note,\n}: {\n packageId: string;\n packageName: string;\n packageVersion: string;\n acceptableVersions: string;\n note?: string;\n}): Promise<void> {\n return traceStep(`check-package-version`, async () => {\n analytics.setTag(`${packageName.toLowerCase()}-version`, packageVersion);\n const isSupportedVersion = fulfillsVersionRange({\n acceptableVersions,\n version: packageVersion,\n canBeLatest: true,\n });\n\n if (isSupportedVersion) {\n analytics.setTag(`${packageName.toLowerCase()}-supported`, true);\n return;\n }\n\n clack.log.warn(\n `You have an unsupported version of ${packageName} installed:\n\n ${packageId}@${packageVersion}`,\n );\n\n clack.note(\n note ??\n `Please upgrade to ${acceptableVersions} if you wish to use the PostHog wizard.`,\n );\n const continueWithUnsupportedVersion = await abortIfCancelled(\n clack.confirm({\n message: 'Do you want to continue anyway?',\n }),\n );\n analytics.setTag(\n `${packageName.toLowerCase()}-continue-with-unsupported-version`,\n continueWithUnsupportedVersion,\n );\n\n if (!continueWithUnsupportedVersion) {\n await abort(undefined, 0);\n }\n });\n}\n\nexport async function isReact19Installed({\n installDir,\n}: Pick<WizardOptions, 'installDir'>): Promise<boolean> {\n try {\n const packageJson = await getPackageDotJson({ installDir });\n const reactVersion = getPackageVersion('react', packageJson);\n\n if (!reactVersion) {\n return false;\n }\n\n return fulfillsVersionRange({\n version: reactVersion,\n acceptableVersions: '>=19.0.0',\n canBeLatest: true,\n });\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Installs or updates a package with the user's package manager.\n *\n * IMPORTANT: This function modifies the `package.json`! Be sure to re-read\n * it if you make additional modifications to it after calling this function!\n */\nexport async function installPackage({\n packageName,\n alreadyInstalled,\n askBeforeUpdating = true,\n packageNameDisplayLabel,\n packageManager,\n forceInstall = false,\n integration,\n installDir,\n}: {\n /** The string that is passed to the package manager CLI as identifier to install (e.g. `posthog-js`, or `posthog-js@^1.100.0`) */\n packageName: string;\n alreadyInstalled: boolean;\n askBeforeUpdating?: boolean;\n /** Overrides what is shown in the installation logs in place of the `packageName` option. Useful if the `packageName` is ugly */\n packageNameDisplayLabel?: string;\n packageManager?: PackageManager;\n /** Add force install flag to command to skip install precondition fails */\n forceInstall?: boolean;\n /** The integration that is being used */\n integration?: string;\n /** The directory to install the package in */\n installDir: string;\n}): Promise<{ packageManager?: PackageManager }> {\n return traceStep('install-package', async () => {\n if (alreadyInstalled && askBeforeUpdating) {\n const shouldUpdatePackage = await abortIfCancelled(\n clack.confirm({\n message: `The ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} package is already installed. Do you want to update it to the latest version?`,\n }),\n );\n\n if (!shouldUpdatePackage) {\n return {};\n }\n }\n\n const sdkInstallSpinner = clack.spinner();\n\n const pkgManager =\n packageManager || (await getPackageManager({ installDir }));\n\n // Most packages aren't compatible with React 19 yet, skip strict peer dependency checks if needed.\n const isReact19 = await isReact19Installed({ installDir });\n const legacyPeerDepsFlag =\n isReact19 && pkgManager.name === 'npm' ? '--legacy-peer-deps' : '';\n\n sdkInstallSpinner.start(\n `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} with ${chalk.bold(pkgManager.label)}.`,\n );\n\n try {\n await new Promise<void>((resolve, reject) => {\n childProcess.exec(\n `${pkgManager.installCommand} ${packageName} ${pkgManager.flags} ${\n forceInstall ? pkgManager.forceInstallFlag : ''\n } ${legacyPeerDepsFlag}`.trim(),\n { cwd: installDir },\n (err, stdout, stderr) => {\n if (err) {\n // Write a log file so we can better troubleshoot issues\n fs.writeFileSync(\n join(\n process.cwd(),\n `posthog-wizard-installation-error-${Date.now()}.log`,\n ),\n JSON.stringify({\n stdout,\n stderr,\n }),\n { encoding: 'utf8' },\n );\n\n reject(err);\n } else {\n resolve();\n }\n },\n );\n });\n } catch (e) {\n sdkInstallSpinner.stop('Installation failed.');\n clack.log.error(\n `${chalk.red(\n 'Encountered the following error during installation:',\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n )}\\n\\n${e}\\n\\n${chalk.dim(\n `The wizard has created a \\`posthog-wizard-installation-error-*.log\\` file. If you think this issue is caused by the PostHog wizard, create an issue on GitHub and include the log file's content:\\n${ISSUES_URL}`,\n )}`,\n );\n await abort();\n }\n\n sdkInstallSpinner.stop(\n `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} with ${chalk.bold(pkgManager.label)}.`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'package installed',\n package_name: packageName,\n package_manager: pkgManager.name,\n integration,\n });\n\n return { packageManager: pkgManager };\n });\n}\n\n/**\n * Checks if @param packageId is listed as a dependency in @param packageJson.\n * If not, it will ask users if they want to continue without the package.\n *\n * Use this function to check if e.g. a the framework of the SDK is installed\n *\n * @param packageJson the package.json object\n * @param packageId the npm name of the package\n * @param packageName a human readable name of the package\n */\nexport async function ensurePackageIsInstalled(\n packageJson: PackageDotJson,\n packageId: string,\n packageName: string,\n): Promise<void> {\n return traceStep('ensure-package-installed', async () => {\n const installed = hasPackageInstalled(packageId, packageJson);\n\n analytics.setTag(`${packageName.toLowerCase()}-installed`, installed);\n\n if (!installed) {\n const continueWithoutPackage = await abortIfCancelled(\n clack.confirm({\n message: `${packageName} does not seem to be installed. Do you still want to continue?`,\n initialValue: false,\n }),\n );\n\n if (!continueWithoutPackage) {\n await abort(undefined, 0);\n }\n }\n });\n}\n\nexport async function getPackageDotJson({\n installDir,\n}: Pick<WizardOptions, 'installDir'>): Promise<PackageDotJson> {\n const packageJsonFileContents = await fs.promises\n .readFile(join(installDir, 'package.json'), 'utf8')\n .catch(() => {\n clack.log.error(\n 'Could not find package.json. Make sure to run the wizard in the root of your app!',\n );\n return abort();\n });\n\n let packageJson: PackageDotJson | undefined = undefined;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n packageJson = JSON.parse(packageJsonFileContents);\n } catch {\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'package.json',\n )}. Make sure it has a valid format!`,\n );\n\n await abort();\n }\n\n return packageJson || {};\n}\n\nexport async function updatePackageDotJson(\n packageDotJson: PackageDotJson,\n { installDir }: Pick<WizardOptions, 'installDir'>,\n): Promise<void> {\n try {\n await fs.promises.writeFile(\n join(installDir, 'package.json'),\n // TODO: maybe figure out the original indentation\n JSON.stringify(packageDotJson, null, 2),\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n } catch {\n clack.log.error(`Unable to update your ${chalk.cyan('package.json')}.`);\n\n await abort();\n }\n}\n\nexport async function getPackageManager({\n installDir,\n}: Pick<WizardOptions, 'installDir'>): Promise<PackageManager> {\n const detectedPackageManagers = detectAllPackageManagers({ installDir });\n\n // If exactly one package manager detected, use it automatically\n if (detectedPackageManagers.length === 1) {\n const detectedPackageManager = detectedPackageManagers[0];\n analytics.setTag('package-manager', detectedPackageManager.name);\n return detectedPackageManager;\n }\n\n // If multiple or no package managers detected, prompt user to select\n const options =\n detectedPackageManagers.length > 0\n ? detectedPackageManagers\n : packageManagers;\n\n const message =\n detectedPackageManagers.length > 1\n ? 'Multiple package managers detected. Please select one:'\n : 'Please select your package manager.';\n\n const selectedPackageManager: PackageManager | symbol =\n await abortIfCancelled(\n clack.select({\n message,\n options: options.map((packageManager) => ({\n value: packageManager,\n label: packageManager.label,\n })),\n }),\n );\n\n analytics.setTag('package-manager', selectedPackageManager.name);\n return selectedPackageManager;\n}\n\nexport function isUsingTypeScript({\n installDir,\n}: Pick<WizardOptions, 'installDir'>) {\n try {\n return fs.existsSync(join(installDir, 'tsconfig.json'));\n } catch {\n return false;\n }\n}\n\n/**\n *\n * Use this function to get project data for the wizard.\n *\n * @param options wizard options\n * @returns project data (token, url)\n */\nexport async function getOrAskForProjectData(\n _options: Pick<WizardOptions, 'signup'> & {\n cloudRegion: CloudRegion;\n },\n): Promise<{\n host: string;\n projectApiKey: string;\n accessToken: string;\n projectId: number;\n}> {\n const cloudUrl = getCloudUrlFromRegion(_options.cloudRegion);\n const { host, projectApiKey, accessToken, projectId } = await traceStep(\n 'login',\n () =>\n askForWizardLogin({\n cloudRegion: _options.cloudRegion,\n signup: _options.signup,\n }),\n );\n\n if (!projectApiKey) {\n clack.log.error(`Didn't receive a project API key. This shouldn't happen :(\n\nPlease let us know if you think this is a bug in the wizard:\n${chalk.cyan(ISSUES_URL)}`);\n\n clack.log\n .info(`In the meantime, we'll add a dummy project API key (${chalk.cyan(\n `\"${DUMMY_PROJECT_API_KEY}\"`,\n )}) for you to replace later.\nYou can find your Project API key here:\n${chalk.cyan(`${cloudUrl}/settings/project#variables`)}`);\n }\n\n return {\n accessToken,\n host: host || DEFAULT_HOST_URL,\n projectApiKey: projectApiKey || DUMMY_PROJECT_API_KEY,\n projectId,\n };\n}\n\nasync function askForWizardLogin(options: {\n cloudRegion: CloudRegion;\n signup: boolean;\n}): Promise<ProjectData> {\n const tokenResponse = await performOAuthFlow({\n cloudRegion: options.cloudRegion,\n scopes: [\n 'user:read',\n 'project:read',\n 'introspection',\n 'task:write',\n 'dashboard:write',\n 'insight:write',\n ],\n signup: options.signup,\n });\n\n const projectId = tokenResponse.scoped_teams?.[0];\n\n if (projectId === undefined) {\n const error = new Error(\n 'No project access granted. Please authorize with project-level access.',\n );\n analytics.captureException(error, {\n step: 'wizard_login',\n has_scoped_teams: !!tokenResponse.scoped_teams,\n });\n clack.log.error(error.message);\n await abort();\n }\n\n const cloudUrl = getCloudUrlFromRegion(options.cloudRegion);\n const host = getHostFromRegion(options.cloudRegion);\n\n const projectData = await fetchProjectData(\n tokenResponse.access_token,\n projectId!,\n cloudUrl,\n );\n const userData = await fetchUserData(tokenResponse.access_token, cloudUrl);\n\n const data: ProjectData = {\n accessToken: tokenResponse.access_token,\n projectApiKey: projectData.api_token,\n host,\n distinctId: userData.distinct_id,\n projectId: projectId!,\n };\n\n clack.log.success(\n `Login complete. ${options.signup ? 'Welcome to PostHog! 🎉' : ''}`,\n );\n analytics.setTag('opened-wizard-link', true);\n analytics.setDistinctId(data.distinctId);\n\n return data;\n}\n\n/**\n * Asks users if they have a config file for @param tool (e.g. Vite).\n * If yes, asks users to specify the path to their config file.\n *\n * Use this helper function as a fallback mechanism if the lookup for\n * a config file with its most usual location/name fails.\n *\n * @param toolName Name of the tool for which we're looking for the config file\n * @param configFileName Name of the most common config file name (e.g. vite.config.js)\n *\n * @returns a user path to the config file or undefined if the user doesn't have a config file\n */\nexport async function askForToolConfigPath(\n toolName: string,\n configFileName: string,\n): Promise<string | undefined> {\n const hasConfig = await abortIfCancelled(\n clack.confirm({\n message: `Do you have a ${toolName} config file (e.g. ${chalk.cyan(\n configFileName,\n )})?`,\n initialValue: true,\n }),\n );\n\n if (!hasConfig) {\n return undefined;\n }\n\n return await abortIfCancelled(\n clack.text({\n message: `Please enter the path to your ${toolName} config file:`,\n placeholder: join('.', configFileName),\n validate: (value) => {\n if (!value) {\n return 'Please enter a path.';\n }\n\n try {\n fs.accessSync(value);\n } catch {\n return 'Could not access the file at this path.';\n }\n },\n }),\n );\n}\n\n/**\n * Prints copy/paste-able instructions to the console.\n * Afterwards asks the user if they added the code snippet to their file.\n *\n * While there's no point in providing a \"no\" answer here, it gives users time to fulfill the\n * task before the wizard continues with additional steps.\n *\n * Use this function if you want to show users instructions on how to add/modify\n * code in their file. This is helpful if automatic insertion failed or is not possible/feasible.\n *\n * @param filename the name of the file to which the code snippet should be applied.\n * If a path is provided, only the filename will be used.\n *\n * @param codeSnippet the snippet to be printed. Use {@link makeCodeSnippet} to create the\n * diff-like format for visually highlighting unchanged or modified lines of code.\n *\n * @param hint (optional) a hint to be printed after the main instruction to add\n * the code from @param codeSnippet to their @param filename.\n *\n * TODO: refactor copy paste instructions across different wizards to use this function.\n * this might require adding a custom message parameter to the function\n */\nexport async function showCopyPasteInstructions(\n filename: string,\n codeSnippet: string,\n hint?: string,\n): Promise<void> {\n clack.log.step(\n `Add the following code to your ${chalk.cyan(basename(filename))} file:${\n hint ? chalk.dim(` (${chalk.dim(hint)})`) : ''\n }`,\n );\n\n // Padding the code snippet to be printed with a \\n at the beginning and end\n // This makes it easier to distinguish the snippet from the rest of the output\n // Intentionally logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(`\\n${codeSnippet}\\n`);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you apply the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n}\n\n/**\n * Callback that exposes formatting helpers for a code snippet.\n * @param unchanged - Formats text as old code.\n * @param plus - Formats text as new code.\n * @param minus - Formats text as removed code.\n */\ntype CodeSnippetFormatter = (\n unchanged: (txt: string) => string,\n plus: (txt: string) => string,\n minus: (txt: string) => string,\n) => string;\n\n/**\n * Crafts a code snippet that can be used to e.g.\n * - print copy/paste instructions to the console\n * - create a new config file.\n *\n * @param colors set this to true if you want the final snippet to be colored.\n * This is useful for printing the snippet to the console as part of copy/paste instructions.\n *\n * @param callback the callback that returns the formatted code snippet.\n * It exposes takes the helper functions for marking code as unchanged, new or removed.\n * These functions no-op if no special formatting should be applied\n * and otherwise apply the appropriate formatting/coloring.\n * (@see {@link CodeSnippetFormatter})\n *\n * @see {@link showCopyPasteInstructions} for the helper with which to display the snippet in the console.\n *\n * @returns a string containing the final, formatted code snippet.\n */\nexport function makeCodeSnippet(\n colors: boolean,\n callback: CodeSnippetFormatter,\n): string {\n const unchanged = (txt: string) => (colors ? chalk.grey(txt) : txt);\n const plus = (txt: string) => (colors ? chalk.greenBright(txt) : txt);\n const minus = (txt: string) => (colors ? chalk.redBright(txt) : txt);\n\n return callback(unchanged, plus, minus);\n}\n\n/**\n * Creates a new config file with the given @param filepath and @param codeSnippet.\n *\n * Use this function to create a new config file for users. This is useful\n * when users answered that they don't yet have a config file for a tool.\n *\n * (This doesn't mean that they don't yet have some other way of configuring\n * their tool but we can leave it up to them to figure out how to merge configs\n * here.)\n *\n * @param filepath absolute path to the new config file\n * @param codeSnippet the snippet to be inserted into the file\n * @param moreInformation (optional) the message to be printed after the file was created\n * For example, this can be a link to more information about configuring the tool.\n *\n * @returns true on success, false otherwise\n */\nexport async function createNewConfigFile(\n filepath: string,\n codeSnippet: string,\n { installDir }: Pick<WizardOptions, 'installDir'>,\n moreInformation?: string,\n): Promise<boolean> {\n if (!isAbsolute(filepath)) {\n debug(`createNewConfigFile: filepath is not absolute: ${filepath}`);\n return false;\n }\n\n const prettyFilename = chalk.cyan(relative(installDir, filepath));\n\n try {\n await fs.promises.writeFile(filepath, codeSnippet);\n\n clack.log.success(`Added new ${prettyFilename} file.`);\n\n if (moreInformation) {\n clack.log.info(chalk.gray(moreInformation));\n }\n\n return true;\n } catch (e) {\n debug(e);\n clack.log.warn(\n `Could not create a new ${prettyFilename} file. Please create one manually and follow the instructions below.`,\n );\n }\n\n return false;\n}\n\nexport async function featureSelectionPrompt<F extends ReadonlyArray<Feature>>(\n features: F,\n): Promise<{ [key in F[number]['id']]: boolean }> {\n return traceStep('feature-selection', async () => {\n const selectedFeatures: Record<string, boolean> = {};\n\n for (const feature of features) {\n const selected = await abortIfCancelled(\n clack.select({\n message: feature.prompt,\n initialValue: true,\n options: [\n {\n value: true,\n label: 'Yes',\n hint: feature.enabledHint,\n },\n {\n value: false,\n label: 'No',\n hint: feature.disabledHint,\n },\n ],\n }),\n );\n\n selectedFeatures[feature.id] = selected;\n }\n\n return selectedFeatures as { [key in F[number]['id']]: boolean };\n });\n}\n\nexport async function askShouldInstallPackage(\n pkgName: string,\n): Promise<boolean> {\n return traceStep(`ask-install-package`, () =>\n abortIfCancelled(\n clack.confirm({\n message: `Do you want to install ${chalk.cyan(pkgName)}?`,\n }),\n ),\n );\n}\n\nexport async function askShouldAddPackageOverride(\n pkgName: string,\n pkgVersion: string,\n): Promise<boolean> {\n return traceStep(`ask-add-package-override`, () =>\n abortIfCancelled(\n clack.confirm({\n message: `Do you want to add an override for ${chalk.cyan(\n pkgName,\n )} version ${chalk.cyan(pkgVersion)}?`,\n }),\n ),\n );\n}\n\nexport async function askForAIConsent(options: Pick<WizardOptions, 'default'>) {\n return await traceStep('ask-for-ai-consent', async () => {\n const aiConsent = options.default\n ? true\n : await abortIfCancelled(\n clack.select({\n message: 'This setup wizard uses AI, are you happy to continue? ✨',\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'We will use AI to help you setup PostHog quickly',\n },\n {\n label: 'No',\n value: false,\n hint: \"I don't like AI\",\n },\n ],\n initialValue: true,\n }),\n );\n\n return aiConsent;\n });\n}\n\nexport async function askForCloudRegion(): Promise<CloudRegion> {\n return await traceStep('ask-for-cloud-region', async () => {\n const cloudRegion: CloudRegion = await abortIfCancelled(\n clack.select({\n message: 'Select your PostHog Cloud region',\n options: [\n {\n label: 'US 🇺🇸',\n value: 'us',\n hint: 'Your data will be stored in the US',\n },\n {\n label: 'EU 🇪🇺',\n value: 'eu',\n hint: 'Your data will be stored in the EU',\n },\n ],\n }),\n );\n\n return cloudRegion;\n });\n}\n"]}
1
+ {"version":3,"file":"clack-utils.js","sourceRoot":"","sources":["../../../src/utils/clack-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,sBAKC;AAED,4CAyBC;AAED,oCAaC;AAED,8EAwDC;AAED,kCASC;AAED,wEAmBC;AAED,kDAmBC;AAED,kGAkDC;AAED,gDAmBC;AAQD,wCAgHC;AAYD,4DAuBC;AAED,8CA4BC;AAED,oDAmBC;AAED,8CAiDC;AAED,8CAQC;AASD,wDA2DC;AAgGD,oDAkCC;AAwBD,8DAwBC;AAgCD,0CASC;AAmBD,kDA+BC;AAED,wDA+BC;AAED,0DAUC;AAED,kEAaC;AAED,0CA8BC;AAED,8CAsBC;AAp/BD,iEAAmD;AACnD,4CAA8B;AAC9B,4CAA8B;AAC9B,yCAAiE;AAEjE,kDAA0B;AAC1B,4CAAyC;AACzC,mCAAgC;AAChC,iDAA0E;AAC1E,uDAK2B;AAC3B,qCAAgD;AAEhD,iDAAmD;AACnD,gDAK0B;AAC1B,2CAAwC;AACxC,oDAA4B;AAC5B,iCAAkE;AAClE,0CAAmD;AACnD,mCAA2C;AAC3C,oCAA6D;AAgCtD,KAAK,UAAU,KAAK,CAAC,OAAgB,EAAE,MAAe;IAC3D,MAAM,qBAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEtC,eAAK,CAAC,KAAK,CAAC,OAAO,IAAI,yBAAyB,CAAC,CAAC;IAClD,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;AACnC,CAAC;AAEM,KAAK,UAAU,gBAAgB,CACpC,KAAqB,EACrB,WAAyB;IAEzB,MAAM,qBAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC;IAElC,IAC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AAE,KAAK,IAAI,EAAE;QACxD,MAAM,WAAW,GAAgB,MAAM,gBAAgB,CACrD,eAAK,CAAC,MAAM,CAAC;YACX,OAAO,EAAE,kCAAkC;YAC3C,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,oCAAoC;iBAC3C;gBACD;oBACE,KAAK,EAAE,SAAS;oBAChB,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,oCAAoC;iBAC3C;aACF;SACF,CAAC,CACH,CAAC;QAEF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import * as childProcess from 'node:child_process';\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport { basename, isAbsolute, join, relative } from 'node:path';\n\nimport chalk from 'chalk';\nimport { traceStep } from '../telemetry';\nimport { debug } from './debug';\nimport { type PackageDotJson, hasPackageInstalled } from './package-json';\nimport {\n type PackageManager,\n detectAllPackageManagers,\n packageManagers,\n NPM as npm,\n} from './package-manager';\nimport { fulfillsVersionRange } from './semver';\nimport type { CloudRegion, Feature, WizardOptions } from './types';\nimport { getPackageVersion } from './package-json';\nimport {\n DEFAULT_HOST_URL,\n DUMMY_PROJECT_API_KEY,\n ISSUES_URL,\n type Integration,\n} from '../lib/constants';\nimport { analytics } from './analytics';\nimport clack from './clack';\nimport { getCloudUrlFromRegion, getHostFromRegion } from './urls';\nimport { INTEGRATION_CONFIG } from '../lib/config';\nimport { performOAuthFlow } from './oauth';\nimport { fetchUserData, fetchProjectData } from '../lib/api';\n\ninterface ProjectData {\n projectApiKey: string;\n accessToken: string;\n host: string;\n distinctId: string;\n projectId: number;\n}\n\nexport interface CliSetupConfig {\n filename: string;\n name: string;\n gitignore: boolean;\n\n likelyAlreadyHasAuthToken(contents: string): boolean;\n tokenContent(authToken: string): string;\n\n likelyAlreadyHasOrgAndProject(contents: string): boolean;\n orgAndProjContent(org: string, project: string): string;\n\n likelyAlreadyHasUrl?(contents: string): boolean;\n urlContent?(url: string): string;\n}\n\nexport interface CliSetupConfigContent {\n authToken: string;\n org?: string;\n project?: string;\n url?: string;\n}\n\nexport async function abort(message?: string, status?: number): Promise<never> {\n await analytics.shutdown('cancelled');\n\n clack.outro(message ?? 'Wizard setup cancelled.');\n return process.exit(status ?? 1);\n}\n\nexport async function abortIfCancelled<T>(\n input: T | Promise<T>,\n integration?: Integration,\n): Promise<Exclude<T, symbol>> {\n await analytics.shutdown('cancelled');\n const resolvedInput = await input;\n\n if (\n clack.isCancel(resolvedInput) ||\n (typeof resolvedInput === 'symbol' &&\n resolvedInput.description === 'clack:cancel')\n ) {\n const docsUrl = integration\n ? INTEGRATION_CONFIG[integration].docsUrl\n : 'https://posthog.com/docs';\n\n clack.cancel(\n `Wizard setup cancelled. You can read the documentation for ${\n integration ?? 'PostHog'\n } at ${chalk.cyan(docsUrl)} to continue with the setup manually.`,\n );\n process.exit(0);\n } else {\n return input as Exclude<T, symbol>;\n }\n}\n\nexport function printWelcome(options: {\n wizardName: string;\n message?: string;\n}): void {\n // eslint-disable-next-line no-console\n console.log('');\n clack.intro(chalk.inverse(` ${options.wizardName} `));\n\n const welcomeText =\n options.message ||\n `The ${options.wizardName} will help you set up PostHog for your application.\\nThank you for using PostHog :)`;\n\n clack.note(welcomeText);\n}\n\nexport async function confirmContinueIfNoOrDirtyGitRepo(\n options: Pick<WizardOptions, 'default' | 'ci'>,\n): Promise<void> {\n return traceStep('check-git-status', async () => {\n if (!isInGitRepo()) {\n // CI mode: auto-continue without git\n const continueWithoutGit =\n options.default || options.ci\n ? true\n : await abortIfCancelled(\n clack.confirm({\n message:\n 'You are not inside a git repository. The wizard will create and update files. Do you want to continue anyway?',\n }),\n );\n\n analytics.setTag('continue-without-git', continueWithoutGit);\n\n if (!continueWithoutGit) {\n await abort(undefined, 0);\n }\n // return early to avoid checking for uncommitted files\n return;\n }\n\n const uncommittedOrUntrackedFiles = getUncommittedOrUntrackedFiles();\n if (uncommittedOrUntrackedFiles.length) {\n // CI mode: auto-continue with dirty repo\n if (options.ci) {\n clack.log.info(\n `CI mode: continuing with uncommitted/untracked files in repo`,\n );\n analytics.setTag('continue-with-dirty-repo', true);\n return;\n }\n\n clack.log.warn(\n `You have uncommitted or untracked files in your repo:\n\n${uncommittedOrUntrackedFiles.join('\\n')}\n\nThe wizard will create and update files.`,\n );\n const continueWithDirtyRepo = await abortIfCancelled(\n clack.confirm({\n message: 'Do you want to continue anyway?',\n }),\n );\n\n analytics.setTag('continue-with-dirty-repo', continueWithDirtyRepo);\n\n if (!continueWithDirtyRepo) {\n await abort(undefined, 0);\n }\n }\n });\n}\n\nexport function isInGitRepo() {\n try {\n childProcess.execSync('git rev-parse --is-inside-work-tree', {\n stdio: 'ignore',\n });\n return true;\n } catch {\n return false;\n }\n}\n\nexport function getUncommittedOrUntrackedFiles(): string[] {\n try {\n const gitStatus = childProcess\n .execSync('git status --porcelain=v1', {\n // we only care about stdout\n stdio: ['ignore', 'pipe', 'ignore'],\n })\n .toString();\n\n const files = gitStatus\n .split(os.EOL)\n .map((line) => line.trim())\n .filter(Boolean)\n .map((f) => `- ${f.split(/\\s+/)[1]}`);\n\n return files;\n } catch {\n return [];\n }\n}\n\nexport async function askForItemSelection(\n items: string[],\n message: string,\n): Promise<{ value: string; index: number }> {\n const selection: { value: string; index: number } | symbol =\n await abortIfCancelled(\n clack.select({\n maxItems: 12,\n message: message,\n options: items.map((item, index) => {\n return {\n value: { value: item, index: index },\n label: item,\n };\n }),\n }),\n );\n\n return selection;\n}\n\nexport async function confirmContinueIfPackageVersionNotSupported({\n packageId,\n packageName,\n packageVersion,\n acceptableVersions,\n note,\n}: {\n packageId: string;\n packageName: string;\n packageVersion: string;\n acceptableVersions: string;\n note?: string;\n}): Promise<void> {\n return traceStep(`check-package-version`, async () => {\n analytics.setTag(`${packageName.toLowerCase()}-version`, packageVersion);\n const isSupportedVersion = fulfillsVersionRange({\n acceptableVersions,\n version: packageVersion,\n canBeLatest: true,\n });\n\n if (isSupportedVersion) {\n analytics.setTag(`${packageName.toLowerCase()}-supported`, true);\n return;\n }\n\n clack.log.warn(\n `You have an unsupported version of ${packageName} installed:\n\n ${packageId}@${packageVersion}`,\n );\n\n clack.note(\n note ??\n `Please upgrade to ${acceptableVersions} if you wish to use the PostHog wizard.`,\n );\n const continueWithUnsupportedVersion = await abortIfCancelled(\n clack.confirm({\n message: 'Do you want to continue anyway?',\n }),\n );\n analytics.setTag(\n `${packageName.toLowerCase()}-continue-with-unsupported-version`,\n continueWithUnsupportedVersion,\n );\n\n if (!continueWithUnsupportedVersion) {\n await abort(undefined, 0);\n }\n });\n}\n\nexport async function isReact19Installed({\n installDir,\n}: Pick<WizardOptions, 'installDir'>): Promise<boolean> {\n try {\n const packageJson = await getPackageDotJson({ installDir });\n const reactVersion = getPackageVersion('react', packageJson);\n\n if (!reactVersion) {\n return false;\n }\n\n return fulfillsVersionRange({\n version: reactVersion,\n acceptableVersions: '>=19.0.0',\n canBeLatest: true,\n });\n } catch (error) {\n return false;\n }\n}\n\n/**\n * Installs or updates a package with the user's package manager.\n *\n * IMPORTANT: This function modifies the `package.json`! Be sure to re-read\n * it if you make additional modifications to it after calling this function!\n */\nexport async function installPackage({\n packageName,\n alreadyInstalled,\n askBeforeUpdating = true,\n packageNameDisplayLabel,\n packageManager,\n forceInstall = false,\n integration,\n installDir,\n}: {\n /** The string that is passed to the package manager CLI as identifier to install (e.g. `posthog-js`, or `posthog-js@^1.100.0`) */\n packageName: string;\n alreadyInstalled: boolean;\n askBeforeUpdating?: boolean;\n /** Overrides what is shown in the installation logs in place of the `packageName` option. Useful if the `packageName` is ugly */\n packageNameDisplayLabel?: string;\n packageManager?: PackageManager;\n /** Add force install flag to command to skip install precondition fails */\n forceInstall?: boolean;\n /** The integration that is being used */\n integration?: string;\n /** The directory to install the package in */\n installDir: string;\n}): Promise<{ packageManager?: PackageManager }> {\n return traceStep('install-package', async () => {\n if (alreadyInstalled && askBeforeUpdating) {\n const shouldUpdatePackage = await abortIfCancelled(\n clack.confirm({\n message: `The ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} package is already installed. Do you want to update it to the latest version?`,\n }),\n );\n\n if (!shouldUpdatePackage) {\n return {};\n }\n }\n\n const sdkInstallSpinner = clack.spinner();\n\n const pkgManager =\n packageManager || (await getPackageManager({ installDir }));\n\n // Most packages aren't compatible with React 19 yet, skip strict peer dependency checks if needed.\n const isReact19 = await isReact19Installed({ installDir });\n const legacyPeerDepsFlag =\n isReact19 && pkgManager.name === 'npm' ? '--legacy-peer-deps' : '';\n\n sdkInstallSpinner.start(\n `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} with ${chalk.bold(pkgManager.label)}.`,\n );\n\n try {\n await new Promise<void>((resolve, reject) => {\n childProcess.exec(\n `${pkgManager.installCommand} ${packageName} ${pkgManager.flags} ${\n forceInstall ? pkgManager.forceInstallFlag : ''\n } ${legacyPeerDepsFlag}`.trim(),\n { cwd: installDir },\n (err, stdout, stderr) => {\n if (err) {\n // Write a log file so we can better troubleshoot issues\n fs.writeFileSync(\n join(\n process.cwd(),\n `posthog-wizard-installation-error-${Date.now()}.log`,\n ),\n JSON.stringify({\n stdout,\n stderr,\n }),\n { encoding: 'utf8' },\n );\n\n reject(err);\n } else {\n resolve();\n }\n },\n );\n });\n } catch (e) {\n sdkInstallSpinner.stop('Installation failed.');\n clack.log.error(\n `${chalk.red(\n 'Encountered the following error during installation:',\n // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n )}\\n\\n${e}\\n\\n${chalk.dim(\n `The wizard has created a \\`posthog-wizard-installation-error-*.log\\` file. If you think this issue is caused by the PostHog wizard, create an issue on GitHub and include the log file's content:\\n${ISSUES_URL}`,\n )}`,\n );\n await abort();\n }\n\n sdkInstallSpinner.stop(\n `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan(\n packageNameDisplayLabel ?? packageName,\n )} with ${chalk.bold(pkgManager.label)}.`,\n );\n\n analytics.capture('wizard interaction', {\n action: 'package installed',\n package_name: packageName,\n package_manager: pkgManager.name,\n integration,\n });\n\n return { packageManager: pkgManager };\n });\n}\n\n/**\n * Checks if @param packageId is listed as a dependency in @param packageJson.\n * If not, it will ask users if they want to continue without the package.\n *\n * Use this function to check if e.g. a the framework of the SDK is installed\n *\n * @param packageJson the package.json object\n * @param packageId the npm name of the package\n * @param packageName a human readable name of the package\n */\nexport async function ensurePackageIsInstalled(\n packageJson: PackageDotJson,\n packageId: string,\n packageName: string,\n): Promise<void> {\n return traceStep('ensure-package-installed', async () => {\n const installed = hasPackageInstalled(packageId, packageJson);\n\n analytics.setTag(`${packageName.toLowerCase()}-installed`, installed);\n\n if (!installed) {\n const continueWithoutPackage = await abortIfCancelled(\n clack.confirm({\n message: `${packageName} does not seem to be installed. Do you still want to continue?`,\n initialValue: false,\n }),\n );\n\n if (!continueWithoutPackage) {\n await abort(undefined, 0);\n }\n }\n });\n}\n\nexport async function getPackageDotJson({\n installDir,\n}: Pick<WizardOptions, 'installDir'>): Promise<PackageDotJson> {\n const packageJsonFileContents = await fs.promises\n .readFile(join(installDir, 'package.json'), 'utf8')\n .catch(() => {\n clack.log.error(\n 'Could not find package.json. Make sure to run the wizard in the root of your app!',\n );\n return abort();\n });\n\n let packageJson: PackageDotJson | undefined = undefined;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n packageJson = JSON.parse(packageJsonFileContents);\n } catch {\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'package.json',\n )}. Make sure it has a valid format!`,\n );\n\n await abort();\n }\n\n return packageJson || {};\n}\n\nexport async function updatePackageDotJson(\n packageDotJson: PackageDotJson,\n { installDir }: Pick<WizardOptions, 'installDir'>,\n): Promise<void> {\n try {\n await fs.promises.writeFile(\n join(installDir, 'package.json'),\n // TODO: maybe figure out the original indentation\n JSON.stringify(packageDotJson, null, 2),\n {\n encoding: 'utf8',\n flag: 'w',\n },\n );\n } catch {\n clack.log.error(`Unable to update your ${chalk.cyan('package.json')}.`);\n\n await abort();\n }\n}\n\nexport async function getPackageManager(\n options: Pick<WizardOptions, 'installDir'> & { ci?: boolean },\n): Promise<PackageManager> {\n const detectedPackageManagers = detectAllPackageManagers({\n installDir: options.installDir,\n });\n\n // If exactly one package manager detected, use it automatically\n if (detectedPackageManagers.length === 1) {\n const detectedPackageManager = detectedPackageManagers[0];\n analytics.setTag('package-manager', detectedPackageManager.name);\n return detectedPackageManager;\n }\n\n // CI mode: auto-select first detected or npm\n if (options.ci) {\n const selectedPackageManager =\n detectedPackageManagers.length > 0 ? detectedPackageManagers[0] : npm;\n clack.log.info(\n `CI mode: auto-selected package manager: ${selectedPackageManager.label}`,\n );\n analytics.setTag('package-manager', selectedPackageManager.name);\n return selectedPackageManager;\n }\n\n // If multiple or no package managers detected, prompt user to select\n const pkgOptions =\n detectedPackageManagers.length > 0\n ? detectedPackageManagers\n : packageManagers;\n\n const message =\n detectedPackageManagers.length > 1\n ? 'Multiple package managers detected. Please select one:'\n : 'Please select your package manager.';\n\n const selectedPackageManager: PackageManager | symbol =\n await abortIfCancelled(\n clack.select({\n message,\n options: pkgOptions.map((packageManager) => ({\n value: packageManager,\n label: packageManager.label,\n })),\n }),\n );\n\n analytics.setTag('package-manager', selectedPackageManager.name);\n return selectedPackageManager;\n}\n\nexport function isUsingTypeScript({\n installDir,\n}: Pick<WizardOptions, 'installDir'>) {\n try {\n return fs.existsSync(join(installDir, 'tsconfig.json'));\n } catch {\n return false;\n }\n}\n\n/**\n *\n * Use this function to get project data for the wizard.\n *\n * @param options wizard options\n * @returns project data (token, url)\n */\nexport async function getOrAskForProjectData(\n _options: Pick<WizardOptions, 'signup' | 'ci' | 'apiKey'> & {\n cloudRegion: CloudRegion;\n },\n): Promise<{\n host: string;\n projectApiKey: string;\n accessToken: string;\n projectId: number;\n}> {\n const cloudUrl = getCloudUrlFromRegion(_options.cloudRegion);\n\n // CI mode: bypass OAuth, use personal API key for LLM gateway\n if (_options.ci && _options.apiKey) {\n const host = getHostFromRegion(_options.cloudRegion);\n clack.log.info('Using provided API key (CI mode - OAuth bypassed)');\n\n const projectData = await fetchProjectDataWithApiKey(\n _options.apiKey,\n _options.cloudRegion,\n );\n\n return {\n host,\n projectApiKey: projectData.api_token, // Project API key for SDK config\n accessToken: _options.apiKey, // Personal API key for LLM gateway\n projectId: projectData.id,\n };\n }\n\n const { host, projectApiKey, accessToken, projectId } = await traceStep(\n 'login',\n () =>\n askForWizardLogin({\n cloudRegion: _options.cloudRegion,\n signup: _options.signup,\n }),\n );\n\n if (!projectApiKey) {\n clack.log.error(`Didn't receive a project API key. This shouldn't happen :(\n\nPlease let us know if you think this is a bug in the wizard:\n${chalk.cyan(ISSUES_URL)}`);\n\n clack.log\n .info(`In the meantime, we'll add a dummy project API key (${chalk.cyan(\n `\"${DUMMY_PROJECT_API_KEY}\"`,\n )}) for you to replace later.\nYou can find your Project API key here:\n${chalk.cyan(`${cloudUrl}/settings/project#variables`)}`);\n }\n\n return {\n accessToken,\n host: host || DEFAULT_HOST_URL,\n projectApiKey: projectApiKey || DUMMY_PROJECT_API_KEY,\n projectId,\n };\n}\n\n/**\n * Fetch project data using a personal API key (for CI mode)\n */\nasync function fetchProjectDataWithApiKey(\n apiKey: string,\n region: CloudRegion,\n): Promise<{ api_token: string; id: number }> {\n const cloudUrl = getCloudUrlFromRegion(region);\n const userData = await fetchUserData(apiKey, cloudUrl);\n const projectId = userData.team?.id;\n\n if (!projectId) {\n throw new Error(\n 'Could not determine project ID from API key. Please ensure your API key has access to a project in this cloud region.',\n );\n }\n\n const projectData = await fetchProjectData(apiKey, projectId, cloudUrl);\n return {\n api_token: projectData.api_token,\n id: projectId,\n };\n}\n\nasync function askForWizardLogin(options: {\n cloudRegion: CloudRegion;\n signup: boolean;\n}): Promise<ProjectData> {\n const tokenResponse = await performOAuthFlow({\n cloudRegion: options.cloudRegion,\n scopes: [\n 'user:read',\n 'project:read',\n 'introspection',\n 'llm_gateway:read',\n 'dashboard:write',\n 'insight:write',\n ],\n signup: options.signup,\n });\n\n const projectId = tokenResponse.scoped_teams?.[0];\n\n if (projectId === undefined) {\n const error = new Error(\n 'No project access granted. Please authorize with project-level access.',\n );\n analytics.captureException(error, {\n step: 'wizard_login',\n has_scoped_teams: !!tokenResponse.scoped_teams,\n });\n clack.log.error(error.message);\n await abort();\n }\n\n const cloudUrl = getCloudUrlFromRegion(options.cloudRegion);\n const host = getHostFromRegion(options.cloudRegion);\n\n const projectData = await fetchProjectData(\n tokenResponse.access_token,\n projectId!,\n cloudUrl,\n );\n const userData = await fetchUserData(tokenResponse.access_token, cloudUrl);\n\n const data: ProjectData = {\n accessToken: tokenResponse.access_token,\n projectApiKey: projectData.api_token,\n host,\n distinctId: userData.distinct_id,\n projectId: projectId!,\n };\n\n clack.log.success(\n `Login complete. ${options.signup ? 'Welcome to PostHog! 🎉' : ''}`,\n );\n analytics.setTag('opened-wizard-link', true);\n analytics.setDistinctId(data.distinctId);\n\n return data;\n}\n\n/**\n * Asks users if they have a config file for @param tool (e.g. Vite).\n * If yes, asks users to specify the path to their config file.\n *\n * Use this helper function as a fallback mechanism if the lookup for\n * a config file with its most usual location/name fails.\n *\n * @param toolName Name of the tool for which we're looking for the config file\n * @param configFileName Name of the most common config file name (e.g. vite.config.js)\n *\n * @returns a user path to the config file or undefined if the user doesn't have a config file\n */\nexport async function askForToolConfigPath(\n toolName: string,\n configFileName: string,\n): Promise<string | undefined> {\n const hasConfig = await abortIfCancelled(\n clack.confirm({\n message: `Do you have a ${toolName} config file (e.g. ${chalk.cyan(\n configFileName,\n )})?`,\n initialValue: true,\n }),\n );\n\n if (!hasConfig) {\n return undefined;\n }\n\n return await abortIfCancelled(\n clack.text({\n message: `Please enter the path to your ${toolName} config file:`,\n placeholder: join('.', configFileName),\n validate: (value) => {\n if (!value) {\n return 'Please enter a path.';\n }\n\n try {\n fs.accessSync(value);\n } catch {\n return 'Could not access the file at this path.';\n }\n },\n }),\n );\n}\n\n/**\n * Prints copy/paste-able instructions to the console.\n * Afterwards asks the user if they added the code snippet to their file.\n *\n * While there's no point in providing a \"no\" answer here, it gives users time to fulfill the\n * task before the wizard continues with additional steps.\n *\n * Use this function if you want to show users instructions on how to add/modify\n * code in their file. This is helpful if automatic insertion failed or is not possible/feasible.\n *\n * @param filename the name of the file to which the code snippet should be applied.\n * If a path is provided, only the filename will be used.\n *\n * @param codeSnippet the snippet to be printed. Use {@link makeCodeSnippet} to create the\n * diff-like format for visually highlighting unchanged or modified lines of code.\n *\n * @param hint (optional) a hint to be printed after the main instruction to add\n * the code from @param codeSnippet to their @param filename.\n *\n * TODO: refactor copy paste instructions across different wizards to use this function.\n * this might require adding a custom message parameter to the function\n */\nexport async function showCopyPasteInstructions(\n filename: string,\n codeSnippet: string,\n hint?: string,\n): Promise<void> {\n clack.log.step(\n `Add the following code to your ${chalk.cyan(basename(filename))} file:${\n hint ? chalk.dim(` (${chalk.dim(hint)})`) : ''\n }`,\n );\n\n // Padding the code snippet to be printed with a \\n at the beginning and end\n // This makes it easier to distinguish the snippet from the rest of the output\n // Intentionally logging directly to console here so that the code can be copied/pasted directly\n // eslint-disable-next-line no-console\n console.log(`\\n${codeSnippet}\\n`);\n\n await abortIfCancelled(\n clack.select({\n message: 'Did you apply the snippet above?',\n options: [{ label: 'Yes, continue!', value: true }],\n initialValue: true,\n }),\n );\n}\n\n/**\n * Callback that exposes formatting helpers for a code snippet.\n * @param unchanged - Formats text as old code.\n * @param plus - Formats text as new code.\n * @param minus - Formats text as removed code.\n */\ntype CodeSnippetFormatter = (\n unchanged: (txt: string) => string,\n plus: (txt: string) => string,\n minus: (txt: string) => string,\n) => string;\n\n/**\n * Crafts a code snippet that can be used to e.g.\n * - print copy/paste instructions to the console\n * - create a new config file.\n *\n * @param colors set this to true if you want the final snippet to be colored.\n * This is useful for printing the snippet to the console as part of copy/paste instructions.\n *\n * @param callback the callback that returns the formatted code snippet.\n * It exposes takes the helper functions for marking code as unchanged, new or removed.\n * These functions no-op if no special formatting should be applied\n * and otherwise apply the appropriate formatting/coloring.\n * (@see {@link CodeSnippetFormatter})\n *\n * @see {@link showCopyPasteInstructions} for the helper with which to display the snippet in the console.\n *\n * @returns a string containing the final, formatted code snippet.\n */\nexport function makeCodeSnippet(\n colors: boolean,\n callback: CodeSnippetFormatter,\n): string {\n const unchanged = (txt: string) => (colors ? chalk.grey(txt) : txt);\n const plus = (txt: string) => (colors ? chalk.greenBright(txt) : txt);\n const minus = (txt: string) => (colors ? chalk.redBright(txt) : txt);\n\n return callback(unchanged, plus, minus);\n}\n\n/**\n * Creates a new config file with the given @param filepath and @param codeSnippet.\n *\n * Use this function to create a new config file for users. This is useful\n * when users answered that they don't yet have a config file for a tool.\n *\n * (This doesn't mean that they don't yet have some other way of configuring\n * their tool but we can leave it up to them to figure out how to merge configs\n * here.)\n *\n * @param filepath absolute path to the new config file\n * @param codeSnippet the snippet to be inserted into the file\n * @param moreInformation (optional) the message to be printed after the file was created\n * For example, this can be a link to more information about configuring the tool.\n *\n * @returns true on success, false otherwise\n */\nexport async function createNewConfigFile(\n filepath: string,\n codeSnippet: string,\n { installDir }: Pick<WizardOptions, 'installDir'>,\n moreInformation?: string,\n): Promise<boolean> {\n if (!isAbsolute(filepath)) {\n debug(`createNewConfigFile: filepath is not absolute: ${filepath}`);\n return false;\n }\n\n const prettyFilename = chalk.cyan(relative(installDir, filepath));\n\n try {\n await fs.promises.writeFile(filepath, codeSnippet);\n\n clack.log.success(`Added new ${prettyFilename} file.`);\n\n if (moreInformation) {\n clack.log.info(chalk.gray(moreInformation));\n }\n\n return true;\n } catch (e) {\n debug(e);\n clack.log.warn(\n `Could not create a new ${prettyFilename} file. Please create one manually and follow the instructions below.`,\n );\n }\n\n return false;\n}\n\nexport async function featureSelectionPrompt<F extends ReadonlyArray<Feature>>(\n features: F,\n): Promise<{ [key in F[number]['id']]: boolean }> {\n return traceStep('feature-selection', async () => {\n const selectedFeatures: Record<string, boolean> = {};\n\n for (const feature of features) {\n const selected = await abortIfCancelled(\n clack.select({\n message: feature.prompt,\n initialValue: true,\n options: [\n {\n value: true,\n label: 'Yes',\n hint: feature.enabledHint,\n },\n {\n value: false,\n label: 'No',\n hint: feature.disabledHint,\n },\n ],\n }),\n );\n\n selectedFeatures[feature.id] = selected;\n }\n\n return selectedFeatures as { [key in F[number]['id']]: boolean };\n });\n}\n\nexport async function askShouldInstallPackage(\n pkgName: string,\n): Promise<boolean> {\n return traceStep(`ask-install-package`, () =>\n abortIfCancelled(\n clack.confirm({\n message: `Do you want to install ${chalk.cyan(pkgName)}?`,\n }),\n ),\n );\n}\n\nexport async function askShouldAddPackageOverride(\n pkgName: string,\n pkgVersion: string,\n): Promise<boolean> {\n return traceStep(`ask-add-package-override`, () =>\n abortIfCancelled(\n clack.confirm({\n message: `Do you want to add an override for ${chalk.cyan(\n pkgName,\n )} version ${chalk.cyan(pkgVersion)}?`,\n }),\n ),\n );\n}\n\nexport async function askForAIConsent(\n options: Pick<WizardOptions, 'default' | 'ci'>,\n) {\n return await traceStep('ask-for-ai-consent', async () => {\n // CI mode: auto-consent to AI\n const aiConsent =\n options.default || options.ci\n ? true\n : await abortIfCancelled(\n clack.select({\n message:\n 'This setup wizard uses AI, are you happy to continue? ✨',\n options: [\n {\n label: 'Yes',\n value: true,\n hint: 'We will use AI to help you setup PostHog quickly',\n },\n {\n label: 'No',\n value: false,\n hint: \"I don't like AI\",\n },\n ],\n initialValue: true,\n }),\n );\n\n return aiConsent;\n });\n}\n\nexport async function askForCloudRegion(): Promise<CloudRegion> {\n return await traceStep('ask-for-cloud-region', async () => {\n const cloudRegion: CloudRegion = await abortIfCancelled(\n clack.select({\n message: 'Select your PostHog Cloud region',\n options: [\n {\n label: 'US 🇺🇸',\n value: 'us',\n hint: 'Your data will be stored in the US',\n },\n {\n label: 'EU 🇪🇺',\n value: 'eu',\n hint: 'Your data will be stored in the EU',\n },\n ],\n }),\n );\n\n return cloudRegion;\n });\n}\n"]}
@@ -37,6 +37,14 @@ export type WizardOptions = {
37
37
  * Whether to use the local MCP server at http://localhost:8787/mcp
38
38
  */
39
39
  localMcp: boolean;
40
+ /**
41
+ * CI mode - non-interactive execution
42
+ */
43
+ ci: boolean;
44
+ /**
45
+ * Personal API key (phx_xxx) - used for LLM gateway auth, skips OAuth
46
+ */
47
+ apiKey?: string;
40
48
  };
41
49
  export interface Feature {
42
50
  id: string;
@@ -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 /**\n * Whether to use the local MCP server at http://localhost:8787/mcp\n */\n localMcp: 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
+ {"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 /**\n * Whether to use the local MCP server at http://localhost:8787/mcp\n */\n localMcp: boolean;\n\n /**\n * CI mode - non-interactive execution\n */\n ci: boolean;\n\n /**\n * Personal API key (phx_xxx) - used for LLM gateway auth, skips OAuth\n */\n apiKey?: string;\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"]}
@@ -4,3 +4,4 @@ export declare const getUiHostFromHost: (host: string) => string;
4
4
  export declare const getHostFromRegion: (region: CloudRegion) => "http://localhost:8010" | "https://us.i.posthog.com" | "https://eu.i.posthog.com";
5
5
  export declare const getCloudUrlFromRegion: (region: CloudRegion) => "http://localhost:8010" | "https://us.posthog.com" | "https://eu.posthog.com";
6
6
  export declare const getOauthClientIdFromRegion: (region: CloudRegion) => "c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM" | "bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy" | "DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ";
7
+ export declare const getLlmGatewayUrlFromHost: (host: string) => "http://localhost:3308/wizard" | "https://gateway.eu.posthog.com/wizard" | "https://gateway.us.posthog.com/wizard";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOauthClientIdFromRegion = exports.getCloudUrlFromRegion = exports.getHostFromRegion = exports.getUiHostFromHost = exports.getAssetHostFromHost = void 0;
3
+ exports.getLlmGatewayUrlFromHost = 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')) {
@@ -52,4 +52,14 @@ const getOauthClientIdFromRegion = (region) => {
52
52
  return constants_1.POSTHOG_EU_CLIENT_ID;
53
53
  };
54
54
  exports.getOauthClientIdFromRegion = getOauthClientIdFromRegion;
55
+ const getLlmGatewayUrlFromHost = (host) => {
56
+ if (host.includes('localhost')) {
57
+ return 'http://localhost:3308/wizard';
58
+ }
59
+ if (host.includes('eu.posthog.com') || host.includes('eu.i.posthog.com')) {
60
+ return 'https://gateway.eu.posthog.com/wizard';
61
+ }
62
+ return 'https://gateway.us.posthog.com/wizard';
63
+ };
64
+ exports.getLlmGatewayUrlFromHost = getLlmGatewayUrlFromHost;
55
65
  //# sourceMappingURL=urls.js.map
@@ -1 +1 @@
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,QAA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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"]}
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,GAA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/B,OAAO,8BAA8B,CAAC;IACxC,CAAC;IAED,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACzE,OAAO,uCAAuC,CAAC;IACjD,CAAC;IAED,OAAO,uCAAuC,CAAC;AACjD,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC","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\nexport const getLlmGatewayUrlFromHost = (host: string) => {\n if (host.includes('localhost')) {\n return 'http://localhost:3308/wizard';\n }\n\n if (host.includes('eu.posthog.com') || host.includes('eu.i.posthog.com')) {\n return 'https://gateway.eu.posthog.com/wizard';\n }\n\n return 'https://gateway.us.posthog.com/wizard';\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/wizard",
3
- "version": "1.22.0",
3
+ "version": "1.24.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",
@@ -1,12 +0,0 @@
1
- export declare const getNextjsAppRouterDocs: ({ host, language, }: {
2
- host: string;
3
- language: "typescript" | "javascript";
4
- }) => string;
5
- export declare const getNextjsPagesRouterDocs: ({ host, language, }: {
6
- host: string;
7
- language: "typescript" | "javascript";
8
- }) => string;
9
- export declare const getModernNextjsDocs: ({ host, language, }: {
10
- host: string;
11
- language: "typescript" | "javascript";
12
- }) => string;
@@ -1,272 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getModernNextjsDocs = exports.getNextjsPagesRouterDocs = exports.getNextjsAppRouterDocs = void 0;
4
- const urls_1 = require("../utils/urls");
5
- const getNextjsAppRouterDocs = ({ host, language, }) => {
6
- return `
7
- ==============================
8
- FILE: PostHogProvider.${language === 'typescript' ? 'tsx' : 'jsx'} (put it somewhere where client files are, like the components folder)
9
- LOCATION: Wherever other providers are, or the components folder
10
- ==============================
11
- Changes:
12
- - Create a PostHogProvider component that will be imported into the layout file.
13
- - Make sure to include the defaults: '2025-05-24' option in the init call.
14
-
15
- Example:
16
- --------------------------------------------------
17
- "use client"
18
-
19
- import posthog from "posthog-js"
20
- import { PostHogProvider as PHProvider, usePostHog } from "posthog-js/react"
21
- import { Suspense, useEffect } from "react"
22
- import { usePathname, useSearchParams } from "next/navigation"
23
-
24
- export function PostHogProvider({ children }: { children: React.ReactNode }) {
25
- useEffect(() => {
26
- posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
27
- api_host: "/ingest",
28
- ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
29
- defaults: '2025-05-24',
30
- capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
31
- debug: process.env.NODE_ENV === "development",
32
- })
33
- }, [])
34
-
35
- return (
36
- <PHProvider client={posthog}>
37
- {children}
38
- </PHProvider>
39
- )
40
- }
41
- --------------------------------------------------
42
-
43
- ==============================
44
- FILE: layout.${language === 'typescript' ? 'tsx' : 'jsx'}
45
- LOCATION: Wherever the root layout is
46
- ==============================
47
- Changes:
48
- - Import the PostHogProvider from the providers file and wrap the app in it.
49
-
50
- Example:
51
- --------------------------------------------------
52
- // other imports
53
- import { PostHogProvider } from "LOCATION_OF_POSTHOG_PROVIDER"
54
-
55
- export default function RootLayout({ children }) {
56
- return (
57
- <html lang="en">
58
- <body>
59
- <PostHogProvider>
60
- {/* other providers */}
61
- {children}
62
- {/* other providers */}
63
- </PostHogProvider>
64
- </body>
65
- </html>
66
- )
67
- }
68
- --------------------------------------------------
69
-
70
- ==============================
71
- FILE: posthog.${language === 'typescript' ? 'ts' : 'js'}
72
- LOCATION: Wherever works best given the project structure
73
- ==============================
74
- Changes:
75
- - Initialize the PostHog Node.js client
76
-
77
- Example:
78
- --------------------------------------------------
79
- import { PostHog } from "posthog-node"
80
-
81
- // NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
82
- export default function PostHogClient() {
83
- const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
84
- host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
85
- flushAt: 1,
86
- flushInterval: 0,
87
- })
88
- return posthogClient
89
- }
90
- --------------------------------------------------
91
-
92
- ==============================
93
- FILE: next.config.{js,ts,mjs,cjs}
94
- LOCATION: Wherever the root next config is
95
- ==============================
96
- Changes:
97
- - Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.
98
- - Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.
99
- - This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.
100
-
101
- Example:
102
- --------------------------------------------------
103
- const nextConfig = {
104
- // other config
105
- async rewrites() {
106
- return [
107
- {
108
- source: "/ingest/static/:path*",
109
- destination: "${(0, urls_1.getAssetHostFromHost)(host)}/static/:path*",
110
- },
111
- {
112
- source: "/ingest/:path*",
113
- destination: "${host}/:path*",
114
- },
115
- ];
116
- },
117
- // This is required to support PostHog trailing slash API requests
118
- skipTrailingSlashRedirect: true,
119
- }
120
- module.exports = nextConfig
121
- --------------------------------------------------`;
122
- };
123
- exports.getNextjsAppRouterDocs = getNextjsAppRouterDocs;
124
- const getNextjsPagesRouterDocs = ({ host, language, }) => {
125
- return `
126
- ==============================
127
- FILE: _app.${language === 'typescript' ? 'tsx' : 'jsx'}
128
- LOCATION: Wherever the root _app.${language === 'typescript' ? 'tsx' : 'jsx'} file is
129
- ==============================
130
- Changes:
131
- - Initialize PostHog in _app.js.
132
- - Wrap the application in PostHogProvider.
133
- - Make sure to include the defaults: '2025-05-24' option in the init call.
134
-
135
- Example:
136
- --------------------------------------------------
137
- import { useEffect } from "react"
138
- import posthog from "posthog-js"
139
- import { PostHogProvider } from "posthog-js/react"
140
-
141
- export default function App({ Component, pageProps }) {
142
- useEffect(() => {
143
- posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
144
- api_host: "/ingest",
145
- ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
146
- defaults: '2025-05-24',
147
- capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
148
- debug: process.env.NODE_ENV === "development",
149
- })
150
- }, [])
151
-
152
- return (
153
- <PostHogProvider client={posthog}>
154
- <Component {...pageProps} />
155
- </PostHogProvider>
156
- )
157
- }
158
- --------------------------------------------------
159
-
160
- ==============================
161
- FILE: posthog.${language === 'typescript' ? 'ts' : 'js'}
162
- LOCATION: Wherever works best given the project structure
163
- ==============================
164
- Changes:
165
- - Initialize the PostHog Node.js client
166
-
167
- Example:
168
- --------------------------------------------------
169
- import { PostHog } from "posthog-node"
170
-
171
- // NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
172
- export default function PostHogClient() {
173
- const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
174
- host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
175
- flushAt: 1,
176
- flushInterval: 0,
177
- })
178
- return posthogClient
179
- }
180
- --------------------------------------------------
181
-
182
- ==============================
183
- FILE: next.config.{js,ts,mjs,cjs}
184
- LOCATION: Wherever the root next config is
185
- ==============================
186
- Changes:
187
- - Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.
188
- - Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.
189
- - This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.
190
-
191
- Example:
192
- --------------------------------------------------
193
- const nextConfig = {
194
- // other config
195
- async rewrites() {
196
- return [
197
- {
198
- source: "/ingest/static/:path*",
199
- destination: "${(0, urls_1.getAssetHostFromHost)(host)}/static/:path*",
200
- },
201
- {
202
- source: "/ingest/:path*",
203
- destination: "${host}/:path*",
204
- },
205
- ];
206
- },
207
- // This is required to support PostHog trailing slash API requests
208
- skipTrailingSlashRedirect: true,
209
- }
210
- module.exports = nextConfig
211
- --------------------------------------------------`;
212
- };
213
- exports.getNextjsPagesRouterDocs = getNextjsPagesRouterDocs;
214
- const getModernNextjsDocs = ({ host, language, }) => {
215
- return `
216
- ==============================
217
- FILE: instrumentation-client.${language === 'typescript' ? 'ts' : 'js'}
218
- LOCATION: in the root of the application or inside an src folder.
219
- ==============================
220
- Changes:
221
- - Create or update the instrumentation-client.${language === 'typescript' ? 'ts' : 'js'} file to use the PostHog client. If the file does not exist yet, create it.
222
- - Do *not* import instrumentation-client.${language === 'typescript' ? 'ts' : 'js'} in any other file; Next.js will automatically handle it.
223
- - Do not modify any other pages/components in the Next.js application; the PostHog client will be automatically initialized and handle all pageview tasks on its own.
224
- - Make sure to include the defaults: '2025-05-24' option in the init call.
225
-
226
- Example:
227
- --------------------------------------------------
228
-
229
- import posthog from "posthog-js"
230
-
231
- posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
232
- api_host: "/ingest",
233
- ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
234
- defaults: '2025-05-24',
235
- capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
236
- debug: process.env.NODE_ENV === "development",
237
- });
238
- --------------------------------------------------
239
-
240
- ==============================
241
- FILE: next.config.{js,ts,mjs,cjs}
242
- LOCATION: Wherever the root next config is
243
- ==============================
244
- Changes:
245
- - Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.
246
- - Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.
247
- - This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.
248
-
249
- Example:
250
- --------------------------------------------------
251
- const nextConfig = {
252
- // other config
253
- async rewrites() {
254
- return [
255
- {
256
- source: "/ingest/static/:path*",
257
- destination: "${(0, urls_1.getAssetHostFromHost)(host)}/static/:path*",
258
- },
259
- {
260
- source: "/ingest/:path*",
261
- destination: "${host}/:path*",
262
- },
263
- ];
264
- },
265
- // This is required to support PostHog trailing slash API requests
266
- skipTrailingSlashRedirect: true,
267
- }
268
- module.exports = nextConfig
269
- --------------------------------------------------`;
270
- };
271
- exports.getModernNextjsDocs = getModernNextjsDocs;
272
- //# sourceMappingURL=docs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../src/nextjs/docs.ts"],"names":[],"mappings":";;;AAAA,wCAAwE;AAEjE,MAAM,sBAAsB,GAAG,CAAC,EACrC,IAAI,EACJ,QAAQ,GAIT,EAAE,EAAE;IACH,OAAO;;wBAGL,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CA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AC,IAAI,CAAC,CAAC,CAAC,IACrC;2CAEE,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IACrC;;;;;;;;;;;cAWY,IAAA,wBAAiB,EAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;wBAwBb,IAAA,2BAAoB,EAAC,IAAI,CAAC;;;;wBAI1B,IAAI;;;;;;;;mDAQuB,CAAC;AACpD,CAAC,CAAC;AAlEW,QAAA,mBAAmB,uBAkE9B","sourcesContent":["import { getAssetHostFromHost, getUiHostFromHost } from '../utils/urls';\n\nexport const getNextjsAppRouterDocs = ({\n host,\n language,\n}: {\n host: string;\n language: 'typescript' | 'javascript';\n}) => {\n return `\n==============================\nFILE: PostHogProvider.${\n language === 'typescript' ? 'tsx' : 'jsx'\n } (put it somewhere where client files are, like the components folder)\nLOCATION: Wherever other providers are, or the components folder\n==============================\nChanges:\n- Create a PostHogProvider component that will be imported into the layout file.\n- Make sure to include the defaults: '2025-05-24' option in the init call.\n\nExample:\n--------------------------------------------------\n\"use client\"\n\nimport posthog from \"posthog-js\"\nimport { PostHogProvider as PHProvider, usePostHog } from \"posthog-js/react\"\nimport { Suspense, useEffect } from \"react\"\nimport { usePathname, useSearchParams } from \"next/navigation\"\n\nexport function PostHogProvider({ children }: { children: React.ReactNode }) {\n useEffect(() => {\n posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {\n api_host: \"/ingest\",\n ui_host: \"${getUiHostFromHost(host)}\",\n defaults: '2025-05-24',\n capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this\n debug: process.env.NODE_ENV === \"development\",\n })\n }, [])\n\n return (\n <PHProvider client={posthog}>\n {children}\n </PHProvider>\n )\n}\n--------------------------------------------------\n\n==============================\nFILE: layout.${language === 'typescript' ? 'tsx' : 'jsx'}\nLOCATION: Wherever the root layout is\n==============================\nChanges:\n- Import the PostHogProvider from the providers file and wrap the app in it.\n\nExample:\n--------------------------------------------------\n// other imports\nimport { PostHogProvider } from \"LOCATION_OF_POSTHOG_PROVIDER\"\n\nexport default function RootLayout({ children }) {\n return (\n <html lang=\"en\">\n <body>\n <PostHogProvider>\n {/* other providers */}\n {children}\n {/* other providers */}\n </PostHogProvider>\n </body>\n </html>\n )\n}\n--------------------------------------------------\n\n==============================\nFILE: posthog.${language === 'typescript' ? 'ts' : 'js'}\nLOCATION: Wherever works best given the project structure\n==============================\nChanges:\n- Initialize the PostHog Node.js client\n\nExample:\n--------------------------------------------------\nimport { PostHog } from \"posthog-node\"\n\n// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.\nexport default function PostHogClient() {\n const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {\n host: process.env.NEXT_PUBLIC_POSTHOG_HOST,\n flushAt: 1,\n flushInterval: 0,\n })\n return posthogClient\n}\n--------------------------------------------------\n\n==============================\nFILE: next.config.{js,ts,mjs,cjs}\nLOCATION: Wherever the root next config is\n==============================\nChanges:\n- Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.\n- Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.\n- This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.\n\nExample:\n--------------------------------------------------\nconst nextConfig = {\n // other config\n async rewrites() {\n return [\n {\n source: \"/ingest/static/:path*\",\n destination: \"${getAssetHostFromHost(host)}/static/:path*\",\n },\n {\n source: \"/ingest/:path*\",\n destination: \"${host}/:path*\",\n },\n ];\n },\n // This is required to support PostHog trailing slash API requests\n skipTrailingSlashRedirect: true,\n}\nmodule.exports = nextConfig\n--------------------------------------------------`;\n};\n\nexport const getNextjsPagesRouterDocs = ({\n host,\n language,\n}: {\n host: string;\n language: 'typescript' | 'javascript';\n}) => {\n return `\n==============================\nFILE: _app.${language === 'typescript' ? 'tsx' : 'jsx'}\nLOCATION: Wherever the root _app.${\n language === 'typescript' ? 'tsx' : 'jsx'\n } file is\n==============================\nChanges:\n- Initialize PostHog in _app.js.\n- Wrap the application in PostHogProvider.\n- Make sure to include the defaults: '2025-05-24' option in the init call.\n\nExample:\n--------------------------------------------------\nimport { useEffect } from \"react\"\nimport posthog from \"posthog-js\"\nimport { PostHogProvider } from \"posthog-js/react\"\n\nexport default function App({ Component, pageProps }) {\n useEffect(() => {\n posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {\n api_host: \"/ingest\",\n ui_host: \"${getUiHostFromHost(host)}\",\n defaults: '2025-05-24',\n capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this\n debug: process.env.NODE_ENV === \"development\",\n })\n }, [])\n\n return (\n <PostHogProvider client={posthog}>\n <Component {...pageProps} />\n </PostHogProvider>\n )\n}\n--------------------------------------------------\n\n==============================\nFILE: posthog.${language === 'typescript' ? 'ts' : 'js'}\nLOCATION: Wherever works best given the project structure\n==============================\nChanges:\n- Initialize the PostHog Node.js client\n\nExample:\n--------------------------------------------------\nimport { PostHog } from \"posthog-node\"\n\n// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.\nexport default function PostHogClient() {\n const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {\n host: process.env.NEXT_PUBLIC_POSTHOG_HOST,\n flushAt: 1,\n flushInterval: 0,\n })\n return posthogClient\n}\n--------------------------------------------------\n\n==============================\nFILE: next.config.{js,ts,mjs,cjs}\nLOCATION: Wherever the root next config is\n==============================\nChanges:\n- Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.\n- Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.\n- This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.\n\nExample:\n--------------------------------------------------\nconst nextConfig = {\n // other config\n async rewrites() {\n return [\n {\n source: \"/ingest/static/:path*\",\n destination: \"${getAssetHostFromHost(host)}/static/:path*\",\n },\n {\n source: \"/ingest/:path*\",\n destination: \"${host}/:path*\",\n },\n ];\n },\n // This is required to support PostHog trailing slash API requests\n skipTrailingSlashRedirect: true,\n}\nmodule.exports = nextConfig\n--------------------------------------------------`;\n};\n\nexport const getModernNextjsDocs = ({\n host,\n language,\n}: {\n host: string;\n language: 'typescript' | 'javascript';\n}) => {\n return `\n==============================\nFILE: instrumentation-client.${language === 'typescript' ? 'ts' : 'js'}\nLOCATION: in the root of the application or inside an src folder.\n==============================\nChanges:\n- Create or update the instrumentation-client.${\n language === 'typescript' ? 'ts' : 'js'\n } file to use the PostHog client. If the file does not exist yet, create it.\n- Do *not* import instrumentation-client.${\n language === 'typescript' ? 'ts' : 'js'\n } in any other file; Next.js will automatically handle it.\n- Do not modify any other pages/components in the Next.js application; the PostHog client will be automatically initialized and handle all pageview tasks on its own.\n- Make sure to include the defaults: '2025-05-24' option in the init call.\n\nExample:\n--------------------------------------------------\n\nimport posthog from \"posthog-js\"\n\nposthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {\n api_host: \"/ingest\",\n ui_host: \"${getUiHostFromHost(host)}\",\n defaults: '2025-05-24',\n capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this\n debug: process.env.NODE_ENV === \"development\",\n});\n--------------------------------------------------\n\n==============================\nFILE: next.config.{js,ts,mjs,cjs}\nLOCATION: Wherever the root next config is\n==============================\nChanges:\n- Add rewrites to the Next.js config to support PostHog, if there are existing rewrites, add the PostHog rewrites to them.\n- Add skipTrailingSlashRedirect to the Next.js config to support PostHog trailing slash API requests.\n- This can be of type js, ts, mjs, cjs etc. You should adapt the file according to what extension it uses, and if it does not exist yet use '.js'.\n\nExample:\n--------------------------------------------------\nconst nextConfig = {\n // other config\n async rewrites() {\n return [\n {\n source: \"/ingest/static/:path*\",\n destination: \"${getAssetHostFromHost(host)}/static/:path*\",\n },\n {\n source: \"/ingest/:path*\",\n destination: \"${host}/:path*\",\n },\n ];\n },\n // This is required to support PostHog trailing slash API requests\n skipTrailingSlashRedirect: true,\n}\nmodule.exports = nextConfig\n--------------------------------------------------`;\n};\n"]}
@@ -1,2 +0,0 @@
1
- import { WizardOptions } from '../utils/types';
2
- export declare function runEventSetupWizard(options: WizardOptions): Promise<void>;