diff --git a/collectors/APICallCollector.js b/collectors/APICallCollector.js index e7599439..be9fc36e 100644 --- a/collectors/APICallCollector.js +++ b/collectors/APICallCollector.js @@ -87,7 +87,13 @@ class APICallCollector extends BaseCollector { this._calls.push({ source: breakpoint.source, description: breakpoint.description, - arguments: breakpoint.arguments + arguments: breakpoint.arguments.map(arg => { + try { + return JSON.parse(arg); + } catch (e) { + return arg; + } + }) }); } } diff --git a/collectors/APICalls/TrackerTracker.js b/collectors/APICalls/TrackerTracker.js index 2535e3e1..1d758a4a 100644 --- a/collectors/APICalls/TrackerTracker.js +++ b/collectors/APICalls/TrackerTracker.js @@ -84,7 +84,13 @@ class TrackerTracker { // only save arguments if requested for given breakpoint if (saveArguments) { conditionScript += ` - data.args = Array.from(arguments).map(a => a.toString()); + data.args = Array.from(arguments).map(a => { + try { + return JSON.stringify(a); + } catch (e) { + return a.toString(); + } + }); `; } diff --git a/tests/collectors/APICallCollector.test.js b/tests/collectors/APICallCollector.test.js index f7a70153..149b8ccf 100644 --- a/tests/collectors/APICallCollector.test.js +++ b/tests/collectors/APICallCollector.test.js @@ -97,7 +97,10 @@ async function main() { payload: JSON.stringify({ description: 'Document.cookie setter', stack: '(https://example.com/different.js:1:23)\n(https://example.com/different.js:2:23)', - args: ['uuid=123'] + args: [ + "\"uuid=123\"", + "{\"key\":\"key\",\"value\":\"value\"}" + ] }) }); @@ -113,7 +116,11 @@ async function main() { source: 'https://example.com/different.js', description: 'Document.cookie setter', arguments: [ - 'uuid=123' + "uuid=123", + { + key: "key", + value: "value" + } ] } ]