AppsFlyer Analytics Implementation
What you'll learn
- Generating the AppsFlyer vendor implementation
- Configuring credentials via
app_config - Bootstrapping the AppsFlyer SDK before event tracking starts
Prerequisites
- Analytics SDK installed in your monorepo
- An AppsFlyer account with a configured app (dev key + App Store / Play Store App ID ready)
Step 1: Generate the Brick
archipelago generate appsflyer_analytics_implYou will be prompted for:
- appName —
MyApp(must match your monorepo app name) - isForMonorepo —
true
The brick is generated into infrastructure/appsflyer_analytics_impl/.
Step 2: Add Credentials to app_config
Open your app_config package and add the two AppsFlyer values to AppEnv:
// lib/src/app_env.dart
class AppEnv {
// existing fields …
final String appsflyerDevKey; // from AppsFlyer dashboard → App Settings
final String appsflyerAppId; // App Store / Play Store App ID
}Populate the values for each environment (dev, staging, prod) in the corresponding .env or config factory.
Step 3: Initialise the SDK at Bootstrap
Important: AppsFlyer requires
initSdk()to be called in your app's bootstrap before any event tracking occurs. This is done in the shell app's initialiser, not inside the generated package.
import 'package:appsflyer_sdk/appsflyer_sdk.dart';
final appsFlyerOptions = AppsFlyerOptions(
afDevKey: AppEnv.current.appsflyerDevKey,
appId: AppEnv.current.appsflyerAppId,
showDebug: kDebugMode,
);
final appsflyerSdk = AppsflyerSdk(appsFlyerOptions);
await appsflyerSdk.initSdk(
registerConversionDataCallback: true,
registerOnAppOpenAttributionCallback: true,
);Register the SDK instance in GetIt so the generated package can resolve it:
getIt.registerSingleton<AppsflyerSdk>(appsflyerSdk);Step 4: Register the Module and Verify
import 'package:appsflyer_analytics_impl/appsflyer_analytics_impl.dart';
await initAppsFlyerAnalyticsImplModule(getIt);The implementation is registered as @Named(AnalyticInjectorKey.appsFlyerImpl). The analytics_sdk orchestrator picks it up automatically via getIt.getAll<AnalyticVendor>().
Trigger an event and verify it appears in the AppsFlyer dashboard under Events (allow a few minutes for ingestion outside DebugMode).
Next Steps
- Set up the Analytics SDK for the full multi-vendor architecture
- Configure app_config to manage per-environment credentials