add this dependency in your build.gradle(app level)
implementation 'com.github.humatv:HumaAnalytics:1.3.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:
- 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)
- 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 :)
- 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, )
>
- 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()
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
- miniPromotionList
- 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
getPromotionListData
getRawData
getJsonData
getJsonStringData)
please be attention that you must call screenNavigated first
-
VoteData:
Attribute Description isOptional typevoteNO idfor handel campaign id NO questionIdfor handel campaign different A/B testing YES titleby using titleanddescriptionyou can ask your vote by app UIYES descriptionby using titleanddescriptionyou can ask your vote by app UIYES conditioncan set any String to set condition and handle in your app YES positiveButtonTitlepositive Button title in dialog YES negativeButtonTitlenegative Button title in dialog YES metaDataany meta data for mor information or handleable YES choice0choice in order YES choice1choice in order YES choice2choice in order YES choice3choice in order YES choice4choice in order YES choice5choice in order YES choice6choice in order YES -
miniPromotion:
Attribute Description isOptional typeminiPromotionNO idfor handel campaign id NO titleby using titleanddescriptionyou can set by app UIYES descriptionby using titleanddescriptionyou can set by app UIYES imageUrlpromotion image Url NO linkUrlpromotion Link Url YES senderPackageNamepromotion owner packageName YES headerIdany meta data for mor information or handleable YES badgeImageUrlbadge image on promotion YES badgeTitlebadge title text on promotion YES indexorder of item in mini promotion list YES
`senderPackageName` and `linkUrl` is required for launcher mini promotion
in launcher `headerId` is mini promotion server headerId
in launcher just use one of `badgeImageUrl` or `badgeTitle` because overlays
-
footer:
Attribute Description isOptional typefooterNO titleby using titleanddescriptionyou can set by app UIYES descriptionby using titleanddescriptionyou can set by app UIYES linkUrlpromotion Link Url YES senderPackageNamepromotion owner packageName YES -
miniPromotionList:
Attribute Description isOptional typeminiPromotionListNO idfor handel campaign id NO titleby using titleanddescriptionyou can set by app UIYES senderPackageNamepromotion owner packageName YES indexorder of list page YES image1image of item in mini promotion list YES link1deepLink of item in mini promotion list YES image2image of item in mini promotion list YES link2deepLink of item in mini promotion list YES image3image of item in mini promotion list YES link3deepLink of item in mini promotion list YES image4image of item in mini promotion list YES link4deepLink of item in mini promotion list YES image5image of item in mini promotion list YES link5deepLink of item in mini promotion list YES
** `senderPackageName` is required for launcher mini promotion **
-
json:
Attribute Description isOptional typejsonNO jsonDataJson valid format type of your data NO -
rawData:
Attribute Description isOptional typerawDataNO you can use key an value to use it and handle by yourself
Contributions are always welcome!
BaseTeam Huma