Policies
Moesif Analytics & Billing Policy
Moesif moesif.com is an API analytics and monetization platform. This policy allows you to measure (and meter) API calls flowing through your Zuplo gateway.
Add the policy to each route you want to meter. Note you can specify the Meter API Name and Meter Value (meter increment) at the policy level.
Configuration
The configuration shows how to configure the policy in the 'policies.json' document.
Policy Options
The options for this policy are specified below. All properties are optional unless specifically marked as required.
applicationId
<string> (Required) -Your Moesif application ID.logRequestBody
<boolean> -Set to false to disable sending the request body to Moesif.Defaults totrue
.logResponseBody
<boolean> -Set to false to disable sending the response body to Moesif.Defaults totrue
.
Using the Policy
By default, Zuplo will read the request.user.sub
property and assign this as
the moesif user_id
attribute when sending to Moesif. However, this and the
following attributes can be overriden in a
custom code policy.
api_version
company_id
session_token
user_id
metadata
Here is some example code that shows how to override two of these attributes
Execute on every route#
If you want to execute this policy on every route, you can add a hook in your
runtime extensions file zuplo.runtime.ts
:
Note you can add a guard clause around the context.invokeInboundPolicy if you want to exclude a few routes.
Read more about how policies work