Merge pull request #1358 from meshtastic/testflight_bool

Add isTestFlight bundle extension, set environments for datadog
This commit is contained in:
Garth Vander Houwen 2025-08-27 19:33:34 -07:00 committed by GitHub
commit 5baf0ad4ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 8 deletions

View file

@ -19,4 +19,8 @@ extension Bundle {
// public var appVersionShort: String { getInfo("CFBundleShortVersion") }
fileprivate func getInfo(_ str: String) -> String { infoDictionary?[str] as? String ?? "⚠️" }
public var isTestFlight: Bool {
return appStoreReceiptURL?.lastPathComponent == "sandboxReceipt"
}
}

View file

@ -44,8 +44,13 @@ struct MeshtasticAppleApp: App {
#if !targetEnvironment(macCatalyst)
#if DEBUG
environment = "TestFlight"
environment = "Local"
#else
if Bundle.main.isTestFlight {
environment = "TestFlight"
}
#endif
Datadog.initialize(
with: Datadog.Configuration(
clientToken: clientToken,
@ -99,10 +104,10 @@ struct MeshtasticAppleApp: App {
// Initialize map data manager
MapDataManager.shared.initialize()
#if DEBUG
#if DEBUG
// Show tips in development
try? Tips.resetDatastore()
#endif
#endif
if !UserDefaults.firstLaunch {
// If this is first launch, we will show onboarding screens which
// Step through the authorization process. Do not start discovery

View file

@ -13,6 +13,7 @@ struct AppSettings: View {
@State private var isPresentingCoreDataResetConfirm = false
@State private var isPresentingDeleteMapTilesConfirm = false
@State private var purgeStaleNodes: Bool = false
@State private var showAutoConnect: Bool = false
@AppStorage("purgeStaleNodeDays") private var purgeStaleNodeDays: Double = 0
@AppStorage("environmentEnableWeatherKit") private var environmentEnableWeatherKit: Bool = true
@AppStorage("enableAdministration") private var enableAdministration: Bool = false
@ -47,12 +48,13 @@ struct AppSettings: View {
Text("Provide anonymous usage statistics and crash reports.")
.foregroundStyle(.secondary)
.font(.caption)
#if DEBUG
Toggle(isOn: autoconnectBinding) {
Label("Automatically Connect", systemImage: "app.connected.to.app.below.fill")
if showAutoConnect {
Toggle(isOn: autoconnectBinding) {
Label("Automatically Connect", systemImage: "app.connected.to.app.below.fill")
}
.tint(.accentColor)
}
.tint(.accentColor)
#endif
}
Section(header: Text("environment")) {
VStack(alignment: .leading) {
@ -73,6 +75,13 @@ struct AppSettings: View {
.onFirstAppear {
purgeStaleNodes = purgeStaleNodeDays > 0
Logger.services.info(" Purge Stale Nodes toggle initialized to \(purgeStaleNodes)")
#if DEBUG
showAutoConnect = true
#else
if Bundle.main.isTestFlight {
showAutoConnect = true
}
#endif
}
.onChange(of: purgeStaleNodes) { _, newValue in
purgeStaleNodeDays = purgeStaleNodeDays > 0 ? purgeStaleNodeDays : 7