The purpose of this manual is to provide all the necessary information for installing and using the tool in applications developed for the Android platform.
This SDK collects data (information and location) from the device and sends it to ClearSale. All collected information is related only to the device, with no relation to the integrated application.
The geolocation information depends on the permission granted by the device user,
The SDK respects Google's privacy policy for capturing device data and the level of permission granted by the user (device user).
The purpose of this manual is to provide all the necessary information for installing and using the tool in applications developed for the Android platform.
This SDK collects data from the device and sends it to ClearSale. All collected information is related only to the device, with no relation to the integrated application.
The SDK respects Google's privacy policy for capturing device data and the level of permission granted by the user (device user).
Package | Digest |
---|---|
sdk-behavior | SHA256: 438240202C4248D0201149F376C5D2C776B81AE9F616317F07F67185F90BB997 |
To verify the checksum of dependencies in Gradle 6.2 or higher, follow the instructions at this link: Dependency Verification
Package | Digest |
---|---|
sdk-behavior | SHA256: ABCCC91058E7005BC7B47A3A242E77575B0086224D18E9C75E85B0AE0ED1C54D |
To verify the checksum of dependencies in Gradle 7.0 or higher, follow the instructions at this link: Dependency Verification
Package | Digest |
---|---|
sdk-behavior | SHA256: F67C436798EFAB2C50446090B39101C75217D724B654713AA8758CF498B51687 |
To verify the checksum of dependencies in Gradle 7.0 or higher, follow the instructions at this link: Dependency Verification
Package | Digest |
---|---|
sdk-behavior | SHA256: 9E55E1A8C668B028481C891ECAB4186281CD725F1BC7700D1E82939D9BA6C433 |
Para verificar o checksum das dependencias no Gradle 7.0 ou superior, siga as instruções desse link: Dependency Verification
To upgrade from version 3.0.2 to version 6.x.x or higher, follow these steps:
The package is available in a private repository. To use it, you need to add the following repository to the root file:
maven {
url 'https://pkgs.dev.azure.com/CS-PublicPackages/Behavior/_packaging/BehaviorAnalytics.SDK/maven/v1'
name 'BehaviorAnalytics.SDK.Android'
}
The package is available in a private repository. To use it, you need to add the following repository to the root file:
maven {
url 'https://pkgs.dev.azure.com/CS-PublicPackages/Behavior/_packaging/BehaviorAnalytics.SDK/maven/v1'
name 'BehaviorAnalytics.SDK.Android'
}
You need to use the following dependencies in your project:
To do this, in the dependencies section, add the following information to your project's Gradle file:
dependencies {
// Other project dependencies.
//...
// Required Dependencies:
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'sale.clear.behavior:sdk-behavior:7.0.0'
}
You need to use the following dependencies in your project:
To do this, in the dependencies section, add the following information to your project's Gradle file:
dependencies {
// Other project dependencies.
//...
// Required Dependencies:
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'sale.clear.behavior:sdk-behavior:6.0.8'
api 'com.google.android.gms:play-services-location:21.0.1'
}
dependencies {
// Other project dependencies.
//...
// Required Dependencies:
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'sale.clear.behavior:sdk-behavior:6.0.0'
api 'com.google.android.gms:play-services-location:21.0.1'
}
You need to use the following dependencies in your project:
To do this, in the dependencies section, add the following information to your project's Gradle file:
dependencies {
// Other project dependencies.
//...
// Required Dependencies:
implementation 'com.google.android.gms:play-services-ads:18.3.0'
api 'com.google.code.gson:gson:2.8.6'
implementation 'sale.clear.behavior:sdk-behavior:3.0.2'
// Optional Dependencies:
api 'com.google.android.gms:play-services-location:17.0.0'
}
Learn more:
The optional dependency 'com.google.android.gms:play-services-location:17.0.0' should be used whenever it is necessary to collect geolocation information.Learn more:
Learn more:
Include this rule if you are using Proguard:
-keep class sale.clear.behavior.** { *; }
To use the SDK, it 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"/>
Attention: For applications targeting version 26 or higher of Android, and that wish to capture geolocation information, it is necessary, in addition to adding the permissions ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION in the manifest, to also request user permission to collect geolocation data. To do this, follow this Android recommendation.
For applications targeting version 33 (Android 13) or higher, it will be necessary to include the AD_ID permission to capture information related to the advertisingID.
To use the SDK, it is necessary to request some permissions in the manifest file. They are:
<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 targeting version 33 (Android 13) or higher, it will be necessary to include the AD_ID permission to capture information related to the advertisingID.
If the user has consented to the collection of geolocation and the list of applications, the methods
allowGeoLocation()
allowAppList()
should be called before
the start() method, as shown in the example below:
@Override
public void onResume() {
super.onResume();
try {
mBehavior.allowGeoLocation(); // Enables geolocation capture
mBehavior.allowAppList(); //Enables the capture of information from applications installed on the device
mBehavior.start(); //Initialization of information capture.
String sessionId = mBehavior.generateSessionID();
//Only on screens where you want to send the collected data to ClearSale
mBehavior.collectDeviceInformation(sessionId); //Preferably after some user interaction time.
}
catch (CaptureWasStartedException e) {
//This error occurs when the start() method was called more than once without using the stop() method.
//Each capture (which starts with the start method) needs to be ended (with the stop method call)
}
}
Behavior is the class responsible for collecting information.
Constructors: this class does not have public constructors. The instance must be created through a static method.Method Name | Description |
---|---|
Behavior.getInstance(String app, Integer consentFlags) :Behavior |
Gets the instance of the Behavior class for an AppKey. It is necessary to pass the AppKey (value provided by ClearSale) as a parameter. It is necessary to pass the Flags parameter indicating if the user consented to the collection of sensitive information. |
Method Name | Description |
---|---|
start() :void |
Starts collecting information about the device and the screen. Exceptions:
|
generateSessionID() :String |
Generates and returns a session identifier. This value must be stored and sent to ClearSale at the time of order integration (it is the parameter used in the collectDeviceInformation method call). |
collectDeviceInformation(String sessionID) :void |
Collects device information
linking it to the Session value. It is necessary to pass the SessionId as a parameter (this value must be unique per session). (*) If you do not have a value, use the method. generateSessionID(). (**) The minimum length of the SessionID to be used is 6 characters and the maximum length is 128 characters. Exceptions:
|
stop() :void | Ends the data capture process. |
allowAppList() :void | Allows the collection of information about the apps installed on the device. |
allowGeoLocation() :void | Allows the collection of geolocation. |
sendEvent(UserEventType eventType, String sessionID) :void | Allows sending user events to the event manager, identifying the event type and user session (beta version). |
There are two ways to initialize the SDK. This depends on the type of screen that will be used. If the screen is an Activity, initialization should be done in the onCreate() method. If it is a Fragment, initialization should be done in the onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) method.
Note: In both cases (Activity or Fragment), if the stop() method is not called within the onStop() method of one of the screens, since it is a singleton, the next screen when start() is called will throw the exception CaptureWasStartedException.
In all examples, the following variables are assumed to exist:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// To get the Context in a Fragment.
View rootView = inflater.inflate(R.layout.fragment_login, container, false);
Context context = rootView.getContext();
//CLEAR_SALE_APP is a unique identification value that must be provided by ClearSale.
mBehavior = Behavior.getInstance(context, CLEAR_SALE_APP);
return rootView;
}
@Override
public void onCreate() {
//CLEAR_SALE_APP is a unique identification value that must be provided by ClearSale.
mBehavior = Behavior.getInstance(this, CLEAR_SALE_APP);
}
@Override
public void onResume() {
super.onResume();
try {
mBehavior.start(); //Initialization of information capture.
String sessionId = mBehavior.generateSessionID();
//Only on screens where you want to send the collected data to ClearSale
mBehavior.collectDeviceInformation(sessionId); //Preferably after some user interaction time.
} catch (CaptureWasStartedException e) {
//This indicates that the mBehavior.start() method has already been called previously and
//the collection was not properly finalized using the mBehavior.stop() method.
} catch (SessionIDAlreadyUsedException e) {
//The same sessionId was used previously. The SessionID must be unique per collection.
}
}
The methods start() and stop() should be implemented only on the screen where the information capture will be performed. The collectDeviceInformation(SESSION_ID) method should be called when you want to send the collected information to ClearSale, on the same screen where the previous methods were implemented.
Note: The collectDeviceInformation method must be called after the start() method has been executed.
We recommend that these methods be implemented on a "finalization" screen where there is user interaction for at least 3 seconds.
@Override
public void onStop() {
super.onStop();
mBehavior.stop(); //Finalization of information capture.
}
public class ExampleImplementationActivity extends AppCompatActivity {
private Behavior mBehavior;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//CLEAR_SALE_APP is a unique identification value that must be provided by ClearSale.
mBehavior = Behavior.getInstance(this, "CLEAR_SALE_APP");
}
@Override
public void onResume() {
super.onResume();
try {
mBehavior.start(); //Initialization of information capture.
String sessionId = mBehavior.generateSessionID();
//Only on the screen where you want to send the collected data to ClearSale
mBehavior.collectDeviceInformation(sessionId); //Preferably after some user interaction time.
} catch (CaptureWasStartedException e) {
//This indicates that the mBehavior.start() method has already been called previously and
//the collection was not properly finalized using the mBehavior.stop() method.
} catch (SessionIDAlreadyUsedException e) {
//The same sessionId was used previously. The SessionID must be unique per collection.
}
}
@Override
public void onStop() {
super.onStop();
mBehavior.stop(); //Finalization of information capture.
}
}
You can view the SDK implementation in an example project by clicking here.
Click here to access our FAQ
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.
ClearSale's SDK collects the following device information:
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 tortious action arising from the use of the Software or other actions related to this Software without the prior written authorization of the Copyright holder.