Skip to content
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
2 changes: 1 addition & 1 deletion src/mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() async {
final postHogConfig = PostHogConfig(postHogApiKey);
postHogConfig.host = postHogHost;
postHogConfig.debug = !kReleaseMode;
postHogConfig.captureApplicationLifecycleEvents = true;
postHogConfig.captureApplicationLifecycleEvents = false;
postHogConfig.personProfiles = PostHogPersonProfiles.always;
try {
await Posthog().setup(postHogConfig);
Expand Down
6 changes: 3 additions & 3 deletions src/mobile/lib/src/app/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with UiLoggy {
await authRepository.loginWithEmailAndPassword(
event.username, event.password);

await AnalyticsService().trackUserLoggedIn();
final userId =
await AuthHelper.getCurrentUserId(suppressGuestWarning: true);
if (userId != null) {
Expand All @@ -97,6 +96,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with UiLoggy {
userProperties: {'email': event.username},
);
}
await AnalyticsService().trackUserLoggedIn();
GlobalAuthManager.instance.resetSessionExpiredGuard();
emit(AuthLoaded(AuthPurpose.login));
} catch (e) {
Expand All @@ -119,7 +119,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with UiLoggy {
emit(AuthLoading());
try {
await authRepository.registerWithEmailAndPassword(event.model);
await AnalyticsService().trackUserRegistered();
final userId =
await AuthHelper.getCurrentUserId(suppressGuestWarning: true);
if (userId != null) {
Expand All @@ -128,6 +127,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with UiLoggy {
userProperties: {'email': event.model.email ?? ''},
);
}
await AnalyticsService().trackUserRegistered();
GlobalAuthManager.instance.resetSessionExpiredGuard();
emit(AuthLoaded(AuthPurpose.register));
} catch (e) {
Expand Down Expand Up @@ -198,12 +198,12 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> with UiLoggy {
emit(AuthLoading());
try {
await socialAuthRepository.loginWithProvider(event.provider);
await AnalyticsService().trackUserLoggedIn(method: event.provider);
final userId =
await AuthHelper.getCurrentUserId(suppressGuestWarning: true);
if (userId != null) {
await AnalyticsService().setUserIdentity(userId: userId);
}
await AnalyticsService().trackUserLoggedIn(method: event.provider);
GlobalAuthManager.instance.resetSessionExpiredGuard();
loggy.info('OAuth login successful via ${event.provider}');
emit(AuthLoaded(AuthPurpose.login));
Expand Down
4 changes: 4 additions & 0 deletions src/mobile/lib/src/app/shared/services/analytics_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class AnalyticsService with UiLoggy {
String eventName, {
Map<String, Object>? properties,
}) async {
if (!FeatureFlagService.instance.isAnalyticsEnabled) {
return;
}

try {
await Posthog().capture(
eventName: eventName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class FeatureFlagService with UiLoggy {

bool isEnabled(AppFeatureFlag flag) => _flags[flag] ?? false;

bool get isAnalyticsEnabled => isEnabled(AppFeatureFlag.researchMode);

Future<void> reloadFlags() async {
try {
await Posthog().reloadFeatureFlags();
Expand Down
Loading