3rd Party Integrations
Product Journal Integrations

Flutter

Instructions for adding Appfit to an application written in Flutter

Add AppFit to Your Flutter Application

Set Up an AppFit Account

If you haven’t already, create an account on AppFit.

During setup, select the appropriate Industry, Platform, and Focus for your company. AppFit will suggest metrics to track based on these selections.

Obtain Your API Key

Navigate to the "Integrations" section on the AppFit dashboard.

Retrieve your API Key from an integration like Amplitude or Segment by copying it from there.

Installing the AppFit SDK

Installing the SDK is as simple as adding AppFit to your pubspec file

appfit:
    git:
      url: https://github.com/uptech/appfit-flutter-sdk.git
      ref: main

The AppFit SDK is Open Source. Find it on GitHub here

Configure the AppFit SDK

To configure the AppFit SDK, simply construct an AppFitConfiguration class and insert your API Key you obtained from AppFit.

final configuration = AppFitConfiguration(apiKey: 'API_KEY');
final appFit = AppFit(configuration: configuration);

Once you have the client constructed, tracking an event is as simple as calling trackEvent

import 'package:appfit/appfit.dart';

void main() {
    // Create the AppFitConfiguration
    final configuration = AppFitConfiguration(apiKey: 'API_KEY');

    // Create the AppFit Client
    final appFit = AppFit(configuration: configuration);

    // Use the client to track events
    appFit.trackEvent('event_name', properties: {'key': 'value'});
}

Identifying Users

The AppFit SDK includes an identify call, that you can use to identify users in your analytic events. This method supports any String-based identifier.

appfit.identifyUser("<id>")

Setting this to null, will remove all events going forward from including the userId.

Cached Events

We cache all events locally in the SDK. This allows us to rety failed events. If a device is experiencing network issues, we will retry the saved events later to help avoid losing any metrics.

Save Changes and Publish

After inserting the code, save the changes to your app and run it to verify that data is flowing into AppFit.

Verify the Integration

Monitor your AppFit dashboard to confirm that events from your application are being tracked and metrics are updating.