2121#import " SEGUserDefaultsStorage.h"
2222#import " SEGIntegrationsManager.h"
2323#import " SEGSegmentIntegrationFactory.h"
24+ #import " SEGSegmentIntegration.h"
2425#import " SEGPayload.h"
2526#import " SEGIdentifyPayload.h"
2627#import " SEGTrackPayload.h"
@@ -396,7 +397,7 @@ - (void)setCachedSettings:(NSDictionary *)settings
396397- (void )updateIntegrationsWithSettings : (NSDictionary *)projectSettings
397398{
398399 // see if we have a new segment API host and set it.
399- NSString *apiHost = projectSettings[@" Segment.io " ][@" apiHost" ];
400+ NSString *apiHost = projectSettings[kSEGSegmentDestinationName ][@" apiHost" ];
400401 if (apiHost) {
401402 [SEGUtils saveAPIHost: apiHost];
402403 }
@@ -443,15 +444,25 @@ - (void)configureEdgeFunctions:(NSDictionary *)settings
443444
444445- (NSDictionary *)defaultSettings
445446{
446- return @{
447+ NSDictionary *segment = [self segmentSettings ];
448+ NSDictionary *result = @{
447449 @" integrations" : @{
448- @" Segment.io" : @{
449- @" apiKey" : self.configuration .writeKey ,
450- @" apiHost" : [SEGUtils getAPIHost ]
451- },
450+ kSEGSegmentDestinationName : segment
452451 },
453- @" plan" : @{@" track" : @{}}
452+ @" plan" : @{
453+ @" track" : @{}
454+ }
455+ };
456+ return result;
457+ }
458+
459+ - (NSDictionary *)segmentSettings
460+ {
461+ NSDictionary *result = @{
462+ @" apiKey" : self.configuration .writeKey ,
463+ @" apiHost" : [SEGUtils getAPIHost ]
454464 };
465+ return result;
455466}
456467
457468- (void )refreshSettings
@@ -485,9 +496,9 @@ - (void)refreshSettings
485496 NSMutableDictionary *newSettings = [self .configuration.defaultSettings serializableMutableDeepCopy ];
486497 NSMutableDictionary *integrations = newSettings[@" integrations" ];
487498 if (integrations != nil ) {
488- integrations[@" Segment.io " ] = @{ @" apiKey " : self. configuration . writeKey , @" apiHost " : [SEGUtils getAPIHost ]} ;
499+ integrations[kSEGSegmentDestinationName ] = [ self segmentSettings ] ;
489500 } else {
490- newSettings[@" integrations" ] = @{@" integrations " : @{ @" apiKey " : self. configuration . writeKey , @" apiHost " : [SEGUtils getAPIHost ]} };
501+ newSettings[@" integrations" ] = @{kSEGSegmentDestinationName : [ self segmentSettings ] };
491502 }
492503
493504 [self setCachedSettings: newSettings];
@@ -510,7 +521,7 @@ - (void)refreshSettings
510521+ (BOOL )isIntegration : (NSString *)key enabledInOptions : (NSDictionary *)options
511522{
512523 // If the event is in the tracking plan, it should always be sent to api.segment.io.
513- if ([@" Segment.io " isEqualToString: key]) {
524+ if ([kSEGSegmentDestinationName isEqualToString: key]) {
514525 return YES ;
515526 }
516527 if (options[key]) {
@@ -540,7 +551,7 @@ + (BOOL)isIntegration:(NSString *)key enabledInOptions:(NSDictionary *)options
540551+ (BOOL )isTrackEvent : (NSString *)event enabledForIntegration : (NSString *)key inPlan : (NSDictionary *)plan
541552{
542553 // Whether the event is enabled or disabled, it should always be sent to api.segment.io.
543- if ([key isEqualToString: @" Segment.io " ]) {
554+ if ([key isEqualToString: kSEGSegmentDestinationName ]) {
544555 return YES ;
545556 }
546557
0 commit comments