Перейти к содержимому

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).

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:86
void sendNow(OnSendSuccessCallback success, OnSendFailedCallback failed); // :91

Event.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:21
static void sendEventNow(Event event, OnSendSuccessCallback success, OnSendFailedCallback failed); // :28

Callback 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)
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
}
}

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 classFile:lineEvent name
AchieveLevelEventachieve_level_event.dart:8AchieveLevel
AddPaymentInfoEventadd_payment_info_event.dart:8AddPaymentInfo
AddToCartEventadd_to_cart_event.dart:8AddToCart
AddToWishlistEventadd_to_wishlist_event.dart:8AddToWishlist
AdRevenueEventad_revenue_event.dart:8AdRevenue
ClickAdvEventclick_adv_event.dart:8ClickAdv
CompleteRegistrationEventcomplete_registration_event.dart:9CompleteRegistration
CompleteStreamEventcomplete_stream_event.dart:8CompleteStream
CompleteTrialEventcomplete_trial_event.dart:8CompleteTrial
CompleteTutorialEventcomplete_tutorial_event.dart:8CompleteTutorial
ContactEventcontact_event.dart:8Contact
ContentItemsViewEventcontent_items_view_event.dart:8ContentItemsView
CustomizeProductEventcustomize_product_event.dart:8CustomizeProduct
DeepLinkedEventdeep_linked_event.dart:8DeepLinked
DonateEventdonate_event.dart:8Donate
FindLocationEventfind_location_event.dart:8FindLocation
InitiateCheckoutEventinitiate_checkout_event.dart:8InitiateCheckout
InitiatePurchaseEventinitiate_purchase_event.dart:8InitiatePurchase
InitiateStreamEventinitiate_stream_event.dart:8InitiateStream
InviteEventinvite_event.dart:8Invite
LastAttributedTouchEventlast_attributed_touch_event.dart:9LastAttributedTouch
LeadEventlead_event.dart:8Lead
ListViewEventlist_view_event.dart:8ListView
LoginEventlogin_event.dart:8Login
OpenedFromPushNotificationEventopened_from_push_notification_event.dart:8OpenedFromPushNotification
OrderEventorder_event.dart:8Order
OrderItemAddedEventorder_item_added_event.dart:8OrderItemAdded
OrderItemRemoveEventorder_item_remove_event.dart:8OrderItemRemove
OrderCancelEventorder_cancel_event.dart:8OrderCancel
OrderReturnRequestEventorder_return_request_event.dart:8OrderReturnRequest
OrderReturnRequestCancelEventorder_return_request_cancel_event.dart:8OrderReturnRequestCancel
PurchaseEventpurchase_event.dart:8Purchase
RateEventrate_event.dart:8Rate
ReEngageEventre_engage_event.dart:8ReEngage
ReserveEventreserve_event.dart:8Reserve
SalesEventsales_event.dart:8Sales
ScheduleEventschedule_event.dart:8Schedule
SearchEventsearch_event.dart:8Search
ShareEventshare_event.dart:8Share
SpendCreditsEventspend_credits_event.dart:8SpendCredits
StartRegistrationEventstart_registration_event.dart:8StartRegistration
StartTrialEventstart_trial_event.dart:8StartTrial
StartTutorialEventstart_tutorial_event.dart:8StartTutorial
SubmitApplicationEventsubmit_application_event.dart:8SubmitApplication
SubscribeEventsubscribe_event.dart:8Subscribe
TravelBookingEventtravel_booking_event.dart:8TravelBooking
UnlockAchievementEventunlock_achievement_event.dart:8UnlockAchievement
UnsubscribeEventunsubscribe_event.dart:8Unsubscribe
UpdateEventupdate_event.dart:9Update
ViewAdvEventview_adv_event.dart:9ViewAdv
ViewCartEventview_cart_event.dart:8ViewCart
ViewContentEventview_content_event.dart:8ViewContent
ViewItemEventview_item_event.dart:8ViewItem
ViewItemsEventview_items_event.dart:8ViewItems

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.

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();

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,
});
}

All extend BaseSubscriptionEvent (lib/events/subscription/base_subscription_event.dart:5-35) and are exported via subscription_events.dart.

