Skip to content

Commit 048b046

Browse files
committed
fix(bugsnag): regenerate api client with original field name casing
1 parent da911d1 commit 048b046

File tree

11 files changed

+1402
-1548
lines changed

11 files changed

+1402
-1548
lines changed

docs/custom-words.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Dsyms
99
Eventmachine
1010
frankkilcommins
1111
jailbroken
12+
Laravel
1213
latestby
1314
Magento
1415
minidump
@@ -22,6 +23,7 @@ petstore
2223
qmetry
2324
Reactnative
2425
reindexing
26+
SCIM
2527
smartbear
2628
sogou
2729
stackframe
@@ -31,6 +33,7 @@ SWAGGERHUB
3133
symbolicate
3234
Symfony
3335
testmanagement
36+
ttfb
3437
Tvos
3538
Unbucketed
3639
undiscard

src/bugsnag/client.ts

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ const PERMITTED_UPDATE_OPERATIONS = [
5252
] as const;
5353

5454
interface StabilityData {
55-
userStability: number;
56-
sessionStability: number;
57-
stabilityTargetType: string;
58-
targetStability: number;
59-
criticalStability: number;
60-
meetsTargetStability: boolean;
61-
meetsCriticalStability: boolean;
55+
user_stability: number;
56+
session_stability: number;
57+
stability_target_type: string;
58+
target_stability: number;
59+
critical_stability: number;
60+
meets_target_stability: boolean;
61+
meets_critical_stability: boolean;
6262
}
6363

