KasyKasy

Analytics (Mixpanel)

Usage events (screens, clicks, conversions) to understand how people use the app.

Without analytics you launch the app blind: you don't know which screen trips users up, which button gets clicked, or where in the funnel people give up. Mixpanel solves this.

The kit ships with Mixpanel enabled by default and an AnalyticsObserver that logs every navigation automatically.

Implementation

Via MCP: ask your assistant "add analytics to my project". It runs add_feature for you. See Kasy MCP.

  1. Run:

    kasy add analytics

    The CLI asks for your Mixpanel token and saves it in the project.

  2. To get the token:

    1. Create an account at mixpanel.com (free tier)
    2. Create Project → name it
    3. Settings → Project Settings → copy the Project Token
    4. Paste it into kasy add analytics when asked
  3. To configure it later, without going through the CLI:

    # .env
    MIXPANEL_TOKEN=your_token_here

    Via MCP: paste the token in chat and ask "set up Mixpanel" — the assistant writes it with configure_project_keys. See Kasy MCP.

Information

What gets logged automatically

EventWhen it fires
Screen ViewEvery navigation between screens
App OpenApp boot
LoginSocial or email login
SignupNew sign-up
PurchaseSubscription purchase (RevenueCat or Stripe)
Subscription RenewedAutomatic renewal

You don't need to add a single line of code for these events.

Logging a custom event

import 'package:kasy_kit/core/data/api/analytics_api.dart';

ref.read(analyticsApiProvider).trackEvent(
  'Workout Started',
  properties: {
    'workout_type': 'cardio',
    'duration_min': 30,
  },
);

Good naming conventions:

  • Past tense verb: Workout Started, Recipe Saved, Lesson Completed
  • Spaces between words (more readable in the dashboard than workout_started)
  • Properties in snake_case

Identifying the user

The kit calls identify automatically when the user logs in. You see who did what in the dashboard: it doesn't stay anonymous.

To add profile attributes:

ref.read(analyticsApiProvider).setUserProperties({
  'plan': 'premium',
  'signup_date': DateTime.now().toIso8601String(),
});

Where to see the data

mixpanel.com → your project. A few useful screens to start with:

  • Events → raw list of everything coming in
  • Funnels → screen A → screen B → subscription (where you're losing people)
  • Retention → how many users come back on day 1, day 7, day 30
  • Insights → custom charts for any event

Privacy (GDPR / LGPD)

  • In production, the user ID is sent along. If you don't want that, you can pass null to identify and use just the device's anonymous ID.
  • Mixpanel has an opt-out: Mixpanel.optOutTracking() turns off tracking for that user (useful on privacy screens).
  • Events go to Mixpanel's servers in the US. Mention this in your terms of use.

Last updated on 08/02/2026