Skip to content

Commit

Permalink
Inject the PostHog/Sentry/Rageshake configuration from the environment.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Feb 24, 2025
1 parent 659dca4 commit 4db05b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
27 changes: 10 additions & 17 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,24 @@ 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.
let bugReportMaxUploadSize = 50 * 1024 * 1024

// 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.
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

///
/// **Note:** Analytics are disabled by default for forks. If you are maintaining a fork
/// you will need to update the Secrets file with your PostHog server and API key.
let analyticsConfiguration = AnalyticsConfiguration(isEnabled: !Secrets.postHogHost.contains("localhost"),
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
Expand Down
9 changes: 9 additions & 0 deletions Secrets/Secrets.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
// Please see LICENSE files in the repository root for full details.
//

// Analytics and Diagnostics

sentryDSN = read("env:SENTRY_DSN")
postHogAPIKey = read("env:POSTHOG_API_KEY")
postHogHost = read("env:POSTHOG_HOST")
rageshakeServerURL = read("env:RAGESHAKE_SERVER_URL")

// Maps

mapLibreAPIKey = read("env:MAPLIBRE_API_KEY")
4 changes: 4 additions & 0 deletions Secrets/Secrets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ import Foundation
// swiftlint:disable identifier_name line_length number_separator type_body_length
internal enum Secrets {
internal static let mapLibreAPIKey: String = "your_key"
internal static let postHogAPIKey: String = "your_key"
internal static let postHogHost: String = "https://get.your.own.io"
internal static let rageshakeServerURL: String = "https://⁦bring.your.own.and.en.joy"
internal static let sentryDSN: String = "https://⁦insert.your.hearts.desire.here"
}
// swiftlint:enable identifier_name line_length number_separator type_body_length

0 comments on commit 4db05b6

Please sign in to comment.