@@ -45,9 +45,6 @@ public class SegmentDestination: DestinationPlugin, Subscriber {
45
45
private let uploadsQueue = DispatchQueue ( label: " uploadsQueue.segment.com " )
46
46
private var storage : Storage ?
47
47
48
- private var apiKey : String ? = nil
49
- private var apiHost : String ? = nil
50
-
51
48
@Atomic internal var eventCount : Int = 0
52
49
internal var flushAt : Int = 0
53
50
internal var flushTimer : QueueTimer ? = nil
@@ -71,11 +68,33 @@ public class SegmentDestination: DestinationPlugin, Subscriber {
71
68
}
72
69
73
70
public func update( settings: Settings , type: UpdateType ) {
71
+ guard let analytics = analytics else { return }
74
72
let segmentInfo = settings. integrationSettings ( forKey: self . key)
75
- apiKey = segmentInfo ? [ Self . Constants. apiKey. rawValue] as? String
76
- apiHost = segmentInfo ? [ Self . Constants. apiHost. rawValue] as? String
77
- if ( apiHost != nil && apiKey != nil ) , let analytics = self . analytics {
78
- httpClient = HTTPClient ( analytics: analytics, apiKey: apiKey, apiHost: apiHost)
73
+ // if customer cycles out a writekey at app.segment.com, this is necessary.
74
+ /*
75
+ This actually works differently than anticipated. It was thought that when a writeKey was
76
+ revoked, it's old writekey would redirect to the new, but it doesn't work this way. As a result
77
+ it doesn't appear writekey can be changed remotely. Leaving this here in case that changes in the
78
+ near future (written on 10/29/2022).
79
+ */
80
+ /*
81
+ if let key = segmentInfo?[Self.Constants.apiKey.rawValue] as? String, key.isEmpty == false {
82
+ if key != analytics.configuration.values.writeKey {
83
+ /*
84
+ - would need to flush.
85
+ - would need to change the writeKey across the system.
86
+ - would need to re-init storage.
87
+ - probably other things too ...
88
+ */
89
+ }
90
+ }
91
+ */
92
+ // if customer specifies a different apiHost (ie: eu1.segmentapis.com) at app.segment.com ...
93
+ if let host = segmentInfo ? [ Self . Constants. apiHost. rawValue] as? String , host. isEmpty == false {
94
+ if host != analytics. configuration. values. writeKey {
95
+ analytics. configuration. values. apiHost = host
96
+ httpClient = HTTPClient ( analytics: analytics)
97
+ }
79
98
}
80
99
}
81
100
0 commit comments