public interface AnalyticsServices
This interface wraps the functionality provided by the Adjust and Swrve SDKs. It also includeds 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.
Modifier and Type | Interface and Description |
---|---|
static interface |
AnalyticsServices.AutoEventListener |
static class |
AnalyticsServices.Events |
static class |
AnalyticsServices.Fields
Kongregate automatic fields you may retrieve using the
getAutoBoolProperty(String) , getAutoIntProperty(String) , etc... |
static class |
AnalyticsServices.IabResult |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ADJUST_EVENT_PREFIX |
static java.lang.String |
DELTA_EVENT_PREFIX |
static java.lang.String |
SWRVE_EVENT_PREFIX |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_EVENT_GIFT |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_EVENT_PURCHASE |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_PARAM_AMOUNT |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_PARAM_COST |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_PARAM_CURRENCY |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_PARAM_ITEM |
static java.lang.String |
SWRVE_VIRTUAL_ECONOMY_PARAM_QUANTITY |
Modifier and Type | Method and Description |
---|---|
void |
addEvent(java.lang.String eventCollection,
java.util.Map<java.lang.String,java.lang.Object> event)
Add an analytics event.
|
void |
addEvent(java.lang.String collection,
java.lang.String eventJson,
java.lang.String commonPropsJson)
Add analytic event using formatted JSON strings
|
void |
addFilterType(java.lang.String value)
Adds a filter type to the list of filters
|
void |
addIapTransaction(double revenueUSD,
java.lang.String receiptOriginalJSON,
java.lang.String receiptSignature,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google Purchase. |
void |
addIapTransaction(double revenueUSD,
java.lang.String receiptOriginalJSON,
java.lang.String receiptSignature,
java.lang.String gameFieldsJson)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google Purchase. |
void |
addIapTransactionWithCurrency(double revenue,
java.lang.String revenueCurrency,
java.lang.String receiptOriginalJSON,
java.lang.String receiptSignature,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google Purchase. |
void |
addIapTransactionWithCurrency(double revenue,
java.lang.String revenueCurrency,
java.lang.String receiptOriginalJSON,
java.lang.String receiptSignature,
java.lang.String gameFieldsJson)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google Purchase. |
void |
addIapTransactionWithoutReceipt(double revenue,
java.lang.String revenueCurrency,
java.lang.String productId,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google App IAP Purchase. |
void |
addIapTransactionWithoutReceipt(double revenue,
java.lang.String revenueCurrency,
java.lang.String productId,
java.lang.String gameFieldsJson)
Add a Kongregate Analytics
iap_transaction event and Adjust sale event for a Google App IAP Purchase. |
void |
finishPromoAward(java.lang.String eventPayload)
Notify the Kongregate SDK that a promo award has been handled.
|
void |
finishPurchase(AnalyticsServices.IabResult resultCode,
java.lang.String resultData,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData.
|
void |
finishPurchase(AnalyticsServices.IabResult resultCode,
java.lang.String resultData,
java.util.Map<java.lang.String,java.lang.Object> gameFields,
java.lang.String dataSignature)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData.
|
void |
finishPurchase(java.lang.String resultCode,
java.lang.String resultData,
java.lang.String gameFieldsJson)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData.
|
void |
finishPurchase(java.lang.String resultCode,
java.lang.String resultData,
java.lang.String gameFieldsJson,
java.lang.String dataSignature)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData.
|
void |
gameUserUpdate(java.util.Map<java.lang.String,java.lang.String> props)
Update game specific Swrve user properties.
|
void |
gameUserUpdate(java.lang.String propsJson)
Update game specific Swrve user properties from a JSON formated string.
|
boolean |
getAutoBoolProperty(java.lang.String field)
Get a boolean automatic property
|
double |
getAutoDoubleProperty(java.lang.String field)
Get a double automatic property
|
int |
getAutoIntProperty(java.lang.String field)
Get an int automatic property
|
long |
getAutoLongProperty(java.lang.String field)
Get a long automatic property
|
java.lang.String |
getAutoPropertiesJSON()
Get kongregate automatic properties as a JSON formatted string
|
java.lang.String |
getAutoStringProperty(java.lang.String field)
Get a string automatic property
|
java.lang.String |
getAutoUTCProperty(java.lang.String field)
Get an UTC formated Timestamp automatic property
|
java.lang.String |
getInstallReferrer()
Get the referrer string
|
java.lang.String |
getKongPropertiesJSON()
Returns the common analytics properties collected by the Kongregate SDK
|
java.util.Set<java.lang.String> |
getResouceNames()
Retrieve the set of Swrve resource names
|
boolean |
getResourceAsBool(java.lang.String resourceId,
java.lang.String attributeId,
boolean defValue)
Retrieve a Swrve A/B test resource as a boolean.
|
float |
getResourceAsFloat(java.lang.String resourceId,
java.lang.String attributeId,
float defValue)
Retrieve a Swrve A/B test resource as a float.
|
int |
getResourceAsInt(java.lang.String resourceId,
java.lang.String attributeId,
int defValue)
Retrieve a Swrve A/B test resource as an int.
|
java.lang.String |
getResourceAsString(java.lang.String resourceId,
java.lang.String attributeId,
java.lang.String defValue)
Retrieve a Swrve A/B test resource as a string.
|
java.lang.String |
getResourceNamesAsJson()
Retrieve the set of Swrve resource names as a JSON array
|
java.util.Map<java.lang.String,java.lang.Object> |
getResources()
Retrieve the map of Swrve resources
|
void |
setAutoEventListener(AnalyticsServices.AutoEventListener listener)
Sets a listener for analytic events the Kongregate SDK automatically fires.
|
void |
setCommonProperties(java.util.Map<java.lang.String,java.lang.Object> commonProps)
Set the common props from a JSON object which will be added to the next event fired, if
setCommonPropertiesEvaluator(CommonPropertiesEvaluator) is not set. |
void |
setCommonProperties(java.lang.String commonPropsJson)
Set the common props from a JSON object which will be added to the next event fired, if
setCommonPropertiesEvaluator(CommonPropertiesEvaluator) is not set. |
void |
setCommonPropertiesEvaluator(CommonPropertiesEvaluator evaluator)
Set common props evaluator which will be invoked each time an event is fired to retrieve a fresh map of common properties.
|
void |
setFilterType(java.lang.String value)
Deprecated.
|
void |
setPushToken(java.lang.String token)
Sets the push token used by Adjust for uninstall tracking.
|
void |
start(android.app.Activity activity)
When using
KongregateAPI.KONGREGATE_OPTION_DEFER_ANALYTICS , this allows you to start the analytics subsystem. |
void |
startPurchase(java.lang.String productId,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Tracks the start of the purchase flow.
|
void |
startPurchase(java.lang.String productId,
java.lang.String gameFieldsJson)
Tracks the start of the purchase flow.
|
void |
trackPurchase(java.lang.String productID)
Deprecated.
|
void |
trackPurchase(java.lang.String productId,
java.util.Map<java.lang.String,java.lang.Object> gameFields)
Deprecated.
|
void |
trackPurchase(java.lang.String productId,
java.lang.String gameFieldsJSON)
Deprecated.
|
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_EVENT_PURCHASE
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_EVENT_GIFT
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_PARAM_ITEM
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_PARAM_CURRENCY
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_PARAM_COST
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_PARAM_QUANTITY
static final java.lang.String SWRVE_VIRTUAL_ECONOMY_PARAM_AMOUNT
static final java.lang.String SWRVE_EVENT_PREFIX
static final java.lang.String DELTA_EVENT_PREFIX
static final java.lang.String ADJUST_EVENT_PREFIX
void addEvent(java.lang.String eventCollection, java.util.Map<java.lang.String,java.lang.Object> event)
Add an analytics event.
eventCollection
- event
- void addEvent(java.lang.String collection, java.lang.String eventJson, java.lang.String commonPropsJson)
Add analytic event using formatted JSON strings
collection
- the collection to add the event toeventJson
- json object for the eventcommonPropsJson
- json object for the common event propertiesvoid setCommonPropertiesEvaluator(CommonPropertiesEvaluator evaluator)
Set common props evaluator which will be invoked each time an event is fired to retrieve a fresh map of common properties.
evaluator
- The evaluator to be invoked with each event.void setAutoEventListener(AnalyticsServices.AutoEventListener listener)
Sets a listener for analytic events the Kongregate SDK automatically fires. Most games will not need to listen for these events. It's useful if you wish to echo the events to your own analytics collection system.
listener
- void setCommonProperties(java.lang.String commonPropsJson)
Set the common props from a JSON object which will be added to the next event fired, if setCommonPropertiesEvaluator(CommonPropertiesEvaluator)
is not set.
commonPropsJson
- A JSON formatted string of common propertiesvoid setCommonProperties(java.util.Map<java.lang.String,java.lang.Object> commonProps)
Set the common props from a JSON object which will be added to the next event fired, if setCommonPropertiesEvaluator(CommonPropertiesEvaluator)
is not set.
commonProps
- A map of common propertiesvoid gameUserUpdate(java.lang.String propsJson)
Update game specific Swrve user properties from a JSON formated string. All values must be strings.
propsJson
- void gameUserUpdate(java.util.Map<java.lang.String,java.lang.String> props)
Update game specific Swrve user properties.
props
- void setPushToken(java.lang.String token)
Sets the push token used by Adjust for uninstall tracking.
token
- @Deprecated void setFilterType(java.lang.String value)
void addFilterType(java.lang.String value)
Adds a filter type to the list of filters
value
- java.lang.String getAutoPropertiesJSON()
Get kongregate automatic properties as a JSON formatted string
java.lang.String getInstallReferrer()
Get the referrer string
java.lang.String getAutoStringProperty(java.lang.String field)
Get a string automatic property
field
- The field namelong getAutoLongProperty(java.lang.String field)
Get a long automatic property
field
- The field nameint getAutoIntProperty(java.lang.String field)
Get an int automatic property
field
- The field namejava.lang.String getAutoUTCProperty(java.lang.String field)
Get an UTC formated Timestamp automatic property
field
- The field nameboolean getAutoBoolProperty(java.lang.String field)
Get a boolean automatic property
field
- The field namedouble getAutoDoubleProperty(java.lang.String field)
Get a double automatic property
field
- The field name@Deprecated void trackPurchase(java.lang.String productID)
@Deprecated void trackPurchase(java.lang.String productId, java.util.Map<java.lang.String,java.lang.Object> gameFields)
@Deprecated void trackPurchase(java.lang.String productId, java.lang.String gameFieldsJSON)
void startPurchase(java.lang.String productId, java.util.Map<java.lang.String,java.lang.Object> gameFields)
Tracks the start of the purchase flow. Fires the the iap_attempts event.
productId
- The productId tht is attempting to be purchasedgameFields
- A map of the game fileds.void startPurchase(java.lang.String productId, java.lang.String gameFieldsJson)
Tracks the start of the purchase flow. Same as startPurchase(String, java.util.Map)
, but accepts the game fields as a JSON String.
productId
- The productId that is attempting to be purchasedgameFieldsJson
- The game fields as a JSON string.void finishPurchase(java.lang.String resultCode, java.lang.String resultData, java.lang.String gameFieldsJson)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData. Invoke this after the purchase is complete and the receipt verified (is using Receipt Verification).
resultCode
- resultData
- gameFieldsJson
- void finishPurchase(java.lang.String resultCode, java.lang.String resultData, java.lang.String gameFieldsJson, java.lang.String dataSignature)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData. Invoke this after the purchase is complete and the receipt verified (is using Receipt Verification).
resultCode
- resultData
- gameFieldsJson
- dataSignature
- the signature used to sign result data. Used by SWRVE analytics to verify the purchase.void finishPurchase(AnalyticsServices.IabResult resultCode, java.lang.String resultData, java.util.Map<java.lang.String,java.lang.Object> gameFields)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData. Invoke this after the purchase is complete and the receipt verified (is using Receipt Verification).
resultCode
- resultData
- gameFields
- void finishPurchase(AnalyticsServices.IabResult resultCode, java.lang.String resultData, java.util.Map<java.lang.String,java.lang.Object> gameFields, java.lang.String dataSignature)
Creates either iap_transactions or iap_fails purchase events depending on resultCode and state of the resultData. Invoke this after the purchase is complete and the receipt verified (is using Receipt Verification).
resultCode
- resultData
- gameFields
- dataSignature
- the signature used to sign result data. Used by SWRVE analytics to verify the purchase.void addIapTransaction(double revenueUSD, java.lang.String receiptOriginalJSON, java.lang.String receiptSignature, java.lang.String gameFieldsJson)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google Purchase.
This is the preferred method to use when the purchased product does not conform to the TXX_description
naming convention. It is preferred because the revenue is explicitly provided in USD where we are unable to infer the USD cost from the ID. By including the original receipt and signature we can extract additional information about the purchase and validate the receipt.
This should be invoked after the purchase is complete and the receipt verified.
revenueUSD
- the purchase price of the item in US DollarsreceiptOriginalJSON
- the original JSON receipt returned by the Google Play StorereceiptSignature
- the signature returned by the Google Play StoregameFieldsJson
- JSON formated object of additional fields to include with the event (e.g. soft_currency_change
)void addIapTransaction(double revenueUSD, java.lang.String receiptOriginalJSON, java.lang.String receiptSignature, java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google Purchase.
This is the preferred method to use when the purchased product does not conform to the TXX_description
naming convention. It is preferred because the revenue is explicitly provided in USD where we are unable to infer the USD cost from the ID. By including the original receipt and signature we can extract additional information about the purchase and validate the receipt.
This should be invoked after the purchase is complete and the receipt verified.
revenueUSD
- the purchase price of the item in US DollarsreceiptOriginalJSON
- the original JSON receipt returned by the Google Play StorereceiptSignature
- the signature returned by the Google Play StoregameFields
- Dictionary of additional fields to include with the event (e.g. soft_currency_change
)void addIapTransactionWithCurrency(double revenue, java.lang.String revenueCurrency, java.lang.String receiptOriginalJSON, java.lang.String receiptSignature, java.lang.String gameFieldsJson)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google Purchase.
AddGoogleIapTransaction()
is the preferred method to use since it allows revenue to be normalized to USD. This method may be used when the USD price is unknown. Adjust does convert the revenue to USD in it's sale event, however Kongregate Analytics will not.
This should be invoked after the purchase is complete and the receipt verified.
revenue
- the purchase price of the item in the given currencyrevenueCurrency
- the currency code the revenue is reported in.receiptOriginalJSON
- the original JSON receipt returned by the Google Play StorereceiptSignature
- the signature returned by the Google Play StoregameFieldsJson
- JSON formated object of additional fields to include with the event (e.g. soft_currency_change
)void addIapTransactionWithCurrency(double revenue, java.lang.String revenueCurrency, java.lang.String receiptOriginalJSON, java.lang.String receiptSignature, java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google Purchase.
AddGoogleIapTransaction()
is the preferred method to use since it allows revenue to be normalized to USD. This method may be used when the USD price is unknown. Adjust does convert the revenue to USD in it's sale event, however Kongregate Analytics will not.
This should be invoked after the purchase is complete and the receipt verified.
revenue
- the purchase price of the item in the given currencyrevenueCurrency
- the currency code the revenue is reported in.receiptOriginalJSON
- the original JSON receipt returned by the Google Play StorereceiptSignature
- the signature returned by the Google Play StoregameFields
- Dictionary of additional fields to include with the event (e.g. soft_currency_change
)void addIapTransactionWithoutReceipt(double revenue, java.lang.String revenueCurrency, java.lang.String productId, java.lang.String gameFieldsJson)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google App IAP Purchase.
addIapTransaction
is the preferred methods. addIapTransactionWithoutReceipt
may be used when the Google receipt is not available.
This should be invoked of the purchase is complete and the receipt has been verified.
revenue
- the purchase price of the item in the given currencyrevenueCurrency
- the currency code the revenue is reported in.productId
- the identifier for the purchased productgameFieldsJson
- JSON formated object of additional fields to include with the event (e.g. soft_currency_change
)void addIapTransactionWithoutReceipt(double revenue, java.lang.String revenueCurrency, java.lang.String productId, java.util.Map<java.lang.String,java.lang.Object> gameFields)
Add a Kongregate Analytics iap_transaction
event and Adjust sale
event for a Google App IAP Purchase.
addIapTransaction
is the preferred methods. addIapTransactionWithoutReceipt
may be used when the Google receipt is not available.
This should be invoked of the purchase is complete and the receipt has been verified.
revenue
- the purchase price of the item in the given currencyrevenueCurrency
- the currency code the revenue is reported in.productId
- the identifier for the purchased productgameFields
- Dictionary of additional fields to include with the event (e.g. soft_currency_change
)void start(android.app.Activity activity)
When using KongregateAPI.KONGREGATE_OPTION_DEFER_ANALYTICS
, this allows you to start the analytics subsystem. You should attempt to call this function as quickly as possible after calling APIBootstrap.initializeNativeAPI(Activity, long, String, Map)
, or you may lose events.
java.lang.String getKongPropertiesJSON()
Returns the common analytics properties collected by the Kongregate SDK
java.util.Map<java.lang.String,java.lang.Object> getResources()
Retrieve the map of Swrve resources
java.util.Set<java.lang.String> getResouceNames()
Retrieve the set of Swrve resource names
java.lang.String getResourceNamesAsJson()
Retrieve the set of Swrve resource names as a JSON array
java.lang.String getResourceAsString(java.lang.String resourceId, java.lang.String attributeId, java.lang.String defValue)
Retrieve a Swrve A/B test resource as a string.
resourceId
- the ID of the Swrve resourceattributeId
- the ID of the attributedefValue
- a devault value if the resource/attribute is not found.int getResourceAsInt(java.lang.String resourceId, java.lang.String attributeId, int defValue)
Retrieve a Swrve A/B test resource as an int.
resourceId
- the ID of the Swrve resourceattributeId
- the ID of the attributedefValue
- a devault value if the resource/attribute is not found.float getResourceAsFloat(java.lang.String resourceId, java.lang.String attributeId, float defValue)
Retrieve a Swrve A/B test resource as a float.
resourceId
- the ID of the Swrve resourceattributeId
- the ID of the attributedefValue
- a devault value if the resource/attribute is not found.boolean getResourceAsBool(java.lang.String resourceId, java.lang.String attributeId, boolean defValue)
Retrieve a Swrve A/B test resource as a boolean.
resourceId
- the ID of the Swrve resourceattributeId
- the ID of the attributedefValue
- a devault value if the resource/attribute is not found.void finishPromoAward(java.lang.String eventPayload)
Notify the Kongregate SDK that a promo award has been handled. This will update a Swrve User Property that may be used as a filter for additional Swrve messaging.
It's a good idea, particularly if your game has a server component, to also track awarded promoIds and to display a message if your game is asked to award a promo that has already been awarded. This will handle an edge case where a user can trick the client into showing an in-app message to perform the award again.
NOTE: you may also simply pass the promoID for the event, rather than the complete payload. When only the promoID is passed, the user property will be updated. When the full event payload is included, the SDK will parse the payload and may automatically preform other actions such as open an install URL.
eventPayload
- the event payload for the PROMO_AWARD event.