@@ -5,7 +5,7 @@ import type {
55} from "../core/usageV2.js" ;
66
77type UsageV2Options = {
8- environment : "development" | "production" ;
8+ usageBaseUrl : string ;
99 source : UsageV2Source ;
1010} & (
1111 | { serviceKey : string ; thirdwebClientId ?: never ; thirdwebSecretKey ?: never }
@@ -34,23 +34,18 @@ export async function sendUsageV2Events<T extends UsageV2Options>(
3434 : ClientUsageV2Event [ ] ,
3535 options : T ,
3636) : Promise < void > {
37- const baseUrl =
38- options . environment === "production"
39- ? "https://u.thirdweb.com"
40- : "https://u.thirdweb-dev.com" ;
41-
4237 // Determine endpoint and auth header based on provided credentials.
4338 let url : string ;
4439 const headers : HeadersInit = { "Content-Type" : "application/json" } ;
4540
4641 if ( options . serviceKey ) {
47- url = `${ baseUrl } /usage-v2/${ options . source } ` ;
42+ url = `${ options . usageBaseUrl } /usage-v2/${ options . source } ` ;
4843 headers [ "x-service-api-key" ] = options . serviceKey ;
4944 } else if ( options . thirdwebSecretKey ) {
50- url = `${ baseUrl } /usage-v2/${ options . source } /client` ;
45+ url = `${ options . usageBaseUrl } /usage-v2/${ options . source } /client` ;
5146 headers [ "x-secret-key" ] = options . thirdwebSecretKey ;
5247 } else if ( options . thirdwebClientId ) {
53- url = `${ baseUrl } /usage-v2/${ options . source } /client` ;
48+ url = `${ options . usageBaseUrl } /usage-v2/${ options . source } /client` ;
5449 headers [ "x-client-id" ] = options . thirdwebClientId ;
5550 } else {
5651 throw new Error ( "[UsageV2] No authentication method provided." ) ;
0 commit comments