Skip to content

Instantly share code, notes, and snippets.

@noahsark769
Created December 5, 2020 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahsark769/37619243e377366ad9b798ef78dc3e20 to your computer and use it in GitHub Desktop.
Save noahsark769/37619243e377366ad9b798ef78dc3e20 to your computer and use it in GitHub Desktop.
AnalyticsController.swift
final class AmplitudeController {
static let shared = AmplitudeController()
private let amplitudeInstance = Amplitude.instance()
private var globalProperties: [String: Any] = [:]
func initialise() {
self.amplitudeInstance.initializeApiKey("bda1f35c62f39a02dc6d4cbf416f9bb8")
self.globalProperties = [
"appVersion": AppEnvironment.version,
"buildNumber": AppEnvironment.buildNumber,
"deviceName": UIDevice.modelName
]
if let userUuid = UserDefaults.standard.string(forKey: "userUDID") {
self.amplitudeInstance.setUserId(userUuid)
} else {
let uuid = UUID()
UserDefaults.standard.setValue(uuid.uuidString, forKey: "userUDID")
self.amplitudeInstance.setUserId(uuid.uuidString)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment