use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class OSFocusTimeProcessorFactory method getTimeProcessorSaved.
FocusTimeController.FocusTimeProcessorBase getTimeProcessorSaved() {
FocusTimeController.FocusTimeProcessorBase attributedProcessor = getAttributedProcessor();
List<OSInfluence> influences = attributedProcessor.getInfluences();
for (OSInfluence influence : influences) {
// Is true is at least one channel attributed the session
if (influence.getInfluenceType().isAttributed())
return attributedProcessor;
}
return getUnattributedProcessor();
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class OSFocusTimeProcessorFactory method getTimeProcessorWithInfluences.
FocusTimeController.FocusTimeProcessorBase getTimeProcessorWithInfluences(List<OSInfluence> influences) {
boolean isAttributed = false;
for (OSInfluence influence : influences) {
// Is true is at least one channel attributed the session
if (influence.getInfluenceType().isAttributed()) {
isAttributed = true;
break;
}
}
FocusTimeController.FocusTimeProcessorBase focusTimeProcessorBase;
if (isAttributed)
focusTimeProcessorBase = getAttributedProcessor();
else
focusTimeProcessorBase = getUnattributedProcessor();
return focusTimeProcessorBase;
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class OSSessionManager method restartSessionIfNeeded.
void restartSessionIfNeeded(OneSignal.AppEntryAction entryAction) {
List<OSChannelTracker> channelTrackers = trackerFactory.getChannelsToResetByEntryAction(entryAction);
List<OSInfluence> updatedInfluences = new ArrayList<>();
logger.debug("OneSignal SessionManager restartSessionIfNeeded with entryAction: " + entryAction + "\n channelTrackers: " + channelTrackers.toString());
for (OSChannelTracker channelTracker : channelTrackers) {
JSONArray lastIds = channelTracker.getLastReceivedIds();
logger.debug("OneSignal SessionManager restartSessionIfNeeded lastIds: " + lastIds);
OSInfluence influence = channelTracker.getCurrentSessionInfluence();
boolean updated;
if (lastIds.length() > 0)
updated = setSession(channelTracker, OSInfluenceType.INDIRECT, null, lastIds);
else
updated = setSession(channelTracker, OSInfluenceType.UNATTRIBUTED, null, null);
if (updated)
updatedInfluences.add(influence);
}
sendSessionEndingWithInfluences(updatedInfluences);
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class OSSessionManager method attemptSessionUpgrade.
private void attemptSessionUpgrade(OneSignal.AppEntryAction entryAction, @Nullable String directId) {
logger.debug("OneSignal SessionManager attemptSessionUpgrade with entryAction: " + entryAction);
OSChannelTracker channelTrackerByAction = trackerFactory.getChannelByEntryAction(entryAction);
List<OSChannelTracker> channelTrackersToReset = trackerFactory.getChannelsToResetByEntryAction(entryAction);
List<OSInfluence> influencesToEnd = new ArrayList<>();
OSInfluence lastInfluence = null;
// We will try to override any session with DIRECT
boolean updated = false;
if (channelTrackerByAction != null) {
lastInfluence = channelTrackerByAction.getCurrentSessionInfluence();
updated = setSession(channelTrackerByAction, OSInfluenceType.DIRECT, directId == null ? channelTrackerByAction.getDirectId() : directId, null);
}
if (updated) {
logger.debug("OneSignal SessionManager attemptSessionUpgrade channel updated, search for ending direct influences on channels: " + channelTrackersToReset);
influencesToEnd.add(lastInfluence);
// In that way we finish the session duration time for the last influenced session
for (OSChannelTracker tracker : channelTrackersToReset) {
if (tracker.getInfluenceType().isDirect()) {
influencesToEnd.add(tracker.getCurrentSessionInfluence());
tracker.resetAndInitInfluence();
}
}
}
logger.debug("OneSignal SessionManager attemptSessionUpgrade try UNATTRIBUTED to INDIRECT upgrade");
// We will try to override the UNATTRIBUTED session with INDIRECT
for (OSChannelTracker channelTracker : channelTrackersToReset) {
if (channelTracker.getInfluenceType().isUnattributed()) {
JSONArray lastIds = channelTracker.getLastReceivedIds();
// There are new ids for attribution and the application was open again without resetting session
if (lastIds.length() > 0 && !entryAction.isAppClose()) {
// Save influence to ended it later if needed
// This influence will be unattributed
OSInfluence influence = channelTracker.getCurrentSessionInfluence();
updated = setSession(channelTracker, OSInfluenceType.INDIRECT, null, lastIds);
// Changed from UNATTRIBUTED to INDIRECT
if (updated)
influencesToEnd.add(influence);
}
}
}
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "Trackers after update attempt: " + trackerFactory.getChannels().toString());
sendSessionEndingWithInfluences(influencesToEnd);
}
use of com.onesignal.influence.domain.OSInfluence in project OneSignal-Android-SDK by OneSignal.
the class OutcomeEventIntegrationTests method assertIAMChannelUnattributedInfluence.
private void assertIAMChannelUnattributedInfluence() {
OSInfluence influence = trackerFactory.getIAMChannelTracker().getCurrentSessionInfluence();
assertTrue(influence.getInfluenceType().isUnattributed());
assertNull(influence.getIds());
}
Aggregations