RES-73 Ajout d'un debugMode iOS
Some checks failed
openium/resgen.swift/pipeline/head There was a failure building this commit

This commit is contained in:
2025-10-20 15:21:47 +02:00
parent f1ca8e92b7
commit f0aac3a91b
4 changed files with 79 additions and 105 deletions

View File

@@ -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(

View File

@@ -175,7 +175,7 @@ enum StringsFileGenerator {
guard section.hasOneOrMoreMatchingTags(tags: inputTags) else {
return // Go to next section
}
print("DOUDOU")
section
.definitions
.forEach { definition in // swiftlint:disable:this closure_body_length
@@ -212,7 +212,6 @@ enum StringsFileGenerator {
// Search for langs in twine
for (lang, value) in definition.translations
where langs.contains(lang) && !value.isEmpty {
print("DOUDOU-> generate for \(lang)")
let localization = XCStringLocalization(
lang: lang,
content: XCStringLocalizationLangContent(