Events tracking
Every event extends abstract class Event : PredefinedParameter (attribution/src/main/java/com/affise/attribution/events/Event.kt:18). Predefined event classes extend NativeEvent (attribution/src/main/java/com/affise/attribution/events/NativeEvent.kt:9-12, category "native") and carry a name from the EventName enum (attribution/src/main/java/com/affise/attribution/events/EventName.kt:3-69).
Send events
Section titled “Send events”Every predefined event class has a @JvmOverloads constructor constructor(userData: String? = null, timeStampMillis: Long = timestamp()).
class Presenter { fun onUserAddsItemsToCart(userData: String) { AddToCartEvent(userData) .send() // Send event }}class Presenter { void onUserAddsItemsToCart(String userData) { new AddToCartEvent(userData) .send(); // Send event }}send vs sendNow
Section titled “send vs sendNow”Two dispatch APIs are defined on Event:
fun send()— stores + schedules (Event.kt:136-138).fun sendNow(success: OnSendSuccessCallback, failed: OnSendFailedCallback)— no retry if failed (Event.kt:143-145).
Callbacks:
fun interface OnSendSuccessCallback { fun handle() }(OnSendSuccessCallback.kt:3-5)fun interface OnSendFailedCallback { fun handle(status: HttpResponse) }(OnSendFailedCallback.kt:5-7)
AddToCartEvent() .send()AddToCartEvent() .sendNow({ // handle event send success }) { errorResponse -> // handle event send failed // Warning: event is NOT cached for later send }Predefined event classes
Section titled “Predefined event classes”All at attribution/src/main/java/com/affise/attribution/events/predefined/ unless noted. Each class extends NativeEvent.
Common / commerce / content
Section titled “Common / commerce / content”AchieveLevelEvent, AddPaymentInfoEvent, AddToCartEvent, AddToWishlistEvent, AdRevenueEvent, ClickAdvEvent, CompleteRegistrationEvent, CompleteStreamEvent, CompleteTrialEvent, CompleteTutorialEvent, ContactEvent, ContentItemsViewEvent, CustomizeProductEvent, DeepLinkedEvent, DonateEvent, FindLocationEvent, InitiateCheckoutEvent, InitiatePurchaseEvent, InitiateStreamEvent, InviteEvent, LastAttributedTouchEvent, LeadEvent, ListViewEvent, LoginEvent, OpenedFromPushNotificationEvent.
Orders
Section titled “Orders”OrderEvent, OrderItemAddedEvent, OrderItemRemoveEvent, OrderCancelEvent, OrderReturnRequestEvent, OrderReturnRequestCancelEvent.
Purchase / engagement
Section titled “Purchase / engagement”PurchaseEvent, FailedPurchaseEvent, RateEvent, ReEngageEvent, ReserveEvent, SalesEvent, ScheduleEvent, SearchEvent, ShareEvent, SpendCreditsEvent, StartRegistrationEvent, StartTrialEvent, StartTutorialEvent, SubmitApplicationEvent, SubscribeEvent, TravelBookingEvent, UnlockAchievementEvent, UnsubscribeEvent, UpdateEvent, ViewAdvEvent, ViewCartEvent, ViewContentEvent, ViewItemEvent, ViewItemsEvent.
Full list + file:line source refs: see README and the events/predefined/ package.
Subscription lifecycle events
Section titled “Subscription lifecycle events”Under attribution/src/main/java/com/affise/attribution/events/subscription/:
InitialSubscriptionEvent—subscription/SubscriptionActivation.kt:8InitialTrialEvent—subscription/SubscriptionActivation.kt:27InitialOfferEvent—subscription/SubscriptionActivation.kt:46ConvertedTrialEvent—subscription/SubscriptionFirstConversion.kt:8ConvertedOfferEvent—subscription/SubscriptionFirstConversion.kt:27TrialInRetryEvent—subscription/SubscriptionEnteredBillingRetry.kt:8OfferInRetryEvent—subscription/SubscriptionEnteredBillingRetry.kt:27SubscriptionInRetryEvent—subscription/SubscriptionEnteredBillingRetry.kt:46RenewedSubscriptionEvent—subscription/SubscriptionRenewal.kt:8FailedSubscriptionFromRetryEvent—subscription/SubscriptionCancellation.kt:103FailedOfferFromRetryEvent—subscription/SubscriptionCancellation.kt:84FailedTrialFromRetryEvent—subscription/SubscriptionCancellation.kt:65FailedSubscriptionEvent—subscription/SubscriptionCancellation.kt:46FailedOfferiseEvent—subscription/SubscriptionCancellation.kt:27FailedTrialEvent—subscription/SubscriptionCancellation.kt:8ReactivatedSubscriptionEvent—subscription/SubscriptionReactivation.kt:8RenewedSubscriptionFromRetryEvent—subscription/SubscriptionRenewalFromBillingRetry.kt:46ConvertedOfferFromRetryEvent—subscription/SubscriptionRenewalFromBillingRetry.kt:27ConvertedTrialFromRetryEvent—subscription/SubscriptionRenewalFromBillingRetry.kt:8UnsubscriptionEvent—subscription/Unsubscription.kt:8
Custom events
Section titled “Custom events”CustomId01 through CustomId10
Section titled “CustomId01 through CustomId10”Classes CustomId01Event…CustomId10Event live under events/predefined/ and are bound to EventName.CUSTOM_ID_01..10 (EventName.kt:16-25).
UserCustomEvent
Section titled “UserCustomEvent”class UserCustomEvent( eventName: String, userData: String? = null, timeStampMillis: Long = timestamp(), category: String? = null,) : NativeEvent(...)(attribution/src/main/java/com/affise/attribution/events/custom/UserCustomEvent.kt:13-24)
UserCustomEvent("MyCustomNameEvent") .addPredefinedParameter(PredefinedString.DESCRIPTION, "best before 2029") .addPredefinedParameter(PredefinedObject.CONTENT, JSONObject().apply { put("collection", "Greatest Hits") }) .send() // Send eventPredefined event parameters
Section titled “Predefined event parameters”Events accept additional typed parameters via Event.addPredefinedParameter(...) overloads (Event.kt:72-115). Base interface chain: PredefinedParameter : PredefinedSimple (attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedParameter.kt:6).
class Presenter { fun onUserAddsItemsToCart(userData: String) { AddToCartEvent(userData) .addPredefinedParameter(PredefinedString.DESCRIPTION, "best before 2029") .addPredefinedParameter(PredefinedObject.CONTENT, JSONObject().apply { put("collection", "Greatest Hits") }) .addPredefinedParameter(PredefinedListObject.CONTENT_LIST, listOf( JSONObject().apply { put("content", "songs, videos") } )) .send() // Send event }}class Presenter { void onUserAddsItemsToCart(String userData) { JSONObject json = new JSONObject() .put("collection", "Greatest Hits");
JSONObject jsonContent = new JSONObject() .put("content", "songs, videos");
List<JSONObject> jsonList = Collections.singletonList(jsonContent);
new AddToCartEvent(userData, System.currentTimeMillis()) .addPredefinedParameter(PredefinedString.DESCRIPTION, "best before 2029") .addPredefinedParameter(PredefinedFloat.PRICE, 2.19f) .addPredefinedParameter(PredefinedObject.CONTENT, json) .addPredefinedParameter(PredefinedListObject.CONTENT_LIST, jsonList) .send(); // Send event }}PredefinedString
Section titled “PredefinedString”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedString.kt:8-80.
ACHIEVEMENT_ID, ADREV_AD_TYPE, BRAND, BRICK, CAMPAIGN_ID, CATALOGUE_ID, CHANNEL_TYPE, CITY, CLASS, CLICK_ID, CONTENT_ID, CONTENT_NAME, CONTENT_TYPE, CONVERSION_ID, COUNTRY, COUPON_CODE, CURRENCY, CUSTOMER_SEGMENT, CUSTOMER_TYPE, CUSTOMER_USER_ID, DEEP_LINK, DESCRIPTION, DESTINATION_A, DESTINATION_B, DESTINATION_LIST, EVENT_NAME, NEW_VERSION, NETWORK, OLD_VERSION, ORDER_ID, ORIGINAL_ORDER_ID, PARAM_01…PARAM_10, PAYMENT_INFO_AVAILABLE, PID, PLACEMENT, PREFERRED_NEIGHBORHOODS, PRODUCT_ID, PRODUCT_NAME, PRODUCT_TYPE, PURCHASE_CURRENCY, RECEIPT_ID, REGION, REGISTRATION_METHOD, REVIEW_TEXT, SEARCH_STRING, SEGMENT, SOURCE, STATUS, SUBSCRIPTION_ID, SUBSCRIPTION_TYPE, SUCCESS, SUGGESTED_DESTINATIONS, SUGGESTED_HOTELS, TUTORIAL_ID, UNIT, UTM_CAMPAIGN, UTM_MEDIUM, UTM_SOURCE, VALIDATED, VERTICAL, VIRTUAL_CURRENCY_NAME, VOUCHER_CODE.
PredefinedLong
Section titled “PredefinedLong”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedLong.kt:8-31.
AMOUNT, DATE_A, DATE_B, DEPARTING_ARRIVAL_DATE, DEPARTING_DEPARTURE_DATE, HOTEL_SCORE, LEVEL, MAX_RATING_VALUE, NUM_ADULTS, NUM_CHILDREN, NUM_INFANTS, PREFERRED_NUM_STOPS, PREFERRED_STAR_RATINGS, QUANTITY, RATING_VALUE, RETURNING_ARRIVAL_DATE, RETURNING_DEPARTURE_DATE, SCORE, TRAVEL_START, TRAVEL_END, USER_SCORE, EVENT_START, EVENT_END.
PredefinedFloat
Section titled “PredefinedFloat”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedFloat.kt:8-13.
PREFERRED_PRICE_RANGE, PRICE, REVENUE, LAT, LONG.
PredefinedObject
Section titled “PredefinedObject”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedObject.kt:8-9 — single value CONTENT.
PredefinedListObject
Section titled “PredefinedListObject”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedListObject.kt:8-9 — single value CONTENT_LIST.
PredefinedListString
Section titled “PredefinedListString”attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedListString.kt:8-9 — single value CONTENT_IDS.
ConversionId helper
Section titled “ConversionId helper”Event.customPredefined(): PredefinedCustom (Event.kt:162-164) exposes PredefinedCustom.conversionId(orderId: String, productId: String): String (attribution/src/main/java/com/affise/attribution/events/parameters/PredefinedCustom.kt:7-13). It sets PredefinedString.ORDER_ID, PredefinedString.PRODUCT_ID, and PredefinedString.CONVERSION_ID (as "${orderId}_${productId}").
val event = AddToCartEvent()
val conversionId = event.customPredefined().conversionId("ORDER_ID", "PRODUCT_ID")
event.send() // Send eventEvents buffering
Section titled “Events buffering”Affise library will send any pending events with first opportunity, but if there is no network connection or device is disabled, events are kept locally for 7 days before deletion.
There is no direct public API to tune this buffering window.