diff --git a/Client/Application/LeanplumIntegration.swift b/Client/Application/LeanplumIntegration.swift index deeae170c470..83158fd28f2e 100644 --- a/Client/Application/LeanplumIntegration.swift +++ b/Client/Application/LeanplumIntegration.swift @@ -104,6 +104,12 @@ struct LPSettings { var productionKey: String } +enum LPSetupType: String { + case debug + case production + case none +} + class LeanPlumClient { static let shared = LeanPlumClient() @@ -111,7 +117,7 @@ class LeanPlumClient { private weak var profile: Profile? private var prefs: Prefs? { return profile?.prefs } private var enabled: Bool = true - + private var setupType: LPSetupType = .none // This defines an external Leanplum varible to enable/disable FxA prepush dialogs. // The primary result is having a feature flag controlled by Leanplum, and falling back // to prompting with native push permissions. @@ -129,6 +135,10 @@ class LeanPlumClient { func isLPEnabled() -> Bool { return enabled && Leanplum.hasStarted() } + + func lpSetupType() -> LPSetupType { + return setupType + } static func shouldEnable(profile: Profile) -> Bool { return AppConstants.MOZ_ENABLE_LEANPLUM && (profile.prefs.boolForKey(AppConstants.PrefSendUsageData) ?? true) @@ -155,6 +165,7 @@ class LeanPlumClient { fileprivate func start() { guard let settings = getSettings(), isLocaleSupported(), !Leanplum.hasStarted() else { enabled = false + Sentry.shared.send(message: "LeanplumIntegration - Could not be started") log.error("LeanplumIntegration - Could not be started") return } @@ -163,9 +174,11 @@ class LeanPlumClient { log.info("LeanplumIntegration - Setting up for Development") Leanplum.setDeviceId(UIDevice.current.identifierForVendor?.uuidString) Leanplum.setAppId(settings.appId, withDevelopmentKey: settings.developmentKey) + setupType = .debug } else { log.info("LeanplumIntegration - Setting up for Production") Leanplum.setAppId(settings.appId, withProductionKey: settings.productionKey) + setupType = .production } Leanplum.syncResourcesAsync(true) @@ -244,7 +257,11 @@ class LeanPlumClient { func isFxAPrePushEnabled() -> Bool { return AppConstants.MOZ_FXA_LEANPLUM_AB_PUSH_TEST && (useFxAPrePush?.boolValue() ?? false) } - + + func isRunning() -> Bool { + return Leanplum.hasStarted() + } + /* This is used to determine if an app was installed after firefox was installed */ diff --git a/Client/Frontend/Settings/AppSettingsOptions.swift b/Client/Frontend/Settings/AppSettingsOptions.swift index 9047e03b7158..4b4c257caf14 100644 --- a/Client/Frontend/Settings/AppSettingsOptions.swift +++ b/Client/Frontend/Settings/AppSettingsOptions.swift @@ -537,6 +537,14 @@ class ToggleOnboarding: HiddenSetting { } } +class LeanplumStatus: HiddenSetting { + let lplumSetupType = LeanPlumClient.shared.lpSetupType() + + override var title: NSAttributedString? { + return NSAttributedString(string: "Leamplum Status: \(lplumSetupType) | Started: \(LeanPlumClient.shared.isRunning())", attributes: [NSAttributedString.Key.foregroundColor: UIColor.theme.tableView.rowText]) + } +} + class SetOnboardingV2: HiddenSetting { override var title: NSAttributedString? { return NSAttributedString(string: NSLocalizedString("Debug: Set onboarding type to v2", comment: "Debug option"), attributes: [NSAttributedString.Key.foregroundColor: UIColor.theme.tableView.rowText]) diff --git a/Client/Frontend/Settings/AppSettingsTableViewController.swift b/Client/Frontend/Settings/AppSettingsTableViewController.swift index fe7bd7ff975d..be7c2f8360e0 100644 --- a/Client/Frontend/Settings/AppSettingsTableViewController.swift +++ b/Client/Frontend/Settings/AppSettingsTableViewController.swift @@ -137,7 +137,8 @@ class AppSettingsTableViewController: SettingsTableViewController { ForgetSyncAuthStateDebugSetting(settings: self), SentryIDSetting(settings: self), ChangeToChinaSetting(settings: self), - ToggleOnboarding(settings: self) + ToggleOnboarding(settings: self), + LeanplumStatus(settings: self) ])] return settings