From 7c25a023ad805e5536ae84201df5e60323512b66 Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 27 Jun 2024 23:38:13 +0100 Subject: [PATCH 1/2] Sets data marketing to false in case of non-selection --- app/components/UI/OptinMetrics/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/components/UI/OptinMetrics/index.js b/app/components/UI/OptinMetrics/index.js index ef195031657..004690410e3 100644 --- a/app/components/UI/OptinMetrics/index.js +++ b/app/components/UI/OptinMetrics/index.js @@ -299,8 +299,15 @@ class OptinMetrics extends PureComponent { * Callback on press cancel */ onCancel = async () => { + const { + isDataCollectionForMarketingEnabled, + setDataCollectionForMarketing, + } = this.props; setTimeout(async () => { const { clearOnboardingEvents, metrics } = this.props; + if (isDataCollectionForMarketingEnabled === null) { + setDataCollectionForMarketing(false); + } // if users refuses tracking, get rid of the stored events // and never send them to Segment // and disable analytics @@ -314,11 +321,20 @@ class OptinMetrics extends PureComponent { * Callback on press confirm */ onConfirm = async () => { - const { events, metrics } = this.props; + const { + events, + metrics, + isDataCollectionForMarketingEnabled, + setDataCollectionForMarketing, + } = this.props; await metrics.enable(); InteractionManager.runAfterInteractions(async () => { // add traits to user for identification + if (isDataCollectionForMarketingEnabled === null) { + setDataCollectionForMarketing(false); + } + // trait indicating if user opts in for data collection for marketing let dataCollectionForMarketingTraits; if (this.props.isDataCollectionForMarketingEnabled) { From 6eb7ff8be22de2b2adfb9cba4a4a4c5dee4b9d3e Mon Sep 17 00:00:00 2001 From: Jonathan Bursztyn Date: Thu, 25 Jul 2024 23:59:27 +0100 Subject: [PATCH 2/2] Checks on method calls before use --- app/components/UI/OptinMetrics/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/components/UI/OptinMetrics/index.js b/app/components/UI/OptinMetrics/index.js index 004690410e3..ba2ec7added 100644 --- a/app/components/UI/OptinMetrics/index.js +++ b/app/components/UI/OptinMetrics/index.js @@ -305,7 +305,10 @@ class OptinMetrics extends PureComponent { } = this.props; setTimeout(async () => { const { clearOnboardingEvents, metrics } = this.props; - if (isDataCollectionForMarketingEnabled === null) { + if ( + isDataCollectionForMarketingEnabled === null && + setDataCollectionForMarketing + ) { setDataCollectionForMarketing(false); } // if users refuses tracking, get rid of the stored events @@ -331,7 +334,10 @@ class OptinMetrics extends PureComponent { InteractionManager.runAfterInteractions(async () => { // add traits to user for identification - if (isDataCollectionForMarketingEnabled === null) { + if ( + isDataCollectionForMarketingEnabled === null && + setDataCollectionForMarketing + ) { setDataCollectionForMarketing(false); }