File tree Expand file tree Collapse file tree 5 files changed +16
-1
lines changed
Expand file tree Collapse file tree 5 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { analytics } from '../utils/analytics';
1111import {
1212 WIZARD_INTERACTION_EVENT_NAME ,
1313 WIZARD_REMARK_EVENT_NAME ,
14+ WIZARD_USER_AGENT ,
1415} from './constants' ;
1516import { getLlmGatewayUrlFromHost } from '../utils/urls' ;
1617import { LINTING_TOOLS } from './safe-tools' ;
@@ -357,6 +358,7 @@ export async function initializeAgent(
357358 url : config . posthogMcpUrl ,
358359 headers : {
359360 Authorization : `Bearer ${ config . posthogApiKey } ` ,
361+ 'User-Agent' : WIZARD_USER_AGENT ,
360362 } ,
361363 } ,
362364 ...Object . fromEntries (
Original file line number Diff line number Diff line change 11import axios , { AxiosError } from 'axios' ;
22import { z } from 'zod' ;
33import { analytics } from '../utils/analytics' ;
4+ import { WIZARD_USER_AGENT } from './constants' ;
45
56export const ApiUserSchema = z . object ( {
67 distinct_id : z . string ( ) ,
@@ -48,6 +49,7 @@ export async function fetchUserData(
4849 const response = await axios . get ( `${ baseUrl } /api/users/@me/` , {
4950 headers : {
5051 Authorization : `Bearer ${ accessToken } ` ,
52+ 'User-Agent' : WIZARD_USER_AGENT ,
5153 } ,
5254 } ) ;
5355
@@ -71,6 +73,7 @@ export async function fetchProjectData(
7173 const response = await axios . get ( `${ baseUrl } /api/projects/${ projectId } /` , {
7274 headers : {
7375 Authorization : `Bearer ${ accessToken } ` ,
76+ 'User-Agent' : WIZARD_USER_AGENT ,
7477 } ,
7578 } ) ;
7679
Original file line number Diff line number Diff line change @@ -57,3 +57,11 @@ export const OAUTH_PORT = 8239;
5757
5858export const WIZARD_INTERACTION_EVENT_NAME = 'wizard interaction' ;
5959export const WIZARD_REMARK_EVENT_NAME = 'wizard remark' ;
60+
61+ /**
62+ * User-Agent string for the wizard when making HTTP requests.
63+ * Used for direct PostHog API calls and passed to the MCP server
64+ * so it can identify requests originating from the wizard.
65+ */
66+ import packageJson from '../../package.json' ;
67+ export const WIZARD_USER_AGENT = `posthog/wizard; version: ${ packageJson . version } ` ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import chalk from 'chalk';
55import opn from 'opn' ;
66import { z } from 'zod' ;
77import clack from './clack' ;
8- import { ISSUES_URL , OAUTH_PORT } from '../lib/constants' ;
8+ import { ISSUES_URL , OAUTH_PORT , WIZARD_USER_AGENT } from '../lib/constants' ;
99import { abort } from './clack-utils' ;
1010import { analytics } from './analytics' ;
1111import type { CloudRegion } from './types' ;
@@ -187,6 +187,7 @@ async function exchangeCodeForToken(
187187 {
188188 headers : {
189189 'Content-Type' : 'application/json' ,
190+ 'User-Agent' : WIZARD_USER_AGENT ,
190191 } ,
191192 } ,
192193 ) ;
Original file line number Diff line number Diff line change 77 "types" : [" node" , " jest" ],
88 "typeRoots" : [" ./node_modules/@types" , " ./types" ],
99 "declaration" : true ,
10+ "resolveJsonModule" : true ,
1011 "outDir" : " dist"
1112 },
1213 "include" : [
You can’t perform that action at this time.
0 commit comments