Add new analytics parameters pathSuffix
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:
@@ -24,7 +24,8 @@ enum AnalyticsGenerator {
|
||||
tags: [String],
|
||||
isStatic: Bool,
|
||||
outputFile: String,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) {
|
||||
// Get target type from enum
|
||||
let targetsString: [String] = target.components(separatedBy: " ")
|
||||
@@ -44,7 +45,8 @@ enum AnalyticsGenerator {
|
||||
sections: sections,
|
||||
tags: tags,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
pathSuffix: pathSuffix
|
||||
)
|
||||
|
||||
// Write content
|
||||
@@ -65,13 +67,15 @@ enum AnalyticsGenerator {
|
||||
sections: [AnalyticsCategory],
|
||||
tags: [String],
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
[
|
||||
getHeader(
|
||||
targets: targets,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
pathSuffix: pathSuffix
|
||||
),
|
||||
getProperties(
|
||||
sections: sections,
|
||||
@@ -89,14 +93,15 @@ enum AnalyticsGenerator {
|
||||
private static func getHeader(
|
||||
targets: [TrackerType],
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
"""
|
||||
// Generated by ResgenSwift.\(Analytics.toolName) \(ResgenSwiftVersion)
|
||||
|
||||
\(Self.getImport(targets: targets))
|
||||
|
||||
\(Self.getAnalyticsProtocol(targets: targets, visibility: visibility))
|
||||
\(Self.getAnalyticsProtocol(targets: targets, visibility: visibility, pathSuffix: pathSuffix))
|
||||
|
||||
\(Self.getTrackerTypeEnum(targets: targets, visibility: visibility))
|
||||
|
||||
@@ -317,7 +322,8 @@ enum AnalyticsGenerator {
|
||||
|
||||
private static func getAnalyticsProtocol(
|
||||
targets: [TrackerType],
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
let proto = """
|
||||
// MARK: - Protocol
|
||||
@@ -344,11 +350,11 @@ enum AnalyticsGenerator {
|
||||
var result: [String] = [proto]
|
||||
|
||||
if targets.contains(TrackerType.matomo) {
|
||||
result.append(MatomoGenerator.service)
|
||||
result.append(MatomoGenerator.service(pathSuffix: pathSuffix))
|
||||
}
|
||||
|
||||
if targets.contains(TrackerType.firebase) {
|
||||
result.append(FirebaseGenerator.service)
|
||||
result.append(FirebaseGenerator.service(pathSuffix: pathSuffix))
|
||||
}
|
||||
|
||||
return result.joined(separator: "\n\n")
|
||||
|
||||
@@ -11,10 +11,10 @@ import Foundation
|
||||
|
||||
enum FirebaseGenerator {
|
||||
|
||||
static var service: String {
|
||||
static func service(pathSuffix: String) -> String {
|
||||
[
|
||||
Self.header,
|
||||
Self.logScreen,
|
||||
Self.logScreen(pathSuffix: pathSuffix),
|
||||
Self.logEvent,
|
||||
Self.enable,
|
||||
Self.footer
|
||||
@@ -35,8 +35,14 @@ enum FirebaseGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static var logScreen: String {
|
||||
"""
|
||||
private static func logScreen(pathSuffix: String) -> String {
|
||||
let pathSuffixCode: String = if pathSuffix.isEmpty == false {
|
||||
" + \"/\(pathSuffix)\""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
@@ -47,7 +53,7 @@ enum FirebaseGenerator {
|
||||
]
|
||||
|
||||
if path.isEmpty == false {
|
||||
parameters["path"] = path + "/iOS" as NSObject
|
||||
parameters["path"] = path\(pathSuffixCode) as NSObject
|
||||
}
|
||||
|
||||
if let supplementaryParameters = params {
|
||||
|
||||
@@ -11,11 +11,11 @@ import Foundation
|
||||
|
||||
enum MatomoGenerator {
|
||||
|
||||
static var service: String {
|
||||
static func service(pathSuffix: String) -> String {
|
||||
[
|
||||
Self.header,
|
||||
Self.setup,
|
||||
Self.logScreen,
|
||||
Self.logScreen(pathSuffix: pathSuffix),
|
||||
Self.logEvent,
|
||||
Self.enable,
|
||||
Self.footer
|
||||
@@ -67,8 +67,14 @@ enum MatomoGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static var logScreen: String {
|
||||
"""
|
||||
private static func logScreen(pathSuffix: String) -> String {
|
||||
let pathSuffixCode: String = if pathSuffix.isEmpty == false {
|
||||
" + \"/\(pathSuffix)\""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
@@ -76,7 +82,7 @@ enum MatomoGenerator {
|
||||
) {
|
||||
guard let trackerUrl = tracker.contentBase?.absoluteString else { return }
|
||||
|
||||
let urlString = URL(string: "\\(trackerUrl)" + "/" + "\\(path)" + "iOS")
|
||||
let urlString = URL(string: "\\(trackerUrl)" + "/" + "\\(path)"\(pathSuffixCode)
|
||||
tracker.track(
|
||||
view: [name],
|
||||
url: urlString
|
||||
|
||||
Reference in New Issue
Block a user