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 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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.api_controllers.AirRobeTelemetryEventController
import com.airrobe.widgetsdk.airrobewidget.service.listeners.AirRobeGetShoppingDataListener
import com.airrobe.widgetsdk.airrobewidget.service.models.AirRobeGetShoppingDataModel
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeAppUtils
Expand Down Expand Up @@ -81,8 +82,16 @@ object AirRobeWidget {
getShoppingDataController.start(config.appId, config.mode)
}

fun telemetryEvent(context: Context, eventName: String, pageName: String) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can now call AirRobeWidget.telemetryEvent from outside sdk.

if (widgetInstance.configuration == null) {
return
}
val telemetryEventController = AirRobeTelemetryEventController()
telemetryEventController.start(context, widgetInstance.configuration!!, eventName, 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 @@ -19,14 +19,6 @@ internal object AirRobeAppUtils {
return Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}

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

fun touchAnimator(context: Context, v: View, event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.util.Log
import android.widget.ProgressBar
import android.widget.RelativeLayout
import android.widget.TextView
import com.airrobe.widgetsdk.airrobewidget.AirRobeWidget.telemetryEvent
import com.airrobe.widgetsdk.airrobewidget.R
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeConstants
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetInstance
Expand Down Expand Up @@ -149,7 +150,7 @@ class AirRobeConfirmation @JvmOverloads constructor(
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(AirRobeConstants.ORDER_ACTIVATE_BASE_URL + widgetInstance.configuration?.appId + "-" + orderId)
context.startActivity(intent)
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Claim link click", "Thank You")
telemetryEvent(context, "Claim link click", "Thank You")
}
true
}
Expand Down Expand Up @@ -188,7 +189,7 @@ class AirRobeConfirmation @JvmOverloads constructor(
visibility = VISIBLE
btnLoading.visibility = VISIBLE
btnLoading.animate()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Thank you")
telemetryEvent(context, "pageview", "Thank you")
emailCheck(email!!)
} else {
visibility = GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.Bundle
import android.text.method.LinkMovementMethod
import android.view.*
import android.widget.*
import com.airrobe.widgetsdk.airrobewidget.AirRobeWidget.telemetryEvent
import com.airrobe.widgetsdk.airrobewidget.R
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeAppUtils
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeSharedPreferenceManager
Expand Down Expand Up @@ -87,15 +88,15 @@ internal class AirRobeLearnMore(context: Context) : Dialog(context) {
}
if (isChecked) {
if (isFromMultiOptIn) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Cart")
telemetryEvent(context, "Opted in to AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Product")
telemetryEvent(context, "Opted in to AirRobe", "Product")
}
} else {
if (isFromMultiOptIn) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Cart")
telemetryEvent(context, "Opted out of AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Product")
telemetryEvent(context, "Opted out of AirRobe", "Product")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import android.text.TextPaint
import android.text.Spanned
import android.view.View
import android.widget.*
import com.airrobe.widgetsdk.airrobewidget.AirRobeWidget.telemetryEvent
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeAppUtils
import com.airrobe.widgetsdk.airrobewidget.utils.AirRobeSharedPreferenceManager

Expand Down Expand Up @@ -202,7 +203,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")
telemetryEvent(context, "Widget Expand Arrow Click", "Cart")
}
}
setDetailedDescriptionText()
Expand All @@ -212,9 +213,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")
telemetryEvent(context, "Opted in to AirRobe", "Cart")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Cart")
telemetryEvent(context, "Opted out of AirRobe", "Cart")
}
}
}
Expand All @@ -233,7 +234,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")
telemetryEvent(context, "Pop up click", "Cart")
}
}

Expand Down Expand Up @@ -265,13 +266,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 +283,7 @@ class AirRobeMultiOptIn @JvmOverloads constructor(
if (to != null) {
visibility = VISIBLE
AirRobeSharedPreferenceManager.setOrderOptedIn(context, AirRobeSharedPreferenceManager.getOptedIn(context))
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Cart")
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 @@ -15,6 +15,7 @@ import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.widget.*
import com.airrobe.widgetsdk.airrobewidget.AirRobeWidget.telemetryEvent
import com.airrobe.widgetsdk.airrobewidget.R
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeConstants
import com.airrobe.widgetsdk.airrobewidget.config.AirRobeWidgetInstance
Expand Down Expand Up @@ -218,7 +219,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")
telemetryEvent(context, "Widget Expand Arrow Click", "Product")
}
}
setDetailedDescriptionText()
Expand All @@ -227,9 +228,9 @@ class AirRobeOptIn @JvmOverloads constructor(
optInSwitch.setOnCheckedChangeListener { _, isChecked ->
AirRobeSharedPreferenceManager.setOptedIn(context, isChecked)
if (isChecked) {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted in to AirRobe", "Product")
telemetryEvent(context, "Opted in to AirRobe", "Product")
} else {
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "Opted out of AirRobe", "Product")
telemetryEvent(context, "Opted out of AirRobe", "Product")
}
}
tvPotentialValue.text = context.resources.getString(R.string.airrobe_potential_value_text)
Expand All @@ -249,7 +250,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")
telemetryEvent(context, "Pop up click", "Product")
}
}

Expand Down Expand Up @@ -315,7 +316,7 @@ class AirRobeOptIn @JvmOverloads constructor(
} else {
visibility = VISIBLE
checkIfPotentialValueTextCutOff()
AirRobeAppUtils.telemetryEvent(context, widgetInstance.configuration, "pageview", "Product")
telemetryEvent(context, "pageview", "Product")
callPriceEngine(to)
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ android {
}

dependencies {
implementation files("libs/AirRobeWidget.aar")
// implementation project(':AirRobeWidget')
// implementation files("libs/AirRobeWidget.aar")
implementation project(':AirRobeWidget')

implementation "androidx.core:core-ktx:$kotlin_version"
implementation "androidx.appcompat:appcompat:$rootProject.ext.appCompatLibVersion"
Expand Down