Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3304,6 +3304,10 @@ public void run() {
return;
}

if (shouldLogUserPrivacyConsentErrorMessageForMethodName("sendOutcome()")) {
return;
}

outcomeEventsController.sendOutcomeEvent(name, callback);
}

Expand All @@ -3329,6 +3333,10 @@ public void run() {
return;
}

if (shouldLogUserPrivacyConsentErrorMessageForMethodName("sendUniqueOutcome()")) {
return;
}

outcomeEventsController.sendUniqueOutcomeEvent(name, callback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,55 @@ public void testDelayOutcomes() throws Exception {
assertMeasureAtIndex(1, ONESIGNAL_OUTCOME_NAME);
}

@Test
public void testSendOutcomesFailWhenRequiresUserPrivacyConsent() throws Exception {
// Enable IAM v2
preferences = new MockOSSharedPreferences();
trackerFactory = new OSTrackerFactory(preferences, logger, time);
sessionManager = new MockSessionManager(sessionListener, trackerFactory, logger);
preferences.saveBool(preferences.getPreferencesName(), preferences.getOutcomesV2KeyName(), true);
OneSignal_setSharedPreferences(preferences);

OneSignalInit();
threadAndTaskWait();
assertRestCalls(2);
OneSignal.setRequiresUserPrivacyConsent(true);

// Make sure session is UNATTRIBUTED
assertNotificationChannelUnattributedInfluence();

// Send unique outcome event
OneSignal.sendUniqueOutcome(ONESIGNAL_OUTCOME_NAME);
threadAndTaskWait();

// Check that the task has been queued until consent is given
assertRestCalls(2);

// Send outcome event
OneSignal.sendOutcome(ONESIGNAL_OUTCOME_NAME);
threadAndTaskWait();

// Ensure still only 2 requests have been made
assertRestCalls(2);

OneSignal.provideUserConsent(true);
threadAndTaskWait();

// Send unique outcome event
OneSignal.sendUniqueOutcome(ONESIGNAL_OUTCOME_NAME);
threadAndTaskWait();

// Send outcome event
OneSignal.sendOutcome(ONESIGNAL_OUTCOME_NAME);
threadAndTaskWait();

// Make sure session is UNATTRIBUTED
assertNotificationChannelUnattributedInfluence();

// Check measure end point was most recent request and contains received notification
assertMeasureOnV2AtIndex(3, ONESIGNAL_OUTCOME_NAME, null, null, null, null);
}

private void foregroundAppAfterClickingNotification() throws Exception {
OneSignalInit();
threadAndTaskWait();
Expand Down