@posthog/wizard 1.29.0 → 1.30.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.
@@ -0,0 +1,5 @@
1
+ import type { WizardOptions } from '../utils/types';
2
+ /**
3
+ * Laravel wizard powered by the universal agent runner.
4
+ */
5
+ export declare function runLaravelWizardAgent(options: WizardOptions): Promise<void>;
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.runLaravelWizardAgent = runLaravelWizardAgent;
40
+ const debug_1 = require("../utils/debug");
41
+ const agent_runner_1 = require("../lib/agent-runner");
42
+ const constants_1 = require("../lib/constants");
43
+ const clack_1 = __importDefault(require("../utils/clack"));
44
+ const chalk_1 = __importDefault(require("chalk"));
45
+ const semver = __importStar(require("semver"));
46
+ const utils_1 = require("./utils");
47
+ /**
48
+ * Laravel framework configuration for the universal agent runner
49
+ */
50
+ const MINIMUM_LARAVEL_VERSION = '9.0.0';
51
+ const LARAVEL_AGENT_CONFIG = {
52
+ metadata: {
53
+ name: 'Laravel',
54
+ integration: constants_1.Integration.laravel,
55
+ docsUrl: 'https://posthog.com/docs/libraries/php',
56
+ unsupportedVersionDocsUrl: 'https://posthog.com/docs/libraries/php',
57
+ gatherContext: async (options) => {
58
+ const projectType = await (0, utils_1.getLaravelProjectType)(options);
59
+ const serviceProvider = await (0, utils_1.findLaravelServiceProvider)(options);
60
+ const bootstrapFile = (0, utils_1.findLaravelBootstrapFile)(options);
61
+ const laravelStructure = (0, utils_1.detectLaravelStructure)(options);
62
+ return {
63
+ projectType,
64
+ serviceProvider,
65
+ bootstrapFile,
66
+ laravelStructure,
67
+ };
68
+ },
69
+ },
70
+ detection: {
71
+ packageName: 'laravel/framework',
72
+ packageDisplayName: 'Laravel',
73
+ usesPackageJson: false,
74
+ getVersion: (_packageJson) => {
75
+ // For Laravel, we don't use package.json. Version is extracted separately
76
+ // from composer.json in the wizard entry point
77
+ return undefined;
78
+ },
79
+ getVersionBucket: utils_1.getLaravelVersionBucket,
80
+ },
81
+ environment: {
82
+ uploadToHosting: false,
83
+ getEnvVars: (apiKey, host) => ({
84
+ POSTHOG_API_KEY: apiKey,
85
+ POSTHOG_HOST: host,
86
+ }),
87
+ },
88
+ analytics: {
89
+ getTags: (context) => {
90
+ const projectType = context.projectType;
91
+ return {
92
+ projectType: projectType || 'unknown',
93
+ laravelStructure: context.laravelStructure || 'unknown',
94
+ };
95
+ },
96
+ },
97
+ prompts: {
98
+ projectTypeDetection: 'This is a PHP/Laravel project. Look for composer.json, artisan CLI, and app/ directory structure to confirm. Check for Laravel-specific packages like laravel/framework.',
99
+ packageInstallation: 'Use Composer to install packages. Run `composer require posthog/posthog-php` without pinning a specific version.',
100
+ getAdditionalContextLines: (context) => {
101
+ const projectType = context.projectType;
102
+ const projectTypeName = projectType
103
+ ? (0, utils_1.getLaravelProjectTypeName)(projectType)
104
+ : 'unknown';
105
+ const lines = [
106
+ `Project type: ${projectTypeName}`,
107
+ `Framework docs ID: php (use posthog://docs/frameworks/php for documentation)`,
108
+ `Laravel structure: ${context.laravelStructure} (affects where to add configuration)`,
109
+ ];
110
+ if (context.serviceProvider) {
111
+ lines.push(`Service provider: ${context.serviceProvider}`);
112
+ }
113
+ if (context.bootstrapFile) {
114
+ lines.push(`Bootstrap file: ${context.bootstrapFile}`);
115
+ }
116
+ // Add Laravel-specific guidance based on version structure
117
+ if (context.laravelStructure === 'latest') {
118
+ lines.push('Note: Laravel 11+ uses simplified bootstrap/app.php for middleware and providers');
119
+ }
120
+ else {
121
+ lines.push('Note: Use app/Http/Kernel.php for middleware, app/Providers for service providers');
122
+ }
123
+ return lines;
124
+ },
125
+ },
126
+ ui: {
127
+ successMessage: 'PostHog integration complete',
128
+ estimatedDurationMinutes: 5,
129
+ getOutroChanges: (context) => {
130
+ const projectType = context.projectType;
131
+ const projectTypeName = projectType
132
+ ? (0, utils_1.getLaravelProjectTypeName)(projectType)
133
+ : 'Laravel';
134
+ const changes = [
135
+ `Analyzed your ${projectTypeName} project structure`,
136
+ `Installed the PostHog PHP package via Composer`,
137
+ `Configured PostHog in your Laravel application`,
138
+ ];
139
+ if (context.laravelStructure === 'latest') {
140
+ changes.push('Added PostHog initialization to bootstrap/app.php');
141
+ }
142
+ else {
143
+ changes.push('Created a PostHog service provider for initialization');
144
+ }
145
+ if (projectType === utils_1.LaravelProjectType.INERTIA) {
146
+ changes.push('Configured PostHog to work with Inertia.js');
147
+ }
148
+ if (projectType === utils_1.LaravelProjectType.LIVEWIRE) {
149
+ changes.push('Configured PostHog to work with Livewire');
150
+ }
151
+ return changes;
152
+ },
153
+ getOutroNextSteps: () => [
154
+ 'Start your Laravel development server with `php artisan serve`',
155
+ 'Visit your PostHog dashboard to see incoming events',
156
+ 'Use PostHog::capture() to track custom events',
157
+ 'Use PostHog::identify() to associate events with users',
158
+ ],
159
+ },
160
+ };
161
+ /**
162
+ * Laravel wizard powered by the universal agent runner.
163
+ */
164
+ async function runLaravelWizardAgent(options) {
165
+ if (options.debug) {
166
+ (0, debug_1.enableDebugLogs)();
167
+ }
168
+ // Check Laravel version - agent wizard requires >= 9.0.0
169
+ const laravelVersion = (0, utils_1.getLaravelVersion)(options);
170
+ if (laravelVersion) {
171
+ const coercedVersion = semver.coerce(laravelVersion);
172
+ if (coercedVersion && semver.lt(coercedVersion, MINIMUM_LARAVEL_VERSION)) {
173
+ const docsUrl = LARAVEL_AGENT_CONFIG.metadata.unsupportedVersionDocsUrl ??
174
+ LARAVEL_AGENT_CONFIG.metadata.docsUrl;
175
+ clack_1.default.log.warn(`Sorry: the wizard can't help you with Laravel ${laravelVersion}. Upgrade to Laravel ${MINIMUM_LARAVEL_VERSION} or later, or check out the manual setup guide.`);
176
+ clack_1.default.log.info(`Setup Laravel manually: ${chalk_1.default.cyan(docsUrl)}`);
177
+ clack_1.default.outro('PostHog wizard will see you next time!');
178
+ return;
179
+ }
180
+ }
181
+ await (0, agent_runner_1.runAgentWizard)(LARAVEL_AGENT_CONFIG, options);
182
+ }
183
+ //# sourceMappingURL=laravel-wizard-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"laravel-wizard-agent.js","sourceRoot":"","sources":["../../../src/laravel/laravel-wizard-agent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+JA,sDA2BC;AAvLD,0CAAiD;AACjD,sDAAqD;AACrD,gDAA+C;AAC/C,2DAAmC;AACnC,kDAA0B;AAC1B,+CAAiC;AAC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G,CAAC,IAAI,CACZ,iDAAiD,cAAc,wBAAwB,uBAAuB,iDAAiD,CAChK,CAAC;YACF,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,2BAA2B,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACjE,eAAK,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,IAAA,6BAAc,EAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;AACtD,CAAC","sourcesContent":["/* Laravel wizard using posthog-agent with PostHog MCP */\nimport type { WizardOptions } from '../utils/types';\nimport type { FrameworkConfig } from '../lib/framework-config';\nimport { enableDebugLogs } from '../utils/debug';\nimport { runAgentWizard } from '../lib/agent-runner';\nimport { Integration } from '../lib/constants';\nimport clack from '../utils/clack';\nimport chalk from 'chalk';\nimport * as semver from 'semver';\nimport {\n getLaravelVersion,\n getLaravelProjectType,\n getLaravelProjectTypeName,\n getLaravelVersionBucket,\n LaravelProjectType,\n findLaravelServiceProvider,\n findLaravelBootstrapFile,\n detectLaravelStructure,\n} from './utils';\n\n/**\n * Laravel framework configuration for the universal agent runner\n */\nconst MINIMUM_LARAVEL_VERSION = '9.0.0';\n\nconst LARAVEL_AGENT_CONFIG: FrameworkConfig = {\n metadata: {\n name: 'Laravel',\n integration: Integration.laravel,\n docsUrl: 'https://posthog.com/docs/libraries/php',\n unsupportedVersionDocsUrl: 'https://posthog.com/docs/libraries/php',\n gatherContext: async (options: WizardOptions) => {\n const projectType = await getLaravelProjectType(options);\n const serviceProvider = await findLaravelServiceProvider(options);\n const bootstrapFile = findLaravelBootstrapFile(options);\n const laravelStructure = detectLaravelStructure(options);\n\n return {\n projectType,\n serviceProvider,\n bootstrapFile,\n laravelStructure,\n };\n },\n },\n\n detection: {\n packageName: 'laravel/framework',\n packageDisplayName: 'Laravel',\n usesPackageJson: false,\n getVersion: (_packageJson: any) => {\n // For Laravel, we don't use package.json. Version is extracted separately\n // from composer.json in the wizard entry point\n return undefined;\n },\n getVersionBucket: getLaravelVersionBucket,\n },\n\n environment: {\n uploadToHosting: false,\n getEnvVars: (apiKey: string, host: string) => ({\n POSTHOG_API_KEY: apiKey,\n POSTHOG_HOST: host,\n }),\n },\n\n analytics: {\n getTags: (context: any) => {\n const projectType = context.projectType as LaravelProjectType;\n return {\n projectType: projectType || 'unknown',\n laravelStructure: context.laravelStructure || 'unknown',\n };\n },\n },\n\n prompts: {\n projectTypeDetection:\n 'This is a PHP/Laravel project. Look for composer.json, artisan CLI, and app/ directory structure to confirm. Check for Laravel-specific packages like laravel/framework.',\n packageInstallation:\n 'Use Composer to install packages. Run `composer require posthog/posthog-php` without pinning a specific version.',\n getAdditionalContextLines: (context: any) => {\n const projectType = context.projectType as LaravelProjectType;\n const projectTypeName = projectType\n ? getLaravelProjectTypeName(projectType)\n : 'unknown';\n\n const lines = [\n `Project type: ${projectTypeName}`,\n `Framework docs ID: php (use posthog://docs/frameworks/php for documentation)`,\n `Laravel structure: ${context.laravelStructure} (affects where to add configuration)`,\n ];\n\n if (context.serviceProvider) {\n lines.push(`Service provider: ${context.serviceProvider}`);\n }\n\n if (context.bootstrapFile) {\n lines.push(`Bootstrap file: ${context.bootstrapFile}`);\n }\n\n // Add Laravel-specific guidance based on version structure\n if (context.laravelStructure === 'latest') {\n lines.push(\n 'Note: Laravel 11+ uses simplified bootstrap/app.php for middleware and providers',\n );\n } else {\n lines.push(\n 'Note: Use app/Http/Kernel.php for middleware, app/Providers for service providers',\n );\n }\n\n return lines;\n },\n },\n\n ui: {\n successMessage: 'PostHog integration complete',\n estimatedDurationMinutes: 5,\n getOutroChanges: (context: any) => {\n const projectType = context.projectType as LaravelProjectType;\n const projectTypeName = projectType\n ? getLaravelProjectTypeName(projectType)\n : 'Laravel';\n\n const changes = [\n `Analyzed your ${projectTypeName} project structure`,\n `Installed the PostHog PHP package via Composer`,\n `Configured PostHog in your Laravel application`,\n ];\n\n if (context.laravelStructure === 'latest') {\n changes.push('Added PostHog initialization to bootstrap/app.php');\n } else {\n changes.push('Created a PostHog service provider for initialization');\n }\n\n if (projectType === LaravelProjectType.INERTIA) {\n changes.push('Configured PostHog to work with Inertia.js');\n }\n\n if (projectType === LaravelProjectType.LIVEWIRE) {\n changes.push('Configured PostHog to work with Livewire');\n }\n\n return changes;\n },\n getOutroNextSteps: () => [\n 'Start your Laravel development server with `php artisan serve`',\n 'Visit your PostHog dashboard to see incoming events',\n 'Use PostHog::capture() to track custom events',\n 'Use PostHog::identify() to associate events with users',\n ],\n },\n};\n\n/**\n * Laravel wizard powered by the universal agent runner.\n */\nexport async function runLaravelWizardAgent(\n options: WizardOptions,\n): Promise<void> {\n if (options.debug) {\n enableDebugLogs();\n }\n\n // Check Laravel version - agent wizard requires >= 9.0.0\n const laravelVersion = getLaravelVersion(options);\n\n if (laravelVersion) {\n const coercedVersion = semver.coerce(laravelVersion);\n if (coercedVersion && semver.lt(coercedVersion, MINIMUM_LARAVEL_VERSION)) {\n const docsUrl =\n LARAVEL_AGENT_CONFIG.metadata.unsupportedVersionDocsUrl ??\n LARAVEL_AGENT_CONFIG.metadata.docsUrl;\n\n clack.log.warn(\n `Sorry: the wizard can't help you with Laravel ${laravelVersion}. Upgrade to Laravel ${MINIMUM_LARAVEL_VERSION} or later, or check out the manual setup guide.`,\n );\n clack.log.info(`Setup Laravel manually: ${chalk.cyan(docsUrl)}`);\n clack.outro('PostHog wizard will see you next time!');\n return;\n }\n }\n\n await runAgentWizard(LARAVEL_AGENT_CONFIG, options);\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import type { WizardOptions } from '../utils/types';
2
+ export declare enum LaravelProjectType {
3
+ STANDARD = "standard",// Basic Laravel app
4
+ INERTIA = "inertia",// Inertia.js (Vue/React SPA) - may need JS SDK too
5
+ LIVEWIRE = "livewire"
6
+ }
7
+ /**
8
+ * Get Laravel version bucket for analytics
9
+ */
10
+ export declare function getLaravelVersionBucket(version: string | undefined): string;
11
+ /**
12
+ * Read and parse composer.json
13
+ */
14
+ export declare function getComposerJson(options: Pick<WizardOptions, 'installDir'>): Record<string, any> | undefined;
15
+ /**
16
+ * Get Laravel version from composer.json
17
+ */
18
+ export declare function getLaravelVersion(options: Pick<WizardOptions, 'installDir'>): string | undefined;
19
+ /**
20
+ * Get human-readable name for Laravel project type
21
+ */
22
+ export declare function getLaravelProjectTypeName(projectType: LaravelProjectType): string;
23
+ /**
24
+ * Detect Laravel project type
25
+ */
26
+ export declare function getLaravelProjectType(options: WizardOptions): Promise<LaravelProjectType>;
27
+ /**
28
+ * Find the main service provider file
29
+ */
30
+ export declare function findLaravelServiceProvider(options: Pick<WizardOptions, 'installDir'>): Promise<string | undefined>;
31
+ /**
32
+ * Find the bootstrap file (differs between Laravel versions)
33
+ */
34
+ export declare function findLaravelBootstrapFile(options: Pick<WizardOptions, 'installDir'>): string | undefined;
35
+ /**
36
+ * Detect Laravel version structure for configuration guidance
37
+ */
38
+ export declare function detectLaravelStructure(options: Pick<WizardOptions, 'installDir'>): 'legacy' | 'modern' | 'latest';
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.LaravelProjectType = void 0;
40
+ exports.getLaravelVersionBucket = getLaravelVersionBucket;
41
+ exports.getComposerJson = getComposerJson;
42
+ exports.getLaravelVersion = getLaravelVersion;
43
+ exports.getLaravelProjectTypeName = getLaravelProjectTypeName;
44
+ exports.getLaravelProjectType = getLaravelProjectType;
45
+ exports.findLaravelServiceProvider = findLaravelServiceProvider;
46
+ exports.findLaravelBootstrapFile = findLaravelBootstrapFile;
47
+ exports.detectLaravelStructure = detectLaravelStructure;
48
+ const semver_1 = require("semver");
49
+ const fast_glob_1 = __importDefault(require("fast-glob"));
50
+ const clack_1 = __importDefault(require("../utils/clack"));
51
+ const fs = __importStar(require("node:fs"));
52
+ const path = __importStar(require("node:path"));
53
+ var LaravelProjectType;
54
+ (function (LaravelProjectType) {
55
+ LaravelProjectType["STANDARD"] = "standard";
56
+ LaravelProjectType["INERTIA"] = "inertia";
57
+ LaravelProjectType["LIVEWIRE"] = "livewire";
58
+ })(LaravelProjectType || (exports.LaravelProjectType = LaravelProjectType = {}));
59
+ /**
60
+ * Ignore patterns for Laravel projects
61
+ */
62
+ const LARAVEL_IGNORE_PATTERNS = [
63
+ '**/node_modules/**',
64
+ '**/vendor/**',
65
+ '**/storage/**',
66
+ '**/bootstrap/cache/**',
67
+ '**/.phpunit.cache/**',
68
+ '**/public/build/**',
69
+ '**/public/hot/**',
70
+ ];
71
+ /**
72
+ * Get Laravel version bucket for analytics
73
+ */
74
+ function getLaravelVersionBucket(version) {
75
+ if (!version) {
76
+ return 'none';
77
+ }
78
+ try {
79
+ const minVer = (0, semver_1.minVersion)(version);
80
+ if (!minVer) {
81
+ return 'invalid';
82
+ }
83
+ const majorVersion = (0, semver_1.major)(minVer);
84
+ if (majorVersion >= 9) {
85
+ return `${majorVersion}.x`;
86
+ }
87
+ return '<9.0.0';
88
+ }
89
+ catch {
90
+ return 'unknown';
91
+ }
92
+ }
93
+ /**
94
+ * Read and parse composer.json
95
+ */
96
+ function getComposerJson(options) {
97
+ const { installDir } = options;
98
+ const composerPath = path.join(installDir, 'composer.json');
99
+ try {
100
+ const content = fs.readFileSync(composerPath, 'utf-8');
101
+ return JSON.parse(content);
102
+ }
103
+ catch {
104
+ return undefined;
105
+ }
106
+ }
107
+ /**
108
+ * Check if a package is installed (present in composer.json)
109
+ */
110
+ function hasComposerPackage(packageName, options) {
111
+ const composer = getComposerJson(options);
112
+ if (!composer)
113
+ return false;
114
+ return !!(composer.require?.[packageName] || composer['require-dev']?.[packageName]);
115
+ }
116
+ /**
117
+ * Extract version for a package from composer.json
118
+ */
119
+ function getComposerPackageVersion(packageName, options) {
120
+ const composer = getComposerJson(options);
121
+ if (!composer)
122
+ return undefined;
123
+ const version = composer.require?.[packageName] || composer['require-dev']?.[packageName];
124
+ if (version) {
125
+ // Clean version string (remove ^, ~, >=, etc.)
126
+ return version.replace(/^[\^~>=<]+/, '');
127
+ }
128
+ return undefined;
129
+ }
130
+ /**
131
+ * Check if a pattern exists in PHP source files
132
+ */
133
+ async function hasLaravelCodePattern(pattern, options, filePatterns = ['**/*.php']) {
134
+ const { installDir } = options;
135
+ const phpFiles = await (0, fast_glob_1.default)(filePatterns, {
136
+ cwd: installDir,
137
+ ignore: LARAVEL_IGNORE_PATTERNS,
138
+ });
139
+ const searchPattern = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
140
+ for (const phpFile of phpFiles) {
141
+ try {
142
+ const content = fs.readFileSync(path.join(installDir, phpFile), 'utf-8');
143
+ if (searchPattern.test(content))
144
+ return true;
145
+ }
146
+ catch {
147
+ continue;
148
+ }
149
+ }
150
+ return false;
151
+ }
152
+ /**
153
+ * Get Laravel version from composer.json
154
+ */
155
+ function getLaravelVersion(options) {
156
+ return getComposerPackageVersion('laravel/framework', options);
157
+ }
158
+ /**
159
+ * Get human-readable name for Laravel project type
160
+ */
161
+ function getLaravelProjectTypeName(projectType) {
162
+ switch (projectType) {
163
+ case LaravelProjectType.STANDARD:
164
+ return 'Standard Laravel';
165
+ case LaravelProjectType.INERTIA:
166
+ return 'Laravel with Inertia.js';
167
+ case LaravelProjectType.LIVEWIRE:
168
+ return 'Laravel with Livewire';
169
+ default:
170
+ return 'Laravel';
171
+ }
172
+ }
173
+ /**
174
+ * Check for Inertia.js
175
+ */
176
+ async function hasInertia(options) {
177
+ return (hasComposerPackage('inertiajs/inertia-laravel', options) ||
178
+ (await hasLaravelCodePattern(/Inertia::render|inertia\(/, options)));
179
+ }
180
+ /**
181
+ * Check for Livewire
182
+ */
183
+ async function hasLivewire(options) {
184
+ return (hasComposerPackage('livewire/livewire', options) ||
185
+ (await hasLaravelCodePattern(/extends\s+Component|@livewire/, options)));
186
+ }
187
+ /**
188
+ * Detect Laravel project type
189
+ */
190
+ async function getLaravelProjectType(options) {
191
+ // Check for SPA/Reactive frameworks (important to detect - affects SDK needs)
192
+ if (await hasInertia(options)) {
193
+ clack_1.default.log.info('Detected Laravel with Inertia.js');
194
+ return LaravelProjectType.INERTIA;
195
+ }
196
+ if (await hasLivewire(options)) {
197
+ clack_1.default.log.info('Detected Laravel with Livewire');
198
+ return LaravelProjectType.LIVEWIRE;
199
+ }
200
+ // Default to standard
201
+ clack_1.default.log.info('Detected standard Laravel project');
202
+ return LaravelProjectType.STANDARD;
203
+ }
204
+ /**
205
+ * Find the main service provider file
206
+ */
207
+ async function findLaravelServiceProvider(options) {
208
+ const { installDir } = options;
209
+ // Look for AppServiceProvider first (most common place for setup)
210
+ const appServiceProvider = path.join(installDir, 'app/Providers/AppServiceProvider.php');
211
+ if (fs.existsSync(appServiceProvider)) {
212
+ return 'app/Providers/AppServiceProvider.php';
213
+ }
214
+ // Fall back to searching for any service provider
215
+ const providers = await (0, fast_glob_1.default)(['**/app/Providers/*ServiceProvider.php'], {
216
+ cwd: installDir,
217
+ ignore: LARAVEL_IGNORE_PATTERNS,
218
+ });
219
+ return providers[0];
220
+ }
221
+ /**
222
+ * Find the bootstrap file (differs between Laravel versions)
223
+ */
224
+ function findLaravelBootstrapFile(options) {
225
+ const { installDir } = options;
226
+ // Laravel 11+ uses bootstrap/app.php with new structure
227
+ const bootstrapApp = path.join(installDir, 'bootstrap/app.php');
228
+ if (fs.existsSync(bootstrapApp)) {
229
+ return 'bootstrap/app.php';
230
+ }
231
+ // Older Laravel uses app/Http/Kernel.php
232
+ const httpKernel = path.join(installDir, 'app/Http/Kernel.php');
233
+ if (fs.existsSync(httpKernel)) {
234
+ return 'app/Http/Kernel.php';
235
+ }
236
+ return undefined;
237
+ }
238
+ /**
239
+ * Detect Laravel version structure for configuration guidance
240
+ */
241
+ function detectLaravelStructure(options) {
242
+ const version = getLaravelVersion(options);
243
+ if (!version)
244
+ return 'modern';
245
+ try {
246
+ const majorVersion = parseInt(version.split('.')[0], 10);
247
+ if (majorVersion >= 11)
248
+ return 'latest'; // Laravel 11+ (new structure)
249
+ if (majorVersion >= 9)
250
+ return 'modern'; // Laravel 9-10
251
+ return 'legacy'; // Laravel 8 and below
252
+ }
253
+ catch {
254
+ return 'modern';
255
+ }
256
+ }
257
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/laravel/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,0DAkBC;AAKD,0CAYC;AAsED,8CAIC;AAKD,8DAaC;AA6BD,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AAC,CAAC;IAChE,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAChC,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,yCAAyC;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;IAChE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CACpC,OAA0C;IAE1C,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO;QAAE,OAAO,QAAQ,CAAC;IAE9B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACzD,IAAI,YAAY,IAAI,EAAE;YAAE,OAAO,QAAQ,CAAC,CAAC,8BAA8B;QACvE,IAAI,YAAY,IAAI,CAAC;YAAE,OAAO,QAAQ,CAAC,CAAC,eAAe;QACvD,OAAO,QAAQ,CAAC,CAAC,sBAAsB;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC","sourcesContent":["import { major, minVersion } from 'semver';\nimport fg from 'fast-glob';\nimport clack from '../utils/clack';\nimport type { WizardOptions } from '../utils/types';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\n\nexport enum LaravelProjectType {\n STANDARD = 'standard', // Basic Laravel app\n INERTIA = 'inertia', // Inertia.js (Vue/React SPA) - may need JS SDK too\n LIVEWIRE = 'livewire', // Livewire (reactive components, includes Filament)\n}\n\n/**\n * Ignore patterns for Laravel projects\n */\nconst LARAVEL_IGNORE_PATTERNS = [\n '**/node_modules/**',\n '**/vendor/**',\n '**/storage/**',\n '**/bootstrap/cache/**',\n '**/.phpunit.cache/**',\n '**/public/build/**',\n '**/public/hot/**',\n];\n\n/**\n * Get Laravel version bucket for analytics\n */\nexport function getLaravelVersionBucket(version: string | undefined): string {\n if (!version) {\n return 'none';\n }\n\n try {\n const minVer = minVersion(version);\n if (!minVer) {\n return 'invalid';\n }\n const majorVersion = major(minVer);\n if (majorVersion >= 9) {\n return `${majorVersion}.x`;\n }\n return '<9.0.0';\n } catch {\n return 'unknown';\n }\n}\n\n/**\n * Read and parse composer.json\n */\nexport function getComposerJson(\n options: Pick<WizardOptions, 'installDir'>,\n): Record<string, any> | undefined {\n const { installDir } = options;\n\n const composerPath = path.join(installDir, 'composer.json');\n try {\n const content = fs.readFileSync(composerPath, 'utf-8');\n return JSON.parse(content);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Check if a package is installed (present in composer.json)\n */\nfunction hasComposerPackage(\n packageName: string,\n options: Pick<WizardOptions, 'installDir'>,\n): boolean {\n const composer = getComposerJson(options);\n if (!composer) return false;\n\n return !!(\n composer.require?.[packageName] || composer['require-dev']?.[packageName]\n );\n}\n\n/**\n * Extract version for a package from composer.json\n */\nfunction getComposerPackageVersion(\n packageName: string,\n options: Pick<WizardOptions, 'installDir'>,\n): string | undefined {\n const composer = getComposerJson(options);\n if (!composer) return undefined;\n\n const version =\n composer.require?.[packageName] || composer['require-dev']?.[packageName];\n if (version) {\n // Clean version string (remove ^, ~, >=, etc.)\n return version.replace(/^[\\^~>=<]+/, '');\n }\n\n return undefined;\n}\n\n/**\n * Check if a pattern exists in PHP source files\n */\nasync function hasLaravelCodePattern(\n pattern: RegExp | string,\n options: Pick<WizardOptions, 'installDir'>,\n filePatterns: string[] = ['**/*.php'],\n): Promise<boolean> {\n const { installDir } = options;\n\n const phpFiles = await fg(filePatterns, {\n cwd: installDir,\n ignore: LARAVEL_IGNORE_PATTERNS,\n });\n\n const searchPattern =\n typeof pattern === 'string' ? new RegExp(pattern) : pattern;\n\n for (const phpFile of phpFiles) {\n try {\n const content = fs.readFileSync(path.join(installDir, phpFile), 'utf-8');\n if (searchPattern.test(content)) return true;\n } catch {\n continue;\n }\n }\n\n return false;\n}\n\n/**\n * Get Laravel version from composer.json\n */\nexport function getLaravelVersion(\n options: Pick<WizardOptions, 'installDir'>,\n): string | undefined {\n return getComposerPackageVersion('laravel/framework', options);\n}\n\n/**\n * Get human-readable name for Laravel project type\n */\nexport function getLaravelProjectTypeName(\n projectType: LaravelProjectType,\n): string {\n switch (projectType) {\n case LaravelProjectType.STANDARD:\n return 'Standard Laravel';\n case LaravelProjectType.INERTIA:\n return 'Laravel with Inertia.js';\n case LaravelProjectType.LIVEWIRE:\n return 'Laravel with Livewire';\n default:\n return 'Laravel';\n }\n}\n\n/**\n * Check for Inertia.js\n */\nasync function hasInertia(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<boolean> {\n return (\n hasComposerPackage('inertiajs/inertia-laravel', options) ||\n (await hasLaravelCodePattern(/Inertia::render|inertia\\(/, options))\n );\n}\n\n/**\n * Check for Livewire\n */\nasync function hasLivewire(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<boolean> {\n return (\n hasComposerPackage('livewire/livewire', options) ||\n (await hasLaravelCodePattern(/extends\\s+Component|@livewire/, options))\n );\n}\n\n/**\n * Detect Laravel project type\n */\nexport async function getLaravelProjectType(\n options: WizardOptions,\n): Promise<LaravelProjectType> {\n // Check for SPA/Reactive frameworks (important to detect - affects SDK needs)\n if (await hasInertia(options)) {\n clack.log.info('Detected Laravel with Inertia.js');\n return LaravelProjectType.INERTIA;\n }\n if (await hasLivewire(options)) {\n clack.log.info('Detected Laravel with Livewire');\n return LaravelProjectType.LIVEWIRE;\n }\n\n // Default to standard\n clack.log.info('Detected standard Laravel project');\n return LaravelProjectType.STANDARD;\n}\n\n/**\n * Find the main service provider file\n */\nexport async function findLaravelServiceProvider(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<string | undefined> {\n const { installDir } = options;\n\n // Look for AppServiceProvider first (most common place for setup)\n const appServiceProvider = path.join(\n installDir,\n 'app/Providers/AppServiceProvider.php',\n );\n\n if (fs.existsSync(appServiceProvider)) {\n return 'app/Providers/AppServiceProvider.php';\n }\n\n // Fall back to searching for any service provider\n const providers = await fg(['**/app/Providers/*ServiceProvider.php'], {\n cwd: installDir,\n ignore: LARAVEL_IGNORE_PATTERNS,\n });\n\n return providers[0];\n}\n\n/**\n * Find the bootstrap file (differs between Laravel versions)\n */\nexport function findLaravelBootstrapFile(\n options: Pick<WizardOptions, 'installDir'>,\n): string | undefined {\n const { installDir } = options;\n\n // Laravel 11+ uses bootstrap/app.php with new structure\n const bootstrapApp = path.join(installDir, 'bootstrap/app.php');\n if (fs.existsSync(bootstrapApp)) {\n return 'bootstrap/app.php';\n }\n\n // Older Laravel uses app/Http/Kernel.php\n const httpKernel = path.join(installDir, 'app/Http/Kernel.php');\n if (fs.existsSync(httpKernel)) {\n return 'app/Http/Kernel.php';\n }\n\n return undefined;\n}\n\n/**\n * Detect Laravel version structure for configuration guidance\n */\nexport function detectLaravelStructure(\n options: Pick<WizardOptions, 'installDir'>,\n): 'legacy' | 'modern' | 'latest' {\n const version = getLaravelVersion(options);\n if (!version) return 'modern';\n\n try {\n const majorVersion = parseInt(version.split('.')[0], 10);\n if (majorVersion >= 11) return 'latest'; // Laravel 11+ (new structure)\n if (majorVersion >= 9) return 'modern'; // Laravel 9-10\n return 'legacy'; // Laravel 8 and below\n } catch {\n return 'modern';\n }\n}\n"]}
@@ -89,5 +89,16 @@ export declare const INTEGRATION_CONFIG: {
89
89
  readonly defaultChanges: "• Installed posthog Python package\n• Added PostHog initialization to your Flask app\n• Configured automatic event tracking";
90
90
  readonly nextSteps: "• Use posthog.identify() to associate events with users\n• Call posthog.capture() to capture custom events\n• Use feature flags with posthog.feature_enabled()";
91
91
  };
92
+ readonly laravel: {
93
+ readonly name: "Laravel";
94
+ readonly filterPatterns: ["**/*.php"];
95
+ readonly ignorePatterns: ["node_modules", "vendor", "storage", "bootstrap/cache", "public/build", "public/hot", ".phpunit.cache"];
96
+ readonly detect: (options: Pick<WizardOptions, "installDir">) => Promise<boolean>;
97
+ readonly generateFilesRules: "";
98
+ readonly filterFilesRules: "";
99
+ readonly docsUrl: "https://posthog.com/docs/libraries/php";
100
+ readonly defaultChanges: "• Installed posthog/posthog-php via Composer\n• Added PostHog service provider\n• Configured automatic event tracking";
101
+ readonly nextSteps: "• Use PostHog::capture() to track custom events\n• Use PostHog::identify() to associate events with users";
102
+ };
92
103
  };
93
- export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.astro, Integration.svelte, Integration.reactNative, Integration.reactRouter, Integration.django, Integration.flask, Integration.react];
104
+ export declare const INTEGRATION_ORDER: readonly [Integration.nextjs, Integration.astro, Integration.svelte, Integration.reactNative, Integration.reactRouter, Integration.django, Integration.flask, Integration.laravel, Integration.react];
@@ -301,6 +301,58 @@ exports.INTEGRATION_CONFIG = {
301
301
  defaultChanges: '• Installed posthog Python package\n• Added PostHog initialization to your Flask app\n• Configured automatic event tracking',
302
302
  nextSteps: '• Use posthog.identify() to associate events with users\n• Call posthog.capture() to capture custom events\n• Use feature flags with posthog.feature_enabled()',
303
303
  },
