diff --git a/app/scripts/controllers/metametrics-controller.test.ts b/app/scripts/controllers/metametrics-controller.test.ts index 99ed4d2e2e48..57c49547c28b 100644 --- a/app/scripts/controllers/metametrics-controller.test.ts +++ b/app/scripts/controllers/metametrics-controller.test.ts @@ -309,6 +309,7 @@ describe('MetaMetricsController', function () { }); const expectedFragment = merge( + {}, SAMPLE_TX_SUBMITTED_PARTIAL_FRAGMENT, SAMPLE_PERSISTED_EVENT_NO_ID, { diff --git a/app/scripts/controllers/metametrics-controller.ts b/app/scripts/controllers/metametrics-controller.ts index e286a3a47d02..27e8ab10de5a 100644 --- a/app/scripts/controllers/metametrics-controller.ts +++ b/app/scripts/controllers/metametrics-controller.ts @@ -1,4 +1,5 @@ import { + cloneDeep, isEqual, memoize, merge, @@ -584,7 +585,8 @@ export default class MetaMetricsController extends BaseController< : {}; this.update((state) => { - state.fragments[id] = merge(additionalFragmentProps, fragment); + // We're cloning "additionalFragmentProps" because it can contain a frozen piece of Immer state + state.fragments[id] = merge({}, additionalFragmentProps, fragment); }); if (fragment.initialEvent) {