File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
packages/service-utils/src/cf-worker Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -5,25 +5,33 @@ import type { UsageV2Event } from "src/core/usageV2.js";
55 * This method may throw. To call this non-blocking:
66 *
77 * ```ts
8- * void sendUsageV2Events("production", events).catch(console.error)
8+ * void sendUsageV2Events(events, {
9+ * environment: "production",
10+ * serviceKey: "..."
11+ * }).catch(console.error)
912 * ```
1013 *
11- * @param environment - The environment the service is running in.
1214 * @param events - The events to send.
15+ * @param options.environment - The environment the service is running in.
16+ * @param options.serviceKey - The service key required for authentication.
1317 */
1418export async function sendUsageV2Events (
15- environment : "development" | "production" ,
1619 events : UsageV2Event [ ] ,
20+ options : {
21+ environment : "development" | "production" ;
22+ serviceKey : string ;
23+ } ,
1724) : Promise < void > {
1825 const baseUrl =
19- environment === "production"
26+ options . environment === "production"
2027 ? "https://u.thirdweb.com"
2128 : "https://u.thirdweb-dev.com" ;
2229
2330 const resp = await fetch ( `${ baseUrl } /usage-v2/raw-events` , {
2431 method : "POST" ,
2532 headers : {
2633 "Content-Type" : "application/json" ,
34+ "x-service-api-key" : options . serviceKey ,
2735 } ,
2836 body : JSON . stringify ( { events } ) ,
2937 } ) ;
You can’t perform that action at this time.
0 commit comments