Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eli/make telemetry event function as public #16

Merged
merged 6 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified AirRobeWidget/releases/AirRobeWidget-1.0.2.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package com.airrobe.widgetsdk.airrobewidget

import android.content.Context
import android.util.Log
import android.widget.RelativeLayout
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetConfig
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetInstance
import com.airrobe.widgetsdk.airrobewidget.service.api_controllers.AirRobeGetShoppingDataController
import com.airrobe.widgetsdk.airrobewidget.service.listeners.AirRobeGetShoppingDataListener
import com.airrobe.widgetsdk.airrobewidget.service.models.AirRobeGetShoppingDataModel
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeAppUtils
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeSharedPreferenceManager
import com.airrobe.widgetsdk.airrobewidget.widgets.AirRobeConfirmation
import kotlin.math.roundToInt

internal val widgetInstance = AirRobeWidgetInstance
Expand Down Expand Up @@ -81,8 +79,12 @@ object AirRobeWidget {
getShoppingDataController.start(config.appId, config.mode)
}

fun trackPageView(context: Context, pageName: String) {
AirRobeAppUtils.telemetryEvent(context, "pageview", pageName)
}

fun checkMultiOptInEligibility(items: ArrayList<String>): Boolean {
if (widgetInstance.shopModel == null || items.isNullOrEmpty() || widgetInstance.categoryMapping.categoryMappingsHashmap.isNullOrEmpty()) {
if (widgetInstance.shopModel == null || items.isEmpty() || widgetInstance.categoryMapping.categoryMappingsHashmap.isNullOrEmpty()) {
return false
}
val to = widgetInstance.categoryMapping.checkCategoryEligible(items)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ internal class AirRobeConstants {
const val PRICE_ENGINE_HOST = "https://price-engine.airrobe.com"
const val EMAIL_CHECK_HOST = "https://shop.airrobe.com"
const val ORDER_ACTIVATE_BASE_URL = "https://shop.airrobe.com/en/orders/"
const val ORDER_ACTIVATE_SANDBOX_BASE_URL = "https://stg.marketplace.airdemo.link/en/orders/"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import android.view.MotionEvent
import android.view.View
import android.view.animation.AnimationUtils
import com.airrobe.widgetsdk.airrobewidget.R
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetConfig
import com.airrobe.widgetsdk.airrobewidget.service.api_controllers.AirRobeTelemetryEventController
import com.airrobe.widgetsdk.airrobewidget.widgetInstance

internal object AirRobeAppUtils {
@SuppressLint("HardwareIds")
fun getDeviceId(context: Context): String {
return Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}

fun telemetryEvent(context: Context, config: AirRobeWidgetConfig?, eventName: String, pageName: String) {
if (config == null) {
fun telemetryEvent(context: Context, eventName: String, pageName: String) {
if (widgetInstance.configuration == null) {
return
}
val telemetryEventController = AirRobeTelemetryEventController()
telemetryEventController.start(context, config, eventName, pageName)
telemetryEventController.start(context, widgetInstance.configuration!!, eventName, pageName)
}

fun touchAnimator(context: Context, v: View, event: MotionEvent): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import android.widget.TextView
import com.airrobe.widgetsdk.airrobewidget.R
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeConstants
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetInstance
import com.airrobe.widgetsdk.airrobewidget.config.Mode
import com.airrobe.widgetsdk.airrobewidget.service.api_controllers.AirRobeEmailCheckController
import com.airrobe.widgetsdk.airrobewidget.service.listeners.AirRobeEmailCheckListener
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeAppUtils
Expand Down Expand Up @@ -147,9 +148,13 @@ class AirRobeConfirmation @JvmOverloads constructor(
tvAction.setOnTouchListener { v, event ->
if (AirRobeAppUtils.touchAnimator(context, v, event)) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(AirRobeConstants.ORDER_ACTIVATE_BASE_URL + widgetInstance.configuration?.appId + "-" + orderId)
val baseUrl = if (widgetInstance.configuration?.mode == Mode.PRODUCTION)
AirRobeConstants.ORDER_ACTIVATE_BASE_URL
else
AirRobeConstants.ORDER_ACTIVATE_SANDBOX_BASE_URL
intent.data = Uri.parse(baseUrl + widgetInstance.configuration?.appId + "-" + orderId + "/claim")
context.startActivity(intent)
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Claim link click", "Thank You")
AirRobeAppUtils.telemetryEvent(context, "Claim link click", "Thank You")
}
true
}
Expand Down Expand Up @@ -188,7 +193,7 @@ class AirRobeConfirmation @JvmOverloads constructor(
visibility = VISIBLE
btnLoading.visibility = VISIBLE
btnLoading.animate()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Thank you")
AirRobeAppUtils.telemetryEvent(context, "pageview", "Thank you")
emailCheck(email!!)
} else {
visibility = GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ internal class AirRobeLearnMore(context: Context) : Dialog(context) {
}
if (isChecked) {
if (isFromMultiOptIn) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Opted in to AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Product")
AirRobeAppUtils.telemetryEvent(context, "Opted in to AirRobe", "Product")
}
} else {
if (isFromMultiOptIn) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Opted out of AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Product")
AirRobeAppUtils.telemetryEvent(context, "Opted out of AirRobe", "Product")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
tvDetailedDescription.visibility = VISIBLE
expandType = ExpandType.Opened
ivArrowDown.animate().rotation(180.0f).duration = 80
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Widget Expand Arrow Click", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Widget Expand Arrow Click", "Cart")
}
}
setDetailedDescriptionText()
Expand All @@ -212,9 +212,9 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
AirRobeSharedPreferenceManager.setOptedIn(context, isChecked)
AirRobeSharedPreferenceManager.setOrderOptedIn(context, isChecked)
if (isChecked) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Opted in to AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Opted out of AirRobe", "Cart")
}
}
}
Expand All @@ -233,7 +233,7 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
dialog.isFromMultiOptIn = false
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dialog.show()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Pop up click", "Cart")
AirRobeAppUtils.telemetryEvent(context, "Pop up click", "Cart")
}
}

