1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 11:22:43 +02:00

Remove callback from being saved in controller state (#16627)

This commit is contained in:
Jyoti Puri 2022-11-23 23:30:05 +05:30 committed by GitHub
parent ab808b670a
commit 82dc628fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -166,11 +166,9 @@ export default class MetaMetricsController {
// Code below submits any pending segmentApiCalls to Segment if/when the controller is re-instantiated
if (isManifestV3) {
Object.values(segmentApiCalls).forEach(
({ eventType, payload, callback }) => {
this._submitSegmentAPICall(eventType, payload, callback);
},
);
Object.values(segmentApiCalls).forEach(({ eventType, payload }) => {
this._submitSegmentAPICall(eventType, payload);
});
}
// Close out event fragments that were created but not progressed. An
@ -961,6 +959,11 @@ export default class MetaMetricsController {
// Saving segmentApiCalls in controller store in MV3 ensures that events are tracked
// even if service worker terminates before events are submiteed to segment.
_submitSegmentAPICall(eventType, payload, callback) {
const { metaMetricsId, participateInMetaMetrics } = this.state;
if (!participateInMetaMetrics || !metaMetricsId) {
return;
}
const messageId = payload.messageId || generateRandomId();
let timestamp = new Date();
if (payload.timestamp) {
@ -979,7 +982,6 @@ export default class MetaMetricsController {
...modifiedPayload,
timestamp: modifiedPayload.timestamp.toString(),
},
callback,
},
},
});

View File

@ -362,7 +362,7 @@ describe('MetaMetricsController', function () {
it('should track an event if user has not opted in, but isOptIn is true', function () {
const mock = sinon.mock(segment);
const metaMetricsController = getMetaMetricsController({
participateInMetaMetrics: false,
participateInMetaMetrics: true,
});
mock
.expects('track')
@ -394,7 +394,7 @@ describe('MetaMetricsController', function () {
it('should track an event during optin and allow for metaMetricsId override', function () {
const mock = sinon.mock(segment);
const metaMetricsController = getMetaMetricsController({
participateInMetaMetrics: false,
participateInMetaMetrics: true,
});
mock
.expects('track')