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

Added debug menu to show type of leanplum settup #6632

Merged
merged 1 commit into from
May 19, 2020
Merged
Show file tree
Hide file tree
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
21 changes: 19 additions & 2 deletions Client/Application/LeanplumIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,20 @@ struct LPSettings {
var productionKey: String
}

enum LPSetupType: String {
case debug
case production
case none
}

class LeanPlumClient {
static let shared = LeanPlumClient()

// Setup
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.
Expand All @@ -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)
Expand All @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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
*/
Expand Down
8 changes: 8 additions & 0 deletions Client/Frontend/Settings/AppSettingsOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down