Skip to content
Closed
Show file tree
Hide file tree
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
61 changes: 17 additions & 44 deletions docs/guides/posthog-github-continuous-ai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,23 @@ sidebarTitle: "PostHog Analytics with Continue CLI"
issues with the GitHub CLI.
</Card>

## What You'll Learn

This cookbook teaches you to:

- Use [PostHog MCP](https://posthog.com/docs/model-context-protocol) to query [analytics](https://posthog.com/docs/web-analytics), [errors](https://posthog.com/docs/error-tracking), and [feature flags](https://posthog.com/docs/feature-flags)
- Analyze user behavior patterns with AI
- Automatically create GitHub issues using GitHub CLI
- Set up continuous monitoring with GitHub Actions

## Prerequisites

Before starting, ensure you have:

- GitHub repository where you want to create issues
- [PostHog account](https://posthog.com) with [session recordings enabled](https://posthog.com/docs/session-replay/installation) and data collecting
- Node.js 18+ installed locally
- [Continue CLI](https://docs.continue.dev/guides/cli) with **active credits** (required for API usage)
- [GitHub CLI](https://cli.github.com/) installed (`gh` command)

<Steps>
<Step title="Install Continue CLI">
```bash
npm i -g @continuedev/cli
```
</Step>

<Step title="Set up Continue CLI Account & API Key">
1. Visit [Continue Organizations](https://hub.continue.dev/settings/organizations)
2. Sign up or log in to your Continue account
3. Navigate to your organization settings
4. Click **"API Keys"** and then **"+ New API Key"**
5. Copy the API key immediately (you won't see it again!)
6. Login to the CLI: `cn login`
</Step>

<Step title="Add Required Secrets to Continue CLI">
Continue CLI will securely store your API keys as secrets that can be referenced in prompts.
</Step>
</Steps>

<Tip>
Continue CLI handles the complex API interactions - you just need to provide
the right prompts!
</Tip>
<Snippet file="cookbook-what-youll-learn.mdx" variables={{
"tool_name": "PostHog MCP",
"primary_function": "query analytics, errors, and feature flags",
"skill_1": "Analyze user behavior patterns with AI",
"skill_2": "Automatically create GitHub issues using GitHub CLI",
"skill_3": "Set up continuous monitoring with GitHub Actions"
}} />

<Snippet file="cookbook-prerequisites.mdx" variables={{
"primary_requirement": "GitHub repository where you want to create issues",
"service_account": "[PostHog account](https://posthog.com) with [session recordings enabled](https://posthog.com/docs/session-replay/installation) and data collecting",
"service_plan": "free tier",
"additional_tool": "[GitHub CLI](https://cli.github.com/)",
"installation_command": "`gh` command",
"setup_step_title": "Add Required Secrets to Continue CLI",
"setup_step_content": "Continue CLI will securely store your API keys as secrets that can be referenced in prompts."
}} />

## Step 1: Set Up Your Credentials

Expand Down
108 changes: 108 additions & 0 deletions docs/snippets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Cookbook Snippets

This directory contains reusable Mintlify snippets for cookbook setup sections, designed to make it easy to maintain consistency across cookbook documentation.

## Available Snippets

### Core Setup Snippets

- **`cookbook-what-youll-learn.mdx`** - Standard "What You'll Learn" section
- **`cookbook-prerequisites.mdx`** - Standard "Prerequisites" section
- **`cookbook-workflow-options.mdx`** - Standard workflow options (Quick Start vs Manual)
- **`cookbook-setup-steps.mdx`** - Common setup steps for Continue CLI
- **`cookbook-manual-setup.mdx`** - Manual setup tab content

### Variable Components

- **`cookbook-learning-points.mdx`** - Learning points list with variables
- **`cookbook-prerequisite-list.mdx`** - Prerequisites list with variables

## Usage

### Basic Usage

```mdx
<Snippet
file="cookbook-what-youll-learn.mdx"
variables={{
tool_name: "PostHog MCP",
primary_function: "query analytics, errors, and feature flags",
skill_1: "Analyze user behavior patterns with AI",
skill_2: "Automatically create GitHub issues using GitHub CLI",
skill_3: "Set up continuous monitoring with GitHub Actions",
}}
/>
```

### Available Variables

#### For `cookbook-learning-points.mdx`:

- `tool_name` - The main tool/MCP name
- `primary_function` - What the tool does
- `skill_1`, `skill_2`, `skill_3` - Specific skills learned

#### For `cookbook-prerequisite-list.mdx`:

- `primary_requirement` - Main requirement (e.g., "GitHub repository")
- `service_account` - Required service account (e.g., "PostHog account")
- `service_plan` - Plan type (e.g., "free tier")
- `additional_tool` - Additional tool needed
- `installation_command` - Installation command for additional tool
- `setup_step_title` - Title for custom setup step
- `setup_step_content` - Content for custom setup step

#### For `cookbook-workflow-options.mdx`:

- `service_name` - Service name (e.g., "PostHog")
- `service_type` - Service type (e.g., "Analytics")
- `additional_features` - Additional agent features
- `quick_start_instruction` - Quick start instructions
- `task_type` - Type of task (e.g., "Analysis")
- `first_task_instruction` - First task instructions
- `agent_benefits` - Benefits of using the agent
- `service_functionality` - What the service does
- `mcp_hub_url` - Hub URL for the MCP
- `mcp_install_command` - MCP install command
- `mcp_installation_details` - Installation details
- `mcp_auth_info` - Authentication information

#### For `cookbook-manual-setup.mdx`:

- `service_name` - Service name
- `mcp_hub_url` - MCP Hub URL
- `mcp_install_command` - MCP install command
- `mcp_installation_details` - Installation details
- `mcp_auth_info` - Authentication info
- `manual_setup_step_title` - Manual setup step title
- `manual_setup_step_content` - Manual setup step content
- `manual_setup_additional_info` - Additional setup information
- `task_type` - Task type
- `manual_first_task` - Manual first task instructions

## Example Implementation

See `docs/guides/posthog-github-continuous-ai.mdx` for a complete example of how these snippets are used with variables.

## Benefits

1. **Consistency** - All cookbooks use the same structure and wording
2. **Maintainability** - Change once, update everywhere
3. **Flexibility** - Variables allow customization while maintaining structure
4. **Efficiency** - No need to copy/paste setup sections

## Adding New Variables

To add new variables:

1. Update the snippet file to include the new variable placeholder: `{{variable_name}}`
2. Update this README with the new variable
3. Update any cookbooks using the snippet to include the new variable value

## Testing

To test snippets locally:

1. Build the docs: `cd docs && npm run build`
2. Check for any variable resolution errors
3. Verify the rendered content looks correct
4 changes: 4 additions & 0 deletions docs/snippets/cookbook-learning-points.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Use {{tool_name}} to {{primary_function}}
- {{skill_1}}
- {{skill_2}}
- {{skill_3}}
35 changes: 35 additions & 0 deletions docs/snippets/cookbook-manual-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Steps>
<Step title="Create a New Agent via the Continue Hub">
Go to the [Continue Hub](https://hub.continue.dev) and [create a new agent](https://hub.continue.dev/new?type=agent).
</Step>

<Step title="Connect {{service_name}} MCP via Continue Hub">
Visit the [{{service_name}} MCP on Continue Hub]({{mcp_hub_url}}) and click **Install** to add it to the agent you created in the step above.

This will add {{service_name}} MCP to your agent's available tools. {{mcp_installation_details}}

<Tip>
**Alternative installation methods:**
1. **Quick CLI install**: `cn --mcp {{mcp_install_command}}`
2. **Manual configuration**: Add the MCP to your `~/.continue/config.json` under the `mcpServers` section

Once installed, {{service_name}} MCP tools become available to your Continue agent for all prompts.
</Tip>

<Info>
{{mcp_auth_info}}
</Info>

</Step>

<Step title="{{manual_setup_step_title}}">
{{manual_setup_step_content}}

{{manual_setup_additional_info}}

</Step>

<Step title="Run Your First {{task_type}}">
{{manual_first_task}}
</Step>
</Steps>
7 changes: 7 additions & 0 deletions docs/snippets/cookbook-prerequisite-list.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- {{primary_requirement}}
- {{service_account}} ({{service_plan}} tier works)
- Node.js 18+ installed locally
- [Continue CLI](https://docs.continue.dev/guides/cli) with **active credits** (required for API usage)
- {{additional_tool}} ({{installation_command}})

<Snippet file="cookbook-setup-steps.mdx" />
5 changes: 5 additions & 0 deletions docs/snippets/cookbook-prerequisites.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Prerequisites

Before starting, ensure you have:

<Snippet file="cookbook-prerequisite-list.mdx" />
26 changes: 26 additions & 0 deletions docs/snippets/cookbook-setup-steps.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
For all options, first:
<Steps>
<Step title="Install Continue CLI">
```bash
npm i -g @continuedev/cli
```
</Step>

<Step title="Set up Continue CLI Account & API Key">
1. Visit [Continue Organizations](https://hub.continue.dev/settings/organizations)
2. Sign up or log in to your Continue account
3. Navigate to your organization settings
4. Click **"API Keys"** and then **"+ New API Key"**
5. Copy the API key immediately (you won't see it again!)
6. Login to the CLI: `cn login`
</Step>

<Step title="{{setup_step_title}}">
{{setup_step_content}}
</Step>
</Steps>

<Tip>
Continue CLI handles the complex API interactions - you just need to provide
the right prompts!
</Tip>
5 changes: 5 additions & 0 deletions docs/snippets/cookbook-what-youll-learn.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## What You'll Learn

This cookbook teaches you to:

<Snippet file="cookbook-learning-points.mdx" />
49 changes: 49 additions & 0 deletions docs/snippets/cookbook-workflow-options.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## {{service_name}} Continuous AI Workflow Options

<Card title="🚀 Fastest Path to Success" icon="zap">
Skip the manual setup and use our pre-built {{service_name}} Continuous AI agent that includes
optimized prompts, rules, and the {{service_name}} MCP for more consistent results.
</Card>

After ensuring you meet the **Prerequisites** above, you have two paths to get started:

<Tabs>
<Tab title="⚡ Quick Start (Recommended)">
<Steps>
<Step title="Add the Pre-Built Agent">
{{quick_start_instruction}}

This agent includes:
- **{{service_name}} MCP** pre-configured and ready to use
- **{{service_type}}-focused rules** for best practices
{{additional_features}}
</Step>

<Step title="Run Your First {{task_type}}">
{{first_task_instruction}}

That's it! The agent handles everything automatically.
</Step>
</Steps>

<Info>
**Why Use the Agent?** {{agent_benefits}}
</Info>

</Tab>

<Tab title="🛠️ Manual Setup">
<Snippet file="cookbook-manual-setup.mdx" />
</Tab>
</Tabs>

<Accordion title="Agent Requirements">
To use the pre-built agent, you need either:
- **Continue CLI Pro Plan** with the models add-on, OR
- **Your own API keys** added to Continue Hub secrets

The agent will automatically detect and use your configuration along with the {{service_name}} MCP for {{service_functionality}}.

</Accordion>

---
64 changes: 64 additions & 0 deletions docs/snippets/validate-snippets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env node

const fs = require("fs");
const path = require("path");

// Find all snippet files
const snippetsDir = __dirname;
const snippetFiles = fs
.readdirSync(snippetsDir)
.filter((file) => file.endsWith(".mdx") && !file.includes("README"))
.map((file) => path.join(snippetsDir, file));

console.log("🔍 Validating snippet files...");

let hasErrors = false;

snippetFiles.forEach((filePath) => {
const fileName = path.basename(filePath);
const content = fs.readFileSync(filePath, "utf8");

// Find all variables in the format {{variable_name}}
const variables = content.match(/\{\{([^}]+)\}\}/g) || [];

if (variables.length > 0) {
console.log(`📄 ${fileName}:`);
variables.forEach((variable) => {
const varName = variable.replace(/[{}]/g, "");
console.log(` - ${varName}`);
});
console.log("");
}
});

// Check if PostHog cookbook uses the snippets correctly
const posthogCookbook = path.join(
__dirname,
"../guides/posthog-github-continuous-ai.mdx",
);
if (fs.existsSync(posthogCookbook)) {
const content = fs.readFileSync(posthogCookbook, "utf8");
const snippetUsages = content.match(/<Snippet\s+file="([^"]+)"/g) || [];

if (snippetUsages.length > 0) {
console.log("✅ PostHog cookbook uses these snippets:");
snippetUsages.forEach((usage) => {
const fileName = usage.match(/file="([^"]+)"/)[1];
console.log(` - ${fileName}`);
});
} else {
console.log("⚠️ PostHog cookbook does not use any snippets");
hasErrors = true;
}
} else {
console.log("❌ PostHog cookbook not found");
hasErrors = true;
}

console.log(
"\n" +
(hasErrors
? "❌ Validation completed with issues"
: "✅ Validation completed successfully"),
);
process.exit(hasErrors ? 1 : 0);
Loading
Loading