Packagecom.myflashlab.air.extensions.fb
Classpublic class AppEvents
InheritanceAppEvents Inheritance flash.events.EventDispatcher

The AppEvents class allows the developer to log various types of events back to Facebook. In order to log events, the ANE must have been initialized first. and then call the various "log" methods.

This client-side event logging is then available through Facebook App Insights and for use with Facebook Ads conversion tracking and optimization.

The AppEvents class has a few related roles:

Below are some important characteristics of the logging mechanism provided by AppEvents:

Events are not sent immediately when logged. They're cached and flushed out to the Facebook servers in a number of situations:

Some things to note when logging events:



Public Properties
 PropertyDefined By
  flushBehavior : int
Access the behavior that AppEvents uses to determine when to flush logged events to the server.
AppEvents
  pushNotificationRegistrationId : String
[write-only] Sets and sends registration id to register the current app for push notifications.
AppEvents
  userId : String
Indicates a user id to associate with all app events.
AppEvents
Public Methods
 MethodDefined By
  
Clears the currently set user id.
AppEvents
  
flush():void
Explicitly flush any stored events to the server.
AppEvents
  
logEvent($eventName:String, $valueToSum:Number = -1, $parameters:Object = null):void
Log an app event with the specified name, supplied value, and set of parameters.
AppEvents
  
logPurchase($purchaseAmount:Number, $currency:String, $parameters:Object = null):void
Logs a purchase event with Facebook, in the specified amount and with the specified currency.
AppEvents
  
logPushNotificationOpen($payload:String):void
Logs an app event that tracks that the application was open via Push Notification.
AppEvents
  
updateUserProperties($properties:Object, $callback:Function):void
An AS3 Object of key-value pairs representing user properties and their values.
AppEvents
Property Detail
flushBehaviorproperty
flushBehavior:int

Access the behavior that AppEvents uses to determine when to flush logged events to the server.


Implementation
    public function get flushBehavior():int
    public function set flushBehavior(value:int):void
pushNotificationRegistrationIdproperty 
pushNotificationRegistrationId:String  [write-only]

Sets and sends registration id to register the current app for push notifications.

You shouldn't call this on the iOS side. on iOS, it will be done automatically for you.


Implementation
    public function set pushNotificationRegistrationId(value:String):void
userIdproperty 
userId:String

Indicates a user id to associate with all app events. This can be used to associate your own user id with the app events logged from this instance of an application.


Implementation
    public function get userId():String
    public function set userId(value:String):void
Method Detail
clearUserID()method
public function clearUserID():void

Clears the currently set user id.

flush()method 
public function flush():void

Explicitly flush any stored events to the server. Implicit flushes may happen depending on the value of flushBehavior. This method allows for explicit, app invoked flushing.

logEvent()method 
public function logEvent($eventName:String, $valueToSum:Number = -1, $parameters:Object = null):void

Log an app event with the specified name, supplied value, and set of parameters. $valueToSum and $parameters are optional.

Parameters

$eventName:String — $eventName used to denote the event. Choose amongst the EVENT_NAME_ constants in AppEventsConstants when possible. Or create your own if none of the EVENT_NAME_constants are applicable. Event names should be 40 characters or less, alphanumeric, and can include spaces, underscores or hyphens, but must not have a space or hyphen as the first character. Any given app should have no more than 1000 distinct event names.
 
$valueToSum:Number (default = -1) — a value to associate with the event which will be summed up in Insights for across all instances of the event, so that average values can be determined, etc. This value shouldn't be negative or it won't be considered.
 
$parameters:Object (default = null) — A Bundle of parameters to log with the event. Insights will allow looking at the logs of these events via different parameter values. You can log on the order of 25 parameters with each distinct eventName. It's advisable to limit the number of unique values provided for each parameter in the thousands. As an example, don't attempt to provide a unique parameter value for each unique user in your app. You won't get meaningful aggregate reporting on so many parameter values. The values in the bundles should be Strings.

logPurchase()method 
public function logPurchase($purchaseAmount:Number, $currency:String, $parameters:Object = null):void

Logs a purchase event with Facebook, in the specified amount and with the specified currency. Additional detail about the purchase can be passed in through the parameters object.

Parameters

$purchaseAmount:Number — Amount of purchase, in the currency specified by the 'currency' parameter. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).
 
$currency:String — Currency used to specify the amount.
 
$parameters:Object (default = null) — Arbitrary additional information for describing this event. This should have no more than 24 entries, and keys should be mostly consistent from one purchase event to the next.

logPushNotificationOpen()method 
public function logPushNotificationOpen($payload:String):void

Logs an app event that tracks that the application was open via Push Notification.

You shouldn't call this on the iOS side. on iOS, it will be done automatically for you.

Parameters

$payload:String — Notification payload received.

updateUserProperties()method 
public function updateUserProperties($properties:Object, $callback:Function):void

An AS3 Object of key-value pairs representing user properties and their values. Values should be strings or numbers only. Each key must be less than 40 character in length, and the key can contain only letters, number, whitespace, hyphens (-), or underscores (_). Each value must be less than 100 characters. The total number of properties associated with your users cannot exceed 100.

Parameters

$properties:Object
 
$callback:Function — This callback function will be called with the result of this operation. It expects one parameter as $error:Error in case an error happened.