Remove cocoapods-keys. Use UUID for analytics.

Make configuration optional.
This commit is contained in:
Doug 2021-11-24 11:07:34 +00:00
parent 23555b00fd
commit 46d264477d
8 changed files with 15 additions and 35 deletions

View file

@ -166,8 +166,10 @@ final class BuildSettings: NSObject {
// MARK: - Analytics
#warning("Testing environment.")
static let analyticsHost = "https://posthog-poc.lab.element.dev"
static let analyticsAppId = "14"
// Optional host for PostHog analytics. Set to nil to disable analytics.
static let analyticsHost: String? = "https://posthog-poc.lab.element.dev"
// Public key for submitting analytics. Set to nil to disable analytics.
static let analyticsKey: String? = "rs-pJjsYJTuAkXJfhaMmPUNBhWliDyTKLOOxike6ck8"
// MARK: - Bug report

View file

@ -3,7 +3,6 @@ source "https://rubygems.org"
gem "xcode-install"
gem "fastlane"
gem "cocoapods", '~>1.11.2'
gem "cocoapods-keys"
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)

View file

@ -3,9 +3,6 @@ GEM
specs:
CFPropertyList (3.0.4)
rexml
RubyInline (3.12.5)
ZenTest (~> 4.3)
ZenTest (4.12.0)
activesupport (6.1.4.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
@ -67,9 +64,6 @@ GEM
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.5.1)
cocoapods-keys (2.2.1)
dotenv
osx_keychain
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
@ -231,8 +225,6 @@ GEM
netrc (0.11.0)
optparse (0.1.1)
os (1.1.1)
osx_keychain (1.0.2)
RubyInline (~> 3)
plist (3.6.0)
public_suffix (4.0.6)
rake (13.0.6)
@ -300,7 +292,6 @@ PLATFORMS
DEPENDENCIES
cocoapods (~> 1.11.2)
cocoapods-keys
fastlane
fastlane-plugin-diawi
fastlane-plugin-versioning
@ -308,4 +299,4 @@ DEPENDENCIES
xcode-install
BUNDLED WITH
2.2.28
2.2.31

View file

@ -127,11 +127,6 @@ abstract_target 'RiotPods' do
end
plugin 'cocoapods-keys', {
:project => "Riot",
:keys => ["PostHog"]
}
post_install do |installer|
installer.pods_project.targets.each do |target|

View file

@ -48,7 +48,6 @@ PODS:
- Introspect (0.1.3)
- JitsiMeetSDK (3.10.2)
- KeychainAccess (4.2.2)
- Keys (1.0.1)
- KituraContracts (1.2.1):
- LoggerAPI (~> 1.7)
- KTCenterFlowLayout (1.3.1)
@ -123,7 +122,6 @@ DEPENDENCIES:
- GBDeviceInfo (~> 6.6.0)
- Introspect (~> 0.1)
- KeychainAccess (~> 4.2.2)
- Keys (from `Pods/CocoaPodsKeys`)
- KTCenterFlowLayout (~> 1.3.1)
- MatrixKit (= 0.16.10)
- MatrixSDK
@ -184,10 +182,6 @@ SPEC REPOS:
- zxcvbn-ios
- ZXingObjC
EXTERNAL SOURCES:
Keys:
:path: Pods/CocoaPodsKeys
SPEC CHECKSUMS:
AFNetworking: 7864c38297c79aaca1500c33288e429c3451fdce
BlueCryptor: b0aee3d9b8f367b49b30de11cda90e1735571c24
@ -207,7 +201,6 @@ SPEC CHECKSUMS:
Introspect: 2be020f30f084ada52bb4387fff83fa52c5c400e
JitsiMeetSDK: 2f118fa770f23e518f3560fc224fae3ac7062223
KeychainAccess: c0c4f7f38f6fc7bbe58f5702e25f7bd2f65abf51
Keys: a576f4c9c1c641ca913a959a9c62ed3f215a8de9
KituraContracts: e845e60dc8627ad0a76fa55ef20a45451d8f830b
KTCenterFlowLayout: 6e02b50ab2bd865025ae82fe266ed13b6d9eaf97
libbase58: 7c040313537b8c44b6e2d15586af8e21f7354efd
@ -231,6 +224,6 @@ SPEC CHECKSUMS:
zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb
PODFILE CHECKSUM: 6d24497e38de7332dbb2c2ff21ad7ed8090c81de
PODFILE CHECKSUM: 06d0fee10c99dee2531993f8cb2e54ec04f0752b
COCOAPODS: 1.11.2

View file

@ -71,7 +71,10 @@ import PostHog
func startIfEnabled() {
guard RiotSettings.shared.enableAnalytics, !isRunning else { return }
postHog = PHGPostHog(configuration: PHGPostHogConfiguration.standard)
// Ensures that analytics are configured BuildSettings
guard let configuration = PHGPostHogConfiguration.standard else { return }
postHog = PHGPostHog(configuration: configuration)
postHog?.enable()
MXLog.debug("[Analytics] Started.")

View file

@ -35,11 +35,7 @@ struct AnalyticsSettings {
/// Generate a new random analytics ID. This method has no effect if an ID already exists.
mutating func generateID() {
guard id == nil else { return }
// Generate a 32 character analytics ID containing the characters 0-f.
id = [UInt8](repeating: 0, count: 16)
.map { _ in String(format: "%02x", UInt8.random(in: 0...UInt8.max)) }
.joined()
id = UUID().uuidString
}
}

View file

@ -15,11 +15,12 @@
//
import PostHog
import Keys
extension PHGPostHogConfiguration {
static var standard: PHGPostHogConfiguration {
let configuration = PHGPostHogConfiguration(apiKey: RiotKeys().postHog, host: BuildSettings.analyticsHost)
static var standard: PHGPostHogConfiguration? {
guard let apiKey = BuildSettings.analyticsKey, let host = BuildSettings.analyticsHost else { return nil }
let configuration = PHGPostHogConfiguration(apiKey: apiKey, host: host)
configuration.shouldSendDeviceID = false
return configuration