-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add Astro support to PostHog Wizard #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
225d220 to
2353c79
Compare
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
|
This is great, thank you so much for taking the time to do this. just a couple of tweaks if you could:
|
Implements a basic structure for an Astro test application. Includes essential files like configuration, package.json, and a README for guidance. Also introduces a PostHog component for analytics tracking and basic layout integration. Updates the .gitignore to exclude unnecessary files and folders specific to build processes and local configurations. Prepares for project expansion by setting up TypeScript support. This foundational setup ensures a clean start for future development and testing.
Implements an interactive wizard for integrating PostHog with Astro applications. The wizard guides users through installation steps, including setting up environment variables, confirming use of TypeScript, and handling package installations. It ensures users have the necessary packages and provides documentation for further configuration. This addition enhances user experience by automating setup tasks and providing clear installation instructions. It further sets up analytics to track Astro version and SDK installation status. No related issues or tickets are referenced.
Implements support for the Astro integration, enhancing the application’s analytics setup capabilities. - Introduces the Astro configuration including detection and file filtering patterns. - Adds Astro to the integration order and allows for running the associated setup wizard. - Updates integration descriptions for better clarity in user prompts. This addition streamlines the setup process for Astro projects and improves overall analytics functionality.
Implements a suite of end-to-end tests for the Astro application, ensuring its functionality in various environments. Tests include verification of `package.json` updates, successful runs in development and production modes, and build correctness. This facilitates automated testing and quality assurance in the deployment process.
Adds Astro to the list of supported frameworks for the wizard. Updates the CLI integration options to reflect this new addition. Encourages users to suggest further integrations via GitHub issues.
Refactors the Astro wizard to streamline PostHog integration steps. Removes unnecessary TypeScript checks and redundant package installations, simplifying the user flow. Introduces a new documentation structure and code snippets for easier implementation guidance. Aims to improve user experience and integration efficiency for analytics in Astro projects.
Eliminates the steps for adding or updating environment variables in the Astro wizard process. Updates the default changes in the integration configuration to reflect these removals while maintaining the functionality of the PostHog component. This streamlining aims to simplify the wizard experience and reduce complexity in managing environment variables.
Cleans up the documentation by removing irrelevant Next Steps related to PostHog instrumentation. This improves clarity for users by eliminating confusion over previously suggested steps no longer applicable. Updates content to streamline the user experience in the Astro and Next.js documentation sources.
Incorporates a default value for the date in the posthog initialization. This change enhances the analytics integration by setting a specific defaults parameter, allowing for more consistent data handling.
Upgrades the Astro framework version to 5.10.1 and removes the PostHog integration components to have bare minimum for more accurate E2E tests
2353c79 to
aa909b4
Compare
daniloc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
|
Thanks again for the help here! |
* Adds initial Astro test application setup Implements a basic structure for an Astro test application. Includes essential files like configuration, package.json, and a README for guidance. Also introduces a PostHog component for analytics tracking and basic layout integration. Updates the .gitignore to exclude unnecessary files and folders specific to build processes and local configurations. Prepares for project expansion by setting up TypeScript support. This foundational setup ensures a clean start for future development and testing. * add PostHog integration AI guidelines for Astro project * Adds PostHog Astro wizard for seamless integration Implements an interactive wizard for integrating PostHog with Astro applications. The wizard guides users through installation steps, including setting up environment variables, confirming use of TypeScript, and handling package installations. It ensures users have the necessary packages and provides documentation for further configuration. This addition enhances user experience by automating setup tasks and providing clear installation instructions. It further sets up analytics to track Astro version and SDK installation status. No related issues or tickets are referenced. * Adds Astro integration support to analytics setup Implements support for the Astro integration, enhancing the application’s analytics setup capabilities. - Introduces the Astro configuration including detection and file filtering patterns. - Adds Astro to the integration order and allows for running the associated setup wizard. - Updates integration descriptions for better clarity in user prompts. This addition streamlines the setup process for Astro projects and improves overall analytics functionality. * Adds end-to-end tests for Astro application Implements a suite of end-to-end tests for the Astro application, ensuring its functionality in various environments. Tests include verification of `package.json` updates, successful runs in development and production modes, and build correctness. This facilitates automated testing and quality assurance in the deployment process. * Updates README to include Astro integration Adds Astro to the list of supported frameworks for the wizard. Updates the CLI integration options to reflect this new addition. Encourages users to suggest further integrations via GitHub issues. * Enhances Astro Wizard for improved PostHog integration Refactors the Astro wizard to streamline PostHog integration steps. Removes unnecessary TypeScript checks and redundant package installations, simplifying the user flow. Introduces a new documentation structure and code snippets for easier implementation guidance. Aims to improve user experience and integration efficiency for analytics in Astro projects. * Removes environment variable steps from wizard Eliminates the steps for adding or updating environment variables in the Astro wizard process. Updates the default changes in the integration configuration to reflect these removals while maintaining the functionality of the PostHog component. This streamlining aims to simplify the wizard experience and reduce complexity in managing environment variables. * Removes outdated PostHog documentation sections Cleans up the documentation by removing irrelevant Next Steps related to PostHog instrumentation. This improves clarity for users by eliminating confusion over previously suggested steps no longer applicable. Updates content to streamline the user experience in the Astro and Next.js documentation sources. * Updates posthog initialization with default date Incorporates a default value for the date in the posthog initialization. This change enhances the analytics integration by setting a specific defaults parameter, allowing for more consistent data handling. * Removes posthog components from Astro test app for more integral test Upgrades the Astro framework version to 5.10.1 and removes the PostHog integration components to have bare minimum for more accurate E2E tests
Deployment.mp4
Summary
This PR adds complete Astro framework support to the PostHog wizard, enabling developers to seamlessly integrate PostHog analytics into their Astro projects with AI-powered setup. The implementation follows PostHog's established patterns while optimizing specifically for Astro's architecture with an inline script approach.
What's Added
Core Features
astropackage inpackage.jsonNew Files
src/astro/astro-wizard.ts- Main Astro wizard implementationsrc/astro/docs.ts- Astro-specific documentation with dynamic variable injectionsrc/utils/rules/astro-rules.md- AI coding rules for Astro projectse2e-tests/test-applications/astro-test-app/- Complete Astro test applicatione2e-tests/tests/astro.test.ts- E2E test suite for Astro integrationModified Files
src/lib/constants.ts- Added Astro to Integration enum and descriptionssrc/lib/config.ts- Added Astro detection logic and optimized success messagessrc/run.ts- Added Astro wizard import and routingbin.ts- Added 'astro' to CLI integration choicesREADME.md- Updated to include Astro integration documentationImplementation Approach
Astro-Optimized Architecture (following PostHog Astro docs)
1. Inline Script Integration
Unlike other frameworks that rely on npm packages, Astro uses PostHog's inline script approach:
Benefits:
2. Component-Based Architecture
Creates reusable Astro components following framework best practices:
PostHog Component (
src/components/posthog.astro):is:inlinedirective to prevent Astro processingLayout System (
src/layouts/PostHogLayout.astro):Architecture Consistency
Follows PostHog wizard patterns:
hasPackageInstalled('astro', packageJson)to auto-pick frameworkUsage
Users can now run:
The wizard will:
What's NOT needed:
posthog-js)Testing
E2E Testing
Created comprehensive test suite following existing patterns:
checkPackageJson()- Verifies no unnecessary package installationscheckIfRunsOnDevMode()- Tests development servercheckIfBuilds()- Verifies build processcheckIfRunsOnProdMode()- Tests preview modeTest Application
create-astrominimal templateManual Testing ✅
User Experience
Breaking Changes
None. This is a pure addition that doesn't affect existing functionality.
Code Quality
pnpm lint)pnpm build)pnpm test)Checklist