Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/lib/agent-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { analytics } from '../utils/analytics';
import {
WIZARD_INTERACTION_EVENT_NAME,
WIZARD_REMARK_EVENT_NAME,
WIZARD_USER_AGENT,
} from './constants';
import { getLlmGatewayUrlFromHost } from '../utils/urls';
import { LINTING_TOOLS } from './safe-tools';
Expand Down Expand Up @@ -357,6 +358,7 @@ export async function initializeAgent(
url: config.posthogMcpUrl,
headers: {
Authorization: `Bearer ${config.posthogApiKey}`,
'User-Agent': WIZARD_USER_AGENT,
},
},
...Object.fromEntries(
Expand Down
3 changes: 3 additions & 0 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios, { AxiosError } from 'axios';
import { z } from 'zod';
import { analytics } from '../utils/analytics';
import { WIZARD_USER_AGENT } from './constants';

export const ApiUserSchema = z.object({
distinct_id: z.string(),
Expand Down Expand Up @@ -48,6 +49,7 @@ export async function fetchUserData(
const response = await axios.get(`${baseUrl}/api/users/@me/`, {
headers: {
Authorization: `Bearer ${accessToken}`,
'User-Agent': WIZARD_USER_AGENT,
},
});

Expand All @@ -71,6 +73,7 @@ export async function fetchProjectData(
const response = await axios.get(`${baseUrl}/api/projects/${projectId}/`, {
headers: {
Authorization: `Bearer ${accessToken}`,
'User-Agent': WIZARD_USER_AGENT,
},
});

Expand Down
8 changes: 8 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,11 @@ export const OAUTH_PORT = 8239;

export const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction';
export const WIZARD_REMARK_EVENT_NAME = 'wizard remark';

/**
* User-Agent string for the wizard when making HTTP requests.
* Used for direct PostHog API calls and passed to the MCP server
* so it can identify requests originating from the wizard.
*/
import packageJson from '../../package.json';
export const WIZARD_USER_AGENT = `posthog/wizard; version: ${packageJson.version}`;
3 changes: 2 additions & 1 deletion src/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import chalk from 'chalk';
import opn from 'opn';
import { z } from 'zod';
import clack from './clack';
import { ISSUES_URL, OAUTH_PORT } from '../lib/constants';
import { ISSUES_URL, OAUTH_PORT, WIZARD_USER_AGENT } from '../lib/constants';
import { abort } from './clack-utils';
import { analytics } from './analytics';
import type { CloudRegion } from './types';
Expand Down Expand Up @@ -187,6 +187,7 @@ async function exchangeCodeForToken(
{
headers: {
'Content-Type': 'application/json',
'User-Agent': WIZARD_USER_AGENT,
},
},
);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"types": ["node", "jest"],
"typeRoots": ["./node_modules/@types", "./types"],
"declaration": true,
"resolveJsonModule": true,
"outDir": "dist"
},
"include": [
Expand Down
Loading