(action: string)
| 84 | |
| 85 | // 6. Helper function to log webhook events |
| 86 | const logWebhook = async (action: string) => { |
| 87 | try { |
| 88 | // Determine owner from integration |
| 89 | const owner = integration.owned_by_organization_id |
| 90 | ? { type: 'org' as const, id: integration.owned_by_organization_id } |
| 91 | : ({ type: 'user' as const, id: integration.owned_by_user_id } as Owner); |
| 92 | |
| 93 | const { event, isDuplicate } = await logWebhookEvent({ |
| 94 | owner, |
| 95 | platform: PLATFORM.GITLAB, |
| 96 | event_type: eventType, |
| 97 | event_action: action, |
| 98 | payload, |
| 99 | headers, |
| 100 | event_signature: eventSignature, |
| 101 | }); |
| 102 | |
| 103 | if (isDuplicate) { |
| 104 | logExceptInTest('Duplicate webhook event detected'); |
| 105 | return { isDuplicate: true, webhookEvent: event }; |
| 106 | } |
| 107 | return { isDuplicate: false, webhookEvent: event }; |
| 108 | } catch (error) { |
| 109 | logExceptInTest('Error logging webhook event:', error); |
| 110 | captureException(error, { |
| 111 | tags: { source: 'gitlab_webhook_event_logging' }, |
| 112 | extra: { event_type: eventType, event_action: action }, |
| 113 | }); |
| 114 | return { isDuplicate: false, webhookEvent: undefined }; |
| 115 | } |
| 116 | }; |
| 117 | |
| 118 | // 7. Route based on event type |
| 119 |
no test coverage detected