SDK Flutter

Last updated: April 30th, 2024

Introdução

The purpose of this manual is to provide all the necessary information for installation and use of the tool in applications developed for the Flutter platform.

This Plugin collects data (information and location) from the device and sends it to ClearSale. All collected information is related only to the device, without any relation to the integrated application.

The geolocation information depends on the permission granted by the user of the device, in this case is necessary that the application requests the access of the user location information (the SDK doesn't requests permission). If the application doesn't request the access or the user doesn't grant permission, for location, the GeoLocation information will not be captured.

The Plugin respects Apple and Google's privacy policies for capturing device data and the permission level assigned by the user (device user).

Checksum

Since Flutter does not have native support for integrity verification, the checksum must be done on each SDK individually.

Platform Documentation
Android click here
iOS click here

Flutter

Installation

The plugin is available on pub.dev, and to use it, follow the example below:

dependencies:
  behavior_analytics_flutter_sdk: ^0.3.3
dependencies:
  behavior_analytics_flutter_sdk: ^0.3.7
dependencies:
  behavior_analytics_flutter_sdk: 
    git:
        url: https://PublicPackagesCS@dev.azure.com/PublicPackagesCS/Behavior/_git/BehaviorAnalytics.SDK.Flutter
        ref: main
        version: 0.5.10

In the pubspec.yaml file, insert the package reference in the dependencies section


Proguard Configuration

If your project is using Proguard, you will need to insert the following configurations:

Mandatory
-keep class sale.clear.behavior.android.** { *; }

Optional
-keepattributes Exceptions


Release Configuration

Below is a recommended base configuration for the release.

buildTypes {
  release {

    shrinkResources true

    minifyEnabled true

    proguardFiles getDefaultProguardFile('proguard-android.txt'),
    'proguard-rules.pro'
    signingConfig signingConfigs.debug 
  }
}
    

Android Configuration

Project Configuration

You must use the following dependencies in your project: play-services-location, play-services-ads-identifier. To do this, add the following information to your project's Gradle file, in the dependencies section.

dependencies {
    // Other dependencies of your project.
    //...
    // Required dependencies:
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
    implementation 'sale.clear.behavior:sdk-behavior:5.6.7'
    api 'com.google.android.gms:play-services-location:21.0.1'
 }

dependencies {
    // Other dependencies of your project.
    //...
    // Required dependencies:
    implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
    implementation 'sale.clear.behavior:sdk-behavior:6.0.4'
    api 'com.google.android.gms:play-services-location:21.0.1'
 }

The dependency 'com.google.android.gms:play-services-ads-identifier:18.0.1' is used to obtain information about the device's advertising identifier.

On the other hand, the dependency 'com.google.android.gms:play-services-location:21.0.1' should be used whenever it is necessary to collect geolocation information from the device.

Application Permissions

To use the SDK is necessary to request some Permissions in the manifest file, they are:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

For applications that use Android version 26 or above as Target, and wishes to capture geolocation information, it's necessary, in addition to adding the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions to the manifest, to request permission from the user to collect geolocation data, following this Android recommendation.


Note: For applications that uses version 33 (Android 13) or above as Target be able to capture information regarding advertisingID, it will be necessary to include the permission below:

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>


iOS Configuration

Project Configuration

Add the ClearSale's native iOS library in your project pod:

source 'https://dev.azure.com/PublicPackagesCS/Behavior/_git/BehaviorAnalytics.SDK.IOS.Specs'
target 'PROJECT_NAME' do
pod 'CSBehavior', '3.0.1'
end
source 'https://dev.azure.com/PublicPackagesCS/Behavior/_git/BehaviorAnalytics.SDK.IOS.Specs'
target 'PROJECT_NAME' do
...

Inside the project folder, access the folder ios and execute the command pod install:

pod install

Case the error Error: EMFILE: too many open files - React Native CLI is shown, install the watchman.

Execute the following commands on the command prompt:

brew update
$ brew install watchman

Add the following option on your plist and after in the xcode Menu Build -> Clean and Build Folder.

<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true />
    <key>NSExceptionDomains</key>
    <dict>
        <key>clearsale.com.br</key>
        <dict>
            <key>NSTemporaryExceptionMinimumTLSVersion</key>
            <string>TLSv1.2</string>
        </dict>
    </dict>
</dict>

Data and Description

Data Description
SessionID Unique ID per session of the device collection, must be sent to ClearSale along with the order.
AppKey Value provided by ClearSale, it helps to identify the device collection origin.

Implementation

SDK Intialization

import  'package:behavior_analytics_flutter_sdk/behavior_analytics_flutter_sdk.dart';


class  MyApp  extends  StatefulWidget {
    @override
    _MyAppState  createState() => _MyAppState();
}

class  _MyAppState  extends  State {
    @override
    void  initState() {
        super.initState();
        BehaviorAnalyticsFlutterSdk.start("appkey_provided_by_clearsale");
    }
}

Device collection

Collection implementation example

void _handleButtonPress() {
    BehaviorAnalyticsFlutterSdk.generateSessionID().then((sessionID) {
        BehaviorAnalyticsFlutterSdk.collectDeviceInformation(sessionID);

        print(sessionID);

        setState(() {
          _sessionID = sessionID;
        });
    });
}

@override
Widget build(BuildContext context) {
    print('build');
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
                title: const Text('BehaviorAnalytics Plugin Example'),
            ),
            body: Center(
                child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                        Text('SessionID: $_sessionID\n'),
                        ElevatedButton(
                            onPressed: _handleButtonPress,
                            child: Text('Collect'),
                        ),
                    ],
                ),
            ),
        ),
    );
}
                            

Example project

It's possible to visualize the SDK implementation in a example project clicking here.

FAQ

Click here to access our FAQ

Privacy Details

Data usage

All information collected by ClearSale's SDK are exclusively for the purpose of fraud prevention and user protection, adherent to the security and privacy policies of Google and Apple platfoms and the LGPD. Therefore, this information must be in the application privacy policy.

Data Type Collected

ClearSale's SDK collects the following device information:

  • Precise location (when allowed by user);
  • Device advertising identification (when allowed by user);
  • Device physical/hardware characteristics (such as display, battery, keyboard, disk space, model, device name);
  • Device software characteristics (such as version, language, build, parental control);
  • Network information (such as connections, IP);
  • SimCard carrier.

Google Privacy Policy
Apple Privacy Policy

Use License

By downloading and using our SDK you are agreeing to the following license.

Copyright © 2024 ClearSale

All rights are reserved, permission is granted to use the software as is, and no modification or copying for any purpose is permitted. The Software is licensed in its current configuration “as is” and without warranty of any kind, either express or implied, including, but not limited to, warranties of merchantability, fitness for a particular purpose and non-infringement of patented rights. Under no circumstances may the Copyright holders be held liable for damages, losses, causes of action, whether in contract or tort, or other tortuous action arising from the use of the Software or other actions related to this Software without the prior written authorization of the Copyright holder.