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

Conversation

evlim
Copy link
Contributor

@evlim evlim commented Oct 27, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new section in the README for optional analytics setup using PostHog.
    • Added a "Community Extensions" section with links and instructions for internationalization and dark mode themes.
  • Documentation

    • Enhanced the README.md to provide clearer guidance on analytics integration and community resources.

Copy link

coderabbitai bot commented Oct 27, 2024

Walkthrough

The changes introduce a new section titled "Setup Analytics -- Optional" in the README.md file. This section provides guidance on integrating PostHog for analytics tracking, including account creation, library installation, layout setup, and event testing. Additionally, a "Community Extensions" section is added, highlighting community-driven extensions for internationalization and dark mode themes, along with relevant links and instructions. The overall structure of the document remains unchanged, with the new content integrated smoothly.

Changes

File Change Summary
README.md Added "Setup Analytics -- Optional" section detailing PostHog integration and a "Community Extensions" section.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PostHog
    participant Site

    User->>Site: Generates events
    Site->>PostHog: Sends event data
    PostHog-->>Site: Confirms event tracking
Loading

🐇 "In the README, new paths we lay,
For tracking events in a clever way.
With PostHog's help, we’ll see the light,
Community extensions make it bright!
Hop along, dear friends, embrace the change,
In our code, let’s joyfully arrange!" 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@evlim evlim mentioned this pull request Oct 27, 2024
2 tasks
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (1)
README.md (1)

Line range hint 339-343: Consider adding contribution guidelines for community extensions.

The Community Extensions section would benefit from additional information:

 ## Community Extensions

 The open source community is extending and improving SaasStarter!

 These extensions are reference implementations of commonly needed features. We don't integrate them into the main branch to keep our dependencies minimal and simplify maintenance. However, if you need them you can cherry pick into your fork/repo:

 - Internationalization: [branch](https://github.com/CriticalMoments/CMSaasStarter/tree/extension/internationalization), and [instructions](https://github.com/CriticalMoments/CMSaasStarter/pull/49)
 - Dark mode theme: [branch](https://github.com/CriticalMoments/CMSaasStarter/tree/extension/dark_mode), and [instructions](https://github.com/CriticalMoments/CMSaasStarter/pull/47)
+
+### Contributing Extensions
+
+Want to contribute a new extension? Follow these steps:
+1. Create a new branch named `extension/your_feature_name`
+2. Implement your feature
+3. Create a PR with detailed implementation instructions
+4. Once approved, your extension will be listed here
+
+Note: Extensions are community-maintained and may need updates to work with the latest version of SaasStarter.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~341-~341: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...s active. ## Community Extensions The open source community is extending and improving Sa...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 29e67ec and b987f62.

📒 Files selected for processing (1)
  • README.md (1 hunks)

Comment on lines +325 to +338
## 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.

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.

@scosman
Copy link
Contributor

scosman commented Nov 2, 2024

@evlim our README is a bit long.

How about a new ANALYTICS.md in root, with a 1 line link to it in the "Add Your Content" section. Optionally: add analytics, like Posthog, to your project. [guide](/ANALYTICS.md)

@scosman scosman changed the base branch from main to analytics_instructions November 5, 2024 17:42
@scosman scosman merged commit 6b23493 into CriticalMoments:analytics_instructions Nov 5, 2024
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants