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
Fetch session replays from Sentry
Call the Sentry Replays API for the last 90 days (up to 1000 results)
Scoped to project xxxx9372441xx; authenticate with the provided Bearer token
Source: https://kognitos.sentry.io/explore/replays/?project=xxxx9372441xx&query=%21user.email%3A%EF%80%8DContains
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
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
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
| account_name | server | org_id |
|---|---|---|
| venXYZ@gmail.com | app.us-1.kognitos.com | AKp0bhpmTrUfzefOAb1ZA |
| divyZ@gmail.com | app.us-1.kognitos.com | BaCpUxEoE3dm2WRcL3vCa |
| abc-interiors | app.us-1.kognitos.com | CGwi5tKnM9hlm3uZoEWei |
| maryXYZ@gmail.com | app.us-1.kognitos.com | Y0UUP4IOSoy8PpzuqeHkV |
| mihirXYZ@gmail.com | app.us-1.kognitos.com | ZvJzUYvLJQw8nB8hwquHb |
No comments:
Post a Comment