Skip to content

Commit

Permalink
feat: test notion insert events
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Feb 24, 2024
1 parent d50e013 commit 0bbd49d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/api/src/routes/leafwatch/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import requestIp from 'request-ip';
import catchedError from 'src/lib/catchedError';
import createClickhouseClient from 'src/lib/createClickhouseClient';
import checkEventExistence from 'src/lib/leafwatch/checkEventExistence';
import { notionText, notionTitle } from 'src/lib/notion/notionBlocks';
import pushToNotionDatabase from 'src/lib/notion/pushToNotionDatabase';
import { invalidBody, noBody } from 'src/lib/responses';
import UAParser from 'ua-parser-js';
import urlcat from 'urlcat';
import { v4 as uuid } from 'uuid';
import { any, object, string } from 'zod';

type ExtensionRequest = {
Expand Down Expand Up @@ -110,6 +113,13 @@ export const post: Handler = async (req, res) => {
}
]
});

pushToNotionDatabase('68a15fd7751a408fb6e6ceedc715639a', {
Actor: notionText(actor || 'N/A'),
Event: notionText(name),
ID: notionTitle(uuid())
});

logger.info('Ingested event to Leafwatch');

return res.status(200).json({ id: result.query_id, success: true });
Expand Down

0 comments on commit 0bbd49d

Please sign in to comment.