Giter Club home page Giter Club logo

humaanalytics's Introduction

HumaAnalytics

A Library For Sending Event And User Attribute For All Huma Apps

๐ŸŒŸ About the Project

๐Ÿ‘พ How to use

Installation

add this dependency in your build.gradle(app level)

implementation 'com.github.humatv:HumaAnalytics:1.2.1'
implementation 'com.google.android.gms:play-services-auth:20.4.1'

and add repository in your project level

 repositories {
        google()
       ...
        maven { url 'https://jitpack.io' }
    }

sync and build your project then follow below steps:

  1. step 1:

extend your application class from AnalyticsApplication and pass your BuildConfig.DEBUG, and BuildConfig.FLAVOR

class MyExampleApplication : AnalyticsApplication(
    isBuildConfigDebug = BuildConfig.DEBUG,
    buildConfigFlavor =  BuildConfig.FLAVOR) {
}
  • FLAVOR must be "prod" and "dev"

If you can not use inheritance for your Application class so you can add this line at the end of onCreat in your Application class instead

WebEngageConfig().initializeWebEngage(this, webEngageLicensesKey, isDebugMode)
  1. Step 2 :

Disable automatic backup inside the application tag in your AndroidManifest.xml file.

<application
        ...
        android:allowBackup="false"
        ....
                >

If your application needs allowBackup to be set as true, then call me :)

  1. Step 3 :

call AnalyticsUtil.loginUser() in first level of entrance to your application (for Example in Application Class) you can pass 3 argument for login user :

 /**
         * You acn login with "user_unique_Id_from_user_manager" which you got from
         * UserManager Server
         * it's recommend to pass userManagerUserId */
        AnalyticsUtil.loginUser(userManagerUserId = "user_unique_Id_from_user_manager",isDevFlavor)


        /**
         * Or You acn login with user's "phoneNumber"
         * example : "09151646562"
         */
        AnalyticsUtil.loginUser(userManagerUserId = null,phoneNumber = "09151646562", isDevFlavor = isDevFlavor, )


        /**
         * Or You acn login with "device mac Address" which you got from
         * UserManager Server
         * it's not Recommended*/
        AnalyticsUtil.loginUser(userManagerUserId = null, macAddress = "4f:54:23:fs:50", isDevFlavor = isDevFlavor, )

                >

Usage

  • Send Events: example of events without parameters:
        AnalyticsUtil.sendEvent("test_event_name")

example of events with parameters:


        val addedToCartAttributes: MutableMap<String, Any> = HashMap()
        addedToCartAttributes["Product ID"] = 1337
        addedToCartAttributes["Price"] = 39.80
        addedToCartAttributes["Quantity"] = 1
        addedToCartAttributes["Product"] = "Givenchy Pour Homme Cologne"
        addedToCartAttributes["Category"] = "Fragrance"
        addedToCartAttributes["Currency"] = "USD"
        addedToCartAttributes["Discounted"] = true

        AnalyticsUtil.sendEvent("test_event_name",addedToCartAttributes)
  • SetUser Attributes: (just for HumaStore Project when user update profile)
 AnalyticsUtil.setUserAttribute(
            UserAttributes(firstName = "first_name",
                lastName = "last_name",
                phoneNumber = "phoneNumber",
                city = "city",
                email = "email",
                avatarUrl = "avatarUrl"
            ))
  • Login User: be careful to login user when user log in

  • Logout User:

AnalyticsUtil.logoutUser()

AppPersonalization InLineContent

config: if Your Application class extended from AnalyticsApplication all thing is set up on the other way add below code after setting up webengage

 WebengagePersonalizationConfig.initPersonalization()

whe have some type which can find in ''' ir.huma.notificationlibrary.utils.personalizition.webengage.models.PersonalizationType '''

  • miniPromotion
  • footer
  • vote
  • json
  • rowData

can send your campain based on it and receive your data like below

 AnalyticsUtil.screenNavigated("ScreenName")
 PersonalizationUtil.getVoteData("parentId"){
    //yourData
 }

[//]: # can also call :(
 getVoteData
getPromotionData
getRawData
getJsonData
getJsonStringData)

please be attention that you must call screenNavigated first

๐Ÿ‘‹ Contributing

Contributions are always welcome!

๐Ÿค Contact

BaseTeam Huma

humaanalytics's People

Contributors

mostafa-imani avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.