Skip to content

Commit

Permalink
make server zone configurable (#277)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike <[email protected]>
  • Loading branch information
mike-dydx and mike-dydx authored Oct 18, 2024
1 parent c4de9d5 commit fa71597
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import Utilities
open class AmplitudeTracking: TransformerTracker {

private let amplitude: Amplitude

public init(_ apiKey: String) {
self.amplitude = Amplitude.init(configuration: .init(apiKey: apiKey, serverZone: .EU))

/// - serverZone: either "EU" or "US", defaults to US
public init(_ apiKey: String, serverZone: String) {
let serverZone: ServerZone = serverZone.uppercased() == "EU" ? .EU : .US
self.amplitude = Amplitude.init(configuration: .init(apiKey: apiKey, serverZone: serverZone))
Console.shared.log("analytics log | Amplitude initialized")
super.init()
}
Expand Down
3 changes: 2 additions & 1 deletion Shared/CommonAppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ open class CommonAppDelegate: ParticlesAppDelegate {
case .appStore:
apiKey = CredientialConfig.shared.credential(for: "amplitudeApiKey")
}
let serverZone = CredientialConfig.shared.credential(for: "amplitudeServerZone") ?? "US"
if let apiKey = apiKey, apiKey.isNotEmpty {
add(tracking: dydxAmplitudeTracking(apiKey))
add(tracking: dydxAmplitudeTracking(apiKey, serverZone: serverZone))
}
}

Expand Down
4 changes: 4 additions & 0 deletions scripts/secrets_default/credentials.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"value": "",
"comment": "Amplitude api key"
},
"amplitudeServerZone": {
"value": "",
"comment": "server region to send amplitude data"
},
"amplitudeStagingApiKey": {
"value": "",
"comment": "Amplitude api key on staging"
Expand Down

0 comments on commit fa71597

Please sign in to comment.