Skip to content

Commit 68b248a

Browse files
committed
Linter + broken test on IE10
1 parent 3fb1e0b commit 68b248a

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function throwObjectError() {
22
// never do this; just making sure Raven.js handles this case
33
// gracefully
4-
throw { error: "stuff is broken" };
4+
throw { error: "stuff is broken", somekey: "ok" };
55
}
66

77
throwObjectError();

packages/browser/test/integration/suites/onerror.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,22 @@ describe("window.onerror", function() {
6161
}).then(function(summary) {
6262
assert.equal(summary.events[0].exception.values[0].type, "Error");
6363

64-
// #<Object> is covering default Android 4.4 and 5.1 browser
65-
assert.match(
66-
summary.events[0].exception.values[0].value,
67-
/^(\[object Object\]|#<Object>)$/
68-
);
64+
// ¯\_(ツ)_/¯
65+
if (summary.window.isBelowIE11()) {
66+
assert.equal(
67+
summary.events[0].exception.values[0].value,
68+
"[object Object]"
69+
);
70+
} else {
71+
assert.equal(
72+
summary.events[0].exception.values[0].value,
73+
"Custom Object"
74+
);
75+
assert.equal(
76+
summary.events[0].message,
77+
"Non-Error exception captured with keys: error, somekey"
78+
);
79+
}
6980
assert.equal(
7081
summary.events[0].exception.values[0].stacktrace.frames.length,
7182
1

packages/node/src/handlers.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,34 @@ function extractRequestData(req: { [key: string]: any }, keys: boolean | string[
138138
const DEFAULT_USER_KEYS = ['id', 'username', 'email'];
139139

140140
/** JSDoc */
141-
function extractUserData(req: { [key: string]: any }, keys: boolean | string[]): { [key: string]: string } {
142-
const user: { [key: string]: string } = {};
141+
function extractUserData(
142+
req: {
143+
ip?: string;
144+
connection?: {
145+
remoteAddress?: string;
146+
};
147+
user?: {
148+
[key: string]: any;
149+
};
150+
},
151+
keys: boolean | string[],
152+
): { [key: string]: any } {
153+
const user: { [key: string]: any } = {};
143154
const attributes = Array.isArray(keys) ? keys : DEFAULT_USER_KEYS;
144155

145156
attributes.forEach(key => {
146-
if (key in req.user) {
147-
user[key] = (req.user as { [key: string]: string })[key];
157+
if (req.user && key in req.user) {
158+
user[key] = req.user[key];
148159
}
149160
});
150161

151162
// client ip:
152163
// node: req.connection.remoteAddress
153164
// express, koa: req.ip
154-
const ip =
155-
req.ip ||
156-
(req.connection &&
157-
(req.connection as {
158-
remoteAddress?: string;
159-
}).remoteAddress);
165+
const ip = req.ip || (req.connection && req.connection.remoteAddress);
160166

161167
if (ip) {
162-
user.ip_address = ip as string;
168+
user.ip_address = ip;
163169
}
164170

165171
return user;

0 commit comments

Comments
 (0)