1.1.0 • Published 3 months ago

contextual-profiler-legacy v1.1.0

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
3 months ago

Getting started contextual-profiler-legacy@1.1.0

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

  • REACT NATIVE VERSION: >= 0.68.0 (For more recent version's dont use the legacy sdk)
  • ANDROID API LEVEL: 21 to 33 (we recommend 24 to 33)
  • MIN JAVA VERSION: jdk11
  • GRADLE DISTRIBUTION: gradle-7.3.3

Installation

Please read this entire section.

npm

npm install contextual-profiler-legacy

yarn

yarn add contextual-profiler

Android

Permissions

AndroidManifest

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

<manifest xmlns:tools="http://schemas.android.com/tools">

Need to add these permissions in the AndroidManifest inside android/app/src/main folder.

<uses-permission  android:name="android.permission.INTERNET" />
<uses-permission  android:name="android.permission.PACKAGE_USAGE_STATS"  tools:ignore="ProtectedPermissions" />

<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>

Integration in App

On android you must request permissions beforehand

Get user permission to check the app's usage

We recommend create a logic with AsyncStorage to remember if the user doesn't want to give access to this perm.

import { getAppUsage, openUsageAccessSettings } from  'contextual-profiler-legacy';
         
    const getAllPermissions = async () => {
      const appUsage = await getAppUsage(30);
      if (appUsage === null) {
        const haveAccess = await openUsageAccessSettings();
      }
    };

Example of use inside a view

    useEffect(() => {
        getAllPermissions();
  }, []);
    

or

   const handleTapPermissionButton = () => getAllPermissions();

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.

Every time this useEffect run, the data will be send to the Fyvvy's API.

  useEffect(() => {
    const contextualConfigObj = {
      customerId: customerId, // Represents an identifier of the current user
      apiKey: API_KEY, // ApiKey of Fivvy's API
      apiSecret: API_SECRET, // ApiSecrey of Fivvy's API
      appUsageDays: DAYS, // Integer that represents the last days to recollect the app usage information of the user
      authApiUrl: AUTH_API_URL, // URL of the Fivvy's Auth API 
      sendDataApiUrl: SEND_DATA_API_URL // URL of the Fivvy's Analytics Data API 
    }
    await initContextualDataCollection(contextualConfigObj);
},[])

API

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

MethodsParams valueReturn valueDescription
initContextualDataCollectionInitConfig {customerId: String, apiKey: String, apiSecret: String, appUsageDays: Int, authApiUrl: String, sendDataApiUrl: String}ContextualDataInitiates data collection, sending it to the Fivvy's Analytics Data API.
getDeviceInformationEmptyPromise<IHardwareAttributes>Returns the device hardware information of the customer.
getAppUsageInt 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.
getAppsInstalledEmptyPromise<IInstalledApps[]>Returns an IInstalledApps Array for all the queries in AndroidManifest that user had install in his phone.
openUsageAccessSettingsEmptyBooleanOpen 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;
  }
  

Example

You can find an example app/showcase here

Getting the installed apps

Recovery of applications installed on the user's device.

getAppsInstalled().then(data =>  console.log('Installed apps:', data));
//  expected output
  Installed Apps: [{"appName": "WhatsApp", "category": "Social", "icon": "iVBORw0KGgoAAAANSUhEUg", "installTime": "2023.02.15 20:07:35", "lastUpdateTime": "2023.08.16 14:52:12", "packageName": "com.whatsapp", "versionCode": "231676002", "versionName": "2.23.16.76"}] 

Terms of use

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

1.2.0-beta.0

3 months ago

1.1.0

5 months ago

1.0.0

6 months ago

0.68.2

6 months ago