Quick start

Learn how to use Sentry (estimated time: 10 mins)

Sentry is real time alerting system designed to be easily integrated into existing DeFi apps.

In this quick start, you will learn the basics to configure your account, create your first users, create user's subscriptions and receive your first real time generated alerts.

Requirements

  • You have an account

  • You have an API key

If you don't already have an account, you can contact us on https://www.aleno.ai

For windows user: CURL commands might need to be adapted using Invoke-WebRequest.

1. Get a test URL

Sentry is deigned to send notifications with webhooks: It sends notifications with POST request to an URL that you can define and update. So the first step is to tell the system where to send notifications by setting up your webhook URL.

In this demo section, we will use a simple online tool (Webhook.site) to get a testing URL for your notifications:

  1. Copy the provided URL

  2. Keep this window open during all the following steps (we will use it to see incoming notifications)

In this section, we propose to use a test URL with Webhook.Site. For a real use case, you would use a URL from your own server to handle the logic of what to do with incoming notifications.

2. Set up your webhook URL

Once you have a test URL on which you can see incomming notifications, you need to give to sentry this URL. To set this URL on your account, you have to use the PUT/account API route. Run the following lines in your terminal:

curl -X PUT \
  https://sentry.aleno.ai/account \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY' \
  -d '{"webhookUrl": "YOUR_WEBHOOK_URL"}'

Don't forget to replace YOUR_API_KEY by your actual API key and YOUR_WEBHOOK_URL by the URL from previous step.

Route documentation at Set your webhook URL.

You should see a success message in your terminal:

{
    "data": {
        "alertOutputs": {
            "webhookUrl": "YOUR_WEBHOOK_URL"
        },
        "message": "Your outputs have been successfully updated"
    }
}

3. Create your first users

The next step is to create your users. A user is an entity that can have subscriptions to track metrics and receive notifications.

To create users, you can use the API POST/users route. In this example we will create one user named "Alice". Run the following command in your terminal:

curl -X POST \
  https://sentry.aleno.ai/users \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "users": [
        { "userName": "Alice", "userContext": "alice_context" }
    ]
}'

In your terminal you should see the response your the newly created users. Keep the ID of created user, it will be used in next step (the ID corresponds to "YOUR_USER_ID" that you will get in the result. It will be a UUID string).

{
    "data": [
        {
            "id": "YOUR_USER_ID",
            "accountId": "938862f0-f629-413d-bc88-a7a4fe54e2ad",
            "userName": "Alice",
            "userContext": "alice_context",
            "createdAt": "2024-03-18T14:45:14.747Z",
            "updatedAt": "2024-03-18T14:45:14.747Z"
        }
    ]
}

Route documentation at Create users

4. Create user's subscriptions

Now that you have a user, you can add a subscription on a metric to this user. A subscription tells the system "This user is following this metric, if the value changes too much, create an alert.".

In this example, we will create the following subscription: "If the total TVL on WETH changes by more than 0.0001 %, create and send an alert" (threshold is intentionally very low to test alerts).

To create this subscription, you can use the API POST/subscriptions route. Run the following command in your terminal:

curl -X POST \
  https://sentry.aleno.ai/subscriptions \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY' \
  -d '{
    "subscriptions": [
        {
            "userId": "YOUR_USER_ID",
            "metricKey": "eth_token_total_tvl_0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
            "threshold": 0.0001
        }
    ]
}'

Don't forget to replace YOUR_API_KEY by your actual API key and replace YOUR_USER_ID by the actual user ID you got from previous step.

In this example, the threshold is set to the minimum value. This is because we want to generate notifications so that you can quickly see the resulting notification without having to wait for a huge variation on this metric.

Route documentation at Create subscriptions. If you want to know all available metrics, check Get available metrics section.

5. Get real time alerts

The subscription we defined on previous step has a very low threshold, so a new alert should be quickly triggered. On Ethereum chain, 1 block is mined every 15 seconds on average. So after 15 seconds maximum, a new alert should be generated and sent to the URL we defined on step 1.

Open your Webhook.Site window from step 1, you should see an incoming POST request with an alert corresponding to the alert setting defined on previous step:

Alert data description under Alert section.

6. Delete test users

That's it ! You have successfully done the following actions:

  • set webhook URL

  • create user

  • create subscription to generate alerts for your users

  • received generated real time alerts

You can now delete your test user with the API DELETE/users route. Run the following command in your terminal:

curl -X DELETE \
  'https://sentry.aleno.ai/users?ids=YOUR_USER_ID' \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY'

Deleting a user deletes all its associated subscriptions. Route documentation under Delete users.

You can also reset your webhook URL to null (in step 2. it was set to a test URL) using the same route as step 2. Run the following command in your terminal:

curl -X PUT \
  https://sentry.aleno.ai/account \
  -H 'accept: application/json' \
  -H 'Authorization: YOUR_API_KEY' \
  -d '{"webhookUrl": null}'

Last updated