diff --git a/flutter/lib/models/app_user.dart b/flutter/lib/models/app_user.dart index 16b5566..3c0cd31 100644 --- a/flutter/lib/models/app_user.dart +++ b/flutter/lib/models/app_user.dart @@ -4,10 +4,12 @@ class AppUser { Session session; AuthChangeEvent? authEvent; List activeProducts; + String? stripeCustomerId; AppUser({ required this.session, this.authEvent, this.activeProducts = const [], + this.stripeCustomerId, }); } diff --git a/flutter/lib/services/auth_notifier.dart b/flutter/lib/services/auth_notifier.dart index 9f70032..48be1d5 100644 --- a/flutter/lib/services/auth_notifier.dart +++ b/flutter/lib/services/auth_notifier.dart @@ -23,11 +23,13 @@ class Auth extends _$Auth { final streamSub = client.auth.onAuthStateChange.listen((authState) async { final appUser = await refreshUser(authState); + // capture posthog events for analytics if (appUser != null) { await Posthog() .identify(userId: appUser.session.user.id, userProperties: { "email": appUser.session.user.email ?? "", "active_products": appUser.activeProducts, + "stripe_customer_id": appUser.stripeCustomerId ?? "", }); } else { await Posthog().reset(); @@ -63,6 +65,7 @@ class Auth extends _$Auth { session: session, authEvent: state.event, activeProducts: List.from(metadata?["active_products"] ?? []), + stripeCustomerId: metadata?["stripe_customer_id"], ); authStateController.add(user); return user;