Search in sources :

Example 6 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method testIndirectIAMInitInfluence.

@Test
public void testIndirectIAMInitInfluence() throws JSONException {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    sessionManager.initSessionFromCache();
    OSChannelTracker iamTracker = trackerFactory.getIAMChannelTracker();
    assertEquals(0, iamTracker.getLastReceivedIds().length());
    sessionManager.onInAppMessageReceived(IAM_ID);
    iamTracker = trackerFactory.getIAMChannelTracker();
    OSInfluence influence = iamTracker.getCurrentSessionInfluence();
    assertEquals(OSInfluenceType.INDIRECT, iamTracker.getInfluenceType());
    assertEquals(IAM_ID, iamTracker.getLastReceivedIds().get(0));
    assertEquals(OSInfluenceChannel.IAM, influence.getInfluenceChannel());
    assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
    assertEquals(1, influence.getIds().length());
    assertEquals(IAM_ID, influence.getIds().get(0));
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker) OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Example 7 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method testDirectIAMInitInfluence.

@Test
public void testDirectIAMInitInfluence() throws JSONException {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    sessionManager.initSessionFromCache();
    OSChannelTracker iamTracker = trackerFactory.getIAMChannelTracker();
    assertEquals(0, iamTracker.getLastReceivedIds().length());
    sessionManager.onInAppMessageReceived(IAM_ID);
    sessionManager.onDirectInfluenceFromIAMClick(IAM_ID);
    iamTracker = trackerFactory.getIAMChannelTracker();
    OSInfluence influence = iamTracker.getCurrentSessionInfluence();
    assertEquals(OSInfluenceType.DIRECT, iamTracker.getInfluenceType());
    assertEquals(IAM_ID, iamTracker.getLastReceivedIds().get(0));
    assertEquals(OSInfluenceChannel.IAM, influence.getInfluenceChannel());
    assertEquals(OSInfluenceType.DIRECT, influence.getInfluenceType());
    assertEquals(1, influence.getIds().length());
    assertEquals(IAM_ID, influence.getIds().get(0));
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker) OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Example 8 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class OSSessionManager method onDirectInfluenceFromIAMClick.

void onDirectInfluenceFromIAMClick(@NonNull String messageId) {
    logger.debug("OneSignal SessionManager onDirectInfluenceFromIAMClick messageId: " + messageId);
    OSChannelTracker inAppMessageTracker = trackerFactory.getIAMChannelTracker();
    // We don't care about ending the session duration because IAM doesn't influence a session
    setSession(inAppMessageTracker, OSInfluenceType.DIRECT, messageId, null);
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker)

Example 9 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class OSSessionManager method onInAppMessageReceived.

void onInAppMessageReceived(@NonNull String messageId) {
    logger.debug("OneSignal SessionManager onInAppMessageReceived messageId: " + messageId);
    OSChannelTracker inAppMessageTracker = trackerFactory.getIAMChannelTracker();
    inAppMessageTracker.saveLastId(messageId);
    inAppMessageTracker.resetAndInitInfluence();
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker)

Example 10 with OSChannelTracker

use of com.onesignal.influence.data.OSChannelTracker in project OneSignal-Android-SDK by OneSignal.

the class SessionManagerUnitTests method testIndirectNotificationInitInfluence.

@Test
public void testIndirectNotificationInitInfluence() throws JSONException {
    trackerFactory.saveInfluenceParams(new OneSignalPackagePrivateHelper.RemoteOutcomeParams());
    sessionManager.initSessionFromCache();
    OSChannelTracker notificationTracker = trackerFactory.getNotificationChannelTracker();
    assertEquals(0, notificationTracker.getLastReceivedIds().length());
    sessionManager.onNotificationReceived(NOTIFICATION_ID);
    sessionManager.attemptSessionUpgrade(OneSignal.AppEntryAction.APP_OPEN);
    notificationTracker = trackerFactory.getNotificationChannelTracker();
    OSInfluence influence = notificationTracker.getCurrentSessionInfluence();
    assertEquals(OSInfluenceType.INDIRECT, notificationTracker.getInfluenceType());
    assertEquals(NOTIFICATION_ID, notificationTracker.getLastReceivedIds().get(0));
    assertEquals(OSInfluenceChannel.NOTIFICATION, influence.getInfluenceChannel());
    assertEquals(OSInfluenceType.INDIRECT, influence.getInfluenceType());
    assertEquals(1, influence.getIds().length());
    assertEquals(NOTIFICATION_ID, influence.getIds().get(0));
}
Also used : OSChannelTracker(com.onesignal.influence.data.OSChannelTracker) OSInfluence(com.onesignal.influence.domain.OSInfluence) OneSignalPackagePrivateHelper(com.onesignal.OneSignalPackagePrivateHelper) Test(org.junit.Test)

Aggregations

OSChannelTracker (com.onesignal.influence.data.OSChannelTracker)11 OSInfluence (com.onesignal.influence.domain.OSInfluence)7 OneSignalPackagePrivateHelper (com.onesignal.OneSignalPackagePrivateHelper)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 JSONArray (org.json.JSONArray)2