Skip to content

Commit 6307759

Browse files
authored
feat: add Astro support to PostHog Wizard (#67)
* 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
1 parent 703ac26 commit 6307759

File tree

20 files changed

+4982
-4
lines changed

20 files changed

+4982
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ To use the wizard, you can run it directly using:
1717
npx @posthog/wizard
1818
```
1919

20-
Currently the wizard can be used for **React, NextJS, Svelte and React Native**
20+
Currently the wizard can be used for **React, NextJS, Svelte, Astro and React Native**
2121
projects. If you have other integrations you would like the wizard to support,
2222
please open a [GitHub issue](https://github.com/posthog/wizard/issues)!
2323

@@ -30,7 +30,7 @@ The following CLI arguments are available:
3030
| `--help` | Show help | boolean | | | |
3131
| `--version` | Show version number | boolean | | | |
3232
| `--debug` | Enable verbose logging | boolean | `false` | | `POSTHOG_WIZARD_DEBUG` |
33-
| `--integration` | Choose the integration to setup | choices | Select integration during setup | "nextjs", "react", "svelte", "react-native" | `POSTHOG_WIZARD_INTEGRATION` |
33+
| `--integration` | Choose the integration to setup | choices | Select integration during setup | "nextjs", "astro", "react", "svelte", "react-native" | `POSTHOG_WIZARD_INTEGRATION` |
3434
| `--force-install` | Force install the SDK NPM package (use with caution!) | boolean | `false` | | |
3535
| `--install-dir` | Relative path to install in | string | `.` | | `POSTHOG_WIZARD_INSTALL_DIR` |
3636
| `--region` | PostHog region to use | choices | | "us", "eu" | `POSTHOG_WIZARD_REGION` |

bin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ yargs(hideBin(process.argv))
6464
},
6565
integration: {
6666
describe: 'Integration to set up',
67-
choices: ['nextjs', 'react', 'svelte', 'react-native'],
67+
choices: ['nextjs', 'astro', 'react', 'svelte', 'react-native'],
6868
type: 'string',
6969
},
7070
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# build output
2+
dist/
3+
# generated types
4+
.astro/
5+
6+
# dependencies
7+
node_modules/
8+
9+
# logs
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
pnpm-debug.log*
14+
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store
22+
23+
# jetbrains setting folder
24+
.idea/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"recommendations": ["astro-build.astro-vscode"],
3+
"unwantedRecommendations": []
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"command": "./node_modules/.bin/astro dev",
6+
"name": "Development server",
7+
"request": "launch",
8+
"type": "node-terminal"
9+
}
10+
]
11+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Astro Starter Kit: Minimal
2+
3+
```sh
4+
npm create astro@latest -- --template minimal
5+
```
6+
7+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)
8+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/minimal)
9+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/minimal/devcontainer.json)
10+
11+
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
12+
13+
## 🚀 Project Structure
14+
15+
Inside of your Astro project, you'll see the following folders and files:
16+
17+
```text
18+
/
19+
├── public/
20+
├── src/
21+
│ └── pages/
22+
│ └── index.astro
23+
└── package.json
24+
```
25+
26+
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
27+
28+
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
29+
30+
Any static assets, like images, can be placed in the `public/` directory.
31+
32+
## 🧞 Commands
33+
34+
All commands are run from the root of the project, from a terminal:
35+
36+
| Command | Action |
37+
| :------------------------ | :----------------------------------------------- |
38+
| `npm install` | Installs dependencies |
39+
| `npm run dev` | Starts local dev server at `localhost:4321` |
40+
| `npm run build` | Build your production site to `./dist/` |
41+
| `npm run preview` | Preview your build locally, before deploying |
42+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
43+
| `npm run astro -- --help` | Get help using the Astro CLI |
44+
45+
## 👀 Want to learn more?
46+
47+
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
4+
// https://astro.build/config
5+
export default defineConfig({});

0 commit comments

Comments
 (0)