Packagecom.kongregate.air
Interfacepublic interface IAnalytics

This interface wraps the functionality provided by the Adjust and Swrve SDKs. It also includes legacy support for Keen. Ad-X has been removed from the Kongregate SDK. The primary purpose of this interface is to expose hooks for games to pass events to Swrve and Adjust. It also provides wrappers for some additional Swrve features such as User Properties, A/B Testing, and Push Notifications. See the Mobile SDK Docs for details of the various features.



Public Methods
 MethodDefined By
  
addEvent(collection:String, evt:Object):void
Add the event to Analytics.
IAnalytics
  
addFilterType(filterType:String):void
Adds a filter type to the filter list
IAnalytics
  
finishPromoAward(promoId:String):void
Finish a cross promotion and award an item.
IAnalytics
  
finishPurchase(resultCode:String, transactionId:String, gameFields:Object = null, dataSignature:String = null):void
Finish a purchase that was started with startPurchase().
IAnalytics
  
finishPurchaseWithProductId(resultCode:String, productId:String, receipt:String, gameFields:Object = null):void
iOS Only Finish a purchase that was started with startPurchase().
IAnalytics
  
gameUserUpdate(props:Object):void
Update Game User Properties.
IAnalytics
  
Get an object containing all automatic properties
IAnalytics
  
Get the install referrer on Android, if set.
IAnalytics
  
getResourceAsString(resourceId:String, attributeId:String, defValue:String):String
Retrieve a Swrve A/B test resource as a string.
IAnalytics
  
Retrieve the set of Swrve resource names
IAnalytics
  
setCommonProperties(props:Object):void
Sets the common properties from an Object.
IAnalytics
  
setCommonPropsCallback(callback:Function):void
Set the common properties callback.
IAnalytics
  
setPushToken(token:String):void
Notifies adjust the device token for iOS and firebase push token for Android.
IAnalytics
  
start():void
When using Settings.deferAnalytics, this allows you to start the analytics subsystem.
IAnalytics
  
startPurchase(productID:String, quantity:int = 1, gameFields:Object = null):void
Creates an Adjust/Swrve iap_attemps event.
IAnalytics
  
Manually run the common properties delegate to update the properties.
IAnalytics
Method Detail
addEvent()method
public function addEvent(collection:String, evt:Object):void

Add the event to Analytics.

The key must be less than 256 characters, not start with '$' or contain '.'

The evt parameter may include a list of keys mapped to Number, String, Array, or Boolean. Other values types will not be submitted as events.

Parameters

collection:String — The name of the event
 
evt:Object — The Object with key/value pairs to submit with the event

addFilterType()method 
public function addFilterType(filterType:String):void

Adds a filter type to the filter list

Parameters

filterType:String — the filter to add

finishPromoAward()method 
public function finishPromoAward(promoId:String):void

Finish a cross promotion and award an item.

Parameters

promoId:String — Promotion ID

finishPurchase()method 
public function finishPurchase(resultCode:String, transactionId:String, gameFields:Object = null, dataSignature:String = null):void

Finish a purchase that was started with startPurchase(). The method will create either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData. Will also fire Adjust and Swrve IAP events upon success.

Invoke this after the purchase is complete and the receipt verified (if using Receipt Verification).

For iOS: be sure to invoke before [SKPaymentQueue finishTransaction:], as the transactionId must still exist in the SKPaymentQueue to extract the required information.

Parameters

resultCode:String — one of SUCCESS, FAIL, RECEIPT_FAIL
 
transactionId:String — value of this parameter is different for iOS and Android.
  • For iOS: the StoreKit transaction ID, if known. The transactionId must be included if the resultCode is SUCCESS or RECEIPT_FAIL. For the FAIL case, some plug-ins do not include the transactionId in the callback. For this case, pass nil and the SDK will attempt to the failed transaction in the StoreKit payment queue.
  • For Android: on SUCCESS or RECEIPT_FAIL this should be the orginal Json returned from the playstore. If the result is fail, pass the error message from the result.
 