6464
const ConfigurationSchema = z.object({
@@ -135,7 +135,7 @@ export class BugsnagClient implements Client {
135135
const projects = await this.getProjects();
136136
// If there's just one project, make this the current project
137137
if (projects.length === 1 && !this.projectApiKey) {
138-
this.projectApiKey = projects[0].apiKey;
138+
this.projectApiKey = projects[0].api_key;
139139
}
140140
} catch (error) {
141141
// Swallow auth errors here to allow the tools to be registered for visibility, even if the token is invalid
@@ -263,7 +263,7 @@ export class BugsnagClient implements Client {
263263
if (!project && this.projectApiKey) {
264264
const projects = await this.getProjects();
265265
project =
266-
projects.find((p: Project) => p.apiKey === this.projectApiKey) ?? null;
266+
projects.find((p: Project) => p.api_key === this.projectApiKey) ?? null;
267267
this.cache?.set(cacheKeys.CURRENT_PROJECT, project);
268268
}
269269
return project;
@@ -285,7 +285,7 @@ export class BugsnagClient implements Client {
285285
}
286286
filtersResponse = filtersResponse.filter(
287287
(field) =>
288-
field.displayId && !EXCLUDED_EVENT_FIELDS.has(field.displayId),
288+
field.display_id && !EXCLUDED_EVENT_FIELDS.has(field.display_id),
289289
);
290290
projectFiltersCache[project.id] = filtersResponse;
291291
this.cache?.set(cacheKeys.PROJECT_EVENT_FIELDS, projectFiltersCache);
@@ -353,42 +353,45 @@ export class BugsnagClient implements Client {
353353
source: T,
354354
project: Project,
355355
): T & StabilityData {
356-
const accumulativeDailyUsersSeen = source.accumulativeDailyUsersSeen || 0;
356+
const accumulativeDailyUsersSeen =
357+
source.accumulative_daily_users_seen || 0;
357358
const accumulativeDailyUsersWithUnhandled =
358-
source.accumulativeDailyUsersWithUnhandled || 0;
359+
source.accumulative_daily_users_with_unhandled || 0;
359360

360361
const userStability =
361362
accumulativeDailyUsersSeen === 0 // avoid division by zero
362363
? 0
363364
: (accumulativeDailyUsersSeen - accumulativeDailyUsersWithUnhandled) /
364365
accumulativeDailyUsersSeen;
365366

366-
const totalSessionsCount = source.totalSessionsCount || 0;
367-
const unhandledSessionsCount = source.unhandledSessionsCount || 0;
367+
const totalSessionsCount = source.total_sessions_count || 0;
368+
const unhandledSessionsCount = source.unhandled_sessions_count || 0;
368369

369370
const sessionStability =
370371
totalSessionsCount === 0 // avoid division by zero
371372
? 0
372373
: (totalSessionsCount - unhandledSessionsCount) / totalSessionsCount;
373374

374375
const stabilityMetric =
375-
project.stabilityTargetType === "user" ? userStability : sessionStability;
376+
project.stability_target_type === "user"
377+
? userStability
378+
: sessionStability;
376379

377-
const targetStability = project.targetStability?.value || 0;
378-
const criticalStability = project.criticalStability?.value || 0;
380+
const targetStability = project.target_stability?.value || 0;
381+
const criticalStability = project.critical_stability?.value || 0;
379382

380383
const meetsTargetStability = stabilityMetric >= targetStability;
381384
const meetsCriticalStability = stabilityMetric >= criticalStability;
382385

383386
return {
384387
...source,
385-
userStability,
386-
sessionStability,
387-
stabilityTargetType: project.stabilityTargetType || "user",
388-
targetStability,
389-
criticalStability,
390-
meetsTargetStability,
391-
meetsCriticalStability,
388+
user_stability: userStability,
389+
session_stability: sessionStability,
390+
stability_target_type: project.stability_target_type || "user",
391+
target_stability: targetStability,
392+
critical_stability: criticalStability,
393+
meets_target_stability: meetsTargetStability,
394+
meets_critical_stability: meetsCriticalStability,
392395
};
393396
}
394397

@@ -458,7 +461,7 @@ export class BugsnagClient implements Client {
458461
}
459462
if (params.apiKey) {
460463
const matchedProject = projects.find(
461-
(p: Project) => p.apiKey === params.apiKey,
464+
(p: Project) => p.api_key === params.apiKey,
462465
);
463466
projects = matchedProject ? [matchedProject] : [];
464467
}
@@ -727,7 +730,7 @@ export class BugsnagClient implements Client {
727730
// Validate filter keys against cached event fields
728731
if (params.filters) {
729732
const eventFields = await this.getProjectEventFields(project);
730-
const validKeys = new Set(eventFields.map((f) => f.displayId));
733+
const validKeys = new Set(eventFields.map((f) => f.display_id));
731734
for (const key of Object.keys(params.filters)) {
732735
if (!validKeys.has(key)) {
733736
throw new ToolError(`Invalid filter key: ${key}`);

src/bugsnag/client/api/CurrentUser.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
import { type ApiResponse, BaseAPI } from "./base.js";
12
import {
23
CurrentUserApiFetchParamCreator,
4+
type Organization,
35
type OrganizationApiView,
4-
} from "./api.js";
5-
import { type ApiResponse, BaseAPI } from "./base.js";
6-
import type { Project } from "./index.js";
6+
type Project,
7+
} from "./index.js";
78
import { ProjectAPI } from "./Project.js";
89

9-
export interface Organization extends OrganizationApiView {
10-
id: string; // ID is always present
11-
}
12-
1310
export class CurrentUserAPI extends BaseAPI {
1411
static organizationFields: (keyof OrganizationApiView)[] = [
1512
"id",

src/bugsnag/client/api/Error.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { FilterObject } from "../filters.js";
2+
import { type ApiResponse, BaseAPI, getQueryParams } from "./base.js";
23
import {
34
type ErrorApiView,
45
ErrorsApiFetchParamCreator,
56
type ErrorUpdateRequest,
67
type EventApiView,
78
type PivotApiView,
8-
} from "./api.js";
9-
import { type ApiResponse, BaseAPI, getQueryParams } from "./base.js";
9+
} from "./index.js";
1010

1111
export class ErrorAPI extends BaseAPI {
1212
static filterFields: string[] = ["url", "project_url", "events_url"];

src/bugsnag/client/api/Project.ts

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,58 @@
11
import { type FilterObject, toUrlSearchParams } from "../filters.js";
2-
import type {
3-
EventField,
4-
ProjectNetworkGroupingRuleset,
5-
Span,
6-
SpanGroup,
7-
TraceField,
8-
} from "./api.js";
9-
import { ProjectsApiFetchParamCreator } from "./api.js";
102
import { type ApiResponse, BaseAPI, getQueryParams } from "./base.js";
11-
import type { Build, Project, Release } from "./index.js";
3+
import {
4+
type Build,
5+
type EventField,
6+
type Project,
7+
type ProjectNetworkGroupingRuleset,
8+
ProjectsApiFetchParamCreator,
9+
type Release,
10+
type Span,
11+
type SpanGroup,
12+
type TraceField,
13+
} from "./index.js";
1214

1315
export class ProjectAPI extends BaseAPI {
1416
static projectFields: (keyof Project)[] = [
1517
"id",
1618
"name",
1719
"slug",
18-
"apiKey",
19-
"stabilityTargetType",
20-
"targetStability",
21-
"criticalStability",
20+
"api_key",
21+
"stability_target_type",
22+
"target_stability",
23+
"critical_stability",
2224
];
2325
static eventFieldFields: (keyof EventField)[] = [
2426
"custom",
25-
"displayId",
26-
"filterOptions",
27-
"pivotOptions",
27+
"display_id",
28+
"filter_options",
29+
"pivot_options",
2830
];
2931
static buildFields: (keyof Build)[] = [
3032
"id",
31-
"releaseTime",
32-
"appVersion",
33-
"releaseStage",
34-
"errorsIntroducedCount",
35-
"errorsSeenCount",
36-
"totalSessionsCount",
37-
"unhandledSessionsCount",
38-
"accumulativeDailyUsersSeen",
39-
"accumulativeDailyUsersWithUnhandled",
33+
"release_time",
34+
"app_version",
35+
"release_stage",
36+
"errors_introduced_count",
37+
"errors_seen_count",
38+
"total_sessions_count",
39+
"unhandled_sessions_count",
40+
"accumulative_daily_users_seen",
41+
"accumulative_daily_users_with_unhandled",
4042
];
4143
static releaseFields: (keyof Release)[] = [
4244
"id",
43-
"releaseStageName",
44-
"appVersion",
45-
"firstReleasedAt",
46-
"firstReleaseId",
47-
"releasesCount",
45+
"release_stage_name",
46+
"app_version",
47+
"first_released_at",
48+
"first_release_id",
49+
"releases_count",
4850
"visible",
49-
"totalSessionsCount",
50-
"unhandledSessionsCount",
51-
"sessionsCountInLast24h",
52-
"accumulativeDailyUsersSeen",
53-
"accumulativeDailyUsersWithUnhandled",
51+
"total_sessions_count",
52+
"unhandled_sessions_count",
53+
"sessions_count_in_last_24h",
54+
"accumulative_daily_users_seen",
55+
"accumulative_daily_users_with_unhandled",
5456
];
5557

5658
/**

0 commit comments

Comments
 (0)