File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed
packages/service-utils/src/cf-worker Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @thirdweb-dev/service-utils " : patch
3+ ---
4+
5+ [ service-utils] Allow client-side usageV2 reporting
Original file line number Diff line number Diff line change @@ -28,14 +28,23 @@ export async function sendUsageV2Events(
2828 ? "https://u.thirdweb.com"
2929 : "https://u.thirdweb-dev.com" ;
3030
31- const headers : HeadersInit = {
32- "Content-Type" : "application/json" ,
33- } ;
31+ // Unauthed calls are routed to the /client path
32+ let url : string ;
33+ let headers : HeadersInit ;
3434 if ( options . serviceKey ) {
35- headers [ "x-service-api-key" ] = options . serviceKey ;
35+ url = `${ baseUrl } /usage-v2/${ options . source } ` ;
36+ headers = {
37+ "Content-Type" : "application/json" ,
38+ "x-service-api-key" : options . serviceKey ,
39+ } ;
40+ } else {
41+ url = `${ baseUrl } /usage-v2/${ options . source } /client` ;
42+ headers = {
43+ "Content-Type" : "application/json" ,
44+ } ;
3645 }
3746
38- const resp = await fetch ( ` ${ baseUrl } /usage-v2/ ${ options . source } ` , {
47+ const resp = await fetch ( url , {
3948 method : "POST" ,
4049 headers,
4150 body : JSON . stringify ( { events } ) ,
You can’t perform that action at this time.
0 commit comments