Events tracking
Every event in the Affise Flutter plugin is a subclass of NativeEvent (lib/events/native_event.dart:6-40), which extends Event (lib/events/event.dart:6-101). All constructors accept {String? userData, int? timeStampMillis} (lib/events/native_event.dart:10-14).
Send control — send() vs sendNow(...)
Section titled “Send control — send() vs sendNow(...)”AddToCartEvent() .send();AddToCartEvent() .sendNow(() { // handle event send success }, (status) { // handle event send failed // 🟥Warning🟥: event is NOT cached for later send });Public Dart APIs on Event:
void send(); // lib/events/event.dart:86void sendNow(OnSendSuccessCallback success, OnSendFailedCallback failed); // :91Event.send() calls Affise.sendEvent(this) (lib/events/event.dart:87); sendNow() calls Affise.sendEventNow(...) (:92). Both top-level shims wrap the call in SchedulerBinding.instance.addPostFrameCallback:
static void sendEvent(Event event); // lib/affise.dart:21static void sendEventNow(Event event, OnSendSuccessCallback success, OnSendFailedCallback failed); // :28Callback typedefs:
typedef OnSendSuccessCallback = void Function();(lib/events/on_send_success_callback.dart:1)typedef OnSendFailedCallback = void Function(HttpResponse status);(lib/events/on_send_failed_callback.dart:3)class HttpResponse { int code; String message; String? body; }(lib/network/http_response.dart:1-12)
Quick example
Section titled “Quick example”import 'package:affise_attribution_lib/affise.dart';
class Presenter { void onUserAddsItemsToCart(String item) { Map<String, dynamic> items = { "items": "cookies, potato, milk", };
AddToCartEvent(userData: "groceries") .addPredefinedObject(PredefinedObject.CONTENT, items) .send(); // Send event }}Predefined events
Section titled “Predefined events”All event classes live under lib/events/predefined/. Each is a NativeEvent subclass whose getName() returns an EventName value from lib/events/event_name.dart.
| Dart class | File:line | Event name |
|---|---|---|
| AchieveLevelEvent | achieve_level_event.dart:8 | AchieveLevel |
| AddPaymentInfoEvent | add_payment_info_event.dart:8 | AddPaymentInfo |
| AddToCartEvent | add_to_cart_event.dart:8 | AddToCart |
| AddToWishlistEvent | add_to_wishlist_event.dart:8 | AddToWishlist |
| AdRevenueEvent | ad_revenue_event.dart:8 | AdRevenue |
| ClickAdvEvent | click_adv_event.dart:8 | ClickAdv |
| CompleteRegistrationEvent | complete_registration_event.dart:9 | CompleteRegistration |
| CompleteStreamEvent | complete_stream_event.dart:8 | CompleteStream |
| CompleteTrialEvent | complete_trial_event.dart:8 | CompleteTrial |
| CompleteTutorialEvent | complete_tutorial_event.dart:8 | CompleteTutorial |
| ContactEvent | contact_event.dart:8 | Contact |
| ContentItemsViewEvent | content_items_view_event.dart:8 | ContentItemsView |
| CustomizeProductEvent | customize_product_event.dart:8 | CustomizeProduct |
| DeepLinkedEvent | deep_linked_event.dart:8 | DeepLinked |
| DonateEvent | donate_event.dart:8 | Donate |
| FindLocationEvent | find_location_event.dart:8 | FindLocation |
| InitiateCheckoutEvent | initiate_checkout_event.dart:8 | InitiateCheckout |
| InitiatePurchaseEvent | initiate_purchase_event.dart:8 | InitiatePurchase |
| InitiateStreamEvent | initiate_stream_event.dart:8 | InitiateStream |
| InviteEvent | invite_event.dart:8 | Invite |
| LastAttributedTouchEvent | last_attributed_touch_event.dart:9 | LastAttributedTouch |
| LeadEvent | lead_event.dart:8 | Lead |
| ListViewEvent | list_view_event.dart:8 | ListView |
| LoginEvent | login_event.dart:8 | Login |
| OpenedFromPushNotificationEvent | opened_from_push_notification_event.dart:8 | OpenedFromPushNotification |
| OrderEvent | order_event.dart:8 | Order |
| OrderItemAddedEvent | order_item_added_event.dart:8 | OrderItemAdded |
| OrderItemRemoveEvent | order_item_remove_event.dart:8 | OrderItemRemove |
| OrderCancelEvent | order_cancel_event.dart:8 | OrderCancel |
| OrderReturnRequestEvent | order_return_request_event.dart:8 | OrderReturnRequest |
| OrderReturnRequestCancelEvent | order_return_request_cancel_event.dart:8 | OrderReturnRequestCancel |
| PurchaseEvent | purchase_event.dart:8 | Purchase |
| RateEvent | rate_event.dart:8 | Rate |
| ReEngageEvent | re_engage_event.dart:8 | ReEngage |
| ReserveEvent | reserve_event.dart:8 | Reserve |
| SalesEvent | sales_event.dart:8 | Sales |
| ScheduleEvent | schedule_event.dart:8 | Schedule |
| SearchEvent | search_event.dart:8 | Search |
| ShareEvent | share_event.dart:8 | Share |
| SpendCreditsEvent | spend_credits_event.dart:8 | SpendCredits |
| StartRegistrationEvent | start_registration_event.dart:8 | StartRegistration |
| StartTrialEvent | start_trial_event.dart:8 | StartTrial |
| StartTutorialEvent | start_tutorial_event.dart:8 | StartTutorial |
| SubmitApplicationEvent | submit_application_event.dart:8 | SubmitApplication |
| SubscribeEvent | subscribe_event.dart:8 | Subscribe |
| TravelBookingEvent | travel_booking_event.dart:8 | TravelBooking |
| UnlockAchievementEvent | unlock_achievement_event.dart:8 | UnlockAchievement |
| UnsubscribeEvent | unsubscribe_event.dart:8 | Unsubscribe |
| UpdateEvent | update_event.dart:9 | Update |
| ViewAdvEvent | view_adv_event.dart:9 | ViewAdv |
| ViewCartEvent | view_cart_event.dart:8 | ViewCart |
| ViewContentEvent | view_content_event.dart:8 | ViewContent |
| ViewItemEvent | view_item_event.dart:8 | ViewItem |
| ViewItemsEvent | view_items_event.dart:8 | ViewItems |
Custom events
Section titled “Custom events”CustomId01Event..CustomId10Event
Section titled “CustomId01Event..CustomId10Event”Ten prebuilt slots at lib/events/predefined/custom_id_01_event.dart:8 … custom_id_10_event.dart:8. They extend NativeEvent with event names CustomId01..CustomId10.
UserCustomEvent
Section titled “UserCustomEvent”Use when you need to supply the event name at runtime. Defined at lib/events/custom/user_custom_event.dart:7-21:
class UserCustomEvent extends NativeEvent { final String eventName; UserCustomEvent({ required this.eventName, super.userData, super.timeStampMillis }); @override String getName() => eventName;}UserCustomEvent(eventName: "MyCustomEvent") .send();UserCustomSubscriptionEvent
Section titled “UserCustomSubscriptionEvent”Freely-typed subscription event. Defined at lib/events/custom/user_custom_subscription_event.dart:3-18:
class UserCustomSubscriptionEvent extends BaseSubscriptionEvent { @override String type; @override String subtype; UserCustomSubscriptionEvent({ required this.type, required this.subtype, required super.data, super.userData, });}Subscription events
Section titled “Subscription events”All extend BaseSubscriptionEvent (lib/events/subscription/base_subscription_event.dart:5-35) and are exported via subscription_events.dart.
| Dart class | File:line | SubscriptionEventName | SubscriptionSubType |
|---|---|---|---|
| InitialSubscriptionEvent | subscription_activation.dart:6 | AFFISE_SUBSCRIPTION_ACTIVATION | AFFISE_SUB_INITIAL_SUBSCRIPTION |
| InitialTrialEvent | subscription_activation.dart:23 | AFFISE_SUBSCRIPTION_ACTIVATION | AFFISE_SUB_INITIAL_TRIAL |
| InitialOfferEvent | subscription_activation.dart:41 | AFFISE_SUBSCRIPTION_ACTIVATION | AFFISE_SUB_INITIAL_OFFER |
| FailedTrialEvent | subscription_cancellation.dart:6 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_TRIAL |
| FailedOfferiseEvent | subscription_cancellation.dart:22 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_OFFERISE |
| FailedSubscriptionEvent | subscription_cancellation.dart:38 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_SUBSCRIPTION |
| FailedTrialFromRetryEvent | subscription_cancellation.dart:54 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_TRIAL_FROM_RETRY |
| FailedOfferFromRetryEvent | subscription_cancellation.dart:70 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_OFFER_FROM_RETRY |
| FailedSubscriptionFromRetryEvent | subscription_cancellation.dart:86 | AFFISE_SUBSCRIPTION_CANCELLATION | AFFISE_SUB_FAILED_SUBSCRIPTION_FROM_RETRY |
| TrialInRetryEvent | subscription_entered_billing_retry.dart:6 | AFFISE_SUBSCRIPTION_ENTERED_BILLING_RETRY | AFFISE_SUB_TRIAL_IN_RETRY |
| OfferInRetryEvent | subscription_entered_billing_retry.dart:22 | same | AFFISE_SUB_OFFER_IN_RETRY |
| SubscriptionInRetryEvent | subscription_entered_billing_retry.dart:38 | same | AFFISE_SUB_SUBSCRIPTION_IN_RETRY |
| ConvertedTrialEvent | subscription_first_conversion.dart:6 | AFFISE_SUBSCRIPTION_FIRST_CONVERSION | AFFISE_SUB_CONVERTED_TRIAL |
| ConvertedOfferEvent | subscription_first_conversion.dart:22 | same | AFFISE_SUB_CONVERTED_OFFER |
| ReactivatedSubscriptionEvent | subscription_reactivation.dart:6 | AFFISE_SUBSCRIPTION_REACTIVATION | AFFISE_SUB_REACTIVATED_SUBSCRIPTION |
| RenewedSubscriptionEvent | subscription_renewal.dart:6 | AFFISE_SUBSCRIPTION_RENEWAL | AFFISE_SUB_RENEWED_SUBSCRIPTION |
| ConvertedTrialFromRetryEvent | subscription_renewal_from_billing_retry.dart:6 | AFFISE_SUBSCRIPTION_RENEWAL_FROM_BILLING_RETRY | AFFISE_SUB_CONVERTED_TRIAL_FROM_RETRY |
| ConvertedOfferFromRetryEvent | subscription_renewal_from_billing_retry.dart:22 | same | AFFISE_SUB_CONVERTED_OFFER_FROM_RETRY |
| RenewedSubscriptionFromRetryEvent | subscription_renewal_from_billing_retry.dart:38 | same | AFFISE_SUB_RENEWED_SUBSCRIPTION_FROM_RETRY |
| UnsubscriptionEvent | unsubscription.dart:6 | AFFISE_UNSUBSCRIPTION | AFFISE_SUB_UNSUBSCRIPTION |
Predefined parameters
Section titled “Predefined parameters”All parameter keys are prefixed with "affise_p_" — class Predefined { static const String PREFIX = "affise_p_"; } (lib/events/parameters/predefined.dart:1-3).
Methods on Event that attach typed parameters (lib/events/event.dart):
| Method | Signature | Line |
|---|---|---|
| addPredefinedFloat | Event addPredefinedFloat(PredefinedFloat parameter, double value) | :36 |
| addPredefinedListObject | Event addPredefinedListObject(PredefinedListObject parameter, List<Map<String, dynamic>> value) | :42 |
| addPredefinedListString | Event addPredefinedListString(PredefinedListString parameter, List<String> value) | :48 |
| addPredefinedLong | Event addPredefinedLong(PredefinedLong parameter, int value) | :54 |
| addPredefinedObject | Event addPredefinedObject(PredefinedObject parameter, Map<String, dynamic> value) | :60 |
| addPredefinedString | Event addPredefinedString(PredefinedString parameter, String value) | :66 |
import 'package:affise_attribution_lib/affise.dart';
class Presenter { void onUserAddsItemsToCart(String item) { Map<String, dynamic> items = { "items": "cookies, potato, milk", };
AddToCartEvent( timeStampMillis: DateTime.now().millisecondsSinceEpoch, ) .addPredefinedString(PredefinedString.DESCRIPTION, "best before 2029") .addPredefinedObject(PredefinedObject.CONTENT, items) .send(); // Send event }}PredefinedString
Section titled “PredefinedString”Declared at lib/events/parameters/predefined_string.dart:3-72.
| Enum | Native key |
|---|---|
| ADREV_AD_TYPE | "adrev_ad_type" |
| CITY | "city" |
| COUNTRY | "country" |
| REGION | "region" |
| CLASS | "class" |
| CONTENT_ID | "content_id" |
| CONTENT_TYPE | "content_type" |
| CURRENCY | "currency" |
| CUSTOMER_USER_ID | "customer_user_id" |
| DESCRIPTION | "description" |
| DESTINATION_A | "destination_a" |
| DESTINATION_B | "destination_b" |
| DESTINATION_LIST | "destination_list" |
| ORDER_ID | "order_id" |
| PAYMENT_INFO_AVAILABLE | "payment_info_available" |
| PREFERRED_NEIGHBORHOODS | "preferred_neighborhoods" |
| PURCHASE_CURRENCY | "purchase_currency" |
| RECEIPT_ID | "receipt_id" |
| REGISTRATION_METHOD | "registration_method" |
| SEARCH_STRING | "search_string" |
| SUBSCRIPTION_ID | "subscription_id" |
| SUCCESS | "success" |
| SUGGESTED_DESTINATIONS | "suggested_destinations" |
| SUGGESTED_HOTELS | "suggested_hotels" |
| VALIDATED | "validated" |
| ACHIEVEMENT_ID | "achievement_id" |
| COUPON_CODE | "coupon_code" |
| CUSTOMER_SEGMENT | "customer_segment" |
| DEEP_LINK | "deep_link" |
| NEW_VERSION | "new_version" |
| OLD_VERSION | "old_version" |
| PARAM_01..PARAM_10 | "param_01".."param_10" |
| REVIEW_TEXT | "review_text" |
| TUTORIAL_ID | "tutorial_id" |
| VIRTUAL_CURRENCY_NAME | "virtual_currency_name" |
| STATUS | "status" |
| BRAND | "brand" |
| BRICK | "brick" |
| CATALOGUE_ID | "catalogue_id" |
| CHANNEL_TYPE | "channel_type" |
| CUSTOMER_TYPE | "customer_type" |
| SEGMENT | "segment" |
| UTM_CAMPAIGN | "utm_campaign" |
| UTM_MEDIUM | "utm_medium" |
| UTM_SOURCE | "utm_source" |
| VERTICAL | "vertical" |
| VOUCHER_CODE | "voucher_code" |
| CLICK_ID | "click_id" |
| CAMPAIGN_ID | "campaign_id" |
| EVENT_NAME | "event_name" |
| PID | "pid" |
| PRODUCT_ID | "product_id" |
| CONVERSION_ID | "conversion_id" |
| CONTENT_NAME | "content_name" |
| PRODUCT_NAME | "product_name" |
| SOURCE | "source" |
| NETWORK | "network" |
| UNIT | "unit" |
| PLACEMENT | "placement" |
PredefinedLong
Section titled “PredefinedLong”Declared at lib/events/parameters/predefined_long.dart:3-27.
| Enum | Native key |
|---|---|
| AMOUNT | "amount" |
| DATE_A | "date_a" |
| DATE_B | "date_b" |
| DEPARTING_ARRIVAL_DATE | "departing_arrival_date" |
| DEPARTING_DEPARTURE_DATE | "departing_departure_date" |
| HOTEL_SCORE | "hotel_score" |
| LEVEL | "level" |
| MAX_RATING_VALUE | "max_rating_value" |
| NUM_ADULTS | "num_adults" |
| NUM_CHILDREN | "num_children" |
| NUM_INFANTS | "num_infants" |
| PREFERRED_NUM_STOPS | "preferred_num_stops" |
| PREFERRED_STAR_RATINGS | "preferred_star_ratings" |
| QUANTITY | "quantity" |
| RATING_VALUE | "rating_value" |
| RETURNING_ARRIVAL_DATE | "returning_arrival_date" |
| RETURNING_DEPARTURE_DATE | "returning_departure_date" |
| SCORE | "score" |
| TRAVEL_START | "travel_start" |
| TRAVEL_END | "travel_end" |
| USER_SCORE | "user_score" |
| EVENT_START | "event_start" |
| EVENT_END | "event_end" |
PredefinedFloat
Section titled “PredefinedFloat”Declared at lib/events/parameters/predefined_float.dart:6-12.
| Enum | Native key |
|---|---|
| PREFERRED_PRICE_RANGE | "preferred_price_range" |
| PRICE | "price" |
| REVENUE | "revenue" |
| LAT | "lat" |
| LONG | "long" |
PredefinedObject
Section titled “PredefinedObject”Declared at lib/events/parameters/predefined_object.dart:3-5.
| Enum | Native key |
|---|---|
| CONTENT | "content" |
PredefinedListObject
Section titled “PredefinedListObject”Declared at lib/events/parameters/predefined_list_object.dart:6-8.
| Enum | Native key |
|---|---|
| CONTENT_LIST | "content_list" |
PredefinedListString
Section titled “PredefinedListString”Declared at lib/events/parameters/predefined_list_string.dart:6-8.
| Enum | Native key |
|---|---|
| CONTENT_IDS | "content_ids" |
Events 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.”
README 1119-1122
Retention is enforced by the underlying native SDKs; no Dart-side tuning is exposed.