Skip to content

Commit 0df066a

Browse files
fix/enum for endpoints names
1 parent f6edcce commit 0df066a

8 files changed

Lines changed: 22 additions & 15 deletions

File tree

packages/browser/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Performance } from "./performance";
44
import { utils } from "./utils";
55
import { stacktrace } from "./exceptions/stacktrace";
66
import { Trace } from "./types/stacktrace";
7-
import { BrowserIncidentType } from "./types/transport";
7+
import { BrowserIncidentType, CAPTURE_ENDPOINT } from "./types/transport";
88
import { EventOnErrorType, EventOnUnhandledRejectionType, windowEventHandlers } from "./handlers";
99
import { BrowserInfoType } from "./types/browser";
1010

@@ -167,6 +167,6 @@ export abstract class BrowserClient implements IBrowserClient {
167167
}
168168

169169
private get incidentsUrl() {
170-
return `/api/worker/incident/${this.configs.options.projectId}`;
170+
return `${CAPTURE_ENDPOINT.INCIDENT}/${this.configs.options.projectId}`;
171171
}
172172
}

packages/browser/src/performance/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Batch } from "../transport/batch";
22
import { BrowserClientConfigType } from "../types/client";
33
import { BrowserPerformanceType, LargestContentfulPaint, LayoutShift, ObserverType } from "../types/performance";
4+
import { CAPTURE_ENDPOINT } from "../types/transport";
45
import { utils } from "../utils";
56

67
export class Performance {
@@ -9,7 +10,7 @@ export class Performance {
910
constructor(configs: BrowserClientConfigType) {
1011
this.batch = new Batch(configs, {
1112
headers: configs?.headers,
12-
url: `/api/worker/browser/perf/${configs?.options?.projectId}`
13+
url: `${CAPTURE_ENDPOINT.BROWSER_PERFS}/${configs?.options?.projectId}`
1314
});
1415
}
1516

packages/browser/src/types/transport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export interface ITransport {
66
request(): Promise<void>;
77
}
88

9+
export enum CAPTURE_ENDPOINT {
10+
INCIDENT = "/api/capture/incident",
11+
BROWSER_PERFS = "/api/capture/browser/perfs"
12+
}
13+
914
export type RequestOptions<T> = {
1015
body: T;
1116
headers: Dictionary<string>;

packages/node/src/exceptions/handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { stacktrace } from "stacktrace-parser-node";
22
import { HttpModule } from "../core/http";
33
import { isClientConnected } from "../core/is";
4-
import { TraceoError, NodeIncidentType } from "../types";
4+
import { TraceoError, NodeIncidentType, CAPTURE_ENDPOINT } from "../types";
55
import { getOsDetails } from "../helpers";
66

77
/**
@@ -30,7 +30,7 @@ const handleException = async (error: TraceoError) => {
3030
const event: NodeIncidentType = await prepareException(error);
3131
const httpModule = HttpModule.getInstance();
3232
httpModule.request({
33-
url: "/api/worker/incident",
33+
url: CAPTURE_ENDPOINT.INCIDENT,
3434
body: event,
3535
onError: (error: Error) => {
3636
console.error(

packages/node/src/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { format } from "util";
22
import { HttpModule } from "./core/http";
3-
import { LogLevel } from "./types";
3+
import { CAPTURE_ENDPOINT, LogLevel } from "./types";
44
import { Client } from "./client";
55

66
export class Logger {
@@ -68,7 +68,7 @@ export class Logger {
6868
private async sendLogs() {
6969
if (this.logsQueue.length > 0) {
7070
this.http.request({
71-
url: "/api/worker/log",
71+
url: CAPTURE_ENDPOINT.LOG,
7272
body: this.logsQueue,
7373
onError: (error: Error) => {
7474
console.error(

packages/node/src/metrics/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MemoryUsageMetrics } from "./default/memory-usage";
77
import { toDecimalNumber } from "../helpers";
88
import * as os from "os";
99
import { HttpModule } from "../core/http";
10-
import { DefaultMetrics, Metrics } from "../types";
10+
import { CAPTURE_ENDPOINT, DefaultMetrics, Metrics } from "../types";
1111

1212
/**
1313
* Runner for metrics collecting
@@ -93,7 +93,7 @@ export class MetricsRunner {
9393
};
9494

9595
this.http.request({
96-
url: "/api/worker/metrics",
96+
url: CAPTURE_ENDPOINT.METRICS,
9797
body: metrics,
9898
onError: (error: Error) => {
9999
console.error(

packages/node/src/scrapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as os from "os";
22
import * as v8 from "v8";
33
import { HttpModule } from "./core/http";
4+
import { CAPTURE_ENDPOINT } from "./types";
45

56
const NPM_PKG_DEP = "npm_package_dependencies_";
67
const NPM_PKG_DEV_DEP = "npm_package_devDependencies_";
@@ -29,7 +30,7 @@ export class Scrapper {
2930
};
3031

3132
this.http.request({
32-
url: "/api/worker/runtime",
33+
url: CAPTURE_ENDPOINT.RUNTIME,
3334
body: data,
3435
onError: (error: Error) => {
3536
console.error(

packages/node/src/types/http.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export enum RequestStatus {
2222
ERROR = "error"
2323
}
2424

25-
export enum HTTP_ENDPOINT {
26-
LOG = "/api/worker/log",
27-
INCIDENT = "/api/worker/incident",
28-
RUNTIME = "/api/worker/runtime",
29-
METRICS = "/api/worker/metrics"
25+
export enum CAPTURE_ENDPOINT {
26+
LOG = "/api/capture/log",
27+
INCIDENT = "/api/capture/incident",
28+
RUNTIME = "/api/capture/runtime",
29+
METRICS = "/api/capture/metrics"
3030
}

0 commit comments

Comments
 (0)