Packageru.kavolorn.ane
Classpublic class Metrica
InheritanceMetrica Inheritance flash.events.EventDispatcher

Main library class for Yandex Metrica native extension.

The following example initializes extension and starts listening to initialization events:

     Metrica.getInstance().addEventListener(MetricaEvent.INITIALIZATION_ERROR, initializationErrorHandler);
     Metrica.getInstance().addEventListener(MetricaEvent.INITIALIZATION_SUCCESS, initializationSuccessHandler);
     Metrica.getInstance().initialize('metricaApplicationId', 'licenseKey');

The following example shows how to report an event:

     Metrica.getInstance().reportEvent('User logged in.', { 
          name : 'Alexey'
     });

See also

Yandex Metrica for apps integration guide
PRO Native Extensions license server


Public Methods
 MethodDefined By
  
Constructs an extension.
Metrica
  
[static] Gets the main instance to interact with.
Metrica
  
initialize(applicationId:String, licenseKey:String):void
Initializes extension.
Metrica
  
isSupported():Boolean
Reports if current platform is supported.
Metrica
  
reportEvent(eventName:String, eventValue:Object):void
Reports an event to Yandex Metrica.
Metrica
  
setDebug(debug:Boolean = false):void
[static] Enables or disables debug output.
Metrica
Events
 Event Summary Defined By
   Dispatched if initialization failed.Metrica
   Dispatched after successful initialization.Metrica
Constructor Detail
Metrica()Constructor
public function Metrica()

Constructs an extension. Don't use it directly but use getInstance() instead.

Method Detail
getInstance()method
public static function getInstance():Metrica

Gets the main instance to interact with. Don't use constructor.

Returns
Metrica — extension instance.
initialize()method 
public function initialize(applicationId:String, licenseKey:String):void

Initializes extension. Should be called before extension can be used.

Parameters

applicationId:String — id obtained from Metrica application configuration.
 
licenseKey:String — key obtained from license server.

isSupported()method 
public function isSupported():Boolean

Reports if current platform is supported.

Returns
Boolean — is platform supported or not.
reportEvent()method 
public function reportEvent(eventName:String, eventValue:Object):void

Reports an event to Yandex Metrica.

Parameters

eventName:String — event name.
 
eventValue:Object — event properties.

setDebug()method 
public static function setDebug(debug:Boolean = false):void

Enables or disables debug output.

Parameters

debug:Boolean (default = false) — flag which enables debug output.

Event Detail
initializationError Event
Event Object Type: ru.kavolorn.ane.MetricaEvent
MetricaEvent.type property = ru.kavolorn.ane.MetricaEvent.INITIALIZATION_ERROR

Dispatched if initialization failed.
initializationSuccess Event  
Event Object Type: ru.kavolorn.ane.MetricaEvent
MetricaEvent.type property = ru.kavolorn.ane.MetricaEvent.INITIALIZATION_SUCCESS

Dispatched after successful initialization.