### Install FlutterFire CLI Source: https://pub.dev/packages/ambilytics Global installation of the FlutterFire CLI tool required for project configuration. ```bash dart pub global activate flutterfire_cli ``` -------------------------------- ### Configure Firebase with FlutterFire CLI Source: https://pub.dev/packages/ambilytics Example output from running the flutterfire configure command to initialize a new Firebase project and register multiple platforms. ```bash user@users-MacBook-Pro example % flutterfire configure i Found 4 Firebase projects. ✔ Select a Firebase project to configure your Flutter application with · ✔ Enter a project id for your new Firebase project (e.g. my-cool-project) · ambilytics-example i New Firebase project ambilytics-example created successfully. ✔ Which platforms should your configuration support (use arrow keys & space to select)? · ios, macos, web, android i Firebase android app com.example.example is not registered on Firebase project ambilytics-example. i Registered a new Firebase android app on Firebase project ambilytics-example. i Firebase ios app com.example.example is not registered on Firebase project ambilytics-example. i Registered a new Firebase ios app on Firebase project ambilytics-example. i Firebase macos app com.example.example.RunnerTests is not registered on Firebase project ambilytics-example. i Registered a new Firebase macos app on Firebase project ambilytics-example. i Firebase web app ambilytics_example (web) is not registered on Firebase project ambilytics-example. i Registered a new Firebase web app on Firebase project ambilytics-example. ? The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to cont ✔ The files android/build.gradle & android/app/build.gradle will be updated to apply Firebase configuration and gradle build plugins. Do you want to continue? · yes Firebase configuration file lib/firebase_options.dart generated successfully with the following Firebase apps: Platform Firebase App Id web 1:777853418226:web:69da4a4f2a495cbc99cdeb android 1:777853418226:android:d5ffad29eb40783199cdeb ios 1:777853418226:ios:5e6533e94fef227899cdeb macos 1:777853418226:ios:e32e65cdbc373d6599cdeb Learn more about using this file and next steps from the documentation: > https://firebase.google.com/docs/flutter/setup ``` -------------------------------- ### Initialize Firebase Project Source: https://pub.dev/packages/ambilytics Run this command within your Flutter project directory to configure Firebase for your target platforms. ```bash flutterfire configure ``` -------------------------------- ### Initialize Ambilytics Platform Options Source: https://pub.dev/packages/ambilytics Custom implementation for selecting the correct FirebaseOptions based on the current target platform. ```dart static FirebaseOptions get currentPlatform { if (kIsWeb) { return web; } switch (defaultTargetPlatform) { case TargetPlatform.android: return android; case TargetPlatform.iOS: return ios; case TargetPlatform.macOS: return macos; default: return macos; } } ``` -------------------------------- ### Add dependency via command line Source: https://pub.dev/packages/ambilytics/install Use this command in your terminal to add the package to your project. ```bash $ flutter pub add ambilytics ``` -------------------------------- ### Configure macOS Network Entitlements Source: https://pub.dev/packages/ambilytics Add the network client entitlement to your macOS entitlements files to ensure proper connectivity. ```xml ... com.apple.security.network.client ``` -------------------------------- ### Check outdated dependencies Source: https://pub.dev/packages/ambilytics/score Command to verify the status of package dependencies and identify potential updates. ```bash dart pub outdated --no-dev-dependencies --up-to-date --no-dependency-overrides ``` -------------------------------- ### Initialize Ambilytics without FirebaseOptions Source: https://pub.dev/packages/ambilytics Use this initialization method when building for Linux or Windows where DefaultFirebaseOptions are not supported. ```dart ambilytics.initAnalytics( measurementId: 'G-6R363DDKTZ', apiSecret: 'uzUv6h_iRS6hEt_sIVtTTA', ); ``` -------------------------------- ### Authenticate with Firebase CLI Source: https://pub.dev/packages/ambilytics Use this command to log into your Google account via the Firebase CLI. ```bash firebase login ``` -------------------------------- ### Analyze Dart source code Source: https://pub.dev/packages/ambilytics/score Command to run static analysis on a specific Dart file to reproduce reported linting issues. ```bash flutter analyze lib/src/ambilytics.dart ``` -------------------------------- ### Initialize Ambilytics Source: https://pub.dev/packages/ambilytics Call the initialization function within the main method, ensuring Firebase options are provided. ```dart void main() async { // This one await ambilytics.initAnalytics( measurementId: 'G-6R363DDKTZ', apiSecret: 'uzUv6h_iRS6hEt_sIVtTTA', firebaseOptions: DefaultFirebaseOptions.currentPlatform); runApp(const MyApp()); } ``` -------------------------------- ### Initialize and Configure ambilytics in Flutter Source: https://pub.dev/packages/ambilytics/example Initializes the analytics service with a measurement ID and API secret, and configures the MaterialApp with an AmbilyticsObserver for route tracking. ```dart import 'package:ambilytics/ambilytics.dart' as ambilytics; import 'package:ambilytics_example/color_screen.dart'; import 'package:ambilytics_example/preferences.dart'; import 'package:flutter/material.dart'; import 'firebase_options.dart'; import 'home_screen.dart'; void main() async { // Inits either Firebase Analytics (macOS, iOS, Android, Web) or GA4 Measurement Protocol, sends out app_launch event with current platform as param var disable = !(await getShareAnalyticsPreference()); await ambilytics.initAnalytics( measurementId: 'G-6R363DDKTZ', apiSecret: 'uzUv6h_iRS6hEt_sIVtTTA', disableAnalytics: disable, firebaseOptions: DefaultFirebaseOptions.currentPlatform); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), navigatorObservers: ambilytics.isAmbilyticsInitialized ? [ ambilytics.AmbilyticsObserver( // Track dialog routes pushed via showDialog() routeFilter: ambilytics.anyRouteFilter, alwaySendScreenViewCust: true) ] : [], routes: { '/': (context) => HomeScreen( title: 'Home', analyticsError: ambilytics.initError, ), '/color/red': (context) => const ColorScreen(), '/color/yellow': (context) => const ColorScreen() }, ); } } ``` -------------------------------- ### Android Build Error Output Source: https://pub.dev/packages/ambilytics Error message encountered during the :app:mapReleaseSourceSetPaths task. ```text Execution failed for task ':app:mapReleaseSourceSetPaths'. > Error while evaluating property 'extraGeneratedResDir' of task ':app:mapReleaseSourceSetPaths' ``` -------------------------------- ### Import Ambilytics Source: https://pub.dev/packages/ambilytics Import the library into your Dart files using the specified alias. ```dart import 'package:ambilytics/ambilytics.dart' as ambilytics; ``` -------------------------------- ### Add dependencies to pubspec.yaml Source: https://pub.dev/packages/ambilytics Include firebase_core and ambilytics in the dependencies section of your project configuration. ```yaml dependencies: dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 firebase_core: ambilytics: ``` -------------------------------- ### Import package in Dart Source: https://pub.dev/packages/ambilytics/install Include this import statement at the top of your Dart files to access the library. ```dart import 'package:ambilytics/ambilytics.dart'; ``` -------------------------------- ### Track navigation events Source: https://pub.dev/packages/ambilytics Add the AmbilyticsObserver to the navigatorObservers property of your MaterialApp. ```dart class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), // Here navigatorObservers: ambilytics.isAmbilyticsInitialized ? [ ambilytics.AmbilyticsObserver( routeFilter: ambilytics.anyRouteFilter, alwaySendScreenViewCust: true) ] : [], routes: { '/': (context) => HomeScreen( title: 'Home', analyticsError: ambilytics.initError, ), '/color/red': (context) => const ColorScreen(), '/color/yellow': (context) => const ColorScreen() }, ); } } ``` -------------------------------- ### Add dependency to pubspec.yaml Source: https://pub.dev/packages/ambilytics/install Manually add this line to the dependencies section of your pubspec.yaml file. ```yaml dependencies: ambilytics: ^1.2.0 ``` -------------------------------- ### Send custom events Source: https://pub.dev/packages/ambilytics Log custom events using the sendEvent function. ```dart void _incrementCounter() { setState(() { _counter++; // Here ambilytics.sendEvent(counterClicked, null); }); } ``` -------------------------------- ### Update Google Services Gradle Dependency Source: https://pub.dev/packages/ambilytics Update the google-services classpath in android/build.gradle to resolve build failures. ```gradle dependencies { classpath 'com.android.tools.build:gradle:7.3.0' // START: FlutterFire Configuration classpath 'com.google.gms:google-services:4.3.15' // END: FlutterFire Configuration classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.