Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updating dependencies and fixes #144

Merged
merged 9 commits into from
Apr 24, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
yarn.lock

build/
.tap/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporal test result files, ignored so they don't get commited

21 changes: 16 additions & 5 deletions lib/raygun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Raygun {
return this;
}

user(req?: Request): RawUserData | null {
user(req?: RequestParams): RawUserData | null {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original code mixed the Request type from Express with the internal RequestParams type, after upgrading dependencies the "compiler" didn't like that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good change. I've seen these type overlays before with NestJS using Express internally, similar problem.

return null;
}

Expand Down Expand Up @@ -189,7 +189,7 @@ class Raygun {
exception: Error | string,
customData?: CustomData,
callback?: (err: Error | null) => void,
request?: Request,
request?: RequestParams,
tags?: Tag[]
): Message {
const sendOptionsResult = this.buildSendOptions(
Expand Down Expand Up @@ -251,7 +251,7 @@ class Raygun {
exception: Error | string,
customData?: CustomData,
callback?: (err: Error | null) => void,
request?: Request,
request?: RequestParams,
tags?: Tag[]
): void {
const result = this.buildSendOptions(
Expand All @@ -276,7 +276,18 @@ class Raygun {
customData = this.expressCustomData;
}

this.send(err, customData || {}, function () {}, req, [
// Convert the Express Request to an object that can be sent to Raygun
const requestParams: RequestParams = {
hostname: req.hostname,
path: req.path,
method: req.method,
ip: req.ip ?? '',
query: req.query,
headers: req.headers,
body: req.body,
};

this.send(err, customData || {}, function () {}, requestParams, [
"UnhandledException",
]);
next(err);
Expand All @@ -293,7 +304,7 @@ class Raygun {
exception: Error | string,
customData?: CustomData,
callback?: Callback<IncomingMessage>,
request?: Request,
request?: RequestParams,
tags?: Tag[]
): SendOptionsResult {
let mergedTags: Tag[] = [];
Expand Down
Loading