Tuesday, April 21, 2026

Kognitos Automation: Problem to a Solution

 As we were developing the product, we were missing a quick identification of the org ID to a user.  To fill in the gap and proactively reachout to the customer, if there is an issue with an Org ID, this automation was created.

Quick Prompt to Kognitos - 

Using the Sentry API (via HTTP with Bearer token auth), fetch the last 30 days of session replays from https://sentry.io/api/0/organizations/kognitos/replays/?limit=100&statsPeriod=30d, excluding any users whose email contains "kognitos.com". Update the notion page.

After few further chats, Kognitos built this SOP:

Overview

Fetches the last 30 days of Sentry session replays, filters out internal kognitos.com users, and produces a table mapping each organization to its account names and server.

Execution Steps

  1. Fetch session replays from Sentry

  1. Filter replays and extract org-user mappings

    • Exclude users whose email contains "kognitos.com" or "kogmail"

    • For each remaining replay, scan its visited URLs for /organizations/{id}/ paths:

      • org_id: the path segment immediately after /organizations/

      • server: the hostname from the absolute URL (e.g. app.us-1.kognitos.com)

      • account_name: derived from the user's email domain stem (e.g. al@wip.com → wip); Gmail users use their full email address

    • One row per unique org_id; multiple account names are comma-separated and deduplicated

    • Skip relative URLs (no hostname), URLs without /organizations/, and entries with empty org IDs

  1. Build and output the org_users_table

    • Assemble one row per org_id with columns:

      • account_name: comma-separated deduplicated account name stems

      • server: hostname where this org's sessions were recorded

      • org_id: unique org ID extracted from /organizations/{id}/ in the URL

  1. Sync new orgs to Notion table

    • Notion page: https://www.notion.so/kognitos/v2-Org-to-User-Information

    • Read the existing rows from the Notion table (page ID: xxxx-4b61-8021-95ad-ec7xxxxx,

    • table block ID: xxxx-4b61-8021-95ad-ec7xxxxx

    • Collect all org_ids already present in Notion; compare against today's results

    • Append a new table_row block for each org_id not yet in Notion

    • Columns: account_name | server | org_id

Notion Updated with this info and Kognitos is scheduled to run every day to get the new users info.
account_nameserverorg_id


venXYZ@gmail.comapp.us-1.kognitos.comAKp0bhpmTrUfzefOAb1ZA
divyZ@gmail.comapp.us-1.kognitos.comBaCpUxEoE3dm2WRcL3vCa
abc-interiorsapp.us-1.kognitos.comCGwi5tKnM9hlm3uZoEWei
maryXYZ@gmail.comapp.us-1.kognitos.comY0UUP4IOSoy8PpzuqeHkV
mihirXYZ@gmail.comapp.us-1.kognitos.comZvJzUYvLJQw8nB8hwquHb

No comments:

Post a Comment

Quick Kognitos Automation - picking a needle:customer info in the haystack:logs

  From Sentry Replays to Org IDs: Closing the Gap With Automation When product development outpaces internal tooling, a quick prompt to Kogn...