profiler 0.5.4 copy "profiler: ^0.5.4" to clipboard
profiler: ^0.5.4 copied to clipboard

PlatformAndroid

A flutter integration for the contextual profiler library. By Fivvy.

Getting started profiler@0.5.4 #

Contextual Profiler SDK offers a comprehensive and efficient solution for collecting valuable information about your users. With this powerful tool, you will be able to gather relevant data that will allow you to conduct in-depth analysis and gain a clear understanding of your users' behavior, preferences, and needs.

See the full API for more methods.

Recommendations #

  • FLUTTER: >= 3.3.0
  • ANDROID API LEVEL: 21 to 33 (we recommend 24 to 33)
  • MIN JAVA VERSION: jdk11
  • GRADLE DISTRIBUTION: gradle-7.5.1

Installation #

Please read this entire section.

add this lines in pubspec.yaml file under dependecies section #

profiler:
  git:
    url: https://gitlab.com/savvyapp/sdks/flutter-library
    ref: main

Android #

Permissions

AndroidManifest #

Necesary to add this xmlns:tools insde the tag manifest on AndroidManifest.xml insde android/app/src/main folder.

<manifest
  <!-- Others manifest properties -->
  xmlns:tools="http://schemas.android.com/tools"
>

Need to add these permissions in the AndroidManifes.xml file inside android/app/src/main before aplication tag.

<manifest>
  <!-- others aplications tags -->
  <uses-permission  android:name="android.permission.INTERNET" />
  <uses-permission  android:name="android.permission.PACKAGE_USAGE_STATS"  tools:ignore="ProtectedPermissions" />

  <!-- List of apps that you want to check on customer device -->
  <queries>
    <!-- List of package's [Max 100] -->
    <package android:name="com.whatsapp"/> <!-- WhatsApp Messenger -->
    <package android:name="com.facebook.katana"/> <!-- Facebook -->
    <package android:name="com.mercadopago.android"/> <!-- Mercado Pago -->

  </queries>

  <application>
    <!-- ... -->
  </application>
</manifest>

Integration in App #

On android you must request permissions beforehand

Init of plugin #

First of all, you will need to instantiated previously the ContextualProfiler plugin on the Widget where you will use the methods.

import 'package:profiler/plugin/contextual_profiler.dart';

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // ADD THIS LINE
  final _profilerPlugin = ContextualProfiler();

  // Your Code
}

Get user permission to check the app's usage #

This is an exclusive custom dialog that you can invoke in your app to get bring a easy way to request access usage permission from the user.

You need to import type [Language] for select the language you want. Supports up to 3 different languages: English, Spanish or Portuguese.

ProfilerUsageDialog ProfilerUsageDialog({
  Key? key,
  Image? image,
  Color? titleColor,
  required Language ln,
  Color? buttonColor,
  double buttonBorderRadious = 8,
})
import 'package:profiler/ui/profiler_usage_dialog/profiler_usage_dialog.dart';
import 'package:profiler/interfaces/language.dart';

  void show(BuildContext context, String text, String title) {
    showDialog(
        barrierColor: Colors.white60,
        context: context,
        builder: (BuildContext context) {
          return ProfilerUsageDialog(
            ln: Language.es,
          );
        });
  }

Another option #

However, there is a separate function in case you want to create a custom dialog that best suits your application. Consider having the ContextualProfiler [here as _profilerPlugin] plugin instantiated previously.

  Future<void> openAccessUsageSettings() async {
    String platformVersion;
    try {
      await _profilerPlugin.openUsageAccessSettings();
      platformVersion = 'opened successfully';
    } on PlatformException {
      platformVersion = 'Failed to openAccessUsageSettings.';
    }

    if (!mounted) return;

    setState(() {
      _response = platformVersion;
    });
  }

Send data to Fivvy's analytics service #

This function will allow your app to send the information of each user to the Fivvy Analytic's API. You must add on some view or loading component that can send the data at least 1 time a day.

  Future<void> initContextualDataCollection() async {
    String response;

    ContextualCredential initConfig = ContextualCredential(
        customerId: customerId,
        apiPassword: apiSecret,
        apiUsername: apiKey,
        authApiUrl: authApiUrl,
        sendDataApiUrl: sendDataApiUrl);

    try {
      await _profilerPlugin.initContextualDataCollection(initConfig);
      response = 'Send data successfully';
    } on PlatformException {
      response = 'Something went wrong.';
    }

    if (!mounted) return;

    setState(() {
      this._response = response;
    });
  }

API #

All the information about the package and how to use functions.

| Methods | Params value | Return value | Description | | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | initContextualDataCollection | InitConfig {customerId: String, apiKey: String, apiSecret: String, appUsageDays: Int, authApiUrl: String, sendDataApiUrl: String} | ContextualData | Initiates data collection, sending it to the Fivvy's Analytics Data API. | | getDeviceInformation | Empty | Promise<IHardwareAttributes> | Returns the device hardware information of the customer. | | getAppUsage | Int days. Represent the last days to get the usage of each app. | Promise<IAppUsage[]> | Returns an IAppUsage Array for all the queries in AndroidManifest that user had install in his phone or null if user doesn’t bring usage access. | Returns null if the user doesnt brings access to the App Usage or an IAppUsage Array for the all used aplications. | | getAppsInstalled | Empty | Promise<IInstalledApps[]> | Returns an IInstalledApps Array for all the queries in AndroidManifest that user had install in his phone. | | openUsageAccessSettings | Empty | Boolean | Open settings view to grant app usage permission. |

Interfaces #

Here you can find the interaces that sdk uses

`initContextualCollectionData param object interface`
 InitConfig {
    customerId: string,
    apiUsername: string,
    apiPassword: string,
    appUsageDays: number,
    authApiUrl: string,
    sendDataApiUrl: string
 }
`getDeviceInformation return interface`
IHardwareAttributes {
    api_level: string;
    device_id: string;
    device: string;
    hardware: string;
    brand: string;
    manufacturer: string;
    model: string;
    product: string;
    tags: string;
    type: string;
    base: string;
    id: string;
    host: string;
    fingerprint: string;
    incremental_version: string;
    release_version: string;
    base_os: string;
    display: string;
    battery_status: number;
  }

  `getAppUsage return object interface`
  IAppUsage {
    appName: string;
    usage: number;
    packageName: string;
  }
  `getAppsInstalled return object interface`
  IInstalledApps {
    appName?: string;
    packageName: string;
    category?: string;
    icon?: string;
    installTime?: string;
    lastUpdateTime?: string;
    versionCode?: string;
    versionName?: string;
  }

Terms of use #

All content here is the property of Fivvy, it should not be used without their permission.

2
likes
115
points
3
downloads

Publisher

verified publishergetfivvy.com

Weekly Downloads

A flutter integration for the contextual profiler library. By Fivvy.

Homepage

Documentation

API reference

License

unknown (license)

Dependencies

flutter, flutter_svg, plugin_platform_interface

More

Packages that depend on profiler

Packages that implement profiler