Add parameter defaultValue and value and add replaceIn parameter in another parameter
Some checks failed
gitea-openium/resgen.swift/pipeline/pr-master There was a failure building this commit

This commit is contained in:
2024-07-18 08:24:23 +02:00
parent ab91c1c277
commit 922ed56959
10 changed files with 206 additions and 43 deletions

View File

@ -5,7 +5,11 @@ import FirebaseAnalytics
// MARK: - Protocol
protocol AnalyticsManagerProtocol {
func logScreen(name: String, path: String)
func logScreen(
name: String,
path: String,
params: [String: Any]?
)
func logEvent(
name: String,
action: String,
@ -17,11 +21,27 @@ protocol AnalyticsManagerProtocol {
// MARK: - Firebase
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
func logScreen(name: String, path: String) {
func logScreen(
name: String,
path: String,
params: [String: Any]?
) {
let parameters = [
AnalyticsParameterScreenName: name as NSObject
]
if let supplementaryParameters = params {
for (newKey, newValue) in supplementaryParameters {
if parameters.contains(where: { (key: String, value: NSObject) in
key == newKey
}) {
continue
}
parameters[newKey] = newValue as? NSObject
}
}
Analytics.logEvent(
AnalyticsEventScreenView,
parameters: parameters
@ -80,11 +100,19 @@ class AnalyticsManager {
managers.append(FirebaseAnalyticsManager())
}
private func logScreen(name: String, path: String) {
private func logScreen(
name: String,
path: String,
params: [String: Any]?
) {
guard isEnabled else { return }
managers.forEach { manager in
manager.logScreen(name: name, path: path)
manager.logScreen(
name: name,
path: path,
params: params
)
}
}
@ -108,31 +136,39 @@ class AnalyticsManager {
// MARK: - section_one
func logScreenS1DefOne(title: String) {
logScreen(
static func logScreenS1DefOne(title: String, test2: String = "test") {
AnalyticsManager.shared.logScreen(
name: "s1 def one \(title)",
path: ""
path: "",
params: ["test2": test2]
)
}
func logEventS1DefTwo(title: String, count: String) {
logEvent(
static func logEventS1DefTwo(
title: String,
count: String,
test2: String = "test"
) {
AnalyticsManager.shared.logEvent(
name: "s1 def two",
action: "test",
category: "test",
params: [
"title": title,
"count": count
"count": count,
"test": "test",
"test2": test2
]
)
}
// MARK: - section_two
func logScreenS2DefOne() {
logScreen(
static func logScreenS2DefOne() {
AnalyticsManager.shared.logScreen(
name: "s2 def one",
path: ""
path: "",
params: nil
)
}
}

View File

@ -10,6 +10,13 @@ categories:
- name: title
type: String
replaceIn: name,path
- name: test
type: String
value: test
replaceIn: name,path
- name: test2
type: String
defaultValue: test
events:
- id: s1_def_two
@ -22,6 +29,12 @@ categories:
type: String
- name: count
type: String
- name: test
type: String
value: test
- name: test2
type: String
defaultValue: test
- id: section_two
screens: