-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set koala's base url based on current environment #820
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,29 +5,22 @@ private let flushInterval = 60.0 | |
private let chunkSize = 4 | ||
|
||
public final class KoalaTrackingClient: TrackingClientType { | ||
fileprivate let endpoint: Endpoint | ||
fileprivate let URLSession: URLSession | ||
fileprivate let queue = DispatchQueue(label: "com.kickstarter.KoalaTrackingClient") | ||
fileprivate var buffer: [[String: Any]] = [] | ||
fileprivate var timer: Timer? | ||
fileprivate var taskId = UIBackgroundTaskIdentifier.invalid | ||
|
||
public enum Endpoint { | ||
case staging | ||
case production | ||
|
||
var base: String { | ||
switch self { | ||
case .staging: | ||
return Secrets.KoalaEndpoint.staging | ||
case .production: | ||
return Secrets.KoalaEndpoint.production | ||
} | ||
fileprivate var base: String { | ||
switch AppEnvironment.current.environmentType { | ||
case .production: | ||
return Secrets.KoalaEndpoint.production | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only |
||
default: | ||
return Secrets.KoalaEndpoint.staging | ||
} | ||
} | ||
|
||
public init(endpoint: Endpoint = .production, URLSession: URLSession = .shared) { | ||
self.endpoint = endpoint | ||
public init(URLSession: URLSession = .shared) { | ||
self.URLSession = URLSession | ||
|
||
let notifications = NotificationCenter.default | ||
|
@@ -130,7 +123,7 @@ public final class KoalaTrackingClient: TrackingClientType { | |
if dataString.count >= 10_000 { | ||
print("π¨ [Koala Error]: Base64 payload is longer than 10,000 characters.") | ||
} | ||
return URL(string: "\(self.endpoint.base)?data=\(dataString)") | ||
return URL(string: "\(self.base)?data=\(dataString)") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately |
||
} | ||
|
||
fileprivate static func koalaRequest(_ url: URL) -> URLRequest { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since our
base url
is being affected byenvironmentType
we no longer require a separateEndpoint
enum.