Skip to content
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

Add PostHog analytics to readme #159

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,20 @@ After the steps above, you’ll have a working version like the demo page. Howev
- Replace the admin dashboard with real content (`/src/routes/(admin)/account/+page.svelte`).
- Add API endpoints and database tables as needed to deliver your SaaS product.

## Setup Analytics -- Optional

### PostHog

- Create a PostHog Account
- Install PostHog JS Library
- Run `npm install posthog-js` in your terminal. This will add PostHog dependencies to your `package.json` and `package-lock.json`.
- Set Up PostHog
- Create a new layout file at `src/routes/+layout.js`
- Log into PostHog. Then copy the code from [Svelte Client-side setup](https://posthog.com/docs/libraries/svelte#client-side-setup) and paste it into your `src/routes/+layout.js` file
- Note: ensure you’re logged into PostHog so that the code includes your unique API key automatically.
- Test analytics
- Click around and view a few pages on your site to generate some events. You can view these events in PostHog to ensure tracking is active.

Comment on lines +325 to +338
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Several improvements needed in the PostHog setup instructions.

The analytics setup section needs the following improvements:

  1. Fix the layout file extension:
-  Create a new layout file at `src/routes/+layout.js`
+  Create a new layout file at `src/routes/+layout.ts` # or .svelte if you need a UI component
  1. Add environment variable setup:
+- Configure Environment Variables
+  - Add `PUBLIC_POSTHOG_KEY=your-project-api-key` to your `.env.local` file for development
+  - Add this environment variable to your deployment environment (Cloudflare/Vercel)
  1. Add security note:
+- Security Note
+  - Ensure you're using the public project API key, not the private API key
+  - The public key is safe to expose in client-side code
  1. Clarify API key location:
-    - Note: ensure you're logged into PostHog so that the code includes your unique API key automatically.
+    - Note: Find your project API key in PostHog under Project Settings > Project API Key
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Setup Analytics -- Optional
### PostHog
- Create a PostHog Account
- Install PostHog JS Library
- Run `npm install posthog-js` in your terminal. This will add PostHog dependencies to your `package.json` and `package-lock.json`.
- Set Up PostHog
- Create a new layout file at `src/routes/+layout.js`
- Log into PostHog. Then copy the code from [Svelte Client-side setup](https://posthog.com/docs/libraries/svelte#client-side-setup) and paste it into your `src/routes/+layout.js` file
- Note: ensure you’re logged into PostHog so that the code includes your unique API key automatically.
- Test analytics
- Click around and view a few pages on your site to generate some events. You can view these events in PostHog to ensure tracking is active.
## Setup Analytics -- Optional
### PostHog
- Create a PostHog Account
- Install PostHog JS Library
- Run `npm install posthog-js` in your terminal. This will add PostHog dependencies to your `package.json` and `package-lock.json`.
- Set Up PostHog
- Create a new layout file at `src/routes/+layout.ts` # or .svelte if you need a UI component
- Log into PostHog. Then copy the code from [Svelte Client-side setup](https://posthog.com/docs/libraries/svelte#client-side-setup) and paste it into your `src/routes/+layout.ts` file
- Note: Find your project API key in PostHog under Project Settings > Project API Key
- Configure Environment Variables
- Add `PUBLIC_POSTHOG_KEY=your-project-api-key` to your `.env.local` file for development
- Add this environment variable to your deployment environment (Cloudflare/Vercel)
- Security Note
- Ensure you're using the public project API key, not the private API key
- The public key is safe to expose in client-side code
- Test analytics
- Click around and view a few pages on your site to generate some events. You can view these events in PostHog to ensure tracking is active.

## Community Extensions

The open source community is extending and improving SaasStarter!
Expand Down
Loading