Skip to content

Commit

Permalink
Release 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cristidregan committed Nov 16, 2022
1 parent da2d36d commit 1d5b507
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 40 deletions.
2 changes: 1 addition & 1 deletion OmetriaSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.3.0"
versionName "1.4.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand Down
13 changes: 11 additions & 2 deletions OmetriaSDK/src/main/java/com/android/ometriasdk/core/Ometria.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,25 @@ class Ometria private constructor() : OmetriaNotificationInteractionHandler {
* Track when a user has added a product to their wishlist.
* @param productId The unique identifier of the product that has been added to the wishlist.
*/
@Deprecated(message = "The event is no longer sent to the Ometria backend. It will be removed in a future version")
fun trackWishlistAddedToEvent(productId: String) {
trackEvent(OmetriaEventType.WISH_LIST_ADDED_TO, mapOf(PRODUCT_ID to productId))
Logger.d(
Constants.Logger.EVENTS,
"The trackWishlistAddedToEvent event is no longer processed by Ometria. It will not produce any result."
)
}

/**
* Track when a user has removed a product to their wishlist.
* @param productId The unique identifier of the product that has been removed from the wishlist.
*/
@Deprecated(message = "The event is no longer sent to the Ometria backend. It will be removed in a future version")
@Suppress("replaceWith")
fun trackWishlistRemovedFromEvent(productId: String) {
trackEvent(OmetriaEventType.WISHLIST_REMOVED_FROM, mapOf(PRODUCT_ID to productId))
Logger.d(
Constants.Logger.EVENTS,
"The trackWishlistRemovedFromEvent event is no longer processed by Ometria. It will not produce any result."
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package com.android.ometriasdk.core.event
/**
* An object that describes the contents of a shopping basket.
*
* @param id A unique identifier for this basket.
* @param totalPrice A float value representing the pricing.
* @param currency A string representing the currency in ISO currency format. e.g. "USD", "GBP"
* @param items (List[OmetriaBasketItem]) An array containing the item entries in this basket.
Expand All @@ -16,6 +17,7 @@ package com.android.ometriasdk.core.event
* Following that link should take them straight to the basket page.
*/
data class OmetriaBasket(
val id: String? = null,
val totalPrice: Float,
val currency: String,
val items: List<OmetriaBasketItem> = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ package com.android.ometriasdk.core.event
* @param productId A string representing the unique identifier of this product.
* @param sku A string representing the stock keeping unit, which allows identifying a particular item.
* @param quantity The number of items that this entry represents.
* @param price Float value representing the price for one item. The currency is established by the [OmetriaBasket] containing this item
* @param price Float value representing the price for one item. The currency is established by the [OmetriaBasket] containing this item.
* @param variantId An identifier for a variant product associated with this line item.
*/
data class OmetriaBasketItem(
val productId: String,
val sku: String? = null,
val quantity: Int,
val price: Float
val price: Float,
val variantId: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ internal enum class OmetriaEventType(var id: String) {
// Product related events
PRODUCT_VIEWED("productViewed"),
PRODUCT_LISTING_VIEWED("productListingViewed"),
WISH_LIST_ADDED_TO("wishlistAddedTo"),
WISHLIST_REMOVED_FROM("wishlistRemovedFrom"),
BASKET_VIEWED("basketViewed"),
BASKET_UPDATED("basketUpdated"),
CHECKOUT_STARTED("checkoutStarted"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal fun String.toOmetriaEvent(): OmetriaEvent {
var sdkVersionRN: String? = null
try {
sdkVersionRN = jsonObject.getString("sdkVersionRN")
} catch (e: JSONException) {
} catch (_: JSONException) {
}

ometriaEvent.sdkVersionRN = sdkVersionRN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal fun OmetriaBasket.toJson(): JSONObject {
jsonObject.put("totalPrice", totalPrice)
jsonObject.put("currency", currency)
jsonObject.put("link", link)
jsonObject.put("id", id)

val jsonArray = JSONArray()

Expand All @@ -77,6 +78,7 @@ internal fun OmetriaBasketItem.toJson(): JSONObject {
jsonObject.put("sku", sku)
jsonObject.put("quantity", quantity)
jsonObject.put("price", price)
jsonObject.put("variantId", variantId)

return jsonObject
}
Expand Down
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To install the library inside **Android Studio**, declare it as dependency in yo

```gradle
dependencies {
implementation 'com.ometria:android-sdk:1.3.0'
implementation 'com.ometria:android-sdk:1.4.0'
}
```

Expand Down Expand Up @@ -99,9 +99,17 @@ val myItem = OmetriaBasketItem(
productId = "product-1",
sku = "sku-product-1",
quantity = 1,
price = 12.0f)
price = 12.0f,
variantId = "variant-id-1"
)
val myItems = listOf(myItem)
val basket = OmetriaBasket(totalPrice = 12.0f, currency = "USD", items = myItems, link = "www.example.com")
val basket = OmetriaBasket(
id = "id-1",
totalPrice = 12.0f,
currency = "USD",
items = myItems,
link = "www.example.com"
)

Ometria.instance().trackBasketUpdatedEvent(basket = basket)
```
Expand Down Expand Up @@ -157,20 +165,6 @@ The value is opaque, and is only used to create segments and automation campaign

Use non-localised, predictable, human readable slugs. E.g. "womens-footwear".

#### Wishlist events

The user has added this product to their wishlist:

```kotlin
trackWishlistAddedToEvent(productId: String)
```

... or removed it:

```kotlin
trackWishlistRemovedFromEvent(productId: String)
```

#### Basket viewed

The user has viewed a dedicated page, screen or modal with the contents of the shopping basket.
Expand Down Expand Up @@ -234,9 +228,9 @@ E.g., A store sells clothing, and the visitor taps on "Women's Footwear" to see

This event should be triggered on:

⋅⋅* search results
⋅⋅* category lists
⋅⋅* any similar screens
* search results
* category lists
* any similar screens

```kotlin
trackProductListingViewedEvent(listingType: String? = null, listingAttributes: Map<String, Any> = mapOf())
Expand Down Expand Up @@ -285,10 +279,11 @@ An object that describes the contents of a shopping basket.

#### Properties

* `id`: (`String`, optional) - A unique identifier for this basket.
* `currency`: (`String`, required) - A string representing the currency in ISO currency format. e.g. `"USD"`, `"GBP"`.
* `price`: (`float`, required) - A float value representing the pricing.
* `totalPrice`: (`float`, required) - A float value representing the pricing.
* `items`: (`Array[OmetriaBasketItem]`) - An array containing the item entries in this basket.
* `link`: (`String`) - A deeplink to the web or in-app page for this basket. Can be used ina notification sent to the user, e.g. "Forgot to check out? Here's
* `link`: (`String`, optional) - A deeplink to the web or in-app page for this basket. Can be used ina notification sent to the user, e.g. "Forgot to check out? Here's
your basket to continue: <link>". Following that link should take them straight to the basket page.

### `OmetriaBasketItem`
Expand All @@ -303,6 +298,7 @@ It can have its own price and quantity based on different rules and promotions t
* `sku`: (`String`, optional) - A string representing the stock keeping unit, which allows identifying a particular item.
* `quantity`: (`Int`, required) - The number of items that this entry represents.
* `price`: (`Float`, required) - Float value representing the price for one item. The currency is established by the OmetriaBasket containing this item.
* `variantId`: (`String`, optional) - An identifier for a variant product associated with this line item.

### Automatically tracked events

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.android.sample"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0.0"
versionCode 3
versionName "1.0.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/com/android/sample/data/EventType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ enum class EventType {
PROFILE_DEIDENTIFIED,
PRODUCT_VIEWED,
PRODUCT_LISTING_VIEWED,
WISH_LIST_ADDED_TO,
WISHLIST_REMOVED_FROM,
BASKET_VIEWED,
BASKET_UPDATED,
CHECKOUT_STARTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class HomeFragment : Fragment() {
binding.customerIdET.isVisible = screenPosition == TAB_ONE
binding.loginWithCustomerIdBTN.isVisible = screenPosition == TAB_ONE

binding.titleTV.isVisible = screenPosition == TAB_ONE && !ometriaNotificationString.isNullOrEmpty()
binding.titleTV.isVisible =
screenPosition == TAB_ONE && !ometriaNotificationString.isNullOrEmpty()
binding.detailsTV.isVisible =
screenPosition == TAB_ONE && !ometriaNotificationString.isNullOrEmpty()
binding.detailsTV.text = ometriaNotificationString
Expand Down Expand Up @@ -127,10 +128,6 @@ class HomeFragment : Fragment() {
"search",
mapOf("searchQuery" to "some search terms")
)
EventType.WISH_LIST_ADDED_TO -> Ometria.instance()
.trackWishlistAddedToEvent("product_1")
EventType.WISHLIST_REMOVED_FROM -> Ometria.instance()
.trackWishlistRemovedFromEvent("product_1")
EventType.BASKET_VIEWED -> Ometria.instance()
.trackBasketViewedEvent()
EventType.BASKET_UPDATED -> Ometria.instance()
Expand All @@ -156,11 +153,13 @@ class HomeFragment : Fragment() {
productId = "product-1",
sku = "sku-product-1",
quantity = 1,
price = 12.0f
price = 12.0f,
variantId = "variant-id-1"
)
val myItems = listOf(myItem)

return OmetriaBasket(
id = "id-1",
totalPrice = 12.0f,
currency = "USD",
items = myItems,
Expand Down

0 comments on commit 1d5b507

Please sign in to comment.