Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced compilation duration #340

Merged
merged 1 commit into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Sources/Segment/Plugins/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ public class Context: PlatformPlugin {
app.merge(localizedInfo) { (_, new) in new }
}
if app.count != 0 {
var name: String = ""
if let displayName = app["CFBundleDisplayName"] as? String {
name = displayName
} else if let displayName = app["CFBundleName"] as? String {
name = displayName
}
staticContext["app"] = [
"name": app["CFBundleDisplayName"] ?? app["CFBundleName"] ?? "" ,
"name": name,
"version": app["CFBundleShortVersionString"] ?? "",
"build": app["CFBundleVersion"] ?? "",
"namespace": Bundle.main.bundleIdentifier ?? ""
Expand Down
45 changes: 23 additions & 22 deletions Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,36 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
return
}

let previousVersion = UserDefaults.standard.string(forKey: Self.versionKey)
let previousBuild = UserDefaults.standard.string(forKey: Self.buildKey)

let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
let currentBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String

if previousBuild == nil {
analytics?.track(name: "Application Installed", properties: [
"version": currentVersion ?? "",
"build": currentBuild ?? ""
])
} else if currentBuild != previousBuild {
let previousVersion: String? = UserDefaults.standard.string(forKey: Self.versionKey)
let previousBuild: String? = UserDefaults.standard.string(forKey: Self.buildKey)

let currentVersion: String = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
let currentBuild: String = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? ""

if let previousBuild,
currentBuild != previousBuild {
analytics?.track(name: "Application Updated", properties: [
"previous_version": previousVersion ?? "",
"previous_build": previousBuild ?? "",
"version": currentVersion ?? "",
"build": currentBuild ?? ""
"previous_build": previousBuild,
"version": currentVersion,
"build": currentBuild
])
} else {
analytics?.track(name: "Application Installed", properties: [
"version": currentVersion,
"build": currentBuild
])
}
let sourceApp: String? = launchOptions?[UIApplication.LaunchOptionsKey.sourceApplication] as? String ?? ""
let url: String? = launchOptions?[UIApplication.LaunchOptionsKey.url] as? String ?? ""

let sourceApp: String = launchOptions?[UIApplication.LaunchOptionsKey.sourceApplication] as? String ?? ""
let url: String = launchOptions?[UIApplication.LaunchOptionsKey.url] as? String ?? ""

analytics?.track(name: "Application Opened", properties: [
"from_background": false,
"version": currentVersion ?? "",
"build": currentBuild ?? "",
"referring_application": sourceApp ?? "",
"url": url ?? ""
"version": currentVersion,
"build": currentBuild,
"referring_application": sourceApp,
"url": url
])

UserDefaults.standard.setValue(currentVersion, forKey: Self.versionKey)
Expand Down
Loading