diff --git a/apps/web/src/app/(app)/settings/developers/logs/[logId]/page.tsx b/apps/web/src/app/(app)/settings/developers/logs/[logId]/page.tsx index d3b4a1e..f6c0581 100644 --- a/apps/web/src/app/(app)/settings/developers/logs/[logId]/page.tsx +++ b/apps/web/src/app/(app)/settings/developers/logs/[logId]/page.tsx @@ -38,6 +38,10 @@ export default async function WebhookLogsDetails({ ? getParsedText(webhookLog.requestBody) : null + const parsedRequestHeaders = webhookLog.requestHeaders + ? getParsedText(webhookLog.requestHeaders) + : null + const parsedResponseBody = webhookLog.responseBody ? getParsedText(webhookLog.responseBody) : null @@ -49,6 +53,13 @@ export default async function WebhookLogsDetails({ }) : null + const highlightedRequestHeaders = parsedRequestHeaders + ? highlighter.codeToHtml(parsedRequestHeaders.code, { + lang: parsedRequestHeaders.lang, + themes: { light: 'rose-pine-dawn', dark: 'vesper' }, + }) + : null + const highlightedResponseBody = parsedResponseBody ? highlighter.codeToHtml(parsedResponseBody.code, { lang: parsedResponseBody.lang, @@ -137,6 +148,17 @@ export default async function WebhookLogsDetails({ </Table> </div> <Separator /> + {highlightedRequestHeaders && ( + <div className="space-y-2"> + <span className="text-sm font-semibold tracking-tight"> + Request Headers + </span> + <div + className="max-h-72 overflow-y-scroll bg-muted p-6 text-sm" + dangerouslySetInnerHTML={{ __html: highlightedRequestHeaders }} + /> + </div> + )} {highlightedRequestBody && ( <div className="space-y-2"> <span className="text-sm font-semibold tracking-tight"> diff --git a/packages/drizzle/migrations/0011_typical_mariko_yashida.sql b/packages/drizzle/migrations/0011_typical_mariko_yashida.sql new file mode 100644 index 0000000..1d8a7cb --- /dev/null +++ b/packages/drizzle/migrations/0011_typical_mariko_yashida.sql @@ -0,0 +1 @@ +ALTER TABLE "company_webhook_logs" ADD COLUMN "request_headers" text; \ No newline at end of file diff --git a/packages/drizzle/migrations/meta/0011_snapshot.json b/packages/drizzle/migrations/meta/0011_snapshot.json new file mode 100644 index 0000000..ba8e674 --- /dev/null +++ b/packages/drizzle/migrations/meta/0011_snapshot.json @@ -0,0 +1,1054 @@ +{ + "id": "7ad3bb32-9f4b-4c61-a6ab-9ac7ccac1814", + "prevId": "36a72c24-5979-420b-a334-d95b9a4d9963", + "version": "5", + "dialect": "pg", + "tables": { + "accounts": { + "name": "accounts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "accounts_provider_provider_account_id_index": { + "name": "accounts_provider_provider_account_id_index", + "columns": [ + "provider", + "provider_account_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "accounts_user_id_users_id_fk": { + "name": "accounts_user_id_users_id_fk", + "tableFrom": "accounts", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "companies": { + "name": "companies", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "domain": { + "name": "domain", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "external_id": { + "name": "external_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_api_key": { + "name": "external_api_key", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "companies_domain_index": { + "name": "companies_domain_index", + "columns": [ + "domain" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sessions": { + "name": "sessions", + "schema": "", + "columns": { + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tag_to_uploads": { + "name": "tag_to_uploads", + "schema": "", + "columns": { + "tag_id": { + "name": "tag_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "upload_id": { + "name": "upload_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "tag_to_uploads_tag_id_upload_id_index": { + "name": "tag_to_uploads_tag_id_upload_id_index", + "columns": [ + "tag_id", + "upload_id" + ], + "isUnique": true + }, + "tag_to_uploads_upload_id_index": { + "name": "tag_to_uploads_upload_id_index", + "columns": [ + "upload_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tag_to_uploads_tag_id_tags_id_fk": { + "name": "tag_to_uploads_tag_id_tags_id_fk", + "tableFrom": "tag_to_uploads", + "tableTo": "tags", + "columnsFrom": [ + "tag_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "tag_to_uploads_upload_id_uploads_id_fk": { + "name": "tag_to_uploads_upload_id_uploads_id_fk", + "tableFrom": "tag_to_uploads", + "tableTo": "uploads", + "columnsFrom": [ + "upload_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "tags": { + "name": "tags", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "tags_slug_index": { + "name": "tags_slug_index", + "columns": [ + "slug" + ], + "isUnique": true + } + }, + "foreignKeys": { + "tags_company_id_companies_id_fk": { + "name": "tags_company_id_companies_id_fk", + "tableFrom": "tags", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "transcriptions": { + "name": "transcriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "upload_id": { + "name": "upload_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "transcriptions_upload_id_index": { + "name": "transcriptions_upload_id_index", + "columns": [ + "upload_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "transcriptions_upload_id_uploads_id_fk": { + "name": "transcriptions_upload_id_uploads_id_fk", + "tableFrom": "transcriptions", + "tableTo": "uploads", + "columnsFrom": [ + "upload_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "transcription_segments": { + "name": "transcription_segments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "transcription_id": { + "name": "transcription_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "end": { + "name": "end", + "type": "numeric(10, 2)", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "transcription_segments_transcription_id_transcriptions_id_fk": { + "name": "transcription_segments_transcription_id_transcriptions_id_fk", + "tableFrom": "transcription_segments", + "tableTo": "transcriptions", + "columnsFrom": [ + "transcription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "upload_batches": { + "name": "upload_batches", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "upload_batches_author_id_users_id_fk": { + "name": "upload_batches_author_id_users_id_fk", + "tableFrom": "upload_batches", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "upload_batches_company_id_companies_id_fk": { + "name": "upload_batches_company_id_companies_id_fk", + "tableFrom": "upload_batches", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": { + "users_company_id_companies_id_fk": { + "name": "users_company_id_companies_id_fk", + "tableFrom": "users", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "verification_tokens": { + "name": "verification_tokens", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "verification_tokens_token_index": { + "name": "verification_tokens_token_index", + "columns": [ + "token" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "verification_tokens_identifier_token_pk": { + "name": "verification_tokens_identifier_token_pk", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": {} + }, + "uploads": { + "name": "uploads", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_key": { + "name": "storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upload_batch_id": { + "name": "upload_batch_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "external_provider_id": { + "name": "external_provider_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_status": { + "name": "external_status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_stream_url": { + "name": "external_stream_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "audio_storage_key": { + "name": "audio_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "processed_at": { + "name": "processed_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "size_in_bytes": { + "name": "size_in_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "upload_order": { + "name": "upload_order", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "commit_url": { + "name": "commit_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "subtitles_storage_key": { + "name": "subtitles_storage_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pt'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "uploads_external_provider_id_index": { + "name": "uploads_external_provider_id_index", + "columns": [ + "external_provider_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "uploads_upload_batch_id_upload_batches_id_fk": { + "name": "uploads_upload_batch_id_upload_batches_id_fk", + "tableFrom": "uploads", + "tableTo": "upload_batches", + "columnsFrom": [ + "upload_batch_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "cascade" + }, + "uploads_company_id_companies_id_fk": { + "name": "uploads_company_id_companies_id_fk", + "tableFrom": "uploads", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + }, + "uploads_author_id_users_id_fk": { + "name": "uploads_author_id_users_id_fk", + "tableFrom": "uploads", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "upload_webhooks": { + "name": "upload_webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "upload_id": { + "name": "upload_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "UploadWebhookType", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "UploadWebhookStatus", + "primaryKey": false, + "notNull": true, + "default": "'RUNNING'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "upload_webhooks_upload_id_uploads_id_fk": { + "name": "upload_webhooks_upload_id_uploads_id_fk", + "tableFrom": "upload_webhooks", + "tableTo": "uploads", + "columnsFrom": [ + "upload_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "company_webhooks": { + "name": "company_webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_id": { + "name": "company_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "signing_key": { + "name": "signing_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "text[]", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "company_webhooks_company_id_url_index": { + "name": "company_webhooks_company_id_url_index", + "columns": [ + "company_id", + "url" + ], + "isUnique": true + } + }, + "foreignKeys": { + "company_webhooks_company_id_companies_id_fk": { + "name": "company_webhooks_company_id_companies_id_fk", + "tableFrom": "company_webhooks", + "tableTo": "companies", + "columnsFrom": [ + "company_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "company_webhook_logs": { + "name": "company_webhook_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "company_webhook_id": { + "name": "company_webhook_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "CompanyWebhookLogStatus", + "primaryKey": false, + "notNull": true, + "default": "'PENDING'" + }, + "error_reason": { + "name": "error_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "http_code": { + "name": "http_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "http_method": { + "name": "http_method", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_body": { + "name": "request_body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "request_headers": { + "name": "request_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "response_body": { + "name": "response_body", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "status_idx": { + "name": "status_idx", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "company_webhook_logs_company_webhook_id_company_webhooks_id_fk": { + "name": "company_webhook_logs_company_webhook_id_company_webhooks_id_fk", + "tableFrom": "company_webhook_logs", + "tableTo": "company_webhooks", + "columnsFrom": [ + "company_webhook_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "UploadWebhookStatus": { + "name": "UploadWebhookStatus", + "values": { + "ERROR": "ERROR", + "SUCCESS": "SUCCESS", + "RUNNING": "RUNNING" + } + }, + "UploadWebhookType": { + "name": "UploadWebhookType", + "values": { + "CREATE_SUBTITLES_FROM_TRANSCRIPTION": "CREATE_SUBTITLES_FROM_TRANSCRIPTION", + "UPDATE_EXTERNAL_PROVIDER_STATUS": "UPDATE_EXTERNAL_PROVIDER_STATUS", + "UPLOAD_TO_EXTERNAL_PROVIDER": "UPLOAD_TO_EXTERNAL_PROVIDER", + "CREATE_TRANSCRIPTION": "CREATE_TRANSCRIPTION", + "PROCESS_VIDEO": "PROCESS_VIDEO" + } + }, + "CompanyWebhookLogStatus": { + "name": "CompanyWebhookLogStatus", + "values": { + "PENDING": "PENDING", + "SUCCESS": "SUCCESS", + "ERROR": "ERROR" + } + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/drizzle/migrations/meta/_journal.json b/packages/drizzle/migrations/meta/_journal.json index 8c5e635..a7acf06 100644 --- a/packages/drizzle/migrations/meta/_journal.json +++ b/packages/drizzle/migrations/meta/_journal.json @@ -78,6 +78,13 @@ "when": 1708109787828, "tag": "0010_glamorous_sharon_ventura", "breakpoints": true + }, + { + "idx": 11, + "version": "5", + "when": 1709384306801, + "tag": "0011_typical_mariko_yashida", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/drizzle/schema/company-webhook-log.ts b/packages/drizzle/schema/company-webhook-log.ts index 9edd1d7..9400dda 100644 --- a/packages/drizzle/schema/company-webhook-log.ts +++ b/packages/drizzle/schema/company-webhook-log.ts @@ -31,6 +31,7 @@ export const companyWebhookLog = pgTable( httpCode: text('http_code'), httpMethod: text('http_method'), requestBody: text('request_body'), + requestHeaders: text('request_headers'), responseBody: text('response_body'), createdAt: timestamp('created_at').defaultNow().notNull(), finishedAt: timestamp('finished_at'), diff --git a/packages/webhooks/src/handle-webhook-event.ts b/packages/webhooks/src/handle-webhook-event.ts index 6d4ec74..db98a56 100644 --- a/packages/webhooks/src/handle-webhook-event.ts +++ b/packages/webhooks/src/handle-webhook-event.ts @@ -32,14 +32,6 @@ export async function handleWebhookEvent({ throw new Error('Company webhook does not exist anymore.') } - await db.insert(companyWebhookLog).values({ - id: webhookLogId, - companyWebhookId, - status: 'PENDING', - httpMethod: 'POST', - requestBody, - }) - const encoder = new TextEncoder() const encodedSigningKey = encoder.encode(companyWebhook.signingKey) @@ -52,13 +44,24 @@ export async function handleWebhookEvent({ const jwt = await signJWT.sign(encodedSigningKey) + const requestHeaders = { + 'Content-Type': 'application/json', + 'Nivo-Signature': jwt, + } + + await db.insert(companyWebhookLog).values({ + id: webhookLogId, + companyWebhookId, + status: 'PENDING', + httpMethod: 'POST', + requestBody, + requestHeaders: JSON.stringify(requestHeaders), + }) + const response = await fetch(deliverTo, { method: 'POST', body: requestBody, - headers: { - 'Content-Type': 'application/json', - 'Nivo-Signature': jwt, - }, + headers: requestHeaders, }) const httpCode = response.status.toString()