21
21
#import " SEGUserDefaultsStorage.h"
22
22
#import " SEGIntegrationsManager.h"
23
23
#import " SEGSegmentIntegrationFactory.h"
24
+ #import " SEGSegmentIntegration.h"
24
25
#import " SEGPayload.h"
25
26
#import " SEGIdentifyPayload.h"
26
27
#import " SEGTrackPayload.h"
@@ -396,7 +397,7 @@ - (void)setCachedSettings:(NSDictionary *)settings
396
397
- (void )updateIntegrationsWithSettings : (NSDictionary *)projectSettings
397
398
{
398
399
// 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" ];
400
401
if (apiHost) {
401
402
[SEGUtils saveAPIHost: apiHost];
402
403
}
@@ -443,15 +444,25 @@ - (void)configureEdgeFunctions:(NSDictionary *)settings
443
444
444
445
- (NSDictionary *)defaultSettings
445
446
{
446
- return @{
447
+ NSDictionary *segment = [self segmentSettings ];
448
+ NSDictionary *result = @{
447
449
@" integrations" : @{
448
- @" Segment.io" : @{
449
- @" apiKey" : self.configuration .writeKey ,
450
- @" apiHost" : [SEGUtils getAPIHost ]
451
- },
450
+ kSEGSegmentDestinationName : segment
452
451
},
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 ]
454
464
};
465
+ return result;
455
466
}
456
467
457
468
- (void )refreshSettings
@@ -485,9 +496,9 @@ - (void)refreshSettings
485
496
NSMutableDictionary *newSettings = [self .configuration.defaultSettings serializableMutableDeepCopy ];
486
497
NSMutableDictionary *integrations = newSettings[@" integrations" ];
487
498
if (integrations != nil ) {
488
- integrations[@" Segment.io " ] = @{ @" apiKey " : self. configuration . writeKey , @" apiHost " : [SEGUtils getAPIHost ]} ;
499
+ integrations[kSEGSegmentDestinationName ] = [ self segmentSettings ] ;
489
500
} else {
490
- newSettings[@" integrations" ] = @{@" integrations " : @{ @" apiKey " : self. configuration . writeKey , @" apiHost " : [SEGUtils getAPIHost ]} };
501
+ newSettings[@" integrations" ] = @{kSEGSegmentDestinationName : [ self segmentSettings ] };
491
502
}
492
503
493
504
[self setCachedSettings: newSettings];
@@ -510,7 +521,7 @@ - (void)refreshSettings
510
521
+ (BOOL )isIntegration : (NSString *)key enabledInOptions : (NSDictionary *)options
511
522
{
512
523
// 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]) {
514
525
return YES ;
515
526
}
516
527
if (options[key]) {
@@ -540,7 +551,7 @@ + (BOOL)isIntegration:(NSString *)key enabledInOptions:(NSDictionary *)options
540
551
+ (BOOL )isTrackEvent : (NSString *)event enabledForIntegration : (NSString *)key inPlan : (NSDictionary *)plan
541
552
{
542
553
// 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 ]) {
544
555
return YES ;
545
556
}
546
557
0 commit comments