Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix direct session count #1240

Merged
merged 1 commit into from
Apr 13, 2023
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 @@ -54,5 +54,6 @@
- (void)onNotificationReceived:(NSString * _Nonnull)notificationId;
- (void)onDirectInfluenceFromNotificationOpen:(AppEntryAction)entryAction withNotificationId:(NSString * _Nonnull)directNotificationId;
- (void)attemptSessionUpgrade:(AppEntryAction)entryAction;
- (void)resetSessionIfDirect;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ - (void)initSessionFromCache {
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:[NSString stringWithFormat:@"SessionManager restored from cache with influences: %@", [self getInfluences].description]];
}

- (void)resetSessionIfDirect {
[OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:@"OneSignal SessionManager resetSessionIfDirect"];
NSArray<OSChannelTracker *> *channels = [_trackerFactory channels];
for (OSChannelTracker *tracker in channels) {
if (tracker.influenceType == DIRECT) {
[tracker resetAndInitInfluence];
}
}
}

- (void)restartSessionIfNeeded:(AppEntryAction)entryAction {
NSArray<OSChannelTracker *> *channelTrackers = [_trackerFactory channelsToResetByEntryAction:entryAction];
NSMutableArray<OSInfluence *> *updatedInfluences = [NSMutableArray new];
Expand Down
3 changes: 3 additions & 0 deletions iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ - (void)sendBackgroundAttributedFocusPingWithParams:(OSFocusCallParams *)params

[OneSignal.stateSynchronizer sendOnFocusTime:totalTimeActive params:params withSuccess:^(NSDictionary *result) {
[super saveUnsentActiveTime:0];
if (params != nil) {
[[OSSessionManager sharedSessionManager] resetSessionIfDirect];
}
[OneSignal onesignalLog:ONE_S_LL_DEBUG message:@"sendOnFocusCallWithParams attributed succeed, saveUnsentActiveTime with 0"];
[self endDelayBackgroundTask];
} onFailure:^(NSDictionary<NSString *, NSError *> *errors) {
Expand Down