Skip to content

Commit

Permalink
Add stringified payload to metametrics controller trackEvent error me…
Browse files Browse the repository at this point in the history
…ssage (#11166)

* Add stringified payload to metametrics controller trackEvent error message

* Don't include full payload when throwing error on missing event or category in trackEvent
  • Loading branch information
danjm authored May 24, 2021
1 parent 3cbef73 commit 1323a77
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,17 @@ export default class MetaMetricsController {
async trackEvent(payload, options) {
// event and category are required fields for all payloads
if (!payload.event || !payload.category) {
throw new Error('Must specify event and category.');
throw new Error(
`Must specify event and category. Event was: ${
payload.event
}. Category was: ${payload.category}. Payload keys were: ${Object.keys(
payload,
)}. ${
typeof payload.properties === 'object'
? `Payload property keys were: ${Object.keys(payload.properties)}`
: ''
}`,
);
}

if (!this.state.participateInMetaMetrics && !options?.isOptIn) {
Expand Down

0 comments on commit 1323a77

Please sign in to comment.