304
+ [constants_1.Integration.laravel]: {
305
+ name: 'Laravel',
306
+ filterPatterns: ['**/*.php'],
307
+ ignorePatterns: [
308
+ 'node_modules',
309
+ 'vendor',
310
+ 'storage',
311
+ 'bootstrap/cache',
312
+ 'public/build',
313
+ 'public/hot',
314
+ '.phpunit.cache',
315
+ ],
316
+ detect: async (options) => {
317
+ const { installDir } = options;
318
+ // Primary check: artisan file (definitive Laravel indicator)
319
+ const artisanPath = path.join(installDir, 'artisan');
320
+ if (fs.existsSync(artisanPath)) {
321
+ try {
322
+ const content = fs.readFileSync(artisanPath, 'utf-8');
323
+ if (content.includes('Laravel') || content.includes('Artisan')) {
324
+ return true;
325
+ }
326
+ }
327
+ catch {
328
+ // Continue to other checks
329
+ }
330
+ }
331
+ // Secondary check: composer.json with laravel/framework
332
+ const composerPath = path.join(installDir, 'composer.json');
333
+ if (fs.existsSync(composerPath)) {
334
+ try {
335
+ const content = fs.readFileSync(composerPath, 'utf-8');
336
+ const composer = JSON.parse(content);
337
+ if (composer.require?.['laravel/framework'] ||
338
+ composer['require-dev']?.['laravel/framework']) {
339
+ return true;
340
+ }
341
+ }
342
+ catch {
343
+ // Continue to other checks
344
+ }
345
+ }
346
+ // Tertiary check: Laravel-specific directory structure
347
+ const hasLaravelStructure = await (0, fast_glob_1.default)(['**/bootstrap/app.php', '**/app/Http/Kernel.php'], { cwd: installDir, ignore: ['**/vendor/**'] });
348
+ return hasLaravelStructure.length > 0;
349
+ },
350
+ generateFilesRules: '',
351
+ filterFilesRules: '',
352
+ docsUrl: 'https://posthog.com/docs/libraries/php',
353
+ defaultChanges: '• Installed posthog/posthog-php via Composer\n• Added PostHog service provider\n• Configured automatic event tracking',
354
+ nextSteps: '• Use PostHog::capture() to track custom events\n• Use PostHog::identify() to associate events with users',
355
+ },
304
356
  };
