Skip to content

Commit

Permalink
✨ Add configuration option for step recovery observer
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed Aug 29, 2024
1 parent 64ebfd1 commit b3bcea3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Sources/AppcuesKit/Appcues+Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public extension Appcues {

var enableTextScaling = false

var enableStepRecoveryObserver = true

/// Create an Appcues SDK configuration
/// - Parameter accountID: Appcues Account ID - a string containing an integer, copied from the Account settings page in Studio.
/// - Parameter applicationID: Appcues Application ID - a string containing a UUID,
Expand Down Expand Up @@ -208,5 +210,21 @@ public extension Appcues {
self.enableTextScaling = enabled
return self
}

/// Set the step recovery observation preference for the configuration.
///
/// When this option is enabled, Appcues will detect recoverable step errors and attempt to retry when scroll changes
/// are observed. Observation uses method swizzling on `UIScrollView`.
///
/// The default value for this configuration is `true`.
///
/// - Parameter enabled: Whether step recovery observation is enabled.
/// - Returns: The `Configuration` object.
@discardableResult
@objc
public func enableStepRecoveryObserver(_ enabled: Bool) -> Self {
self.enableStepRecoveryObserver = enabled
return self
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ internal class ExperienceRenderer: ExperienceRendering, StateMachineOwning {
// we always add an analytics observer, it will internally filter out unpublished flows (builder previews)
stateMachine.addObserver(analyticsObserver)

if experience.renderContext == .modal {
if experience.renderContext == .modal && config.enableStepRecoveryObserver {
// add recovery observer - on recoverable step errors, initiate recovery and retry
stateMachine.addObserver(stepRecoveryObserver)
}
Expand Down

0 comments on commit b3bcea3

Please sign in to comment.