RES-73 Ajout d'un debugMode iOS
Some checks failed
openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -143,13 +143,17 @@ enum AnalyticsGenerator {
|
||||
visibility: ExtensionVisibility
|
||||
) -> String {
|
||||
"""
|
||||
private var isEnabled: Bool {
|
||||
private var isDebugMode: Bool = false
|
||||
|
||||
private var isEnabled: Bool {
|
||||
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private let logger = Logger(subsystem: "resgen", category: "analytics")
|
||||
|
||||
// MARK: - Enable Methods
|
||||
|
||||
@@ -186,6 +190,8 @@ enum AnalyticsGenerator {
|
||||
result.append("import FirebaseAnalytics")
|
||||
}
|
||||
|
||||
result.append("import os")
|
||||
|
||||
return result.joined(separator: "\n")
|
||||
}
|
||||
|
||||
@@ -198,9 +204,19 @@ enum AnalyticsGenerator {
|
||||
path: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
guard isEnabled else { return }
|
||||
guard isEnabled else {
|
||||
if isDebugMode {
|
||||
logger.log("Analytics disabled")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
managers.values.forEach { manager in
|
||||
|
||||
if isDebugMode {
|
||||
logger.debug("🖥️ Screen: \\(name, privacy: .public) | path: \\(path, privacy: .public) | params: \\(String(describing: params ?? [:]), privacy: .public)")
|
||||
}
|
||||
|
||||
manager.logScreen(
|
||||
name: name,
|
||||
path: path,
|
||||
@@ -215,9 +231,19 @@ enum AnalyticsGenerator {
|
||||
category: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
guard isEnabled else { return }
|
||||
guard isEnabled else {
|
||||
if isDebugMode {
|
||||
logger.log("Analytics disabled")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
managers.values.forEach { manager in
|
||||
|
||||
if isDebugMode {
|
||||
logger.debug("📊 Event: \\(name, privacy: .public) | action: \\(action, privacy: .public) | category: \\(category, privacy: .public) | params: \\(String(describing: params ?? [:]), privacy: .public)")
|
||||
}
|
||||
|
||||
manager.logEvent(
|
||||
name: name,
|
||||
action: action,
|
||||
@@ -238,11 +264,13 @@ enum AnalyticsGenerator {
|
||||
let footer = " }"
|
||||
|
||||
if targets.contains(TrackerType.matomo) {
|
||||
header = "\(visibility) func configure(siteId: String, url: String) {"
|
||||
header = "\(visibility) func configure(siteId: String, url: String, isDebugMode: Bool = false) {"
|
||||
} else if targets.contains(TrackerType.firebase) {
|
||||
header = "\(visibility) func configure() {"
|
||||
header = "\(visibility) func configure(isDebugMode: Bool = false) {"
|
||||
}
|
||||
|
||||
content.append(" self.isDebugMode = isDebugMode")
|
||||
|
||||
if targets.contains(TrackerType.matomo) {
|
||||
content.append("""
|
||||
managers[TrackerType.matomo] = MatomoAnalyticsManager(
|
||||
|
Reference in New Issue
Block a user