Skip to content

Commit bf14ffd

Browse files
committed
Configure Statsig for all build targets (#2831)
1 parent 643434f commit bf14ffd

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

Kickstarter-Framework/Sources/Kickstarter-Framework/Kickstarter-iOS/AppDelegateViewModel.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public protocol AppDelegateViewModelOutputs {
100100
/// Emits when the application should configure Segment with an instance of Braze.
101101
var configureSegmentWithBraze: Signal<String, Never> { get }
102102

103-
/// Emits when the application should configure Statsig.
104-
var configureStatsig: Signal<(), Never> { get }
103+
/// Emits when the application should configure Statsig and returns the correct API Key.
104+
var configureStatsig: Signal<String, Never> { get }
105105

106106
/// Return this value in the delegate method.
107107
var continueUserActivityReturnValue: MutableProperty<Bool> { get }
@@ -721,6 +721,11 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
721721
self.configureFirebase = self.applicationLaunchOptionsProperty.signal.ignoreValues()
722722

723723
self.configureStatsig = self.applicationLaunchOptionsProperty.signal.ignoreValues()
724+
.map { _ in
725+
AppEnvironment.current.mainBundle.isRelease
726+
? Secrets.Statsig.production
727+
: Secrets.Statsig.staging
728+
}
724729

725730
self.setApplicationShortcutItems = currentUserEvent
726731
.values()
@@ -927,7 +932,7 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
927932
public let applicationIconBadgeNumber: Signal<Int, Never>
928933
public let configureFirebase: Signal<(), Never>
929934
public let configureSegmentWithBraze: Signal<String, Never>
930-
public let configureStatsig: Signal<(), Never>
935+
public let configureStatsig: Signal<String, Never>
931936
public let continueUserActivityReturnValue = MutableProperty(false)
932937
public let emailVerificationCompleted: Signal<(String, Bool), Never>
933938
public let findRedirectUrl: Signal<URL, Never>

Kickstarter-iOS/AppDelegate.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,11 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
218218

219219
strongSelf.configureRemoteConfig()
220220
}
221-
#endif
222221

223-
#if INTERNAL_BUILD
224222
self.viewModel.outputs.configureStatsig
225223
.observeForUI()
226-
.observeValues { [weak self] in
227-
self?.configureStatsig()
224+
.observeValues { [weak self] key in
225+
self?.configureStatsig(with: key)
228226
}
229227
#endif
230228

@@ -467,8 +465,8 @@ internal final class AppDelegate: UIResponder, UIApplicationDelegate {
467465
}
468466
}
469467

470-
private func configureStatsig() {
471-
let client = StatsigClient(sdkKey: Secrets.Statsig.staging)
468+
private func configureStatsig(with key: String) {
469+
let client = StatsigClient(sdkKey: key)
472470
AppEnvironment.updateStatsigClient(client)
473471

474472
client.initialize(userID: AppEnvironment.current.currentUser?.id.toString())

0 commit comments

Comments
 (0)