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
|
||||
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,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user