Skip to content

Commit b710775

Browse files
committed
[Breaking] Removed addRequestInfo from EventBuilder
This was platform specific.
1 parent 9a99b3b commit b710775

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

example/express/app.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from "express";
22
const app = express();
33

4+
import { KnownEventDataKeys } from "@exceptionless/core";
45
import { Exceptionless } from "@exceptionless/node";
56

67
await Exceptionless.startup((c) => {
@@ -46,7 +47,7 @@ app.get("/trycatch", async (req, res) => {
4647
throw new Error("Caught in try/catch");
4748
} catch (error) {
4849
await Exceptionless.createException(error)
49-
.addRequestInfo(req)
50+
.setContextProperty(KnownEventDataKeys.RequestInfo, req)
5051
.submit();
5152

5253
res.status(500).send("Error caught in try/catch");
@@ -59,14 +60,14 @@ app.use(async (err, req, res, next) => {
5960
}
6061

6162
await Exceptionless.createUnhandledException(err, "express")
62-
.addRequestInfo(req)
63+
.setContextProperty(KnownEventDataKeys.RequestInfo, req)
6364
.submit();
6465

6566
res.status(500).send("Something broke!");
6667
});
6768

6869
app.use(async (req, res) => {
69-
await Exceptionless.createNotFound(req.originalUrl).addRequestInfo(req).submit();
70+
await Exceptionless.createNotFound(req.originalUrl).setContextProperty(KnownEventDataKeys.RequestInfo, req).submit();
7071
res.status(404).send("Sorry cant find that!");
7172
});
7273

packages/core/src/EventBuilder.ts

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ExceptionlessClient } from "./ExceptionlessClient.js";
22
import { Event, KnownEventDataKeys } from "./models/Event.js";
33
import { ManualStackingInfo } from "./models/data/ManualStackingInfo.js";
4-
import { RequestInfo } from "./models/data/RequestInfo.js";
54
import { UserInfo } from "./models/data/UserInfo.js";
65
import { EventContext } from "./models/EventContext.js";
76
import { isEmpty, stringify } from "./Utils.js";
@@ -193,17 +192,14 @@ export class EventBuilder {
193192
return this;
194193
}
195194

196-
public markAsCritical(critical: boolean): EventBuilder {
197-
if (critical) {
198-
this.addTags("Critical");
199-
}
200-
195+
public setContextProperty(name: string, value: unknown): EventBuilder {
196+
this.context[name] = value;
201197
return this;
202198
}
203199

204-
public addRequestInfo(request: RequestInfo): EventBuilder {
205-
if (request) {
206-
this.context[KnownEventDataKeys.RequestInfo] = request;
200+
public markAsCritical(critical: boolean): EventBuilder {
201+
if (critical) {
202+
this.addTags("Critical");
207203
}
208204

209205
return this;

0 commit comments

Comments
 (0)