iHook

iHook

  • Blog
  • Docs
  • Dashboard

›All Blog Posts

All Blog Posts

  • July 2024 update
  • March 2023 update
  • August 2022 Update
  • May 2022 Update
  • September 2021 Update
  • May 2021 Update
  • February 2021 Update
  • December 2020 Update
  • October 2020 Update
  • September 2020 Update
  • August 2020 Update
  • How iHook uses iHook
  • July 2020 Update
  • June 2020 Update
  • May 2020 Update

How iHook uses iHook

August 14, 2020

Team iHook

A lot of worldwide popular products are heavily adopted by their internal team, such as Slack and Notion. In this article, we'll talk about how we use iHook in our daily operations.

Email Notification Volume Monitoring

Email notification is a critical component at iHook, to ensure the component functions properly, we constantly monitor the email notification traffic to identify abuse. There are two ways to approach this: one is to generate a log each time an email is delivered, and use analytics solutions such as Splunk to fire an alert if the email traffic exceeds a certain threshold; at iHook though, we realized that we could achieve this by setting up a scheduled iHook task.

The problem we are solving here is essentially counting email delivery events. So we created a database table that stores all such events.

CREATE TABLE `event` (
  `id` varchar(255) NOT NULL,
  `event_type` varchar(255) DEFAULT NULL,
  `data` mediumtext,
  `account_id` varchar(255) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `created_by` varchar(255) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `updated_by` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_event_created_at` (`created_at`),
  KEY `idx_event_event_type` (`event_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The schema is pretty straightforward but allows us to store user account id and additional data if we want to investigate further about the event. Whenever an email is delivered, we will create an event of type email.send.success and persist it in the database.

Then we created an API endpoint for us to count the events based on event_type and time range:

Request:

GET /api/v1/events/count?eventType=email.send.success&sinceMinsAgo=5

Response Body:

{
    "eventType": "email.send.success",
    "count": 128
}

Now we just need to create an iHook task that monitors the result of this API, and notify us when needed. Here's the task configuration:

blog-aug-dogfood-email-volume-task-config

Every 5 minutes, the task issues an HTTP request to our event count API and then evaluates a notification rule that checks the count property of the JSON response, when the count exceeds 5000, we will be notified via email.

blog-aug-dogfood-email-volume-email-config

Note that you may set up additional notifications via other channels such as SMS, Slack, and HTTP, in case the primary channel failed to deliver. Using the same pattern, we created more tasks to monitor events such as task execution failure and user account upgrade/downgrade.

The API runs efficiently since we've indexed the event_type db column. And this approach freed us from uploading log entries to a log analytics solution for monitoring, and thus reduces our cost.

User Growth Tracking

We feel super excited when a new user joins iHook - it's a validation of our product value and means more people could potentially benefit from iHook's automation capabilities. To better monitor user growth, we created a daily iHook email notification task.

iHook uses Okta for identity management, which means most iHook user profiles are stored and maintained at Okta. To retrieve iHook's total user count, we created a daily task that monitors Okta's user API.

Here's the task configuration:

blog-aug-dogfood-new-user-task-config

Once everyday, the task issues a GET request to Okta's user API, which returns a list of active user object in JSON format, and then evaluates a notification rule that checks the user list size via the length() JSON path expression, when it changed from its last evaluated value, an email notification will be sent.

blog-aug-dogfood-new-user-email-config

Note that the email template contains a template variable ${condition.evaluatedSourceValue} that would turn into the actual total user count when the emails are delivered.

The task saved us from implementing a custom notification logic in the user registration flow, and it had been working great so far!

Recent Posts
Copyright © 2024 iHook, Inc.