Using Plugins to trigger custom actions
The plugins feature is useful to trigger custom actions based on the occurrence of our Events. For example, everytime an OPEN event is sent by your app, Kiwi can perform some action.
The actions available are:
Invoke an AWS's Lambda function (EVENT_TO_LAMBDA)
Send the event to an AWS's SQS queue (EVENT_TO_SQS)
Send the event to an AWS's SNS topic (EVENT_TO_SNS)
Send the event to an AWS's Kinesis stream (EVENT_TO_KINESIS)
Snapshot the state of some Kiwi's entity i.e. AppInstall (SNAPSHOT)
Perform a HTTP request using any Kiwi's information (EVENT_TO_URL)
To configure a new plugin:
Go to your app's page, click on
Settings>Plugins. You'll see all the plugins configured for your app.Press the
+Newbutton.Fill the
Descriptionfield with the meaning of your plugin.Choose the value
EVENTin thePlugin Typefield.Choose one of the plugins listed above and select it into the
Plugin Handler Typefield.Include all the event types you desire in the
Supported Eventsfield, or, alternatively, mark theSupport All Eventsbutton. Putting an event type in this list means that every time an event of this type is sent to Kiwi, the plugin will be triggered.In case you add
CUSTOMevents to theSupported Eventsfield, theApp Type Patternfield will show up. This field accepts Java regular expressions and it defines whichCUSTOMevents are supported by matching its app type against the expression.The next configurations depends on the
Plugin Handler Typeyou choosed. Follow the instructions above.Press the
Savebutton.You are done! :)
EVENT_TO_URL Plugin
This plugin can perform a HTTP request to any endpoint, based on Kiwi's data.
Continuing the configuration process described above:
In the field
URL, insert the URL that will be called by the plugin (See: the Wildcards below).In the field
HTTP Method, choose betweenGETandPOST.If the http method is
POST, fill the fieldBodywith the content you are about to post (See: the Wildcards below).Again, if the http method is
POST, fill the fieldContent Typeif you desire.If your request fails, Kiwi will retry it. In the field
Retry Interval in Seconds, put the interval to wait between retries. Kiwi will try to complete your request at most in three attempts.
Wildcards
When configuring an URL or a request body, you can use placeholders that will be replaced with real Kiwi values. We call it Wildcards.
For example, lets say will want to request the URL http://myservice.com/${event.appInstallId}/${event.userId}. ${event.appInstallId} and ${event.userId} will both be replaced with the real values of the appInstallId and userId, both part of the Event domain.
Wildcard composition
Take the wildcard ${event.appInstallId} as an example, it is a string composed of three parts:
Wildcard Mode: The first character of the wildcard, it must be present in one of the two options:
$: Mandatory. If the value represented by the given wildcard is not present (i.e.
null), the request will fail.#: Optional. If the value represented by the given wildcard is not present (i.e.
null), the wildcard will be removed from the URL/Body.
Wildcard Domain: The Kiwi's entity that holds the value you want. In our example, the domain is
event.Wildcard Field: The value after the
.character, it represents the property of the Wildcard's entity. In our example, the field isappInstallid.
Supported Wildcards:
eventdomain:event.applicationIdevent.productIdevent.applicationKeyevent.userIdevent.appInstallIdevent.serverEventTimeevent.requesterLocalTimeevent.requesterEventTimeevent.deviceLanguageevent.deviceTimezoneevent.deviceSystemNameevent.deviceSystemVersionevent.deviceManufacturerevent.deviceModelevent.installedAtevent.appSdkVersionevent.countryByIpevent.deviceCountryevent.appVersionevent.androidIdevent.openUdidevent.ifaevent.imeievent.odin1event.ifvevent.advertisingIdevent.scenarioIdevent.eventTypeNameevent.eventTypeIdevent.appEventTypeevent.payload(this wildcard can also be in the formevent.payload.key1, wherekey1is a key of thepayloadmap)event.currencyevent.price
appInstalldomain:appInstall.platformNameappInstall.platformIdappInstall.initialAppVersionappInstall.initialSdkVersionappInstall.lastAppUpdatedAtappInstall.isAppInstallInvalidatedappInstall.pushTokenappInstall.pushEnvironmentNameappInstall.pushEnvironmentIdappInstall.pushTokenInvalidatedappInstall.pushTokenInvalidatedAtappInstall.pushTokenRefreshedAtappInstall.lastOpenAtappInstall.carrierappInstall.carrierIdappInstall.msisdnappInstall.newsletterEmailappInstall.platformAccountEmailappInstall.subscribedToNewsletterappInstall.scenarioCountryappInstall.activeSubscriptionsappInstall.campaignappInstall.campaignAsDefaultappInstall.externalMediaCampaignIdappInstall.externalMediaCampaignNameappInstall.externalMediaNetworkappInstall.externalMediaUserIdappInstall.externalMediaSiteappInstall.externalMediaAdappInstall.externalMediaGroupappInstall.externalMediaClickIdappInstall.accountUUIDappInstall.tags
userdomain:the
.<namespace>and.<key>are optional, if present will return only the value of the key, otherwise return a json representation of all data.user.privateSettings.<namespace>.<key>user.sharedSettings.<namespace>.<key>
subscriptiondomain:subscription.idsubscription.monetizationPlatformIdsubscription.monetizationPlatformNamesubscription.subscriptionTypeIdsubscription.subscriptionTypeNamesubscription.subscriptionStatusIdsubscription.subscriptionStatusNamesubscription.skusubscription.currencyCodesubscription.pricesubscription.priceInUSDollarssubscription.priceConvertedAtsubscription.receiptDatasubscription.externalTransactionIdsubscription.createdAsTrialsubscription.trialDurationInDayssubscription.activatedAtsubscription.expiresAtsubscription.lastRenewAtsubscription.lastSyncAtsubscription.renewCountsubscription.extraDatasubscription.lastRenewSyncAtsubscription.convertedsubscription.convertedAtsubscription.expiredAtsubscription.activationsCountsubscription.originalReceiptsubscription.cancelReasonIdsubscription.cancelReasonNamesubscription.renewPeriodIdsubscription.renewPeriodNamesubscription.accountssubscription.environmentIdsubscription.environmentNamesubscription.mediaInformation.campaignIdsubscription.mediaInformation.campaignNetworksubscription.mediaInformation.raw
accountdomain:account.accountUUIDaccount.identityPoolaccount.emailaccount.msisdnaccount.facebookId
customdomain (This domain contains useful functions, it isn't related to any Kiwi's entity):custom.now: the current time in milliseconds.
Examples
URL:
https://service.io/monitoring?teste=${event.appInstallId}&teste2=${appInstall.platformName}&teste3=${appInstall.platformId}#teste4=${custom.now}https://service.io/${event.appInstallId}/#{appInstall.platformName}
Body:
EVENT_TO_LAMBDA Plugin
This plugin invokes an AWS's Lambda function.
EVENT_TO_SQS Plugin
This plugin sends the event to an AWS's SQS queue.
EVENT_TO_SNS Plugin
This plugin sends the event to an AWS's SNS topic.
EVENT_TO_KINESIS Plugin
This plugin sends the event to an AWS's Kinesis stream.
SNAPSHOT Plugin
This plugin snapshots the state of some Kiwi's entity i.e. AppInstall.
Last updated