From e82847bd32fac8825528020d7e1cc9bfeb12ef1b Mon Sep 17 00:00:00 2001 From: RyosukeCla Date: Thu, 12 Sep 2024 16:58:38 +0900 Subject: [PATCH 1/4] [ios] sync generated --- ios/Nativebrik/Nativebrik/generated.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/Nativebrik/Nativebrik/generated.swift b/ios/Nativebrik/Nativebrik/generated.swift index 4c727d9..07dcf03 100644 --- a/ios/Nativebrik/Nativebrik/generated.swift +++ b/ios/Nativebrik/Nativebrik/generated.swift @@ -56,6 +56,7 @@ enum BuiltinUserProperty: String, Decodable, Encodable { case sdkVersion = "sdkVersion" case osVersion = "osVersion" case osName = "osName" + case appId = "appId" case appVersion = "appVersion" case cfBundleVersion = "cfBundleVersion" case localYear = "localYear" From 479f1667fc9627462d8ac0e02e89b33e68fa78a1 Mon Sep 17 00:00:00 2001 From: RyosukeCla Date: Thu, 12 Sep 2024 16:58:51 +0900 Subject: [PATCH 2/4] support appId condition --- ios/Nativebrik/Nativebrik/data/user.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ios/Nativebrik/Nativebrik/data/user.swift b/ios/Nativebrik/Nativebrik/data/user.swift index d5ce3bf..e0f2573 100644 --- a/ios/Nativebrik/Nativebrik/data/user.swift +++ b/ios/Nativebrik/Nativebrik/data/user.swift @@ -102,6 +102,9 @@ public class NativebrikUser { self.properties[BuiltinUserProperty.sdkVersion.rawValue] = nativebrikSdkVersion self.properties[BuiltinUserProperty.osName.rawValue] = UIDevice.current.systemName self.properties[BuiltinUserProperty.osVersion.rawValue] = UIDevice.current.systemVersion + + let appId = Bundle.main.bundleIdentifier ?? "" + self.properties[BuiltinUserProperty.appId.rawValue] = appId let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" self.properties[BuiltinUserProperty.appVersion.rawValue] = appVersion From dbc971d9da60679eb8b98b852fd7cfe9c765dcd0 Mon Sep 17 00:00:00 2001 From: RyosukeCla Date: Thu, 12 Sep 2024 16:59:17 +0900 Subject: [PATCH 3/4] send track event metadata --- ios/Nativebrik/Nativebrik/data/track.swift | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ios/Nativebrik/Nativebrik/data/track.swift b/ios/Nativebrik/Nativebrik/data/track.swift index 16e82fe..090a50b 100644 --- a/ios/Nativebrik/Nativebrik/data/track.swift +++ b/ios/Nativebrik/Nativebrik/data/track.swift @@ -6,6 +6,7 @@ // import Foundation +import UIKit private let CRASH_RECORD_KEY: String = "NATIVEBRIK_CRASH_RECORD" @@ -26,6 +27,7 @@ struct TrackRequest: Encodable { var userId: String var timestamp: DateTime var events: [TrackEvent] + var meta: TrackEventMeta } struct TrackEvent: Encodable { @@ -40,6 +42,15 @@ struct TrackEvent: Encodable { var timestamp: DateTime } +struct TrackEventMeta: Encodable { + var appId: String? + var appVersion: String? + var cfBundleVersion: String? + var osName: String? + var osVersion: String? + var sdkVersion: String? +} + struct TrackUserEvent { var name: String } @@ -124,11 +135,23 @@ class TrackRespositoryImpl: TrackRepository2 { } let events = self.buffer self.buffer = [] + + let appId = Bundle.main.bundleIdentifier ?? "" + let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" + let cfBundleVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "" + let trackMeta = await TrackEventMeta( + appId: appId, + appVersion: appVersion, + cfBundleVersion: cfBundleVersion, + osName: UIDevice.current.systemName, + osVersion: UIDevice.current.systemVersion + ) let trackRequest = TrackRequest( projectId: self.config.projectId, userId: self.user.id, timestamp: formatToISO8601(getCurrentDate()), - events: events + events: events, + meta: trackMeta ) do { From cf1776107f4ba334076ab30f2519518c7d248409 Mon Sep 17 00:00:00 2001 From: RyosukeCla Date: Thu, 12 Sep 2024 17:05:03 +0900 Subject: [PATCH 4/4] add sdkVersion --- ios/Nativebrik/Nativebrik/data/track.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ios/Nativebrik/Nativebrik/data/track.swift b/ios/Nativebrik/Nativebrik/data/track.swift index 090a50b..866bb3d 100644 --- a/ios/Nativebrik/Nativebrik/data/track.swift +++ b/ios/Nativebrik/Nativebrik/data/track.swift @@ -144,7 +144,8 @@ class TrackRespositoryImpl: TrackRepository2 { appVersion: appVersion, cfBundleVersion: cfBundleVersion, osName: UIDevice.current.systemName, - osVersion: UIDevice.current.systemVersion + osVersion: UIDevice.current.systemVersion, + sdkVersion: nativebrikSdkVersion ) let trackRequest = TrackRequest( projectId: self.config.projectId,