@posthog/wizard 1.3.1 → 1.5.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.
- package/README.md +2 -2
- package/dist/bin.js +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/src/astro/astro-wizard.d.ts +2 -0
- package/dist/src/astro/astro-wizard.js +86 -0
- package/dist/src/astro/astro-wizard.js.map +1 -0
- package/dist/src/astro/docs.d.ts +4 -0
- package/dist/src/astro/docs.js +101 -0
- package/dist/src/astro/docs.js.map +1 -0
- package/dist/src/lib/config.d.ts +12 -1
- package/dist/src/lib/config.js +15 -0
- package/dist/src/lib/config.js.map +1 -1
- package/dist/src/lib/constants.d.ts +2 -1
- package/dist/src/lib/constants.js +3 -0
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/messages.d.ts +1 -2
- package/dist/src/lib/messages.js +2 -3
- package/dist/src/lib/messages.js.map +1 -1
- package/dist/src/nextjs/docs.js +8 -14
- package/dist/src/nextjs/docs.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +0 -6
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/react/docs.js +1 -0
- package/dist/src/react/docs.js.map +1 -1
- package/dist/src/run.js +5 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/steps/index.d.ts +0 -1
- package/dist/src/steps/index.js +0 -1
- package/dist/src/steps/index.js.map +1 -1
- package/dist/src/utils/rules/astro-rules.md +44 -0
- package/package.json +1 -1
- package/dist/src/steps/__tests__/create-pr.test.d.ts +0 -1
- package/dist/src/steps/__tests__/create-pr.test.js +0 -193
- package/dist/src/steps/__tests__/create-pr.test.js.map +0 -1
- package/dist/src/steps/create-pr.d.ts +0 -27
- package/dist/src/steps/create-pr.js +0 -305
- package/dist/src/steps/create-pr.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ To use the wizard, you can run it directly using:
|
|
|
17
17
|
npx @posthog/wizard
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Currently the wizard can be used for **React, NextJS, Svelte and React Native**
|
|
20
|
+
Currently the wizard can be used for **React, NextJS, Svelte, Astro and React Native**
|
|
21
21
|
projects. If you have other integrations you would like the wizard to support,
|
|
22
22
|
please open a [GitHub issue](https://github.com/posthog/wizard/issues)!
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ The following CLI arguments are available:
|
|
|
30
30
|
| `--help` | Show help | boolean | | | |
|
|
31
31
|
| `--version` | Show version number | boolean | | | |
|
|
32
32
|
| `--debug` | Enable verbose logging | boolean | `false` | | `POSTHOG_WIZARD_DEBUG` |
|
|
33
|
-
| `--integration` | Choose the integration to setup | choices | Select integration during setup | "nextjs", "react", "svelte", "react-native" | `POSTHOG_WIZARD_INTEGRATION` |
|
|
33
|
+
| `--integration` | Choose the integration to setup | choices | Select integration during setup | "nextjs", "astro", "react", "svelte", "react-native" | `POSTHOG_WIZARD_INTEGRATION` |
|
|
34
34
|
| `--force-install` | Force install the SDK NPM package (use with caution!) | boolean | `false` | | |
|
|
35
35
|
| `--install-dir` | Relative path to install in | string | `.` | | `POSTHOG_WIZARD_INSTALL_DIR` |
|
|
36
36
|
| `--region` | PostHog region to use | choices | | "us", "eu" | `POSTHOG_WIZARD_REGION` |
|
package/dist/bin.js
CHANGED
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../bin.ts"],"names":[],"mappings":";;;;;;AACA,mCAAmC;AACnC,iDAA0C;AAE1C,kDAA0B;AAC1B,2CAAwC;AAExC,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC,iFAAiF;AACjF,+BAA+B;AAC/B,IAAI,CAAC,IAAA,kBAAS,EAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC,EAAE,CAAC;IACpD,IAAA,aAAG,EACD,mCAAmC,kBAAkB,2BAA2B,OAAO,CAAC,OAAO,wCAAwC,CACxI,CAAC;IAC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AC;AACL,CAAC,EACD,CAAC,IAAI,EAAE,EAAE;IACP,KAAK,IAAA,eAAS,EAAC,IAAgC,CAAC,CAAC;AACnD,CAAC,CACF;KACA,OAAO,CAAC,eAAe,EAAE,gCAAgC,EAAE,CAAC,KAAK,EAAE,EAAE;IACpE,OAAO,KAAK;SACT,OAAO,CACN,KAAK,EACL,iDAAiD,EACjD,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,EACD,CAAC,IAAI,EAAE,EAAE;QACP,KAAK,IAAA,mBAAa,EAChB,IAA4D,CAC7D,CAAC;IACJ,CAAC,CACF;SACA,OAAO,CACN,QAAQ,EACR,kDAAkD,EAClD,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC,EACD,GAAG,EAAE;QACH,KAAK,IAAA,kBAAY,GAAE,CAAC;IACtB,CAAC,CACF;SACA,aAAa,CAAC,CAAC,EAAE,+CAA+C,CAAC;SACjE,IAAI,EAAE,CAAC;AACZ,CAAC,CAAC;KACD,IAAI,EAAE;KACN,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;KAClB,OAAO,EAAE;KACT,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC;KACrB,IAAI,CAAC,eAAK,CAAC,aAAa,EAAE,CAAC,CAAC,IAAI,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { satisfies } from 'semver';\nimport { red } from './src/utils/logging';\n\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\n\nconst NODE_VERSION_RANGE = '>=18.17.0';\n\n// Have to run this above the other imports because they are importing clack that\n// has the problematic imports.\nif (!satisfies(process.version, NODE_VERSION_RANGE)) {\n red(\n `PostHog wizard requires Node.js ${NODE_VERSION_RANGE}. You are using Node.js ${process.version}. Please upgrade your Node.js version.`,\n );\n process.exit(1);\n}\n\nimport { runMCPInstall, runMCPRemove } from './src/mcp';\nimport type { CloudRegion, WizardOptions } from './src/utils/types';\nimport { runWizard } from './src/run';\n\nyargs(hideBin(process.argv))\n // global options\n .options({\n debug: {\n default: false,\n describe: 'Enable verbose logging\\nenv: POSTHOG_WIZARD_DEBUG',\n type: 'boolean',\n },\n region: {\n describe: 'PostHog cloud region\\nenv: POSTHOG_WIZARD_REGION',\n choices: ['us', 'eu'],\n type: 'string',\n },\n default: {\n default: false,\n describe:\n 'Use default options for all prompts\\nenv: POSTHOG_WIZARD_DEFAULT',\n type: 'boolean',\n },\n signup: {\n default: false,\n describe:\n 'Create a new PostHog account during setup\\nenv: POSTHOG_WIZARD_SIGNUP',\n type: 'boolean',\n },\n })\n .command(\n ['$0'],\n 'Run the PostHog setup wizard',\n (yargs) => {\n return yargs.options({\n 'force-install': {\n default: false,\n describe:\n 'Force install packages even if peer dependency checks fail\\nenv: POSTHOG_WIZARD_FORCE_INSTALL',\n type: 'boolean',\n },\n 'install-dir': {\n describe:\n 'Directory to install PostHog in\\nenv: POSTHOG_WIZARD_INSTALL_DIR',\n type: 'string',\n },\n integration: {\n describe: 'Integration to set up',\n choices: ['nextjs', 'astro', 'react', 'svelte', 'react-native'],\n type: 'string',\n },\n });\n },\n (argv) => {\n void runWizard(argv as unknown as WizardOptions);\n },\n )\n .command('mcp <command>', 'MCP server management commands', (yargs) => {\n return yargs\n .command(\n 'add',\n 'Install PostHog MCP server to supported clients',\n (yargs) => {\n return yargs.options({});\n },\n (argv) => {\n void runMCPInstall(\n argv as unknown as { signup: boolean; region?: CloudRegion },\n );\n },\n )\n .command(\n 'remove',\n 'Remove PostHog MCP server from supported clients',\n (yargs) => {\n return yargs.options({});\n },\n () => {\n void runMCPRemove();\n },\n )\n .demandCommand(1, 'You must specify a subcommand (add or remove)')\n .help();\n })\n .help()\n .alias('help', 'h')\n .version()\n .alias('version', 'v')\n .wrap(yargs.terminalWidth()).argv;\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-lines */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.runAstroWizard = runAstroWizard;
|
|
8
|
+
const clack_utils_1 = require("../utils/clack-utils");
|
|
9
|
+
const package_json_1 = require("../utils/package-json");
|
|
10
|
+
const clack_1 = __importDefault(require("../utils/clack"));
|
|
11
|
+
const constants_1 = require("../lib/constants");
|
|
12
|
+
const docs_1 = require("./docs");
|
|
13
|
+
const analytics_1 = require("../utils/analytics");
|
|
14
|
+
const file_utils_1 = require("../utils/file-utils");
|
|
15
|
+
const clack_utils_2 = require("../utils/clack-utils");
|
|
16
|
+
const messages_1 = require("../lib/messages");
|
|
17
|
+
const steps_1 = require("../steps");
|
|
18
|
+
async function runAstroWizard(options) {
|
|
19
|
+
(0, clack_utils_1.printWelcome)({
|
|
20
|
+
wizardName: 'PostHog Astro wizard',
|
|
21
|
+
});
|
|
22
|
+
const aiConsent = await (0, clack_utils_1.askForAIConsent)(options);
|
|
23
|
+
if (!aiConsent) {
|
|
24
|
+
await (0, clack_utils_1.abort)('The Astro wizard requires AI to get setup right now. Please view the docs to setup Astro manually instead: https://posthog.com/docs/libraries/js', 0);
|
|
25
|
+
}
|
|
26
|
+
const cloudRegion = options.cloudRegion ?? (await (0, clack_utils_2.askForCloudRegion)());
|
|
27
|
+
await (0, clack_utils_1.confirmContinueIfNoOrDirtyGitRepo)(options);
|
|
28
|
+
const packageJson = await (0, clack_utils_1.getPackageDotJson)(options);
|
|
29
|
+
await (0, clack_utils_1.ensurePackageIsInstalled)(packageJson, 'astro', 'Astro');
|
|
30
|
+
const astroVersion = (0, package_json_1.getPackageVersion)('astro', packageJson);
|
|
31
|
+
if (astroVersion) {
|
|
32
|
+
analytics_1.analytics.setTag('astro-version', astroVersion);
|
|
33
|
+
}
|
|
34
|
+
const { projectApiKey, wizardHash, host } = await (0, clack_utils_1.getOrAskForProjectData)({
|
|
35
|
+
...options,
|
|
36
|
+
cloudRegion,
|
|
37
|
+
});
|
|
38
|
+
clack_1.default.log.info('Heading to include the PostHogSnippet in your Astro project');
|
|
39
|
+
const relevantFiles = await (0, file_utils_1.getRelevantFilesForIntegration)({
|
|
40
|
+
installDir: options.installDir,
|
|
41
|
+
integration: constants_1.Integration.astro,
|
|
42
|
+
});
|
|
43
|
+
const installationDocumentation = (0, docs_1.getAstroDocumentation)({
|
|
44
|
+
projectApiKey,
|
|
45
|
+
host,
|
|
46
|
+
});
|
|
47
|
+
clack_1.default.log.info('Reviewing PostHog documentation for Astro');
|
|
48
|
+
const filesToChange = await (0, file_utils_1.getFilesToChange)({
|
|
49
|
+
integration: constants_1.Integration.astro,
|
|
50
|
+
relevantFiles,
|
|
51
|
+
documentation: installationDocumentation,
|
|
52
|
+
wizardHash,
|
|
53
|
+
cloudRegion,
|
|
54
|
+
});
|
|
55
|
+
await (0, file_utils_1.generateFileChangesForIntegration)({
|
|
56
|
+
integration: constants_1.Integration.astro,
|
|
57
|
+
filesToChange,
|
|
58
|
+
wizardHash,
|
|
59
|
+
installDir: options.installDir,
|
|
60
|
+
documentation: installationDocumentation,
|
|
61
|
+
cloudRegion,
|
|
62
|
+
});
|
|
63
|
+
await (0, steps_1.runPrettierStep)({
|
|
64
|
+
installDir: options.installDir,
|
|
65
|
+
integration: constants_1.Integration.astro,
|
|
66
|
+
});
|
|
67
|
+
const addedEditorRules = await (0, steps_1.addEditorRulesStep)({
|
|
68
|
+
installDir: options.installDir,
|
|
69
|
+
rulesName: 'astro-rules.md',
|
|
70
|
+
integration: constants_1.Integration.astro,
|
|
71
|
+
});
|
|
72
|
+
await (0, steps_1.addMCPServerToClientsStep)({
|
|
73
|
+
cloudRegion,
|
|
74
|
+
integration: constants_1.Integration.astro,
|
|
75
|
+
});
|
|
76
|
+
const outroMessage = (0, messages_1.getOutroMessage)({
|
|
77
|
+
options,
|
|
78
|
+
integration: constants_1.Integration.astro,
|
|
79
|
+
cloudRegion,
|
|
80
|
+
addedEditorRules,
|
|
81
|
+
uploadedEnvVars: [],
|
|
82
|
+
});
|
|
83
|
+
clack_1.default.outro(outroMessage);
|
|
84
|
+
await analytics_1.analytics.shutdown('success');
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=astro-wizard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro-wizard.js","sourceRoot":"","sources":["../../../src/astro/astro-wizard.ts"],"names":[],"mappings":";AAAA,8BAA8B;;;;;AA8B9B,wCA2FC;AAvHD,sDAQ8B;AAC9B,wDAA0D;AAC1D,2DAAmC;AACnC,gDAA+C;AAC/C,iCAA+C;AAC/C,kDAA+C;AAC/C,oDAI6B;AAE7B,sDAAyD;AACzD,8CAAkD;AAClD,oCAIkB;AAEX,KAAK,UAAU,cAAc,CAAC,OAAsB;IACzD,IAAA,0BAAY,EAAC;QACX,UAAU,EAAE,sBAAsB;KACnC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAe,EAAC,OAAO,CAAC,CAAC;IAEjD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAA,mBAAK,EACT,kJAAkJ,EAClJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,CAAC,MAAM,IAAA,+BAAiB,GAAE,CAAC,CAAC;IAEvE,MAAM,IAAA,+CAAiC,EAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;IAErD,MAAM,IAAA,sCAAwB,EAAC,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,YAAY,GAAG,IAAA,gCAAiB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAE7D,IAAI,YAAY,EAAE,CAAC;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AAA,iCAAyB,EAAC;QAC9B,WAAW;QACX,WAAW,EAAE,uBAAW,CAAC,KAAK;KAC/B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAA,0BAAe,EAAC;QACnC,OAAO;QACP,WAAW,EAAE,uBAAW,CAAC,KAAK;QAC9B,WAAW;QACX,gBAAgB;QAChB,eAAe,EAAE,EAAE;KACpB,CAAC,CAAC;IAEH,eAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAE1B,MAAM,qBAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/* eslint-disable max-lines */\n\nimport {\n abort,\n askForAIConsent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n printWelcome,\n} from '../utils/clack-utils';\nimport { getPackageVersion } from '../utils/package-json';\nimport clack from '../utils/clack';\nimport { Integration } from '../lib/constants';\nimport { getAstroDocumentation } from './docs';\nimport { analytics } from '../utils/analytics';\nimport {\n generateFileChangesForIntegration,\n getFilesToChange,\n getRelevantFilesForIntegration,\n} from '../utils/file-utils';\nimport type { WizardOptions } from '../utils/types';\nimport { askForCloudRegion } from '../utils/clack-utils';\nimport { getOutroMessage } from '../lib/messages';\nimport {\n addEditorRulesStep,\n addMCPServerToClientsStep,\n runPrettierStep,\n} from '../steps';\n\nexport async function runAstroWizard(options: WizardOptions): Promise<void> {\n printWelcome({\n wizardName: 'PostHog Astro wizard',\n });\n\n const aiConsent = await askForAIConsent(options);\n\n if (!aiConsent) {\n await abort(\n 'The Astro wizard requires AI to get setup right now. Please view the docs to setup Astro manually instead: https://posthog.com/docs/libraries/js',\n 0,\n );\n }\n\n const cloudRegion = options.cloudRegion ?? (await askForCloudRegion());\n\n await confirmContinueIfNoOrDirtyGitRepo(options);\n\n const packageJson = await getPackageDotJson(options);\n\n await ensurePackageIsInstalled(packageJson, 'astro', 'Astro');\n\n const astroVersion = getPackageVersion('astro', packageJson);\n\n if (astroVersion) {\n analytics.setTag('astro-version', astroVersion);\n }\n\n const { projectApiKey, wizardHash, host } = await getOrAskForProjectData({\n ...options,\n cloudRegion,\n });\n\n clack.log.info('Heading to include the PostHogSnippet in your Astro project');\n\n const relevantFiles = await getRelevantFilesForIntegration({\n installDir: options.installDir,\n integration: Integration.astro,\n });\n\n const installationDocumentation = getAstroDocumentation({\n projectApiKey,\n host,\n });\n\n clack.log.info('Reviewing PostHog documentation for Astro');\n\n const filesToChange = await getFilesToChange({\n integration: Integration.astro,\n relevantFiles,\n documentation: installationDocumentation,\n wizardHash,\n cloudRegion,\n });\n\n await generateFileChangesForIntegration({\n integration: Integration.astro,\n filesToChange,\n wizardHash,\n installDir: options.installDir,\n documentation: installationDocumentation,\n cloudRegion,\n });\n\n await runPrettierStep({\n installDir: options.installDir,\n integration: Integration.astro,\n });\n\n const addedEditorRules = await addEditorRulesStep({\n installDir: options.installDir,\n rulesName: 'astro-rules.md',\n integration: Integration.astro,\n });\n\n await addMCPServerToClientsStep({\n cloudRegion,\n integration: Integration.astro,\n });\n\n const outroMessage = getOutroMessage({\n options,\n integration: Integration.astro,\n cloudRegion,\n addedEditorRules,\n uploadedEnvVars: [],\n });\n\n clack.outro(outroMessage);\n\n await analytics.shutdown('success');\n}\n"]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAstroDocumentation = getAstroDocumentation;
|
|
4
|
+
function getAstroDocumentation({ projectApiKey = 'your_project_api_key', host = 'https://us.i.posthog.com', }) {
|
|
5
|
+
return `
|
|
6
|
+
==============================
|
|
7
|
+
FILE: src/components/posthog.astro
|
|
8
|
+
LOCATION: Components folder (create if missing)
|
|
9
|
+
==============================
|
|
10
|
+
Changes:
|
|
11
|
+
- Add a PostHog loader script with \`is:inline\`.
|
|
12
|
+
|
|
13
|
+
Example:
|
|
14
|
+
--------------------------------------------------
|
|
15
|
+
---
|
|
16
|
+
// src/components/posthog.astro
|
|
17
|
+
---
|
|
18
|
+
<script is:inline type="text/javascript" id="posthog-js">
|
|
19
|
+
!(function(t, e) {
|
|
20
|
+
var o, n, p, r;
|
|
21
|
+
e.__SV ||
|
|
22
|
+
((window.posthog = e),
|
|
23
|
+
(e._i = []),
|
|
24
|
+
(e.init = function(i, s, a) {
|
|
25
|
+
function g(t, e) {
|
|
26
|
+
var o = e.split('.');
|
|
27
|
+
2 == o.length && ((t = t[o[0]]), (e = o[1])),
|
|
28
|
+
(t[e] = function() {
|
|
29
|
+
t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
((p = t.createElement('script')).type = 'text/javascript'),
|
|
33
|
+
(p.crossOrigin = 'anonymous'),
|
|
34
|
+
(p.async = true),
|
|
35
|
+
(p.src = s.api_host + '/static/array.js'),
|
|
36
|
+
(r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r);
|
|
37
|
+
var u = e;
|
|
38
|
+
void 0 !== a ? (u = e[a] = []) : (a = 'posthog');
|
|
39
|
+
u.people = u.people || [];
|
|
40
|
+
u.toString = function(t) {
|
|
41
|
+
var e = 'posthog';
|
|
42
|
+
return 'posthog' !== a && (e += '.' + a), t || (e += ' (stub)'), e;
|
|
43
|
+
};
|
|
44
|
+
u.people.toString = function() {
|
|
45
|
+
return u.toString(1) + '.people (stub)';
|
|
46
|
+
};
|
|
47
|
+
o =
|
|
48
|
+
'capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId'.split(
|
|
49
|
+
' '
|
|
50
|
+
);
|
|
51
|
+
for (n = 0; n < o.length; n++) g(u, o[n]);
|
|
52
|
+
e._i.push([i, s, a]);
|
|
53
|
+
}),
|
|
54
|
+
(e.__SV = 1));
|
|
55
|
+
})(document, window.posthog || []);
|
|
56
|
+
posthog.init('${projectApiKey}', { api_host: '${host}', defaults: '2025-05-24' });
|
|
57
|
+
</script>
|
|
58
|
+
--------------------------------------------------
|
|
59
|
+
|
|
60
|
+
==============================
|
|
61
|
+
FILE: src/layouts/PostHogLayout.astro
|
|
62
|
+
LOCATION: Layouts folder (create if missing)
|
|
63
|
+
==============================
|
|
64
|
+
Changes:
|
|
65
|
+
- Insert the new \`<PostHog />\` component in the \`<head>\`.
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
--------------------------------------------------
|
|
69
|
+
---
|
|
70
|
+
import PostHog from '../components/posthog.astro';
|
|
71
|
+
---
|
|
72
|
+
<html>
|
|
73
|
+
<head>
|
|
74
|
+
<PostHog />
|
|
75
|
+
</head>
|
|
76
|
+
<body>
|
|
77
|
+
<slot />
|
|
78
|
+
</body>
|
|
79
|
+
</html>
|
|
80
|
+
--------------------------------------------------
|
|
81
|
+
|
|
82
|
+
==============================
|
|
83
|
+
FILE: any page you want analytics on, e.g. src/pages/index.astro
|
|
84
|
+
LOCATION: Your page file
|
|
85
|
+
==============================
|
|
86
|
+
Changes:
|
|
87
|
+
- Wrap content with the new layout.
|
|
88
|
+
|
|
89
|
+
Example:
|
|
90
|
+
--------------------------------------------------
|
|
91
|
+
---
|
|
92
|
+
import PostHogLayout from '../layouts/PostHogLayout.astro';
|
|
93
|
+
---
|
|
94
|
+
<PostHogLayout>
|
|
95
|
+
<!-- existing page content -->
|
|
96
|
+
<h1>Welcome to Astro</h1>
|
|
97
|
+
</PostHogLayout>
|
|
98
|
+
--------------------------------------------------
|
|
99
|
+
`;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../src/astro/docs.ts"],"names":[],"mappings":";;AAAA,sDAsGC;AAtGD,SAAgB,qBAAqB,CAAC,EACpC,aAAa,GAAG,sBAAsB,EACtC,IAAI,GAAG,0BAA0B,GAIlC;IACC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmDS,aAAa,mBAAmB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CrD,CAAC;AACF,CAAC","sourcesContent":["export function getAstroDocumentation({\n projectApiKey = 'your_project_api_key',\n host = 'https://us.i.posthog.com',\n}: {\n projectApiKey?: string;\n host?: string;\n}) {\n return `\n==============================\nFILE: src/components/posthog.astro\nLOCATION: Components folder (create if missing)\n==============================\nChanges:\n- Add a PostHog loader script with \\`is:inline\\`.\n\nExample:\n--------------------------------------------------\n---\n// src/components/posthog.astro\n---\n<script is:inline type=\"text/javascript\" id=\"posthog-js\">\n !(function(t, e) {\n var o, n, p, r;\n e.__SV ||\n ((window.posthog = e),\n (e._i = []),\n (e.init = function(i, s, a) {\n function g(t, e) {\n var o = e.split('.');\n 2 == o.length && ((t = t[o[0]]), (e = o[1])),\n (t[e] = function() {\n t.push([e].concat(Array.prototype.slice.call(arguments, 0)));\n });\n }\n ((p = t.createElement('script')).type = 'text/javascript'),\n (p.crossOrigin = 'anonymous'),\n (p.async = true),\n (p.src = s.api_host + '/static/array.js'),\n (r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(p, r);\n var u = e;\n void 0 !== a ? (u = e[a] = []) : (a = 'posthog');\n u.people = u.people || [];\n u.toString = function(t) {\n var e = 'posthog';\n return 'posthog' !== a && (e += '.' + a), t || (e += ' (stub)'), e;\n };\n u.people.toString = function() {\n return u.toString(1) + '.people (stub)';\n };\n o =\n 'capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId'.split(\n ' '\n );\n for (n = 0; n < o.length; n++) g(u, o[n]);\n e._i.push([i, s, a]);\n }),\n (e.__SV = 1));\n })(document, window.posthog || []);\n posthog.init('${projectApiKey}', { api_host: '${host}', defaults: '2025-05-24' });\n</script>\n--------------------------------------------------\n\n==============================\nFILE: src/layouts/PostHogLayout.astro\nLOCATION: Layouts folder (create if missing)\n==============================\nChanges:\n- Insert the new \\`<PostHog />\\` component in the \\`<head>\\`.\n\nExample:\n--------------------------------------------------\n---\nimport PostHog from '../components/posthog.astro';\n---\n<html>\n <head>\n <PostHog />\n </head>\n <body>\n <slot />\n </body>\n</html>\n--------------------------------------------------\n\n==============================\nFILE: any page you want analytics on, e.g. src/pages/index.astro\nLOCATION: Your page file\n==============================\nChanges:\n- Wrap content with the new layout.\n\nExample:\n--------------------------------------------------\n---\nimport PostHogLayout from '../layouts/PostHogLayout.astro';\n---\n<PostHogLayout>\n <!-- existing page content -->\n <h1>Welcome to Astro</h1>\n</PostHogLayout>\n--------------------------------------------------\n`;\n}\n"]}
|
package/dist/src/lib/config.d.ts
CHANGED
|
@@ -45,5 +45,16 @@ export declare const INTEGRATION_CONFIG: {
|
|
|
45
45
|
readonly defaultChanges: "• Installed required packages\n• Added PostHogProvider to the root of the app\n• Enabled autocapture and session replay";
|
|
46
46
|
readonly nextSteps: "• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app";
|
|
47
47
|
};
|
|
48
|
+
readonly astro: {
|
|
49
|
+
readonly name: "Astro";
|
|
50
|
+
readonly filterPatterns: ["**/*.{astro,ts,js,jsx,tsx}"];
|
|
51
|
+
readonly ignorePatterns: ["node_modules", "dist", "build", "public", "static"];
|
|
52
|
+
readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
|
|
53
|
+
readonly generateFilesRules: "";
|
|
54
|
+
readonly filterFilesRules: "";
|
|
55
|
+
readonly docsUrl: "https://posthog.com/docs/libraries/js";
|
|
56
|
+
readonly defaultChanges: "• Added PostHog component with initialization script\n• Created PostHogLayout for consistent analytics tracking";
|
|
57
|
+
readonly nextSteps: "• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app\n• Use posthog.isFeatureEnabled() for feature flags";
|
|
58
|
+
};
|
|
48
59
|
};
|
|
49
|
-
export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.svelte, Integration.reactNative, Integration.react];
|
|
60
|
+
export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.astro, Integration.svelte, Integration.reactNative, Integration.react];
|
package/dist/src/lib/config.js
CHANGED
|
@@ -75,9 +75,24 @@ exports.INTEGRATION_CONFIG = {
|
|
|
75
75
|
defaultChanges: '• Installed required packages\n• Added PostHogProvider to the root of the app\n• Enabled autocapture and session replay',
|
|
76
76
|
nextSteps: '• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app',
|
|
77
77
|
},
|
|
78
|
+
[constants_1.Integration.astro]: {
|
|
79
|
+
name: 'Astro',
|
|
80
|
+
filterPatterns: ['**/*.{astro,ts,js,jsx,tsx}'],
|
|
81
|
+
ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],
|
|
82
|
+
detect: async (options) => {
|
|
83
|
+
const packageJson = await (0, clack_utils_1.getPackageDotJson)(options);
|
|
84
|
+
return (0, package_json_1.hasPackageInstalled)('astro', packageJson);
|
|
85
|
+
},
|
|
86
|
+
generateFilesRules: '',
|
|
87
|
+
filterFilesRules: '',
|
|
88
|
+
docsUrl: 'https://posthog.com/docs/libraries/js',
|
|
89
|
+
defaultChanges: '• Added PostHog component with initialization script\n• Created PostHogLayout for consistent analytics tracking',
|
|
90
|
+
nextSteps: '• Call posthog.identify() when a user signs into your app\n• Call posthog.capture() to capture custom events in your app\n• Use posthog.isFeatureEnabled() for feature flags',
|
|
91
|
+
},
|
|
78
92
|
};
|
|
79
93
|
exports.INTEGRATION_ORDER = [
|
|
80
94
|
constants_1.Integration.nextjs,
|
|
95
|
+
constants_1.Integration.astro,
|
|
81
96
|
constants_1.Integration.svelte,
|
|
82
97
|
constants_1.Integration.reactNative,
|
|
83
98
|
constants_1.Integration.react,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AACzD,wDAA4D;AAE5D,2CAA0C;AAc7B,QAAA,kBAAkB,GAAG;IAChC,CAAC,uBAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,cAAc,EAAE;YACd,cAAc;YACd,MAAM;YACN,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,cAAc;SACf;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAClD,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAAE;QACpB,OAAO,EAAE,4CAA4C;QACrD,cAAc,EACZ,mOAAmO;QACrO,SAAS,EACP,0HAA0H;KAC7H;IACD,CAAC,uBAAW,CAAC,KAAK,CAAC,EAAE;QACnB,IAAI,EAAE,OAAO;QACb,cAAc,EAAE,CAAC,sBAAsB,CAAC;QACxC,cAAc,EAAE;YACd,cAAc;YACd,MAAM;YACN,OAAO;YACP,QAAQ;YACR,QAAQ;YACR,QAAQ;SACT;QACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAiB,EAAC,OAAO,CAAC,CAAC;YACrD,OAAO,IAAA,kCAAmB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,CAAC;QACD,kBAAkB,EAAE,EAAE;QACtB,gBAAgB,EAAE,EAA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BAAW,CAAC,WAAW;IACvB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { getPackageDotJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\n\ntype IntegrationConfig = {\n name: string;\n filterPatterns: string[];\n ignorePatterns: string[];\n detect: (options: Pick<WizardOptions, 'installDir'>) => Promise<boolean>;\n generateFilesRules: string;\n filterFilesRules: string;\n docsUrl: string;\n nextSteps: string;\n defaultChanges: string;\n};\n\nexport const INTEGRATION_CONFIG = {\n [Integration.nextjs]: {\n name: 'Next.js',\n filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'next-env.d.*',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('next', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/next-js',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Initialized PostHog and added pageview tracking\\n• Created a PostHogClient to use PostHog server-side\\n• Setup a reverse proxy to avoid ad blockers blocking analytics requests',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.react]: {\n name: 'React',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'assets',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app, to initialize PostHog and enable autocapture',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.svelte]: {\n name: 'Svelte',\n filterPatterns: ['**/*.{svelte,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('@sveltejs/kit', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/svelte',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Added PostHog initialization to your Svelte app\\n• Setup pageview & pageleave tracking\\n• Setup event auto - capture to capture events as users interact with your app\\n• Added a getPostHogClient() function to use PostHog server-side',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Use getPostHogClient() to start capturing events server - side',\n },\n [Integration.reactNative]: {\n name: 'React Native',\n filterPatterns: ['**/*.{ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-native', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react-native',\n defaultChanges:\n '• Installed required packages\\n• Added PostHogProvider to the root of the app\\n• Enabled autocapture and session replay',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n} as const satisfies Record<Integration, IntegrationConfig>;\n\nexport const INTEGRATION_ORDER = [\n Integration.nextjs,\n Integration.svelte,\n Integration.reactNative,\n Integration.react,\n] as const;\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AACzD,wDAA4D;AAE5D,2CAA0C;AAc7B,QAAA,kBAAkB,GAAG;IAChC,CAAC,uBAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,cAAc,EAAE;YACd,cAAc;YACd,MAAM;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CACwD,CAAC;AAE/C,QAAA,iBAAiB,GAAG;IAC/B,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,KAAK;IACjB,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,WAAW;IACvB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { getPackageDotJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\n\ntype IntegrationConfig = {\n name: string;\n filterPatterns: string[];\n ignorePatterns: string[];\n detect: (options: Pick<WizardOptions, 'installDir'>) => Promise<boolean>;\n generateFilesRules: string;\n filterFilesRules: string;\n docsUrl: string;\n nextSteps: string;\n defaultChanges: string;\n};\n\nexport const INTEGRATION_CONFIG = {\n [Integration.nextjs]: {\n name: 'Next.js',\n filterPatterns: ['**/*.{tsx,ts,jsx,js,mjs,cjs}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'next-env.d.*',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('next', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/next-js',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Initialized PostHog and added pageview tracking\\n• Created a PostHogClient to use PostHog server-side\\n• Setup a reverse proxy to avoid ad blockers blocking analytics requests',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.react]: {\n name: 'React',\n filterPatterns: ['**/*.{tsx,ts,jsx,js}'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'assets',\n ],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app, to initialize PostHog and enable autocapture',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.svelte]: {\n name: 'Svelte',\n filterPatterns: ['**/*.{svelte,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('@sveltejs/kit', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/svelte',\n defaultChanges:\n '• Installed posthog-js & posthog-node packages\\n• Added PostHog initialization to your Svelte app\\n• Setup pageview & pageleave tracking\\n• Setup event auto - capture to capture events as users interact with your app\\n• Added a getPostHogClient() function to use PostHog server-side',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Use getPostHogClient() to start capturing events server - side',\n },\n [Integration.reactNative]: {\n name: 'React Native',\n filterPatterns: ['**/*.{ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('react-native', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/react-native',\n defaultChanges:\n '• Installed required packages\\n• Added PostHogProvider to the root of the app\\n• Enabled autocapture and session replay',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app',\n },\n [Integration.astro]: {\n name: 'Astro',\n filterPatterns: ['**/*.{astro,ts,js,jsx,tsx}'],\n ignorePatterns: ['node_modules', 'dist', 'build', 'public', 'static'],\n detect: async (options) => {\n const packageJson = await getPackageDotJson(options);\n return hasPackageInstalled('astro', packageJson);\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/js',\n defaultChanges:\n '• Added PostHog component with initialization script\\n• Created PostHogLayout for consistent analytics tracking',\n nextSteps:\n '• Call posthog.identify() when a user signs into your app\\n• Call posthog.capture() to capture custom events in your app\\n• Use posthog.isFeatureEnabled() for feature flags',\n },\n} as const satisfies Record<Integration, IntegrationConfig>;\n\nexport const INTEGRATION_ORDER = [\n Integration.nextjs,\n Integration.astro,\n Integration.svelte,\n Integration.reactNative,\n Integration.react,\n] as const;\n"]}
|
|
@@ -2,7 +2,8 @@ export declare enum Integration {
|
|
|
2
2
|
nextjs = "nextjs",
|
|
3
3
|
react = "react",
|
|
4
4
|
svelte = "svelte",
|
|
5
|
-
reactNative = "react-native"
|
|
5
|
+
reactNative = "react-native",
|
|
6
|
+
astro = "astro"
|
|
6
7
|
}
|
|
7
8
|
export declare function getIntegrationDescription(type: string): string;
|
|
8
9
|
type IntegrationChoice = {
|
|
@@ -9,6 +9,7 @@ var Integration;
|
|
|
9
9
|
Integration["react"] = "react";
|
|
10
10
|
Integration["svelte"] = "svelte";
|
|
11
11
|
Integration["reactNative"] = "react-native";
|
|
12
|
+
Integration["astro"] = "astro";
|
|
12
13
|
})(Integration || (exports.Integration = Integration = {}));
|
|
13
14
|
function getIntegrationDescription(type) {
|
|
14
15
|
switch (type) {
|
|
@@ -20,6 +21,8 @@ function getIntegrationDescription(type) {
|
|
|
20
21
|
return 'React Native';
|
|
21
22
|
case Integration.svelte:
|
|
22
23
|
return 'Svelte';
|
|
24
|
+
case Integration.astro:
|
|
25
|
+
return 'Astro';
|
|
23
26
|
default:
|
|
24
27
|
throw new Error(`Unknown integration ${type}`);
|
|
25
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAQA,8DAeC;AAOD,sDAKC;AAnCD,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,8BA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te = 'svelte',\n reactNative = 'react-native',\n astro = 'astro',\n}\n\nexport function getIntegrationDescription(type: string): string {\n switch (type) {\n case Integration.nextjs:\n return 'Next.js';\n case Integration.react:\n return 'React';\n case Integration.reactNative:\n return 'React Native';\n case Integration.svelte:\n return 'Svelte';\n case Integration.astro:\n return 'Astro';\n default:\n throw new Error(`Unknown integration ${type}`);\n }\n}\n\ntype IntegrationChoice = {\n name: string;\n value: string;\n};\n\nexport function getIntegrationChoices(): IntegrationChoice[] {\n return Object.keys(Integration).map((type: string) => ({\n name: getIntegrationDescription(type),\n value: type,\n }));\n}\n\nexport interface Args {\n debug: boolean;\n integration: Integration;\n}\n\nexport const IS_DEV = false;\n\nexport const DEBUG = false;\n\nexport const DEFAULT_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.posthog.com';\nexport const ISSUES_URL = 'https://github.com/posthog/wizard/issues';\nexport const DEFAULT_HOST_URL = IS_DEV\n ? 'http://localhost:8010'\n : 'https://us.i.posthog.com';\nexport const ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY = 'sTMFPsFhdP1Ssg';\nexport const ANALYTICS_HOST_URL = 'https://internal-t.posthog.com';\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n"]}
|
|
@@ -5,13 +5,12 @@ export declare const getPRDescription: ({ integration, addedEditorRules, }: {
|
|
|
5
5
|
integration: Integration;
|
|
6
6
|
addedEditorRules: boolean;
|
|
7
7
|
}) => string;
|
|
8
|
-
export declare const getOutroMessage: ({ options, integration, cloudRegion, addedEditorRules, packageManager, envFileChanged, uploadedEnvVars,
|
|
8
|
+
export declare const getOutroMessage: ({ options, integration, cloudRegion, addedEditorRules, packageManager, envFileChanged, uploadedEnvVars, }: {
|
|
9
9
|
options: WizardOptions;
|
|
10
10
|
integration: Integration;
|
|
11
11
|
cloudRegion: CloudRegion;
|
|
12
12
|
addedEditorRules: boolean;
|
|
13
13
|
packageManager?: PackageManager;
|
|
14
14
|
envFileChanged?: string;
|
|
15
|
-
prUrl?: string;
|
|
16
15
|
uploadedEnvVars: string[];
|
|
17
16
|
}) => string;
|
package/dist/src/lib/messages.js
CHANGED
|
@@ -22,14 +22,13 @@ const getPRDescription = ({ integration, addedEditorRules, }) => {
|
|
|
22
22
|
Learn more about PostHog + ${integrationConfig.name}: ${integrationConfig.docsUrl}`;
|
|
23
23
|
};
|
|
24
24
|
exports.getPRDescription = getPRDescription;
|
|
25
|
-
const getOutroMessage = ({ options, integration, cloudRegion, addedEditorRules, packageManager, envFileChanged, uploadedEnvVars,
|
|
25
|
+
const getOutroMessage = ({ options, integration, cloudRegion, addedEditorRules, packageManager, envFileChanged, uploadedEnvVars, }) => {
|
|
26
26
|
const continueUrl = options.signup
|
|
27
27
|
? `${(0, urls_1.getCloudUrlFromRegion)(cloudRegion)}/products?source=wizard`
|
|
28
28
|
: undefined;
|
|
29
29
|
const integrationConfig = config_1.INTEGRATION_CONFIG[integration];
|
|
30
30
|
const changes = [
|
|
31
31
|
addedEditorRules ? `Added Cursor rules for PostHog` : '',
|
|
32
|
-
prUrl ? `Created a PR for your changes: ${chalk_1.default.cyan(prUrl)}` : '',
|
|
33
32
|
envFileChanged
|
|
34
33
|
? `Added your Project API key to your ${envFileChanged} file`
|
|
35
34
|
: '',
|
|
@@ -41,7 +40,7 @@ const getOutroMessage = ({ options, integration, cloudRegion, addedEditorRules,
|
|
|
41
40
|
uploadedEnvVars.length === 0
|
|
42
41
|
? `Upload your Project API key to your hosting provider`
|
|
43
42
|
: '',
|
|
44
|
-
|
|
43
|
+
`Create a PR for your changes`,
|
|
45
44
|
].filter(Boolean);
|
|
46
45
|
return `
|
|
47
46
|
${chalk_1.default.green('Successfully installed PostHog!')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/lib/messages.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wCAAsD;AAEtD,2CAAsD;AACtD,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E,cAAc;QACZ,CAAC,CAAC,UAAU,eAAK,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,gBAAgB,MAAM,CAAC,IAAI;QACpE,CAAC,CAAC,GACN;;EAEA,eAAK,CAAC,GAAG,CAAC,kDAAkD,sBAAU,EAAE,CAAC,EAAE,CAAC;AAC9E,CAAC,CAAC;AAhEW,QAAA,eAAe,mBAgE1B","sourcesContent":["import chalk from 'chalk';\nimport type { CloudRegion, WizardOptions } from '../utils/types';\nimport { getCloudUrlFromRegion } from '../utils/urls';\nimport type { PackageManager } from '../utils/package-manager';\nimport { ISSUES_URL, Integration } from './constants';\nimport { INTEGRATION_CONFIG } from './config';\n\nexport const getPRDescription = ({\n integration,\n addedEditorRules,\n}: {\n integration: Integration;\n addedEditorRules: boolean;\n}) => {\n const integrationConfig = INTEGRATION_CONFIG[integration];\n\n return `This PR adds an integration for PostHog.\n\n The following changes were made:\n ${integrationConfig.defaultChanges}\n ${addedEditorRules ? `• Added Cursor rules for PostHog\\n` : ''}\n \n \n Note: This used the ${\n integrationConfig.name\n } wizard to setup PostHog, this is still in alpha and like all AI, might have got it wrong. Please check the installation carefully!\n \n Learn more about PostHog + ${integrationConfig.name}: ${\n integrationConfig.docsUrl\n }`;\n};\n\nexport const getOutroMessage = ({\n options,\n integration,\n cloudRegion,\n addedEditorRules,\n packageManager,\n envFileChanged,\n uploadedEnvVars,\n}: {\n options: WizardOptions;\n integration: Integration;\n cloudRegion: CloudRegion;\n addedEditorRules: boolean;\n packageManager?: PackageManager;\n envFileChanged?: string;\n uploadedEnvVars: string[];\n}) => {\n const continueUrl = options.signup\n ? `${getCloudUrlFromRegion(cloudRegion)}/products?source=wizard`\n : undefined;\n\n const integrationConfig = INTEGRATION_CONFIG[integration];\n\n const changes = [\n addedEditorRules ? `Added Cursor rules for PostHog` : '',\n envFileChanged\n ? `Added your Project API key to your ${envFileChanged} file`\n : '',\n uploadedEnvVars.length > 0\n ? `Uploaded your Project API key to your hosting provider`\n : '',\n ].filter(Boolean);\n\n const nextSteps = [\n uploadedEnvVars.length === 0\n ? `Upload your Project API key to your hosting provider`\n : '',\n `Create a PR for your changes`,\n ].filter(Boolean);\n\n return `\n${chalk.green('Successfully installed PostHog!')} \n \n${chalk.cyan('Changes made:')}\n${integrationConfig.defaultChanges}\n${changes.map((change) => `• ${change}`).join('\\n')}\n\n${chalk.yellow('Next steps:')}\n${integrationConfig.nextSteps}\n${nextSteps.map((step) => `• ${step}`).join('\\n')}\n\nLearn more about PostHog + ${integrationConfig.name}: ${chalk.cyan(\n integrationConfig.docsUrl,\n )}\n${continueUrl ? `\\nContinue onboarding: ${chalk.cyan(continueUrl)}\\n` : ``}\nNote: This uses experimental AI to setup your project. It might have got it wrong, please check!\n\nYou should validate your setup by (re)starting your dev environment${\n packageManager\n ? ` (e.g. ${chalk.cyan(`${packageManager.runScriptCommand} dev`)}).`\n : `.`\n }\n\n${chalk.dim(`If you encounter any issues, let us know here: ${ISSUES_URL}`)}`;\n};\n"]}
|
package/dist/src/nextjs/docs.js
CHANGED
|
@@ -25,8 +25,7 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
|
|
25
25
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
26
26
|
api_host: "/ingest",
|
|
27
27
|
ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
|
|
28
|
-
|
|
29
|
-
capture_pageleave: true, // Enable pageleave capture
|
|
28
|
+
defaults: '2025-05-24',
|
|
30
29
|
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
|
|
31
30
|
debug: process.env.NODE_ENV === "development",
|
|
32
31
|
})
|
|
@@ -34,7 +33,6 @@ export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
|
|
34
33
|
|
|
35
34
|
return (
|
|
36
35
|
<PHProvider client={posthog}>
|
|
37
|
-
<SuspendedPostHogPageView />
|
|
38
36
|
{children}
|
|
39
37
|
</PHProvider>
|
|
40
38
|
)
|
|
@@ -79,10 +77,10 @@ Example:
|
|
|
79
77
|
--------------------------------------------------
|
|
80
78
|
import { PostHog } from "posthog-node"
|
|
81
79
|
|
|
80
|
+
// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
|
|
82
81
|
export default function PostHogClient() {
|
|
83
82
|
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
84
83
|
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
|
85
|
-
capture_pageview: 'history_change',
|
|
86
84
|
flushAt: 1,
|
|
87
85
|
flushInterval: 0,
|
|
88
86
|
})
|
|
@@ -148,11 +146,8 @@ export default function App({ Component, pageProps }) {
|
|
|
148
146
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
|
149
147
|
api_host: "/ingest",
|
|
150
148
|
ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
|
|
151
|
-
|
|
149
|
+
defaults: '2025-05-24',
|
|
152
150
|
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
|
|
153
|
-
loaded: (posthog) => {
|
|
154
|
-
if (process.env.NODE_ENV === "development") posthog.debug()
|
|
155
|
-
},
|
|
156
151
|
debug: process.env.NODE_ENV === "development",
|
|
157
152
|
})
|
|
158
153
|
}, [])
|
|
@@ -176,10 +171,10 @@ Example:
|
|
|
176
171
|
--------------------------------------------------
|
|
177
172
|
import { PostHog } from "posthog-node"
|
|
178
173
|
|
|
174
|
+
// NOTE: This is a Node.js client, so you can use it for sending events from the server side to PostHog.
|
|
179
175
|
export default function PostHogClient() {
|
|
180
176
|
const posthogClient = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
181
177
|
host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
|
182
|
-
capture_pageview: 'history_change',
|
|
183
178
|
flushAt: 1,
|
|
184
179
|
flushInterval: 0,
|
|
185
180
|
})
|
|
@@ -226,12 +221,12 @@ exports.getNextjsPagesRouterDocs = getNextjsPagesRouterDocs;
|
|
|
226
221
|
const getModernNextjsDocs = ({ host, language, }) => {
|
|
227
222
|
return `
|
|
228
223
|
==============================
|
|
229
|
-
FILE: instrumentation-client.${language === 'typescript' ? 'ts' : 'js'}
|
|
224
|
+
FILE: instrumentation-client.${language === 'typescript' ? 'ts' : 'js'}
|
|
230
225
|
LOCATION: in the root of the application or inside an src folder.
|
|
231
226
|
==============================
|
|
232
227
|
Changes:
|
|
233
|
-
- Create or update the instrumentation-client.${language === 'typescript' ? '
|
|
234
|
-
- Do *not* import instrumentation-client.${language === 'typescript' ? '
|
|
228
|
+
- 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.
|
|
229
|
+
- Do *not* import instrumentation-client.${language === 'typescript' ? 'ts' : 'js'} in any other file; Next.js will automatically handle it.
|
|
235
230
|
- 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.
|
|
236
231
|
|
|
237
232
|
Example:
|
|
@@ -242,8 +237,7 @@ import posthog from "posthog-js"
|
|
|
242
237
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
|
|
243
238
|
api_host: "/ingest",
|
|
244
239
|
ui_host: "${(0, urls_1.getUiHostFromHost)(host)}",
|
|
245
|
-
|
|
246
|
-
capture_pageleave: true, // Enable pageleave capture
|
|
240
|
+
defaults: '2025-05-24',
|
|
247
241
|
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
|
|
248
242
|
debug: process.env.NODE_ENV === "development",
|
|
249
243
|
});
|