1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

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
This commit is contained in:
Dan J Miller 2021-05-24 16:57:07 -02:30 committed by ryanml
parent a137cd1aca
commit 452a5e7de6

View File

@ -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) {