diff --git a/Btchap/Config/BuildSettings.swift b/Btchap/Config/BuildSettings.swift index 32ddc2f78..e75c3b93d 100644 --- a/Btchap/Config/BuildSettings.swift +++ b/Btchap/Config/BuildSettings.swift @@ -173,10 +173,10 @@ final class BuildSettings: NSObject { #if DEBUG /// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds. - static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, - host: "", - apiKey: "", - termsURL: URL(string: "https://")!) + static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: true, // Tchap: enable PostHog analytics on DEBUG + host: "https://us.i.posthog.com", // Tchap: dev posthog, + apiKey: "phc_eQOeaQiaIxdX9kaQmqYTD7RJLyFubYmGYKUI9czqqQD", // Tchap: dev posthog, + termsURL: URL(string: "https://tchap.beta.gouv.fr/politique-de-confidentialite")!) // Tchap: dev posthog, #else /// The configuration to use for analytics. Set `isEnabled` to false to disable analytics. static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, diff --git a/DevTchap/Config/BuildSettings.swift b/DevTchap/Config/BuildSettings.swift index 08f236910..9798d0917 100644 --- a/DevTchap/Config/BuildSettings.swift +++ b/DevTchap/Config/BuildSettings.swift @@ -174,10 +174,10 @@ final class BuildSettings: NSObject { #if DEBUG /// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds. - static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, - host: "", - apiKey: "", - termsURL: URL(string: "")!) + static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: true, // Tchap: enable PostHog analytics on DEBUG + host: "https://us.i.posthog.com", // Tchap: dev posthog, + apiKey: "phc_eQOeaQiaIxdX9kaQmqYTD7RJLyFubYmGYKUI9czqqQD", // Tchap: dev posthog, + termsURL: URL(string: "https://tchap.beta.gouv.fr/politique-de-confidentialite")!) // Tchap: dev posthog, #else /// The configuration to use for analytics. Set `isEnabled` to false to disable analytics. static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, diff --git a/Riot/Modules/Analytics/Analytics.swift b/Riot/Modules/Analytics/Analytics.swift index 3b19c9809..22343098c 100644 --- a/Riot/Modules/Analytics/Analytics.swift +++ b/Riot/Modules/Analytics/Analytics.swift @@ -50,7 +50,9 @@ import AnalyticsEvents /// Whether to show the user the analytics opt in prompt. var shouldShowAnalyticsPrompt: Bool { // Only show the prompt once, and when analytics are enabled in BuildSettings. - !RiotSettings.shared.hasSeenAnalyticsPrompt && BuildSettings.analyticsConfiguration.isEnabled + // Tchap: always return FALSE because user already agreed about analytics in the private policy +// !RiotSettings.shared.hasSeenAnalyticsPrompt && BuildSettings.analyticsConfiguration.isEnabled + false } /// Indicates whether the user previously accepted Matomo analytics and should be shown the upgrade prompt. diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 99fe7fcc5..ae34bcb44 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -480,7 +480,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( profiler.analytics = analytics; [MXSDKOptions sharedInstance].profiler = profiler; - [analytics startIfEnabled]; + // Tchap: Don't try to start analytics here. + // Wait to have MXSession initialized in `handleAppState` method. +// [analytics startIfEnabled]; self.localAuthenticationService = [[LocalAuthenticationService alloc] initWithPinCodePreferences:[PinCodePreferences shared]]; @@ -2551,6 +2553,24 @@ - (void)handleAppState // An observer has been set in didFinishLaunching that will call the stored block when ready self.roomListDataReadyCompletion = finishAppLaunch; } + + // Tchap: handle analytics start now that a MXSession is known. + // Check classes with `object_getClass` function because they are `id` conforming to protocols and not direct objects. + if (object_getClass(MXSDKOptions.sharedInstance.profiler) == MXBaseProfiler.class && + object_getClass(((MXBaseProfiler *)MXSDKOptions.sharedInstance.profiler).analytics) == Analytics.class) + { + Analytics *analytics = (Analytics *)((MXBaseProfiler *)MXSDKOptions.sharedInstance.profiler).analytics; +#if DEBUG + // Tchap: Force analytics acceptance in DEBUG mode + // `optInWith:` calls `startIfEnabled` + [analytics optInWith:mainSession]; +#else + // Tchap: start analytics as it was done in `application:didFinishLaunchingWithOptions:` + [analytics startIfEnabled]; +#endif + } + + } } diff --git a/Tchap/Config/BuildSettings.swift b/Tchap/Config/BuildSettings.swift index ee36bd4db..a8481355e 100644 --- a/Tchap/Config/BuildSettings.swift +++ b/Tchap/Config/BuildSettings.swift @@ -203,10 +203,10 @@ final class BuildSettings: NSObject { #if DEBUG /// The configuration to use for analytics during development. Set `isEnabled` to false to disable analytics in debug builds. - static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, - host: "", - apiKey: "", - termsURL: URL(string: "https://")!) + static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: true, // Tchap: enable PostHog analytics on DEBUG + host: "https://us.i.posthog.com", // Tchap: dev posthog, + apiKey: "phc_eQOeaQiaIxdX9kaQmqYTD7RJLyFubYmGYKUI9czqqQD", // Tchap: dev posthog, + termsURL: URL(string: "https://tchap.beta.gouv.fr/politique-de-confidentialite")!) // Tchap: dev posthog, #else /// The configuration to use for analytics. Set `isEnabled` to false to disable analytics. static let analyticsConfiguration = AnalyticsConfiguration(isEnabled: false, diff --git a/changelog.d/1078.change b/changelog.d/1078.change new file mode 100644 index 000000000..5e4f71be0 --- /dev/null +++ b/changelog.d/1078.change @@ -0,0 +1 @@ +Activation de l'analytics PostHog en version Debug \ No newline at end of file