I have a Node JS 11.9 application
Just upgraded the package to "@sentry/node": "^4.6.5" from "@sentry/node": "^4.5.4".
When adding objects to Addition Data I would see the following logged:
{
ExMessage: ,
level: error,
Payload: {
AcquisitionId: ,
ClientId: ,
DeviceData: { << - Note this
Browser: {
major: ,
name: ,
version:
},
Cpu: {},
Device: {
type:
},
Engine: {
name: ,
version:
},
Os: {
name: ,
version:
}
},
Environment: ,
EventDate: {}, << - Note this
Fingerprint: ,
Geographical: {}, << - Note this
IpAddress: ,
Referer: ,
Sequence: ,
SessionId: ,
Type: ,
Url: ,
UserAgent: ,
UserName: ,
Version: ,
Weather: {} << - Note this
}
}
Unfortunately, now after upgrading I am getting:
{
ExMessage: ,
level: ,
Payload: {
AcquisitionId: ,
ClientId: ,
DeviceData: [Object], <<- Note this
Environment: ,
EventDate: [Object], <<- Note this
Fingerprint: ,
Geographical: [Object], <<- Note this
IpAddress: ,
Referer: ,
Sequence: ,
SessionId: ,
Type: ,
Url: ,
UserAgent: ,
UserName: ,
Version: ,
Weather: [Object] <<- Note this
}
}
I have this class
export class TrackerError extends Error {
Payload: any;
ExMessage: string;
constructor(message: string, err: Error, payload: any) {
super(message);
if (err) {
this.stack = this.stack
.split("\n")
.slice(0, 2)
.join("\n") +
"\n" +
err.stack;
this.ExMessage = err.message;
} else {
Error.captureStackTrace(this, this.constructor);
}
if (payload) {
this.Payload = payload;
}
}
}
which I then use as follows:
Sentry.captureException(new TrackerError("My Error Message", myErrObj, myPayloadObj));
As per previous versions, deep objects should be logged in detail
You should be able to define the depth yourself:
Sentry.init({
...
integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 10 })],
...
});
We reduced the limit drastically since it caused many problems for users.
Hope this helps.
@HazAT
Where is this documented? And is this specific to the JS library?
TBH, this is sadly poorly documented and should be here:
https://docs.sentry.io/platforms/javascript/default-integrations/#extraerrordata
I will write this down to improve, and yes, this is JS specific.
OK Thank you.
Sorry to come back to this but I have just updated to 5.4.0 and its now erroring with:
Property 'ExtraErrorData' does not exist on type '{ Console: typeof Console; Http: typeof Http; OnUncaughtException: typeof OnUncaughtException; OnUnhandledRejection: typeof OnUnhandledRejection; LinkedErrors: typeof LinkedErrors; Modules: typeof Modules; FunctionToString: typeof FunctionToString; InboundFilters: typeof InboundFilters; }'.
21 integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 10 })]
@drwharris
import { ExtraErrorData } from '@sentry/integrations';
This seems to have regressed. I have this:
import { ExtraErrorData } from '@sentry/integrations';
Sentry.init({
dsn: 'MYDSN',
release: `${Settings.name}@${module.exports.version}`,
integrations: [new ExtraErrorData({ depth: 10 })],
});
And I get this
{
AcquisitionId: "",
ClientId: "",
DeviceData: [Object], <<- Note this
Environment: "",
EventDate: [Object], <<- Note this
Fingerprint: "",
Geographical: [Object], <<- Note this
IpAddress: "",
Referer: "",
Sequence: "",
SessionId: "",
Type: "",
Url: "",
UserAgent: "",
UserName: "",
Version: ""
}
You need to use the undocumented new param normalizeDepth
and set it to normalizeDepth: depth + 1
:
In your example:
Sentry.init({
dsn: 'MYDSN',
release: `${Settings.name}@${module.exports.version}`,
integrations: [new ExtraErrorData({ depth: 10 })],
normalizeDepth: 11
});
See also: https://github.com/getsentry/sentry-javascript/pull/2404
I've run into the same problem and can confirm that adding normalizeDepth
resolves the problem. I also double checked if integrations: [new ExtraErrorData({ depth: 10 })],
is necessary at all and it turns out it is not, removing it results in the same output on Sentry.
The option was add in https://github.com/getsentry/sentry-javascript/pull/2404 (shipped in v5.12.0), but I could not find any documentation
We are aware of this issue - https://github.com/getsentry/sentry-javascript/issues/2539#issuecomment-616638746
It will be fixed in v6, as it's breaking change.
Hello,
I have an issue that might be related and that I can not get to work. Just to be sure, [new ExtraErrorData({ depth: 10 })]
is supposed to modify ADDITIONAL DATA
field depth in the error report right ?
If so, I am using Sentry 5.22.1 and it doesn't seems to work:
javascript
Sentry.init({
dsn: 'https://mydsn',
integrations: [new ExtraErrorData({ depth: 9 })],
normalizeDepth: 10,
});
And the additional data __serialized__
object looks loke this:
JSON
{
error: {
errors: {
Views: [Array]
},
status: 400,
...
},
...
}
I just verified it locally and it works just fine for me:
Sentry.init({
dsn: "__public_dsn__",
integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 9 })],
normalizeDepth: 10,
beforeSend(event) {
console.log(event);
return null;
},
});
const err = new Error("foo");
err.some = {
additional: {
data: [{ foo: { bar: 123 } }],
},
};
Sentry.captureException(err);
Ok, thank you for your reply, I'll try to figure out where my problem comes from.
Most helpful comment
This seems to have regressed. I have this:
And I get this