Skip to content

Commit f72f6b1

Browse files
committed
Checking shouldLogUserPrivacyConsentErrorMessage for outcomes
1 parent 09b8d91 commit f72f6b1

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,10 @@ public void run() {
33043304
return;
33053305
}
33063306

3307+
if (shouldLogUserPrivacyConsentErrorMessageForMethodName("sendOutcome()")) {
3308+
return;
3309+
}
3310+
33073311
outcomeEventsController.sendOutcomeEvent(name, callback);
33083312
}
33093313

@@ -3329,6 +3333,10 @@ public void run() {
33293333
return;
33303334
}
33313335

3336+
if (shouldLogUserPrivacyConsentErrorMessageForMethodName("sendUniqueOutcome()")) {
3337+
return;
3338+
}
3339+
33323340
outcomeEventsController.sendUniqueOutcomeEvent(name, callback);
33333341
}
33343342

OneSignalSDK/unittest/src/test/java/com/test/onesignal/OutcomeEventIntegrationTests.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,55 @@ public void testDelayOutcomes() throws Exception {
11411141
assertMeasureAtIndex(1, ONESIGNAL_OUTCOME_NAME);
11421142
}
11431143

1144+
@Test
1145+
public void testSendOutcomesFailWhenRequiresUserPrivacyConsent() throws Exception {
1146+
// Enable IAM v2
1147+
preferences = new MockOSSharedPreferences();
1148+
trackerFactory = new OSTrackerFactory(preferences, logger, time);
1149+
sessionManager = new MockSessionManager(sessionListener, trackerFactory, logger);
1150+
preferences.saveBool(preferences.getPreferencesName(), preferences.getOutcomesV2KeyName(), true);
1151+
OneSignal_setSharedPreferences(preferences);
1152+
1153+
OneSignalInit();
1154+
threadAndTaskWait();
1155+
assertRestCalls(2);
1156+
OneSignal.setRequiresUserPrivacyConsent(true);
1157+
1158+
// Make sure session is UNATTRIBUTED
1159+
assertNotificationChannelUnattributedInfluence();
1160+
1161+
// Send unique outcome event
1162+
OneSignal.sendUniqueOutcome(ONESIGNAL_OUTCOME_NAME);
1163+
threadAndTaskWait();
1164+
1165+
// Check that the task has been queued until consent is given
1166+
assertRestCalls(2);
1167+
1168+
// Send outcome event
1169+
OneSignal.sendOutcome(ONESIGNAL_OUTCOME_NAME);
1170+
threadAndTaskWait();
1171+
1172+
// Ensure still only 2 requests have been made
1173+
assertRestCalls(2);
1174+
1175+
OneSignal.provideUserConsent(true);
1176+
threadAndTaskWait();
1177+
1178+
// Send unique outcome event
1179+
OneSignal.sendUniqueOutcome(ONESIGNAL_OUTCOME_NAME);
1180+
threadAndTaskWait();
1181+
1182+
// Send outcome event
1183+
OneSignal.sendOutcome(ONESIGNAL_OUTCOME_NAME);
1184+
threadAndTaskWait();
1185+
1186+
// Make sure session is UNATTRIBUTED
1187+
assertNotificationChannelUnattributedInfluence();
1188+
1189+
// Check measure end point was most recent request and contains received notification
1190+
assertMeasureOnV2AtIndex(3, ONESIGNAL_OUTCOME_NAME, null, null, null, null);
1191+
}
1192+
11441193
private void foregroundAppAfterClickingNotification() throws Exception {
11451194
OneSignalInit();
11461195
threadAndTaskWait();

0 commit comments

Comments
 (0)