Skip to content

Commit 91e0859

Browse files
committed
user agent to both jobApi routes
1 parent 69807b2 commit 91e0859

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/github/copilotApi.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ export class CopilotApi {
6868
return this.makeApiCallFullUrl(`${this.baseUrl}${api}`, init);
6969
}
7070

71+
private get userAgent(): string {
72+
const extensionVersion = vscode.extensions.getExtension('GitHub.vscode-pull-request-github')?.packageJSON.version ?? 'unknown';
73+
return `vscode-pull-request-github/${extensionVersion}`;
74+
}
75+
76+
7177
async postRemoteAgentJob(
7278
owner: string,
7379
name: string,
@@ -81,9 +87,6 @@ export class CopilotApi {
8187
const problemStatementLength = payload.problem_statement.length.toString();
8288
const payloadJson = JSON.stringify(payload);
8389
const payloadLength = payloadJson.length.toString();
84-
const extensionVersion = vscode.extensions.getExtension('GitHub.vscode-pull-request-github')?.packageJSON.version ?? 'unknown';
85-
const userAgent = `vscode-pull-request-github/${extensionVersion}`;
86-
Logger.trace(`postRemoteAgentJob: User-Agent: ${userAgent}`, CopilotApi.ID);
8790
Logger.trace(`postRemoteAgentJob: Posting job to ${apiUrl} with payload: ${JSON.stringify(payload)}`, CopilotApi.ID);
8891
try {
8992
const response = await this.makeApiCall(apiUrl, {
@@ -92,7 +95,7 @@ export class CopilotApi {
9295
'Authorization': `Bearer ${this.token}`,
9396
'Content-Type': 'application/json',
9497
'Accept': 'application/json',
95-
'User-Agent': userAgent,
98+
'User-Agent': this.userAgent,
9699
},
97100
body: payloadJson
98101
});
@@ -274,7 +277,8 @@ export class CopilotApi {
274277
headers: {
275278
'Authorization': `Bearer ${this.token}`,
276279
'Content-Type': 'application/json',
277-
'Accept': 'application/json'
280+
'Accept': 'application/json',
281+
'User-Agent': this.userAgent,
278282
}
279283
});
280284
if (!response.ok) {

0 commit comments

Comments
 (0)