Dart classFile:lineSubscriptionEventNameSubscriptionSubType
InitialSubscriptionEventsubscription_activation.dart:6AFFISE_SUBSCRIPTION_ACTIVATIONAFFISE_SUB_INITIAL_SUBSCRIPTION
InitialTrialEventsubscription_activation.dart:23AFFISE_SUBSCRIPTION_ACTIVATIONAFFISE_SUB_INITIAL_TRIAL
InitialOfferEventsubscription_activation.dart:41AFFISE_SUBSCRIPTION_ACTIVATIONAFFISE_SUB_INITIAL_OFFER
FailedTrialEventsubscription_cancellation.dart:6AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_TRIAL
FailedOfferiseEventsubscription_cancellation.dart:22AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_OFFERISE
FailedSubscriptionEventsubscription_cancellation.dart:38AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_SUBSCRIPTION
FailedTrialFromRetryEventsubscription_cancellation.dart:54AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_TRIAL_FROM_RETRY
FailedOfferFromRetryEventsubscription_cancellation.dart:70AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_OFFER_FROM_RETRY
FailedSubscriptionFromRetryEventsubscription_cancellation.dart:86AFFISE_SUBSCRIPTION_CANCELLATIONAFFISE_SUB_FAILED_SUBSCRIPTION_FROM_RETRY
TrialInRetryEventsubscription_entered_billing_retry.dart:6AFFISE_SUBSCRIPTION_ENTERED_BILLING_RETRYAFFISE_SUB_TRIAL_IN_RETRY
OfferInRetryEventsubscription_entered_billing_retry.dart:22sameAFFISE_SUB_OFFER_IN_RETRY
SubscriptionInRetryEventsubscription_entered_billing_retry.dart:38sameAFFISE_SUB_SUBSCRIPTION_IN_RETRY
ConvertedTrialEventsubscription_first_conversion.dart:6AFFISE_SUBSCRIPTION_FIRST_CONVERSIONAFFISE_SUB_CONVERTED_TRIAL
ConvertedOfferEventsubscription_first_conversion.dart:22sameAFFISE_SUB_CONVERTED_OFFER
ReactivatedSubscriptionEventsubscription_reactivation.dart:6AFFISE_SUBSCRIPTION_REACTIVATIONAFFISE_SUB_REACTIVATED_SUBSCRIPTION
RenewedSubscriptionEventsubscription_renewal.dart:6AFFISE_SUBSCRIPTION_RENEWALAFFISE_SUB_RENEWED_SUBSCRIPTION
ConvertedTrialFromRetryEventsubscription_renewal_from_billing_retry.dart:6AFFISE_SUBSCRIPTION_RENEWAL_FROM_BILLING_RETRYAFFISE_SUB_CONVERTED_TRIAL_FROM_RETRY
ConvertedOfferFromRetryEventsubscription_renewal_from_billing_retry.dart:22sameAFFISE_SUB_CONVERTED_OFFER_FROM_RETRY
RenewedSubscriptionFromRetryEventsubscription_renewal_from_billing_retry.dart:38sameAFFISE_SUB_RENEWED_SUBSCRIPTION_FROM_RETRY
UnsubscriptionEventunsubscription.dart:6AFFISE_UNSUBSCRIPTIONAFFISE_SUB_UNSUBSCRIPTION

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):

MethodSignatureLine
addPredefinedFloatEvent addPredefinedFloat(PredefinedFloat parameter, double value):36
addPredefinedListObjectEvent addPredefinedListObject(PredefinedListObject parameter, List<Map<String, dynamic>> value):42
addPredefinedListStringEvent addPredefinedListString(PredefinedListString parameter, List<String> value):48
addPredefinedLongEvent addPredefinedLong(PredefinedLong parameter, int value):54
addPredefinedObjectEvent addPredefinedObject(PredefinedObject parameter, Map<String, dynamic> value):60
addPredefinedStringEvent 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
}
}

Declared at lib/events/parameters/predefined_string.dart:3-72.

EnumNative 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"

Declared at lib/events/parameters/predefined_long.dart:3-27.

EnumNative 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"

Declared at lib/events/parameters/predefined_float.dart:6-12.

EnumNative key
PREFERRED_PRICE_RANGE"preferred_price_range"
PRICE"price"
REVENUE"revenue"
LAT"lat"
LONG"long"

Declared at lib/events/parameters/predefined_object.dart:3-5.

EnumNative key
CONTENT"content"

Declared at lib/events/parameters/predefined_list_object.dart:6-8.

EnumNative key
CONTENT_LIST"content_list"

Declared at lib/events/parameters/predefined_list_string.dart:6-8.

EnumNative key
CONTENT_IDS"content_ids"

“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 1237-1238

Retention is enforced by the underlying native SDKs; no Dart-side tuning is exposed.