Skip to content

Commit bd54e3d

Browse files
Release 1.0.4
🐛 Fix step number in dismiss state 🐛 Fix app life cycle state detection for plugins and wrappers over SDK
1 parent 8135c69 commit bd54e3d

File tree

6 files changed

+24
-8
lines changed

6 files changed

+24
-8
lines changed

Sample/UserPilotSample/UserpilotSample.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@
915915
"$(inherited)",
916916
"@executable_path/Frameworks",
917917
);
918-
MARKETING_VERSION = 1.0.3;
918+
MARKETING_VERSION = 1.0.4;
919919
PRODUCT_BUNDLE_IDENTIFIER = com.userpilot.sample.dev;
920920
PRODUCT_NAME = "$(TARGET_NAME)";
921921
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -950,7 +950,7 @@
950950
"$(inherited)",
951951
"@executable_path/Frameworks",
952952
);
953-
MARKETING_VERSION = 1.0.3;
953+
MARKETING_VERSION = 1.0.4;
954954
PRODUCT_BUNDLE_IDENTIFIER = com.userpilot.sample;
955955
PRODUCT_NAME = "$(TARGET_NAME)";
956956
PROVISIONING_PROFILE_SPECIFIER = "";

Sources/Userpilot/Analytics/AnalyticsPublisher.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extension AnalyticsPublisher: AnalyticsPublishing {
284284
case .identify:
285285
cachedIdentifyEvent = event
286286
case .screen:
287-
setupScreenEvent(event)
287+
_ = setupScreenEvent(event)
288288
case .event:
289289
cachedEvent = event
290290
}
@@ -325,7 +325,7 @@ extension AnalyticsPublisher: AnalyticsPublishing {
325325
private func screen(_ event: Event) {
326326
tryCatch {
327327
if setupScreenEvent(event) {
328-
eventThrottle.shouldThrottleScreenEvent(screenTitle: event.screenTitle ?? "")
328+
_ = eventThrottle.shouldThrottleScreenEvent(screenTitle: event.screenTitle ?? "")
329329
flushPriorityEvents()
330330
return
331331
}

Sources/Userpilot/Analytics/SessionMonitor.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ internal class SessionMonitor: SessionMonitoring, BootUp {
3030
/// The storage used to store user-related data.
3131
private let storage: DataStoring
3232

33+
// A flag to prevent calling didEnterForeground twice
34+
private var hasInitializedForeground = false
35+
3336
/// Initializes the `SessionMonitor` with a dependency container that resolves an `AnalyticsPublishing` instance.
3437
/// - Parameter container: The dependency injection container used to resolve the required dependencies.
3538
init(container: DIContainer) {
@@ -59,6 +62,18 @@ internal class SessionMonitor: SessionMonitoring, BootUp {
5962
name: UIApplication.willEnterForegroundNotification,
6063
object: nil
6164
)
65+
66+
// Handle initial state only if app is currently active
67+
// This is a common issue when using native iOS SDKs within Flutter or ReactNative plugins.
68+
// The problem occurs due to the different lifecycle management between
69+
// these plugins and native iOS apps.
70+
DispatchQueue.main.async { [weak self] in
71+
guard let self = self else { return }
72+
if UIApplication.shared.applicationState == .active && !self.hasInitializedForeground {
73+
self.hasInitializedForeground = true
74+
self.analyticsPublisher.resume()
75+
}
76+
}
6277
}
6378

6479
func reset() {
@@ -86,6 +101,7 @@ internal class SessionMonitor: SessionMonitoring, BootUp {
86101
/// - Parameter notification: The notification object containing information about the event.
87102
@objc
88103
func didEnterForeground(notification: Notification) {
104+
hasInitializedForeground = true
89105
analyticsPublisher.resume()
90106
}
91107
}

Sources/Userpilot/Experiences/Content/Flows/ExperienceViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,14 @@ internal class ExperienceViewModel {
283283
experienceId: NSNumber(value: flowContent.id),
284284
stepId: NSNumber(value: step.id),
285285
stepState: .dismissed,
286-
step: NSNumber(value: lastStep),
286+
step: NSNumber(value: lastStep + 1),
287287
totalSteps: NSNumber(value: flowContent.steps.count)
288288
)
289289
logStep(
290290
state: "Dismissed",
291291
experienceId: flowContent.id,
292292
stepId: step.id,
293-
step: lastStep,
293+
step: lastStep + 1,
294294
totalSteps: flowContent.steps.count
295295
)
296296

Sources/Userpilot/Version.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ import Foundation
1414
/// The current version of the Userpilot SDK.
1515
private let versionMajor = "1"
1616
private let versionMinor = "0"
17-
private let versionPatch = "3"
17+
private let versionPatch = "4"
1818
let userpilotVersion = "\(versionMajor).\(versionMinor).\(versionPatch)"

Userpilot.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Pod::Spec.new do |spec|
22

33
spec.name = "Userpilot"
44
spec.module_name = "Userpilot"
5-
spec.version = "1.0.3"
5+
spec.version = "1.0.4"
66
spec.summary = "Userpilot iOS SDK allows you to integrate Userpilot experiences into your native iOS apps"
77

88
spec.description = <<-DESC

0 commit comments

Comments
 (0)