gameFields:Object (default = null) — dictionary values to pass along with the event (e.g. hard_currency_changed, soft_currency_changed, etc.)
 
dataSignature:String (default = null) — the optional signature used to sign result data. Used by SWRVE analytics to verify the purchase (Android Only). Ignored on iOS. If nil on Android, Swrve will no validate the receipt.

finishPurchaseWithProductId()method 
public function finishPurchaseWithProductId(resultCode:String, productId:String, receipt:String, gameFields:Object = null):void

iOS Only

Finish a purchase that was started with startPurchase(). Will result in either an iap_fails or iap_transactions event.

Use this version for iOS only, if you have a Product ID and receipt, but not the transaction ID. The other finishPurchase() methods are preferrable, because transaction information may be pulled directly from the transaction.

Parameters

resultCode:String — one of PURCHASE_FAIL, PURCHASE_SUCCESS, PURCHASE_RECEIPT_FAIL
 
productId:String — the product of the item purchased.
 
receipt:String — the receipt data base64 encoded
 
gameFields:Object (default = null) — dictionary game fields to send up with the event.

gameUserUpdate()method 
public function gameUserUpdate(props:Object):void

Update Game User Properties. If Swrve is enabled, these will be passed to the Swrve SDK. All keys and values must be Strings.

Parameters

props:Object

getAutoProperties()method 
public function getAutoProperties():Object

Get an object containing all automatic properties

Returns
Object — an object of all automatic properties
getInstallReferrer()method 
public function getInstallReferrer():String

Get the install referrer on Android, if set. Otherwise, returns an empty string.

Returns
String
getResourceAsString()method 
public function getResourceAsString(resourceId:String, attributeId:String, defValue:String):String

Retrieve a Swrve A/B test resource as a string.

Parameters

resourceId:String — the ID of the Swrve resource
 
attributeId:String — the ID of the attribute
 
defValue:String — a devault value if the resource/attribute is not found.

Returns
String — the value of the attribute in the resource, or the default alue if not found.
getResourceNames()method 
public function getResourceNames():Array

Retrieve the set of Swrve resource names

Returns
Array — the resource names as an array
setCommonProperties()method 
public function setCommonProperties(props:Object):void

Sets the common properties from an Object. The allowed types for the props parameter are the same as addEvent.

Parameters

props:Object

setCommonPropsCallback()method 
public function setCommonPropsCallback(callback:Function):void

Set the common properties callback. If set, this method is invoked when events are added.

Parameters

callback:Function — The function to generate the common properties. it should return an Object.

setPushToken()method 
public function setPushToken(token:String):void

Notifies adjust the device token for iOS and firebase push token for Android. When set and configured on the Adjust dashboard, Adjust will track [uninstall and re-install](https://docs.adjust.com/en/tracking-app-uninstalls/) events.

Parameters

token:String — The Firebase push token for Android or the base64 encoded device token for iOS

start()method 
public function start():void

When using Settings.deferAnalytics, this allows you to start the analytics subsystem. You should attempt to call this function as quickly as possible after initializing the SDK, or you may miss events.

startPurchase()method 
public function startPurchase(productID:String, quantity:int = 1, gameFields:Object = null):void

Creates an Adjust/Swrve iap_attemps event. The SKU must match the one set up in the iTunes Connect portal, and must contain the pricing tier, such as: t05_hard.

Be careful not to start multiple purchase flows at once. Disable the UI that initiates the purchase flow until it's complete or cancelled.

Parameters

productID:String — The product ID
 
quantity:int (default = 1) — The quantity of items purchased
 
gameFields:Object (default = null) — An optional dictionary containing custom event fields to pass along

updateCommonProps()method 
public function updateCommonProps():void

Manually run the common properties delegate to update the properties. In general you should not need to call this