Configure diagnostics (and MapLibre) using Pkl. (#3820)

* Bump the version for the next release.

* Ignore all generated sources.

* Use Pkl+XcodeGen to inject secrets instead of the project.

* Inject the PostHog/Sentry/Rageshake configuration from the environment.

* Fix bad unicode.

* Fix unit tests.
This commit is contained in:
Doug
2025-02-24 18:36:08 +00:00
committed by GitHub
parent 773d44cafa
commit 6ded867bcc
18 changed files with 95 additions and 99 deletions
+10 -17
View File
@@ -200,8 +200,8 @@ final class AppSettings {
// MARK: - Bug report
let bugReportServiceBaseURL: URL = "https://riot.im/bugreports"
let bugReportSentryURL: URL = "https://f39ac49e97714316965b777d9f3d6cd8@sentry.tools.element.io/44"
let bugReportServiceBaseURL: URL! = URL(string: Secrets.rageshakeServerURL)
let bugReportSentryURL: URL! = URL(string: Secrets.sentryDSN)
// Use the name allocated by the bug report server
let bugReportApplicationId = "element-x-ios"
/// The maximum size of the upload request. Default value is just below CloudFlare's max request size.
@@ -209,22 +209,15 @@ final class AppSettings {
// MARK: - Analytics
#if DEBUG
/// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds.
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations.
let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element."),
host: "https://posthog.element.dev",
apiKey: "phc_VtA1L35nw3aeAtHIx1ayrGdzGkss7k1xINeXcoIQzXN",
termsURL: "https://element.io/cookie-policy")
#else
/// The configuration to use for analytics. Set `isEnabled` to false to disable analytics.
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork, set custom configurations.
///
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork you will
/// need to regenerate the Secrets file with your PostHog server and API key before enabling.
let analyticsConfiguration = AnalyticsConfiguration(isEnabled: InfoPlistReader.main.bundleIdentifier.starts(with: "io.element."),
host: "https://posthog.element.io",
apiKey: "phc_Jzsm6DTm6V2705zeU5dcNvQDlonOR68XvX2sh1sEOHO",
termsURL: URL("https://element.io/cookie-policy"))
#endif
host: Secrets.postHogHost,
apiKey: Secrets.postHogAPIKey,
termsURL: "https://element.io/cookie-policy")
/// Whether the user has opted in to send analytics.
@UserPreference(key: UserDefaultsKeys.analyticsConsentState, defaultValue: AnalyticsConsentState.unknown, storageType: .userDefaults(store))
var analyticsConsentState
@@ -273,7 +266,7 @@ final class AppSettings {
let mapTilerBaseURL: URL = "https://api.maptiler.com/maps"
// maptiler api key
let mapTilerApiKey = InfoPlistReader.main.mapLibreAPIKey
let mapTilerApiKey = Secrets.mapLibreAPIKey
// MARK: - Presence
@@ -15,7 +15,6 @@ struct InfoPlistReader {
static let bundleShortVersion = "CFBundleShortVersionString"
static let bundleDisplayName = "CFBundleDisplayName"
static let productionAppName = "productionAppName"
static let mapLibreAPIKey = "mapLibreAPIKey"
static let utExportedTypeDeclarationsKey = "UTExportedTypeDeclarations"
static let utTypeIdentifierKey = "UTTypeIdentifier"
static let utDescriptionKey = "UTTypeDescription"
@@ -87,12 +86,6 @@ struct InfoPlistReader {
var productionAppName: String {
infoPlistValue(forKey: Keys.productionAppName)
}
// MARK: - MapLibre
var mapLibreAPIKey: String {
infoPlistValue(forKey: Keys.mapLibreAPIKey)
}
// MARK: - Custom App Scheme
-2
View File
@@ -117,8 +117,6 @@
<string>$(BASE_BUNDLE_IDENTIFIER)</string>
<key>keychainAccessGroupIdentifier</key>
<string>$(KEYCHAIN_ACCESS_GROUP_IDENTIFIER)</string>
<key>mapLibreAPIKey</key>
<string>$(MAPLIBRE_API_KEY)</string>
<key>productionAppName</key>
<string>$(PRODUCTION_APP_NAME)</string>
</dict>
-21
View File
@@ -1,21 +0,0 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
// MARK: - MapLibre
MAPLIBRE_API_KEY = your_key
+1 -6
View File
@@ -42,10 +42,6 @@ targets:
type: application
platform: iOS
configFiles:
Debug: ../SupportingFiles/secrets.xcconfig
Release: ../SupportingFiles/secrets.xcconfig
info:
path: ../SupportingFiles/Info.plist
properties:
@@ -109,8 +105,6 @@ targets:
LSHandlerRank: Owner
LSItemContentTypes: $(PILLS_UT_TYPE_IDENTIFIER)
LSSupportsOpeningDocumentsInPlace: false
mapLibreAPIKey: $(MAPLIBRE_API_KEY)
settings:
base:
@@ -226,6 +220,7 @@ targets:
excludes:
- Other/Extensions/XCTestCase.swift
- Other/Extensions/XCUIElement.swift
- path: ../../Secrets/Secrets.swift
- path: ../Resources
- path: ../SupportingFiles
- path: ../../Tools/Scripts/Templates/SimpleScreenExample/ElementX