1 | |
2 | type Brevo = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Get detailed attribution metrics for a single Brevo campaign or workflow |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Brevo, |
11 | conversionSource: |
12 | | "email_campaign" |
13 | | "sms_campaign" |
14 | | "automation_workflow_email" |
15 | | "automation_workflow_sms", |
16 | conversionSourceId: string, |
17 | ) { |
18 | const url = new URL( |
19 | `https://api.brevo.com/v3/ecommerce/attribution/metrics/${conversionSource}/${conversionSourceId}`, |
20 | ); |
21 |
|
22 | const response = await fetch(url, { |
23 | method: "GET", |
24 | headers: { |
25 | "api-key": auth.apiKey, |
26 | }, |
27 | body: undefined, |
28 | }); |
29 | if (!response.ok) { |
30 | const text = await response.text(); |
31 | throw new Error(`${response.status} ${text}`); |
32 | } |
33 | return await response.json(); |
34 | } |
35 |
|