feat: Event setup mode#94
Merged
Merged
Conversation
8bff812 to
a8f1deb
Compare
007ea8c to
6fae908
Compare
6fae908 to
4fc3429
Compare
Collaborator
Author
|
a couple remaining to-dos:
|
…r devs to improve on
# Conflicts: # src/utils/query.ts
Collaborator
Author
|
@jonathanlab welp: it's not nearly as ambitious as I'd hoped but: constraining to client-side files at least provides consistent, reliable outcomes. It gets the ball rolling, and when we have a proper library for this framework we can take another pass for the more compelling version! |
jonathanlab
reviewed
Jul 29, 2025
jonathanlab
reviewed
Jul 29, 2025
jonathanlab
reviewed
Jul 29, 2025
jonathanlab
requested changes
Jul 29, 2025
Collaborator
There was a problem hiding this comment.
This is genuinely so nice: I think it's a great start to just try this out with client side analytics first. Excited to see how people use it!
I ran into an issue with the next-js-instrumentation-client-app where it would sometimes fail to enhance one of the pages available:
│ Enhancing files with event tracking. Changes will be applied as they come in. Use your git interface to review new events. Feel free to toss anything you don't like...
│
◇ ✗ Failed to enhance src/app/example/page.tsx
│
◇ ✓ Enhanced src/app/page.tsx with 3 events
│
└ Success! Added 3 events across 1 files.
Event tracking plan saved to: event-tracking-report.md
Next steps:
1. Review changes with your favorite git tool
2. Revert unwanted changes with git checkout <file>
3. Test that events are being captured in your PostHog project
4. Create insights in PostHog
I ran it again and it enhanced the failed file successfully, so more of a transient error I guess 🤷🏻
Co-authored-by: Jonathan Mieloo <32547391+JonathanLab@users.noreply.github.com>
jonathanlab
approved these changes
Jul 29, 2025
daniloc
added a commit
that referenced
this pull request
Oct 27, 2025
* 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull adds experimental event setup for Nexts.js 15.3+:
src/nextjs/event-setup.ts
This adds the new workflow, including a very thorough prompt with rules that prevent stupid changes from happening. In addition, the workflow creates a markdown report at the end explaining what happened and providing next steps.
Other changes
I needed debug logging for
query.tsat various points, so that's in here too. Can take or leave.Testing
I found a nice and meaty project to test this on:
https://github.com/nextjs/saas-starter