mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Remove callback from being saved in controller state (#16627)
This commit is contained in:
parent
ab808b670a
commit
82dc628fa3
@ -166,11 +166,9 @@ export default class MetaMetricsController {
|
|||||||
|
|
||||||
// Code below submits any pending segmentApiCalls to Segment if/when the controller is re-instantiated
|
// Code below submits any pending segmentApiCalls to Segment if/when the controller is re-instantiated
|
||||||
if (isManifestV3) {
|
if (isManifestV3) {
|
||||||
Object.values(segmentApiCalls).forEach(
|
Object.values(segmentApiCalls).forEach(({ eventType, payload }) => {
|
||||||
({ eventType, payload, callback }) => {
|
this._submitSegmentAPICall(eventType, payload);
|
||||||
this._submitSegmentAPICall(eventType, payload, callback);
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close out event fragments that were created but not progressed. An
|
// 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
|
// Saving segmentApiCalls in controller store in MV3 ensures that events are tracked
|
||||||
// even if service worker terminates before events are submiteed to segment.
|
// even if service worker terminates before events are submiteed to segment.
|
||||||
_submitSegmentAPICall(eventType, payload, callback) {
|
_submitSegmentAPICall(eventType, payload, callback) {
|
||||||
|
const { metaMetricsId, participateInMetaMetrics } = this.state;
|
||||||
|
if (!participateInMetaMetrics || !metaMetricsId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const messageId = payload.messageId || generateRandomId();
|
const messageId = payload.messageId || generateRandomId();
|
||||||
let timestamp = new Date();
|
let timestamp = new Date();
|
||||||
if (payload.timestamp) {
|
if (payload.timestamp) {
|
||||||
@ -979,7 +982,6 @@ export default class MetaMetricsController {
|
|||||||
...modifiedPayload,
|
...modifiedPayload,
|
||||||
timestamp: modifiedPayload.timestamp.toString(),
|
timestamp: modifiedPayload.timestamp.toString(),
|
||||||
},
|
},
|
||||||
callback,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -362,7 +362,7 @@ describe('MetaMetricsController', function () {
|
|||||||
it('should track an event if user has not opted in, but isOptIn is true', function () {
|
it('should track an event if user has not opted in, but isOptIn is true', function () {
|
||||||
const mock = sinon.mock(segment);
|
const mock = sinon.mock(segment);
|
||||||
const metaMetricsController = getMetaMetricsController({
|
const metaMetricsController = getMetaMetricsController({
|
||||||
participateInMetaMetrics: false,
|
participateInMetaMetrics: true,
|
||||||
});
|
});
|
||||||
mock
|
mock
|
||||||
.expects('track')
|
.expects('track')
|
||||||
@ -394,7 +394,7 @@ describe('MetaMetricsController', function () {
|
|||||||
it('should track an event during optin and allow for metaMetricsId override', function () {
|
it('should track an event during optin and allow for metaMetricsId override', function () {
|
||||||
const mock = sinon.mock(segment);
|
const mock = sinon.mock(segment);
|
||||||
const metaMetricsController = getMetaMetricsController({
|
const metaMetricsController = getMetaMetricsController({
|
||||||
participateInMetaMetrics: false,
|
participateInMetaMetrics: true,
|
||||||
});
|
});
|
||||||
mock
|
mock
|
||||||
.expects('track')
|
.expects('track')
|
||||||
|
Loading…
Reference in New Issue
Block a user