Expand Down Expand Up @@ -265,13 +265,13 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
AirRobeSharedPreferenceManager.setOrderOptedIn(context, false)
return
}
if (widgetInstance.shopModel == null || widgetInstance.categoryMapping.categoryMappingsHashmap.isNullOrEmpty()) {
if (widgetInstance.shopModel == null || widgetInstance.categoryMapping.categoryMappingsHashmap.isEmpty()) {
Log.e(TAG, "Category Mapping Info is not loaded")
visibility = GONE
AirRobeSharedPreferenceManager.setOrderOptedIn(context, false)
return
}
if (items.isNullOrEmpty()) {
if (items.isEmpty()) {
Log.e(TAG, "Required params can't be empty")
visibility = GONE
AirRobeSharedPreferenceManager.setOrderOptedIn(context, false)
Expand All @@ -282,7 +282,7 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
if (to != null) {
visibility = VISIBLE
AirRobeSharedPreferenceManager.setOrderOptedIn(context, AirRobeSharedPreferenceManager.getOptedIn(context))
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Cart")
AirRobeAppUtils.telemetryEvent(context, "pageview", "Cart")
} else {
visibility = GONE
AirRobeSharedPreferenceManager.setOrderOptedIn(context, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class AirRobeOptIn @JvmOverloads constructor(
tvDetailedDescription.visibility = VISIBLE
expandType = ExpandType.Opened
ivArrowDown.animate().rotation(180.0f).duration = 80
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Widget Expand Arrow Click", "Product")
AirRobeAppUtils.telemetryEvent(context, "Widget Expand Arrow Click", "Product")
}
}
setDetailedDescriptionText()
Expand All @@ -227,9 +227,9 @@ class AirRobeOptIn @JvmOverloads constructor(
optInSwitch.setOnCheckedChangeListener { _, isChecked ->
AirRobeSharedPreferenceManager.setOptedIn(context, isChecked)
if (isChecked) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Product")
AirRobeAppUtils.telemetryEvent(context, "Opted in to AirRobe", "Product")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Product")
AirRobeAppUtils.telemetryEvent(context, "Opted out of AirRobe", "Product")
}
}
tvPotentialValue.text = context.resources.getString(R.string.airrobe_potential_value_text)
Expand All @@ -249,7 +249,7 @@ class AirRobeOptIn @JvmOverloads constructor(
dialog.isFromMultiOptIn = false
dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
dialog.show()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Pop up click", "Product")
AirRobeAppUtils.telemetryEvent(context, "Pop up click", "Product")
}
}

Expand Down Expand Up @@ -315,7 +315,7 @@ class AirRobeOptIn @JvmOverloads constructor(
} else {
visibility = VISIBLE
checkIfPotentialValueTextCutOff()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Product")
AirRobeAppUtils.telemetryEvent(context, "pageview", "Product")
callPriceEngine(to)
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.7.0'
ext.kotlin_gradle_plugin_version = '1.6.20'
ext.kotlin_gradle_plugin_version = '1.6.21'

repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_gradle_plugin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -26,7 +26,7 @@ ext {
minSdkVersion = 21
compileSdkVersion = targetSdkVersion
appCompatLibVersion = '1.4.1'
materialLibVersion = '1.5.0'
materialLibVersion = '1.6.0'
constraintLayoutVersion = '2.1.3'
junitVersion = '4.13.2'
extjunitVersion = '1.1.3'
Expand Down
Binary file modified demo/libs/AirRobeWidget.aar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Dec 21 02:47:08 EST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME