Skip to content

Commit a9d9d29

Browse files
danilocjonathanlab
andauthored
feat: Event setup mode (#94)
* Basics of event tracking setup * Add debug flag handling to query.ts * Working API connection * Get better event suggestions * Rework event generation * Better prompting * Move Wizard into next-specific directory for now * Update import paths * Iterating prompt * More robust server-side handling * Aggressively detect client vs server, discourage bad events * Add helper * IT WORKS WELL * Prevent weird mangling of file endings * UI tweaks * Use the query implementation from main * Add newline * Replace debug logging * remove unneeded file picker * Remove unneeded package * Let's make typescript happy * Prettier * Add event tracking for event workflow * Check for git status before proceeding * harmonize events with rest of project * Opt out of no-console for the helper file; logging is a good start for devs to improve on * obeisance to the linter * More linter deference * prevent posthog-node being included in client bundle * Restore old approach * Lint and pretty * Copy tweaks * Radically simplify: client-side only for now * Invite folks to try the event-setup mode * Check for dirty git status before proceeding * prettier * Update src/nextjs/event-setup.ts Co-authored-by: Jonathan Mieloo <32547391+JonathanLab@users.noreply.github.com> * Re-add analytics --------- Co-authored-by: Jonathan Mieloo <32547391+JonathanLab@users.noreply.github.com>
1 parent 1e557fc commit a9d9d29

4 files changed

Lines changed: 497 additions & 1 deletion

File tree

bin.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ if (!satisfies(process.version, NODE_VERSION_RANGE)) {
1919
import { runMCPInstall, runMCPRemove } from './src/mcp';
2020
import type { CloudRegion, WizardOptions } from './src/utils/types';
2121
import { runWizard } from './src/run';
22+
import { runEventSetupWizard } from './src/nextjs/event-setup';
23+
import { readEnvironment } from './src/utils/environment';
24+
import path from 'path';
2225

2326
if (process.env.NODE_ENV === 'test') {
2427
void (async () => {
@@ -88,6 +91,47 @@ yargs(hideBin(process.argv))
8891
void runWizard(options as unknown as WizardOptions);
8992
},
9093
)
94+
.command(
95+
'event-setup',
96+
'Run the event setup wizard',
97+
(yargs) => {
98+
return yargs.options({
99+
'install-dir': {
100+
describe:
101+
'Directory to run the wizard in\nenv: POSTHOG_WIZARD_INSTALL_DIR',
102+
type: 'string',
103+
},
104+
});
105+
},
106+
(argv) => {
107+
const finalArgs = {
108+
...argv,
109+
...readEnvironment(),
110+
} as any;
111+
112+
let resolvedInstallDir: string;
113+
if (finalArgs.installDir) {
114+
if (path.isAbsolute(finalArgs.installDir)) {
115+
resolvedInstallDir = finalArgs.installDir;
116+
} else {
117+
resolvedInstallDir = path.join(process.cwd(), finalArgs.installDir);
118+
}
119+
} else {
120+
resolvedInstallDir = process.cwd();
121+
}
122+
123+
const wizardOptions: WizardOptions = {
124+
debug: finalArgs.debug ?? false,
125+
installDir: resolvedInstallDir,
126+
cloudRegion: finalArgs.region as CloudRegion | undefined,
127+
default: finalArgs.default ?? false,
128+
signup: finalArgs.signup ?? false,
129+
forceInstall: false,
130+
};
131+
132+
void runEventSetupWizard(wizardOptions);
133+
},
134+
)
91135
.command('mcp <command>', 'MCP server management commands', (yargs) => {
92136
return yargs
93137
.command(

0 commit comments

Comments
 (0)