Add stringified payload to metametrics controller trackEvent error message (#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
feature/default_network_editable
Dan J Miller 4 years ago committed by ryanml
parent a137cd1aca
commit 452a5e7de6
  1. 12
      app/scripts/controllers/metametrics.js

@ -330,7 +330,17 @@ export default class MetaMetricsController {
async trackEvent(payload, options) { async trackEvent(payload, options) {
// event and category are required fields for all payloads // event and category are required fields for all payloads
if (!payload.event || !payload.category) { 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) { if (!this.state.participateInMetaMetrics && !options?.isOptIn) {

Loading…
Cancel
Save