Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activation de l'analytics PostHog en version Debug #1079

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Btchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions DevTchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion Riot/Modules/Analytics/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 21 additions & 1 deletion Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]];

Expand Down Expand Up @@ -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
}


}
}

Expand Down
8 changes: 4 additions & 4 deletions Tchap/Config/BuildSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1078.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Activation de l'analytics PostHog en version Debug
Loading