Skip to content

Commit 9d1a74e

Browse files
committed
feat: Capture wrapped function arguments as extra
1 parent cc7de02 commit 9d1a74e

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
- [browser] ref: Expose `ReportDialogOptions`
66
- [browser] ref: Use better default message for ReportingObserver
7+
- [browser] feat: Capture wrapped function arguments as extra
8+
- [browser] ref: Unify integrations options and set proper defaults
9+
- [browser] fix: Array.from is not available in old mobile browsers
10+
- [browser] fix: Check for anonymous function before getting its name for mechanism
11+
- [browser] test: Add loader + integration tests
712

813
## 4.0.4
914

packages/browser/src/integrations/helpers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getCurrentHub, withScope } from '@sentry/core';
22
import { Mechanism, SentryEvent, SentryWrappedFunction } from '@sentry/types';
33
import { isFunction } from '@sentry/utils/is';
44
import { htmlTreeAsString } from '@sentry/utils/misc';
5+
import { serializeObject } from '@sentry/utils/object';
56

67
const debounceDuration: number = 1000;
78
let keypressTimeout: number | undefined;
@@ -61,12 +62,14 @@ export function wrap(
6162
before.apply(this, arguments);
6263
}
6364

65+
const args = Array.prototype.slice.call(arguments);
66+
6467
try {
6568
// Attempt to invoke user-land function
6669
// NOTE: If you are a Sentry user, and you are seeing this stack frame, it
6770
// means Raven caught an error invoking your application code. This is
6871
// expected behavior and NOT indicative of a bug with Raven.js.
69-
const wrappedArguments = Array.prototype.slice.call(arguments).map((arg: any) => wrap(arg, options));
72+
const wrappedArguments = args.map((arg: any) => wrap(arg, options));
7073

7174
if (fn.handleEvent) {
7275
return fn.handleEvent.apply(this, wrappedArguments);
@@ -85,6 +88,11 @@ export function wrap(
8588
processedEvent.exception.mechanism = options.mechanism;
8689
}
8790

91+
processedEvent.extra = {
92+
...processedEvent.extra,
93+
arguments: serializeObject(args, 2),
94+
};
95+
8896
return processedEvent;
8997
});
9098

packages/utils/src/object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function serializeValue<T>(value: T): T | string {
232232
}
233233

234234
/** JSDoc */
235-
function serializeObject<T>(value: T, depth: number): T | string | {} {
235+
export function serializeObject<T>(value: T, depth: number): T | string | {} {
236236
if (depth === 0) {
237237
return serializeValue(value);
238238
}

0 commit comments

Comments
 (0)