diff --git a/ios/Nativebrik/Nativebrik/data/track.swift b/ios/Nativebrik/Nativebrik/data/track.swift index 16e82fe..866bb3d 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,24 @@ 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, + sdkVersion: nativebrikSdkVersion + ) let trackRequest = TrackRequest( projectId: self.config.projectId, userId: self.user.id, timestamp: formatToISO8601(getCurrentDate()), - events: events + events: events, + meta: trackMeta ) do { 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 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"