Created
December 5, 2020 22:21
-
-
Save noahsark769/37619243e377366ad9b798ef78dc3e20 to your computer and use it in GitHub Desktop.
AnalyticsController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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