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
6 changes: 2 additions & 4 deletions UnitTests/ObjCTests/MPBackendControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ - (void)handleApplicationDidBecomeActive:(NSNotification *)notification;
- (void)logRemoteNotificationWithNotificationController:(MPNotificationController_PRIVATE *const)notificationController;
- (void)parseConfigResponse:(NSDictionary *)configurationDictionary;
- (void)parseResponseHeader:(NSDictionary *)responseDictionary session:(MPSession *)session;
- (NSNumber *)previousSessionSuccessfullyClosed;
- (void)setPreviousSessionSuccessfullyClosed:(NSNumber *)previousSessionSuccessfullyClosed;
- (void)processOpenSessionsEndingCurrent:(BOOL)endCurrentSession completionHandler:(dispatch_block_t)completionHandler;
- (void)resetUserIdentitiesFirstTimeUseFlag;
- (void)saveMessage:(MPMessage *)message updateSession:(BOOL)updateSession;
Expand Down Expand Up @@ -125,10 +123,10 @@ @implementation MPBackendControllerTests

- (void)setUp {
[super setUp];

[MPPersistenceController_PRIVATE setMpid:@1];
[MParticle sharedInstance].persistenceController = [[MPPersistenceController_PRIVATE alloc] init];

// Must read messageQueue AFTER [MParticle sharedInstance] triggers singleton
// recreation, otherwise we get the old executor's queue.
messageQueue = [MParticle messageQueue];
Expand Down
47 changes: 0 additions & 47 deletions mParticle-Apple-SDK/MPBackendController.m
Original file line number Diff line number Diff line change
Expand Up @@ -324,50 +324,6 @@ - (void)logUserIdentityChange:(MPUserIdentityChange_PRIVATE *)userIdentityChange
[self saveMessage:message updateSession:YES];
}

- (NSNumber *)previousSessionSuccessfullyClosed {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *stateMachineDirectoryPath = STATE_MACHINE_DIRECTORY_PATH;
NSString *previousSessionStateFile = [stateMachineDirectoryPath stringByAppendingPathComponent:kMPPreviousSessionStateFileName];
NSNumber *previousSessionSuccessfullyClosed = nil;
if ([fileManager fileExistsAtPath:previousSessionStateFile]) {
NSDictionary *previousSessionStateDictionary = [NSDictionary dictionaryWithContentsOfFile:previousSessionStateFile];
previousSessionSuccessfullyClosed = previousSessionStateDictionary[kMPASTPreviousSessionSuccessfullyClosedKey];
}

if (previousSessionSuccessfullyClosed == nil) {
previousSessionSuccessfullyClosed = @YES;
}

return previousSessionSuccessfullyClosed;
}

- (void)setPreviousSessionSuccessfullyClosed:(NSNumber *)previousSessionSuccessfullyClosed {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *stateMachineDirectoryPath = STATE_MACHINE_DIRECTORY_PATH;
NSString *previousSessionStateFile = [stateMachineDirectoryPath stringByAppendingPathComponent:kMPPreviousSessionStateFileName];
NSDictionary *previousSessionStateDictionary = @{kMPASTPreviousSessionSuccessfullyClosedKey:previousSessionSuccessfullyClosed};

@try {
if (![fileManager fileExistsAtPath:stateMachineDirectoryPath]) {
NSError *dirError = nil;
[fileManager createDirectoryAtPath:stateMachineDirectoryPath withIntermediateDirectories:YES attributes:nil error:&dirError];
if (dirError) {
MPILogError(@"Failed to create state machine directory: %@", dirError);
return;
}
} else if ([fileManager fileExistsAtPath:previousSessionStateFile]) {
[fileManager removeItemAtPath:previousSessionStateFile error:nil];
}

BOOL success = [previousSessionStateDictionary writeToFile:previousSessionStateFile atomically:YES];
if (!success) {
MPILogError(@"Failed to write previous session state to file");
}
} @catch (NSException *exception) {
MPILogError(@"Exception writing previous session state: %@", exception);
}
}

- (void)processDidFinishLaunching:(NSNotification *)notification {
NSString *astType = kMPASTInitKey;
NSMutableDictionary *messageInfo = [[NSMutableDictionary alloc] initWithCapacity:3];
Expand All @@ -384,8 +340,6 @@ - (void)processDidFinishLaunching:(NSNotification *)notification {
isInstallOrUpgrade = YES;
}

messageInfo[kMPASTPreviousSessionSuccessfullyClosedKey] = [self previousSessionSuccessfullyClosed];

NSDictionary *userInfo = [notification userInfo];

if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
Expand Down Expand Up @@ -2136,7 +2090,6 @@ - (void)handleApplicationDidEnterBackground:(NSNotification *)notification {
self.timeAppWentToBackgroundInCurrentSession = currentTime;
self.timeOfLastEventInBackground = currentTime;

[self setPreviousSessionSuccessfullyClosed:@YES];
[self cleanUp];

MPMessageBuilder *messageBuilder = [[MPMessageBuilder alloc] initWithMessageType:MPMessageTypeAppStateTransition
Expand Down
2 changes: 0 additions & 2 deletions mParticle-Apple-SDK/MPIConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ extern NSString * _Nonnull const kMPUploadIntervalKey;
extern NSString * _Nonnull const kMPPreviousSessionLengthKey;
extern NSString * _Nonnull const kMPLifeTimeValueKey;
extern NSString * _Nonnull const kMPIncreasedLifeTimeValueKey;
extern NSString * _Nonnull const kMPPreviousSessionStateFileName;
extern NSString * _Nonnull const kMPHTTPMethodPost;
extern NSString * _Nonnull const kMPHTTPMethodGet;
extern NSString * _Nonnull const kMPPreviousSessionIdKey;
Expand Down Expand Up @@ -365,7 +364,6 @@ extern NSString * _Nonnull const kMPASTBackgroundKey;
extern NSString * _Nonnull const kMPASTForegroundKey;
extern NSString * _Nonnull const kMPASTIsFirstRunKey;
extern NSString * _Nonnull const kMPASTIsUpgradeKey;
extern NSString * _Nonnull const kMPASTPreviousSessionSuccessfullyClosedKey;

// Network performance
extern NSString * _Nonnull const kMPNetworkPerformanceMeasurementNotification;
Expand Down
2 changes: 0 additions & 2 deletions mParticle-Apple-SDK/MPIConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
NSString *const kMPPreviousSessionLengthKey = @"psl";
NSString *const kMPLifeTimeValueKey = @"ltv";
NSString *const kMPIncreasedLifeTimeValueKey = @"iltv";
NSString *const kMPPreviousSessionStateFileName = @"PreviousSessionState.dic";
NSString *const kMPHTTPMethodPost = @"POST";
NSString *const kMPHTTPMethodGet = @"GET";
NSString *const kMPPreviousSessionIdKey = @"pid";
Expand Down Expand Up @@ -310,7 +309,6 @@
NSString *const kMPASTForegroundKey = @"app_fore";
NSString *const kMPASTIsFirstRunKey = @"ifr";
NSString *const kMPASTIsUpgradeKey = @"iu";
NSString *const kMPASTPreviousSessionSuccessfullyClosedKey = @"sc";

// Network performance
NSString *const kMPNetworkPerformanceMeasurementNotification = @"MPNetworkPerformanceMeasurement";
Expand Down
Loading