-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prune oldest instead of newest persisted sessions
- Loading branch information
1 parent
887be55
commit 3320b6f
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
features/fixtures/shared/scenarios/MaxPersistedSessionsScenario.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// MaxPersistedSessionsScenario.m | ||
// macOSTestApp | ||
// | ||
// Created by Nick Dowell on 13/05/2022. | ||
// Copyright © 2022 Bugsnag Inc. All rights reserved. | ||
// | ||
|
||
#import "Scenario.h" | ||
|
||
@interface MaxPersistedSessionsScenario : Scenario | ||
@end | ||
|
||
@implementation MaxPersistedSessionsScenario | ||
|
||
- (void)startBugsnag { | ||
self.config.autoTrackSessions = NO; | ||
self.config.maxPersistedSessions = 1; | ||
|
||
[super startBugsnag]; | ||
|
||
[Bugsnag setUser:[self nextUserId] withEmail:nil andName:nil]; | ||
[Bugsnag startSession]; | ||
} | ||
|
||
- (void)run { | ||
[Bugsnag setUser:[self nextUserId] withEmail:nil andName:nil]; | ||
[Bugsnag startSession]; | ||
} | ||
|
||
- (NSString *)nextUserId { | ||
NSString *key = @"sessionCounter"; | ||
NSInteger sessionCounter = [NSUserDefaults.standardUserDefaults integerForKey:key] + 1; | ||
[NSUserDefaults.standardUserDefaults setInteger:sessionCounter forKey:key]; | ||
return [NSString stringWithFormat:@"%ld", sessionCounter]; | ||
} | ||
|
||
@end |