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

Tightened up application opened events to prevent duplicates #267

Merged
merged 1 commit into from
Nov 6, 2023
Merged
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
22 changes: 8 additions & 14 deletions Sources/Segment/Plugins/Platforms/iOS/iOSLifecycleEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,28 @@ class iOSLifecycleEvents: PlatformPlugin, iOSLifecycle {
let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
let currentBuild = Bundle.main.infoDictionary?["CFBundleVersion"] as? String

analytics?.track(name: "Application Opened", properties: [
"from_background": true,
"version": currentVersion ?? "",
"build": currentBuild ?? ""
])
if didFinishLaunching == false {
analytics?.track(name: "Application Opened", properties: [
"from_background": true,
"version": currentVersion ?? "",
"build": currentBuild ?? ""
])
}
}

func applicationDidEnterBackground(application: UIApplication?) {
didFinishLaunching = false
if analytics?.configuration.values.trackApplicationLifecycleEvents == false {
return
}

analytics?.track(name: "Application Backgrounded")
}

func applicationDidBecomeActive(application: UIApplication?) {
if analytics?.configuration.values.trackApplicationLifecycleEvents == false {
return
}

analytics?.track(name: "Application Foregrounded")

// Lets check if we skipped application:didFinishLaunchingWithOptions,
// if so, lets call it.
if didFinishLaunching == false {
// Call application did finish launching
self.application(nil, didFinishLaunchingWithOptions: nil)
}
}
}

Expand Down
Loading