mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
MESSENGER-4494 reset matomo instance after logout -> New ID generation
This commit is contained in:
@@ -37,7 +37,7 @@ import MatomoTracker
|
||||
}
|
||||
}
|
||||
|
||||
private let matomo: MatomoTracker?
|
||||
private var matomo: MatomoTracker?
|
||||
private let appName: String
|
||||
private let appVersion: String
|
||||
private let appPlattform = "iOS"
|
||||
@@ -59,32 +59,9 @@ import MatomoTracker
|
||||
|
||||
analyticsConfig = AnalyticsConfiguration()
|
||||
|
||||
if BWIBuildSettings.shared.bwiMatomoEnabled {
|
||||
|
||||
if let path = Bundle.main.path(forResource: "trackingConfig", ofType: "json") {
|
||||
analyticsConfig.readConfig(jsonFile: path)
|
||||
}
|
||||
|
||||
// bwi: Analytics use custom config
|
||||
guard let urlPath = analyticsConfig.selectedBaseURL(),
|
||||
let url = URL(string: urlPath),
|
||||
let siteID = analyticsConfig.selectedSiteID() else {
|
||||
matomo = nil
|
||||
return
|
||||
}
|
||||
|
||||
matomo = MatomoTracker.init(siteId: siteID, baseURL:url, userAgent: nil)
|
||||
|
||||
matomo?.isOptedOut = false
|
||||
matomo?.dispatchInterval = 5.0
|
||||
|
||||
matomo?.logger = DefaultLogger(minLevel: .verbose)
|
||||
|
||||
matomo?.setCustomVariable(withIndex: 1, name: "App Platform", value: appPlattform)
|
||||
matomo?.setCustomVariable(withIndex: 2, name: "App Version", value: appVersion)
|
||||
} else {
|
||||
matomo = nil
|
||||
}
|
||||
super.init()
|
||||
|
||||
resetMatomo()
|
||||
}
|
||||
|
||||
func setSession(session: MXSession) {
|
||||
@@ -115,7 +92,9 @@ import MatomoTracker
|
||||
userdefaults.removeObject(forKey: "PiwikVisitorUserIDKey")
|
||||
userdefaults.removeObject(forKey: "PiwikOptOutKey")
|
||||
userdefaults.removeObject(forKey: "PiwikLastOrderDateKey")
|
||||
}
|
||||
}
|
||||
|
||||
resetMatomo()
|
||||
}
|
||||
|
||||
// Uses Userdefaults instead of Account Data because it needs to be shown on every login
|
||||
@@ -131,6 +110,35 @@ import MatomoTracker
|
||||
return BWIAnalyticsAccountDataService(mxSession: session).needsToShowPromt()
|
||||
}
|
||||
|
||||
private func resetMatomo() {
|
||||
if BWIBuildSettings.shared.bwiMatomoEnabled {
|
||||
|
||||
if let path = Bundle.main.path(forResource: "trackingConfig", ofType: "json") {
|
||||
analyticsConfig.readConfig(jsonFile: path)
|
||||
}
|
||||
|
||||
// bwi: Analytics use custom config
|
||||
guard let urlPath = analyticsConfig.selectedBaseURL(),
|
||||
let url = URL(string: urlPath),
|
||||
let siteID = analyticsConfig.selectedSiteID() else {
|
||||
matomo = nil
|
||||
return
|
||||
}
|
||||
|
||||
matomo = MatomoTracker.init(siteId: siteID, baseURL:url, userAgent: nil)
|
||||
|
||||
matomo?.isOptedOut = false
|
||||
matomo?.dispatchInterval = 5.0
|
||||
|
||||
matomo?.logger = DefaultLogger(minLevel: .verbose)
|
||||
|
||||
matomo?.setCustomVariable(withIndex: 1, name: "App Platform", value: appPlattform)
|
||||
matomo?.setCustomVariable(withIndex: 2, name: "App Version", value: appVersion)
|
||||
} else {
|
||||
matomo = nil
|
||||
}
|
||||
}
|
||||
|
||||
func dispatchAll() {
|
||||
if fastRunning {
|
||||
matomo?.dispatch()
|
||||
|
||||
Reference in New Issue
Block a user