File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
packages/service-utils/src/cf-worker Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 1- import type { ServiceName } from "../core/services.js" ;
2- import type { UsageV2Event } from "../core/usageV2.js" ;
1+ import type { UsageV2Event , UsageV2Source } from "../core/usageV2.js" ;
32
43/**
54 * Send events to Kafka.
@@ -20,21 +19,25 @@ export async function sendUsageV2Events(
2019 events : UsageV2Event [ ] ,
2120 options : {
2221 environment : "development" | "production" ;
23- productName : ServiceName ;
24- serviceKey : string ;
22+ source : UsageV2Source ;
23+ serviceKey ? : string ;
2524 } ,
2625) : Promise < void > {
2726 const baseUrl =
2827 options . environment === "production"
2928 ? "https://u.thirdweb.com"
3029 : "https://u.thirdweb-dev.com" ;
3130
32- const resp = await fetch ( `${ baseUrl } /usage-v2/${ options . productName } ` , {
31+ const headers : HeadersInit = {
32+ "Content-Type" : "application/json" ,
33+ } ;
34+ if ( options . serviceKey ) {
35+ headers [ "x-service-api-key" ] = options . serviceKey ;
36+ }
37+
38+ const resp = await fetch ( `${ baseUrl } /usage-v2/${ options . source } ` , {
3339 method : "POST" ,
34- headers : {
35- "Content-Type" : "application/json" ,
36- "x-service-api-key" : options . serviceKey ,
37- } ,
40+ headers,
3841 body : JSON . stringify ( { events } ) ,
3942 } ) ;
4043
You can’t perform that action at this time.
0 commit comments