Skip to content

Commit

Permalink
Publish filenames used for data storage (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejo authored and Brandon Sneed committed May 1, 2020
1 parent cb623dc commit e848f2a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions Analytics/Classes/Integrations/SEGIntegrationsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
#import <Foundation/Foundation.h>
#import "SEGMiddleware.h"

/**
* Filenames of "Application Support" files where essential data is stored.
*/
extern NSString *_Nonnull const kSEGAnonymousIdFilename;
extern NSString *_Nonnull const kSEGCachedSettingsFilename;

/**
* NSNotification name, that is posted after integrations are loaded.
*/
Expand Down
14 changes: 7 additions & 7 deletions Analytics/Classes/Integrations/SEGIntegrationsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#import "SEGAliasPayload.h"

NSString *SEGAnalyticsIntegrationDidStart = @"io.segment.analytics.integration.did.start";
static NSString *const SEGAnonymousIdKey = @"SEGAnonymousId";
static NSString *const kSEGAnonymousIdFilename = @"segment.anonymousId";
static NSString *const SEGCachedSettingsKey = @"analytics.settings.v2.plist";
NSString *const SEGAnonymousIdKey = @"SEGAnonymousId";
NSString *const kSEGAnonymousIdFilename = @"segment.anonymousId";
NSString *const kSEGCachedSettingsFilename = @"analytics.settings.v2.plist";


@interface SEGIdentifyPayload (AnonymousId)
Expand Down Expand Up @@ -357,9 +357,9 @@ - (NSDictionary *)cachedSettings
{
if (!_cachedSettings) {
#if TARGET_OS_TV
_cachedSettings = [self.userDefaultsStorage dictionaryForKey:SEGCachedSettingsKey] ?: @{};
_cachedSettings = [self.userDefaultsStorage dictionaryForKey:kSEGCachedSettingsFilename] ?: @{};
#else
_cachedSettings = [self.fileStorage dictionaryForKey:SEGCachedSettingsKey] ?: @{};
_cachedSettings = [self.fileStorage dictionaryForKey:kSEGCachedSettingsFilename] ?: @{};
#endif
}

Expand All @@ -375,9 +375,9 @@ - (void)setCachedSettings:(NSDictionary *)settings
}

#if TARGET_OS_TV
[self.userDefaultsStorage setDictionary:_cachedSettings forKey:SEGCachedSettingsKey];
[self.userDefaultsStorage setDictionary:_cachedSettings forKey:kSEGCachedSettingsFilename];
#else
[self.fileStorage setDictionary:_cachedSettings forKey:SEGCachedSettingsKey];
[self.fileStorage setDictionary:_cachedSettings forKey:kSEGCachedSettingsFilename];
#endif

[self updateIntegrationsWithSettings:settings[@"integrations"]];
Expand Down
7 changes: 7 additions & 0 deletions Analytics/Classes/Internal/SEGSegmentIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ extern NSString *const SEGSegmentDidSendRequestNotification;
extern NSString *const SEGSegmentRequestDidSucceedNotification;
extern NSString *const SEGSegmentRequestDidFailNotification;

/**
* Filenames of "Application Support" files where essential data is stored.
*/
extern NSString *const kSEGUserIdFilename;
extern NSString *const kSEGQueueFilename;
extern NSString *const kSEGTraitsFilename;


@interface SEGSegmentIntegration : NSObject <SEGIntegration>

Expand Down

0 comments on commit e848f2a

Please sign in to comment.