Analytics improvement (#9)
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Co-authored-by: Quentin Bandera <q.bandera@openium.fr> Reviewed-on: #9 Co-authored-by: Loris Perret <l.perret@openium.fr> Co-committed-by: Loris Perret <l.perret@openium.fr>
This commit is contained in:
@ -11,11 +11,12 @@ enum MatomoGenerator {
|
||||
|
||||
static var service: String {
|
||||
[
|
||||
Self.header,
|
||||
Self.setup,
|
||||
Self.logScreen,
|
||||
Self.logEvent,
|
||||
Self.footer
|
||||
MatomoGenerator.header,
|
||||
MatomoGenerator.setup,
|
||||
MatomoGenerator.logScreen,
|
||||
MatomoGenerator.logEvent,
|
||||
MatomoGenerator.enable,
|
||||
MatomoGenerator.footer
|
||||
]
|
||||
.joined(separator: "\n")
|
||||
}
|
||||
@ -66,8 +67,11 @@ enum MatomoGenerator {
|
||||
|
||||
private static var logScreen: String {
|
||||
"""
|
||||
func logScreen(name: String, path: String) {
|
||||
guard !tracker.isOptedOut else { return }
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
guard let trackerUrl = tracker.contentBase?.absoluteString else { return }
|
||||
|
||||
let urlString = URL(string: "\\(trackerUrl)" + "/" + "\\(path)" + "iOS")
|
||||
@ -88,8 +92,6 @@ enum MatomoGenerator {
|
||||
category: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
guard !tracker.isOptedOut else { return }
|
||||
|
||||
tracker.track(
|
||||
eventWithCategory: category,
|
||||
action: action,
|
||||
@ -98,6 +100,15 @@ enum MatomoGenerator {
|
||||
url: nil
|
||||
)
|
||||
}
|
||||
|
||||
"""
|
||||
}
|
||||
|
||||
private static var enable: String {
|
||||
"""
|
||||
func setEnable(_ enable: Bool) {
|
||||
tracker.isOptedOut = !enable
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user