305
357
  exports.INTEGRATION_ORDER = [
306
358
  constants_1.Integration.nextjs,
@@ -310,6 +362,7 @@ exports.INTEGRATION_ORDER = [
310
362
  constants_1.Integration.reactRouter,
311
363
  constants_1.Integration.django,
312
364
  constants_1.Integration.flask,
365
+ constants_1.Integration.laravel,
313
366
  constants_1.Integration.react,
314
367
  ];
315
368
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAyD;AACzD,wDAA4D;AAE5D,2CAA0C;AAC1C,0DAA2B;AAC3B,4CAA8B;AAC9B,gDAAkC;AAcrB,QAAA,kBAAkB,GAAG;IAChC,CAAC,uBAAW,CAAC,MAAM,CAAC,EAAE;QACpB,IAAI,EAAE,SAAS;QACf,cAAc,EAAE,CAAC,8BAA8B,CAAC;QAChD,c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C,MAAM;IAClB,uBAAW,CAAC,KAAK;IACjB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { tryGetPackageJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\nimport fg from 'fast-glob';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('next', packageJson) : false;\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('react', packageJson) : false;\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('@sveltejs/kit', packageJson)\n : false;\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('react-native', packageJson)\n : false;\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('astro', packageJson) : false;\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 [Integration.reactRouter]: {\n name: 'React Router',\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('react-router', packageJson)\n : false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl:\n 'https://posthog-git-react-post-hog.vercel.app/docs/libraries/react-router',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app\\n• Integrated PostHog with React Router for pageview 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 },\n [Integration.django]: {\n name: 'Django',\n filterPatterns: ['**/*.py'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'venv',\n '.venv',\n 'env',\n '.env',\n '__pycache__',\n '*.pyc',\n 'migrations',\n ],\n detect: async (options) => {\n const { installDir } = options;\n\n // Check for manage.py (Django project indicator)\n const managePyMatches = await fg('**/manage.py', {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n });\n\n if (managePyMatches.length > 0) {\n // Verify it's a Django manage.py by checking content\n for (const match of managePyMatches) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, match),\n 'utf-8',\n );\n if (\n content.includes('django') ||\n content.includes('DJANGO_SETTINGS_MODULE')\n ) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n }\n\n // Check for Django in requirements files\n const requirementsFiles = await fg(\n ['**/requirements*.txt', '**/pyproject.toml', '**/setup.py'],\n {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n },\n );\n\n for (const reqFile of requirementsFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, reqFile),\n 'utf-8',\n );\n // Check for Django package reference\n if (\n content.toLowerCase().includes('django') &&\n !content.toLowerCase().includes('django-') // Avoid false positives from Django plugins only\n ) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n\n return false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/django',\n defaultChanges:\n '• Installed posthog Python package\\n• Added PostHog middleware for automatic event tracking\\n• Configured PostHog settings in Django settings file',\n nextSteps:\n '• Use identify_context() within new_context() to associate events with users\\n• Call posthog.capture() to capture custom events\\n• Use feature flags with posthog.feature_enabled()',\n },\n [Integration.flask]: {\n name: 'Flask',\n filterPatterns: ['**/*.py'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'venv',\n '.venv',\n 'env',\n '.env',\n '__pycache__',\n '*.pyc',\n 'migrations',\n 'instance',\n ],\n detect: async (options) => {\n const { installDir } = options;\n\n // Note: Django is checked before Flask in INTEGRATION_ORDER,\n // so if we get here, the project is not a Django project.\n\n // Check for Flask in requirements files\n const requirementsFiles = await fg(\n [\n '**/requirements*.txt',\n '**/pyproject.toml',\n '**/setup.py',\n '**/Pipfile',\n ],\n {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n },\n );\n\n for (const reqFile of requirementsFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, reqFile),\n 'utf-8',\n );\n // Check for flask package (case-insensitive)\n // Match \"flask\" as a standalone package, not just as part of plugin names\n if (\n /^flask([<>=~!]|$|\\s)/im.test(content) ||\n /[\"']flask[\"']/i.test(content)\n ) {\n return true;\n }\n } catch {\n continue;\n }\n }\n\n // Check for Flask app patterns in Python files\n const pyFiles = await fg(\n ['**/app.py', '**/wsgi.py', '**/application.py', '**/__init__.py'],\n {\n cwd: installDir,\n ignore: [\n '**/venv/**',\n '**/.venv/**',\n '**/env/**',\n '**/.env/**',\n '**/__pycache__/**',\n ],\n },\n );\n\n for (const pyFile of pyFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, pyFile),\n 'utf-8',\n );\n if (\n content.includes('from flask import') ||\n content.includes('import flask') ||\n /Flask\\s*\\(/.test(content)\n ) {\n return true;\n }\n } catch {\n continue;\n }\n }\n\n return false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/flask',\n defaultChanges:\n '• Installed posthog Python package\\n• Added PostHog initialization to your Flask app\\n• Configured automatic event tracking',\n nextSteps:\n '• Use posthog.identify() to associate events with users\\n• Call posthog.capture() to capture custom events\\n• Use feature flags with posthog.feature_enabled()',\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.reactRouter,\n Integration.django,\n Integration.flask,\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;AAC1C,0DAA2B;AAC3B,4CAA8B;AAC9B,gDAAkC;AAcrB,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,WAAW,CAAC,CAAC,CAAC,IAAA,kCAAm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cAAc,EACZ,uHAAuH;QACzH,SAAS,EACP,2GAA2G;KAC9G;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,WAAW;IACvB,uBAAW,CAAC,MAAM;IAClB,uBAAW,CAAC,KAAK;IACjB,uBAAW,CAAC,OAAO;IACnB,uBAAW,CAAC,KAAK;CACT,CAAC","sourcesContent":["import { tryGetPackageJson } from '../utils/clack-utils';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { Integration } from './constants';\nimport fg from 'fast-glob';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('next', packageJson) : false;\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('react', packageJson) : false;\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('@sveltejs/kit', packageJson)\n : false;\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('react-native', packageJson)\n : false;\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 tryGetPackageJson(options);\n return packageJson ? hasPackageInstalled('astro', packageJson) : false;\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 [Integration.reactRouter]: {\n name: 'React Router',\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 tryGetPackageJson(options);\n return packageJson\n ? hasPackageInstalled('react-router', packageJson)\n : false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl:\n 'https://posthog-git-react-post-hog.vercel.app/docs/libraries/react-router',\n defaultChanges:\n '• Installed posthog-js package\\n• Added PostHogProvider to the root of the app\\n• Integrated PostHog with React Router for pageview 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 },\n [Integration.django]: {\n name: 'Django',\n filterPatterns: ['**/*.py'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'venv',\n '.venv',\n 'env',\n '.env',\n '__pycache__',\n '*.pyc',\n 'migrations',\n ],\n detect: async (options) => {\n const { installDir } = options;\n\n // Check for manage.py (Django project indicator)\n const managePyMatches = await fg('**/manage.py', {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n });\n\n if (managePyMatches.length > 0) {\n // Verify it's a Django manage.py by checking content\n for (const match of managePyMatches) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, match),\n 'utf-8',\n );\n if (\n content.includes('django') ||\n content.includes('DJANGO_SETTINGS_MODULE')\n ) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n }\n\n // Check for Django in requirements files\n const requirementsFiles = await fg(\n ['**/requirements*.txt', '**/pyproject.toml', '**/setup.py'],\n {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n },\n );\n\n for (const reqFile of requirementsFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, reqFile),\n 'utf-8',\n );\n // Check for Django package reference\n if (\n content.toLowerCase().includes('django') &&\n !content.toLowerCase().includes('django-') // Avoid false positives from Django plugins only\n ) {\n return true;\n }\n } catch {\n // Skip files that can't be read\n continue;\n }\n }\n\n return false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/django',\n defaultChanges:\n '• Installed posthog Python package\\n• Added PostHog middleware for automatic event tracking\\n• Configured PostHog settings in Django settings file',\n nextSteps:\n '• Use identify_context() within new_context() to associate events with users\\n• Call posthog.capture() to capture custom events\\n• Use feature flags with posthog.feature_enabled()',\n },\n [Integration.flask]: {\n name: 'Flask',\n filterPatterns: ['**/*.py'],\n ignorePatterns: [\n 'node_modules',\n 'dist',\n 'build',\n 'public',\n 'static',\n 'venv',\n '.venv',\n 'env',\n '.env',\n '__pycache__',\n '*.pyc',\n 'migrations',\n 'instance',\n ],\n detect: async (options) => {\n const { installDir } = options;\n\n // Note: Django is checked before Flask in INTEGRATION_ORDER,\n // so if we get here, the project is not a Django project.\n\n // Check for Flask in requirements files\n const requirementsFiles = await fg(\n [\n '**/requirements*.txt',\n '**/pyproject.toml',\n '**/setup.py',\n '**/Pipfile',\n ],\n {\n cwd: installDir,\n ignore: ['**/venv/**', '**/.venv/**', '**/env/**', '**/.env/**'],\n },\n );\n\n for (const reqFile of requirementsFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, reqFile),\n 'utf-8',\n );\n // Check for flask package (case-insensitive)\n // Match \"flask\" as a standalone package, not just as part of plugin names\n if (\n /^flask([<>=~!]|$|\\s)/im.test(content) ||\n /[\"']flask[\"']/i.test(content)\n ) {\n return true;\n }\n } catch {\n continue;\n }\n }\n\n // Check for Flask app patterns in Python files\n const pyFiles = await fg(\n ['**/app.py', '**/wsgi.py', '**/application.py', '**/__init__.py'],\n {\n cwd: installDir,\n ignore: [\n '**/venv/**',\n '**/.venv/**',\n '**/env/**',\n '**/.env/**',\n '**/__pycache__/**',\n ],\n },\n );\n\n for (const pyFile of pyFiles) {\n try {\n const content = fs.readFileSync(\n path.join(installDir, pyFile),\n 'utf-8',\n );\n if (\n content.includes('from flask import') ||\n content.includes('import flask') ||\n /Flask\\s*\\(/.test(content)\n ) {\n return true;\n }\n } catch {\n continue;\n }\n }\n\n return false;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/flask',\n defaultChanges:\n '• Installed posthog Python package\\n• Added PostHog initialization to your Flask app\\n• Configured automatic event tracking',\n nextSteps:\n '• Use posthog.identify() to associate events with users\\n• Call posthog.capture() to capture custom events\\n• Use feature flags with posthog.feature_enabled()',\n },\n [Integration.laravel]: {\n name: 'Laravel',\n filterPatterns: ['**/*.php'],\n ignorePatterns: [\n 'node_modules',\n 'vendor',\n 'storage',\n 'bootstrap/cache',\n 'public/build',\n 'public/hot',\n '.phpunit.cache',\n ],\n detect: async (options) => {\n const { installDir } = options;\n\n // Primary check: artisan file (definitive Laravel indicator)\n const artisanPath = path.join(installDir, 'artisan');\n if (fs.existsSync(artisanPath)) {\n try {\n const content = fs.readFileSync(artisanPath, 'utf-8');\n if (content.includes('Laravel') || content.includes('Artisan')) {\n return true;\n }\n } catch {\n // Continue to other checks\n }\n }\n\n // Secondary check: composer.json with laravel/framework\n const composerPath = path.join(installDir, 'composer.json');\n if (fs.existsSync(composerPath)) {\n try {\n const content = fs.readFileSync(composerPath, 'utf-8');\n const composer = JSON.parse(content);\n if (\n composer.require?.['laravel/framework'] ||\n composer['require-dev']?.['laravel/framework']\n ) {\n return true;\n }\n } catch {\n // Continue to other checks\n }\n }\n\n // Tertiary check: Laravel-specific directory structure\n const hasLaravelStructure = await fg(\n ['**/bootstrap/app.php', '**/app/Http/Kernel.php'],\n { cwd: installDir, ignore: ['**/vendor/**'] },\n );\n\n return hasLaravelStructure.length > 0;\n },\n generateFilesRules: '',\n filterFilesRules: '',\n docsUrl: 'https://posthog.com/docs/libraries/php',\n defaultChanges:\n '• Installed posthog/posthog-php via Composer\\n• Added PostHog service provider\\n• Configured automatic event tracking',\n nextSteps:\n '• Use PostHog::capture() to track custom events\\n• Use PostHog::identify() to associate events with users',\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.reactRouter,\n Integration.django,\n Integration.flask,\n Integration.laravel,\n Integration.react,\n] as const;\n"]}
@@ -6,7 +6,8 @@ export declare enum Integration {
6
6
  astro = "astro",
7
7
  reactRouter = "react-router",
8
8
  django = "django",
9
- flask = "flask"
9
+ flask = "flask",
10
+ laravel = "laravel"
10
11
  }
11
12
  export declare enum FeatureFlagDefinition {
12
13
  ReactRouter = "wizard-react-router"
@@ -13,6 +13,7 @@ var Integration;
13
13
  Integration["reactRouter"] = "react-router";
14
14
  Integration["django"] = "django";
15
15
  Integration["flask"] = "flask";
16
+ Integration["laravel"] = "laravel";
16
17
  })(Integration || (exports.Integration = Integration = {}));
17
18
  var FeatureFlagDefinition;
18
19
  (function (FeatureFlagDefinition) {
@@ -36,6 +37,8 @@ function getIntegrationDescription(type) {
36
37
  return 'Django';
37
38
  case Integration.flask:
38
39
  return 'Flask';
40
+ case Integration.laravel:
41
+ return 'Laravel';
39
42
  default:
40
43
  throw new Error(`Unknown integration ${type}`);
41
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/const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,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,QAAQ,CACpD,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAC3B,CAAC;AAEW,QAAA,KAAK,GAAG,KAAK,CAAC;AAEd,QAAA,WAAW,GAAG,cAAM;IAC/B,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,wBAAwB,CAAC;AAChB,QAAA,UAAU,GAAG,0CAA0C,CAAC;AACxD,QAAA,gBAAgB,GAAG,cAAM;IACpC,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,0BAA0B,CAAC;AAClB,QAAA,0CAA0C,GAAG,gBAAgB,CAAC;AAC9D,QAAA,kBAAkB,GAAG,gCAAgC,CAAC;AACtD,QAAA,kBAAkB,GAAG,iBAAiB,CAAC;AACvC,QAAA,qBAAqB,GAAG,gCAAgC,CAAC;AAEzD,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,qBAAqB,GAAG,0CAA0C,CAAC;AACnE,QAAA,UAAU,GAAG,IAAI,CAAC;AAElB,QAAA,6BAA6B,GAAG,oBAAoB,CAAC","sourcesContent":["export enum Integration {\n nextjs = 'nextjs',\n react = 'react',\n svelte = 'svelte',\n reactNative = 'react-native',\n astro = 'astro',\n reactRouter = 'react-router',\n django = 'django',\n flask = 'flask',\n}\n\nexport enum FeatureFlagDefinition {\n ReactRouter = 'wizard-react-router',\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 case Integration.reactRouter:\n return 'React Router';\n case Integration.django:\n return 'Django';\n case Integration.flask:\n return 'Flask';\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 = ['test', 'development'].includes(\n process.env.NODE_ENV ?? '',\n);\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-j.posthog.com';\nexport const ANALYTICS_TEAM_TAG = 'docs-and-wizard';\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n\nexport const POSTHOG_US_CLIENT_ID = 'c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM';\nexport const POSTHOG_EU_CLIENT_ID = 'bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy';\nexport const POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';\nexport const OAUTH_PORT = 8239;\n\nexport const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":";;;AAgBA,8DAuBC;AAOD,sDAKC;AAnDD,IAAY,WAUX;AAVD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,gCAAiB,CAAA;IACjB,2CAA4B,CAAA;IAC5B,8BAAe,CAAA;IACf,2CAA4B,CAAA;IAC5B,gCAAiB,CAAA;IACjB,8BAAe,CAAA;IACf,kCAAmB,CAAA;AACrB,CAAC,EAVW,WAAW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,CAAC,CAAC,wBAAwB,CAAC;AAChB,QAAA,UAAU,GAAG,0CAA0C,CAAC;AACxD,QAAA,gBAAgB,GAAG,cAAM;IACpC,CAAC,CAAC,uBAAuB;IACzB,CAAC,CAAC,0BAA0B,CAAC;AAClB,QAAA,0CAA0C,GAAG,gBAAgB,CAAC;AAC9D,QAAA,kBAAkB,GAAG,gCAAgC,CAAC;AACtD,QAAA,kBAAkB,GAAG,iBAAiB,CAAC;AACvC,QAAA,qBAAqB,GAAG,gCAAgC,CAAC;AAEzD,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAClE,QAAA,qBAAqB,GAAG,0CAA0C,CAAC;AACnE,QAAA,UAAU,GAAG,IAAI,CAAC;AAElB,QAAA,6BAA6B,GAAG,oBAAoB,CAAC","sourcesContent":["export enum Integration {\n nextjs = 'nextjs',\n react = 'react',\n svelte = 'svelte',\n reactNative = 'react-native',\n astro = 'astro',\n reactRouter = 'react-router',\n django = 'django',\n flask = 'flask',\n laravel = 'laravel',\n}\n\nexport enum FeatureFlagDefinition {\n ReactRouter = 'wizard-react-router',\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 case Integration.reactRouter:\n return 'React Router';\n case Integration.django:\n return 'Django';\n case Integration.flask:\n return 'Flask';\n case Integration.laravel:\n return 'Laravel';\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 = ['test', 'development'].includes(\n process.env.NODE_ENV ?? '',\n);\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-j.posthog.com';\nexport const ANALYTICS_TEAM_TAG = 'docs-and-wizard';\nexport const DUMMY_PROJECT_API_KEY = '_YOUR_POSTHOG_PROJECT_API_KEY_';\n\nexport const POSTHOG_US_CLIENT_ID = 'c4Rdw8DIxgtQfA80IiSnGKlNX8QN00cFWF00QQhM';\nexport const POSTHOG_EU_CLIENT_ID = 'bx2C5sZRN03TkdjraCcetvQFPGH6N2Y9vRLkcKEy';\nexport const POSTHOG_DEV_CLIENT_ID = 'DC5uRLVbGI02YQ82grxgnK6Qn12SXWpCqdPb60oZ';\nexport const OAUTH_PORT = 8239;\n\nexport const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';\n"]}
package/dist/src/run.js CHANGED
@@ -19,6 +19,7 @@ const astro_wizard_1 = require("./astro/astro-wizard");
19
19
  const react_router_wizard_agent_1 = require("./react-router/react-router-wizard-agent");
20
20
  const django_wizard_agent_1 = require("./django/django-wizard-agent");
21
21
  const flask_wizard_agent_1 = require("./flask/flask-wizard-agent");
22
+ const laravel_wizard_agent_1 = require("./laravel/laravel-wizard-agent");
22
23
  const events_1 = require("events");
23
24
  const chalk_1 = __importDefault(require("chalk"));
24
25
  const errors_1 = require("./utils/errors");
@@ -93,6 +94,10 @@ async function runWizard(argv) {
93
94
  clack_1.default.log.info(`${chalk_1.default.yellow('[BETA]')} The Flask wizard is in beta. Questions or feedback? Email ${chalk_1.default.cyan('wizard@posthog.com')}`);
94
95
  await (0, flask_wizard_agent_1.runFlaskWizardAgent)(wizardOptions);
95
96
  break;
97
+ case constants_1.Integration.laravel:
98
+ clack_1.default.log.info(`${chalk_1.default.yellow('[BETA]')} The Laravel wizard is in beta. Questions or feedback? Email ${chalk_1.default.cyan('wizard@posthog.com')}`);
99
+ await (0, laravel_wizard_agent_1.runLaravelWizardAgent)(wizardOptions);
100
+ break;
96
101
  default:
97
102
  clack_1.default.log.error('No setup wizard selected!');
98
103
  }
@@ -137,6 +142,7 @@ async function getIntegrationForSetup(options) {
137
142
  { value: constants_1.Integration.reactRouter, label: 'React Router' },
138
143
  { value: constants_1.Integration.django, label: 'Django' },
139
144
  { value: constants_1.Integration.flask, label: 'Flask' },
145
+ { value: constants_1.Integration.laravel, label: 'Laravel' },
140
146
  { value: constants_1.Integration.svelte, label: 'Svelte' },
141
147
  { value: constants_1.Integration.reactNative, label: 'React Native' },
142
148
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;AAyCA,8BA+GC;AAxJD,qDAAuD;AAEvD,sEAAoE;AAGpE,+CAIyB;AACzB,qDAAsD;AACtD,0DAAkC;AAClC,gDAAwB;AACxB,yCAAqE;AACrE,uDAAsD;AACtD,iDAA8C;AAC9C,0DAAyD;AACzD,4EAA0E;AAC1E,uDAAsD;AACtD,wFAAqF;AACrF,sEAAoE;AACpE,mEAAiE;AACjE,mCAAsC;AACtC,kDAA0B;AAC1B,2CAAgD;AAEhD,qBAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;AAe/B,KAAK,UAAU,SAAS,CAAC,IAAU;IACxC,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI;QACP,GAAG,IAAA,6BAAe,GAAE;KACrB,CAAC;IAEF,IAAI,kBAA0B,CAAC;IAC/B,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1C,kBAAkB,GAAG,SAAS,CAAC,UAAU,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iBAAiB,CAAC,OAAO,CAAC,CAAC;IAE7D,IAAI,mBAAmB,EAAE,CAAC;QACxB,eAAK,CAAC,GAAG,CAAC,OAAO,CACf,yBAAyB,IAAA,qCAAyB,EAAC,mBAAmB,CAAC,EAAE,CAC1E,CAAC;QACF,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,MAAM,WAAW,GAAgB,MAAM,IAAA,8BAAgB,EACrD,eAAK,CAAC,MAAM,CAAC;QACX,OAAO,EAAE,6BAA6B;QACtC,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE;YAC/C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;YACzD,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;YAC5C,EAAE,KAAK,EAAE,uBAAW,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE;YAC9C,EAAE,KAAK,EAAE,uBAAW,CAAC,WAAW,EAAE,KAAK,EAAE,cAAc,EAAE;SAC1D;KACF,CAAC,CACH,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { abortIfCancelled } from './utils/clack-utils';\n\nimport { runNextjsWizardAgent } from './nextjs/nextjs-wizard-agent';\nimport type { CloudRegion, WizardOptions } from './utils/types';\n\nimport {\n getIntegrationDescription,\n Integration,\n FeatureFlagDefinition,\n} from './lib/constants';\nimport { readEnvironment } from './utils/environment';\nimport clack from './utils/clack';\nimport path from 'path';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './lib/config';\nimport { runReactWizard } from './react/react-wizard';\nimport { analytics } from './utils/analytics';\nimport { runSvelteWizard } from './svelte/svelte-wizard';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\nimport { runAstroWizard } from './astro/astro-wizard';\nimport { runReactRouterWizardAgent } from './react-router/react-router-wizard-agent';\nimport { runDjangoWizardAgent } from './django/django-wizard-agent';\nimport { runFlaskWizardAgent } from './flask/flask-wizard-agent';\nimport { EventEmitter } from 'events';\nimport chalk from 'chalk';\nimport { RateLimitError } from './utils/errors';\n\nEventEmitter.defaultMaxListeners = 50;\n\ntype Args = {\n integration?: Integration;\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n region?: CloudRegion;\n default?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n ci?: boolean;\n apiKey?: string;\n};\n\nexport async function runWizard(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let resolvedInstallDir: string;\n if (finalArgs.installDir) {\n if (path.isAbsolute(finalArgs.installDir)) {\n resolvedInstallDir = finalArgs.installDir;\n } else {\n resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);\n }\n } else {\n resolvedInstallDir = process.cwd();\n }\n\n const wizardOptions: WizardOptions = {\n debug: finalArgs.debug ?? false,\n forceInstall: finalArgs.forceInstall ?? false,\n installDir: resolvedInstallDir,\n cloudRegion: finalArgs.region ?? undefined,\n default: finalArgs.default ?? false,\n signup: finalArgs.signup ?? false,\n localMcp: finalArgs.localMcp ?? false,\n ci: finalArgs.ci ?? false,\n apiKey: finalArgs.apiKey,\n };\n\n clack.intro(`Welcome to the PostHog setup wizard ✨`);\n\n if (wizardOptions.ci) {\n clack.log.info(chalk.dim('Running in CI mode'));\n }\n\n const integration =\n finalArgs.integration ?? (await getIntegrationForSetup(wizardOptions));\n\n analytics.setTag('integration', integration);\n\n try {\n switch (integration) {\n case Integration.nextjs:\n await runNextjsWizardAgent(wizardOptions);\n break;\n case Integration.react:\n await runReactWizard(wizardOptions);\n break;\n case Integration.svelte:\n await runSvelteWizard(wizardOptions);\n break;\n case Integration.reactNative:\n await runReactNativeWizard(wizardOptions);\n break;\n case Integration.astro:\n await runAstroWizard(wizardOptions);\n break;\n case Integration.reactRouter: {\n const flagValue = await analytics.getFeatureFlag(\n FeatureFlagDefinition.ReactRouter,\n );\n // In CI mode, bypass feature flags and always use the React Router wizard\n if (wizardOptions.ci || flagValue === true) {\n await runReactRouterWizardAgent(wizardOptions);\n } else {\n await runReactWizard(wizardOptions);\n }\n break;\n }\n case Integration.django:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Django wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runDjangoWizardAgent(wizardOptions);\n break;\n case Integration.flask:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Flask wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runFlaskWizardAgent(wizardOptions);\n break;\n default:\n clack.log.error('No setup wizard selected!');\n }\n } catch (error) {\n analytics.captureException(error as Error, {\n integration,\n arguments: JSON.stringify(finalArgs),\n });\n\n await analytics.shutdown('error');\n\n if (error instanceof RateLimitError) {\n clack.log.error('Wizard usage limit reached. Please try again later.');\n } else {\n clack.log.error(\n `Something went wrong. You can read the documentation at ${chalk.cyan(\n `${INTEGRATION_CONFIG[integration].docsUrl}`,\n )} to set up PostHog manually.`,\n );\n }\n process.exit(1);\n }\n}\n\nasync function detectIntegration(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) =>\n INTEGRATION_ORDER.indexOf(a as Integration) -\n INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n}\n\nasync function getIntegrationForSetup(\n options: Pick<WizardOptions, 'installDir'>,\n) {\n const detectedIntegration = await detectIntegration(options);\n\n if (detectedIntegration) {\n clack.log.success(\n `Detected integration: ${getIntegrationDescription(detectedIntegration)}`,\n );\n return detectedIntegration;\n }\n\n const integration: Integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: Integration.nextjs, label: 'Next.js' },\n { value: Integration.astro, label: 'Astro' },\n { value: Integration.react, label: 'React' },\n { value: Integration.reactRouter, label: 'React Router' },\n { value: Integration.django, label: 'Django' },\n { value: Integration.flask, label: 'Flask' },\n { value: Integration.svelte, label: 'Svelte' },\n { value: Integration.reactNative, label: 'React Native' },\n ],\n }),\n );\n\n return integration;\n}\n"]}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run.ts"],"names":[],"mappings":";;;;;AA0CA,8BAyHC;AAnKD,qDAAuD;AAEvD,sEAAoE;AAGpE,+CAIyB;AACzB,qDAAsD;AACtD,0DAAkC;AAClC,gDAAwB;AACxB,yCAAqE;AACrE,uDAAsD;AACtD,iDAA8C;AAC9C,0DAAyD;AACzD,4EAA0E;AAC1E,uDAAsD;AACtD,wFAAqF;AACrF,sEAAoE;AACpE,mEAAiE;AACjE,yEAAuE;AACvE,mCAAsC;AACtC,kDAA0B;AAC1B,2CAAgD;AAEhD,qBAAY,CAAC,mBAAmB,GAAG,EAAE,CAAC;AAe/B,KAAK,UAAU,SAAS,CAAC,IAAU;IACxC,MAAM,SAAS,GAAG;QAChB,GAAG,IAAI;QACP,GAAG,IAAA,6BAAe,GAAE;KACrB,CAAC;IAEF,IAAI,kBAA0B,CAAC;IAC/B,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1C,kBAAkB,GAAG,SAAS,CAAC,UAAU,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,kBAAkB,GAAG,cAAI,CAAC,IAAI,CAA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sourcesContent":["import { abortIfCancelled } from './utils/clack-utils';\n\nimport { runNextjsWizardAgent } from './nextjs/nextjs-wizard-agent';\nimport type { CloudRegion, WizardOptions } from './utils/types';\n\nimport {\n getIntegrationDescription,\n Integration,\n FeatureFlagDefinition,\n} from './lib/constants';\nimport { readEnvironment } from './utils/environment';\nimport clack from './utils/clack';\nimport path from 'path';\nimport { INTEGRATION_CONFIG, INTEGRATION_ORDER } from './lib/config';\nimport { runReactWizard } from './react/react-wizard';\nimport { analytics } from './utils/analytics';\nimport { runSvelteWizard } from './svelte/svelte-wizard';\nimport { runReactNativeWizard } from './react-native/react-native-wizard';\nimport { runAstroWizard } from './astro/astro-wizard';\nimport { runReactRouterWizardAgent } from './react-router/react-router-wizard-agent';\nimport { runDjangoWizardAgent } from './django/django-wizard-agent';\nimport { runFlaskWizardAgent } from './flask/flask-wizard-agent';\nimport { runLaravelWizardAgent } from './laravel/laravel-wizard-agent';\nimport { EventEmitter } from 'events';\nimport chalk from 'chalk';\nimport { RateLimitError } from './utils/errors';\n\nEventEmitter.defaultMaxListeners = 50;\n\ntype Args = {\n integration?: Integration;\n debug?: boolean;\n forceInstall?: boolean;\n installDir?: string;\n region?: CloudRegion;\n default?: boolean;\n signup?: boolean;\n localMcp?: boolean;\n ci?: boolean;\n apiKey?: string;\n};\n\nexport async function runWizard(argv: Args) {\n const finalArgs = {\n ...argv,\n ...readEnvironment(),\n };\n\n let resolvedInstallDir: string;\n if (finalArgs.installDir) {\n if (path.isAbsolute(finalArgs.installDir)) {\n resolvedInstallDir = finalArgs.installDir;\n } else {\n resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);\n }\n } else {\n resolvedInstallDir = process.cwd();\n }\n\n const wizardOptions: WizardOptions = {\n debug: finalArgs.debug ?? false,\n forceInstall: finalArgs.forceInstall ?? false,\n installDir: resolvedInstallDir,\n cloudRegion: finalArgs.region ?? undefined,\n default: finalArgs.default ?? false,\n signup: finalArgs.signup ?? false,\n localMcp: finalArgs.localMcp ?? false,\n ci: finalArgs.ci ?? false,\n apiKey: finalArgs.apiKey,\n };\n\n clack.intro(`Welcome to the PostHog setup wizard ✨`);\n\n if (wizardOptions.ci) {\n clack.log.info(chalk.dim('Running in CI mode'));\n }\n\n const integration =\n finalArgs.integration ?? (await getIntegrationForSetup(wizardOptions));\n\n analytics.setTag('integration', integration);\n\n try {\n switch (integration) {\n case Integration.nextjs:\n await runNextjsWizardAgent(wizardOptions);\n break;\n case Integration.react:\n await runReactWizard(wizardOptions);\n break;\n case Integration.svelte:\n await runSvelteWizard(wizardOptions);\n break;\n case Integration.reactNative:\n await runReactNativeWizard(wizardOptions);\n break;\n case Integration.astro:\n await runAstroWizard(wizardOptions);\n break;\n case Integration.reactRouter: {\n const flagValue = await analytics.getFeatureFlag(\n FeatureFlagDefinition.ReactRouter,\n );\n // In CI mode, bypass feature flags and always use the React Router wizard\n if (wizardOptions.ci || flagValue === true) {\n await runReactRouterWizardAgent(wizardOptions);\n } else {\n await runReactWizard(wizardOptions);\n }\n break;\n }\n case Integration.django:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Django wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runDjangoWizardAgent(wizardOptions);\n break;\n case Integration.flask:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Flask wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runFlaskWizardAgent(wizardOptions);\n break;\n case Integration.laravel:\n clack.log.info(\n `${chalk.yellow(\n '[BETA]',\n )} The Laravel wizard is in beta. Questions or feedback? Email ${chalk.cyan(\n 'wizard@posthog.com',\n )}`,\n );\n await runLaravelWizardAgent(wizardOptions);\n break;\n default:\n clack.log.error('No setup wizard selected!');\n }\n } catch (error) {\n analytics.captureException(error as Error, {\n integration,\n arguments: JSON.stringify(finalArgs),\n });\n\n await analytics.shutdown('error');\n\n if (error instanceof RateLimitError) {\n clack.log.error('Wizard usage limit reached. Please try again later.');\n } else {\n clack.log.error(\n `Something went wrong. You can read the documentation at ${chalk.cyan(\n `${INTEGRATION_CONFIG[integration].docsUrl}`,\n )} to set up PostHog manually.`,\n );\n }\n process.exit(1);\n }\n}\n\nasync function detectIntegration(\n options: Pick<WizardOptions, 'installDir'>,\n): Promise<Integration | undefined> {\n const integrationConfigs = Object.entries(INTEGRATION_CONFIG).sort(\n ([a], [b]) =>\n INTEGRATION_ORDER.indexOf(a as Integration) -\n INTEGRATION_ORDER.indexOf(b as Integration),\n );\n\n for (const [integration, config] of integrationConfigs) {\n const detected = await config.detect(options);\n if (detected) {\n return integration as Integration;\n }\n }\n}\n\nasync function getIntegrationForSetup(\n options: Pick<WizardOptions, 'installDir'>,\n) {\n const detectedIntegration = await detectIntegration(options);\n\n if (detectedIntegration) {\n clack.log.success(\n `Detected integration: ${getIntegrationDescription(detectedIntegration)}`,\n );\n return detectedIntegration;\n }\n\n const integration: Integration = await abortIfCancelled(\n clack.select({\n message: 'What do you want to set up?',\n options: [\n { value: Integration.nextjs, label: 'Next.js' },\n { value: Integration.astro, label: 'Astro' },\n { value: Integration.react, label: 'React' },\n { value: Integration.reactRouter, label: 'React Router' },\n { value: Integration.django, label: 'Django' },\n { value: Integration.flask, label: 'Flask' },\n { value: Integration.laravel, label: 'Laravel' },\n { value: Integration.svelte, label: 'Svelte' },\n { value: Integration.reactNative, label: 'React Native' },\n ],\n }),\n );\n\n return integration;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/wizard",
3
- "version": "1.29.0",
3
+ "version": "1.30.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",