diff --git a/Analytics/Classes/Internal/SEGSegmentIntegration.m b/Analytics/Classes/Internal/SEGSegmentIntegration.m index ead3a5a8a..67d07dafc 100644 --- a/Analytics/Classes/Internal/SEGSegmentIntegration.m +++ b/Analytics/Classes/Internal/SEGSegmentIntegration.m @@ -102,6 +102,10 @@ - (id)initWithAnalytics:(SEGAnalytics *)analytics dispatch_sync(dispatch_get_main_queue(), ^{ self.flushTimer = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(flush) userInfo:nil repeats:YES]; }); + [self addSkipBackupAttributeToItemAtPath:self.userIDURL]; + [self addSkipBackupAttributeToItemAtPath:self.anonymousIDURL]; + [self addSkipBackupAttributeToItemAtPath:self.traitsURL]; + [self addSkipBackupAttributeToItemAtPath:self.queueURL]; } return self; } @@ -504,6 +508,24 @@ - (void)reset }]; } +- (void)addSkipBackupAttributeToItemAtPath:(NSURL *)url +{ + BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:[url path]]; + if (!exists) { + return; + } + + NSError *error = nil; + BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES] + forKey:NSURLIsExcludedFromBackupKey + error:&error]; + if (!success) { + SEGLog(@"Error excluding %@ from backup %@", [url lastPathComponent], error); + } + return; +} + + - (void)notifyForName:(NSString *)name userInfo:(id)userInfo { dispatch_async(dispatch_get_main_queue(), ^{