File tree Expand file tree Collapse file tree 3 files changed +25
-9
lines changed
packages/service-utils/src Expand file tree Collapse file tree 3 files changed +25
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @thirdweb-dev/service-utils " : patch
3+ ---
4+
5+ [ service-utils] Omit team_id for client usageV2 events
Original file line number Diff line number Diff line change 1- import type { UsageV2Event , UsageV2Source } from "../core/usageV2.js" ;
1+ import type {
2+ ClientUsageV2Event ,
3+ UsageV2Event ,
4+ UsageV2Source ,
5+ } from "../core/usageV2.js" ;
26
37type UsageV2Options = {
48 environment : "development" | "production" ;
@@ -17,14 +21,18 @@ type UsageV2Options = {
1721 * - thirdwebClientId: for public clients (MUST be the user's project)
1822 * - thirdwebSecretKey: for public clients (MUST be the user's project)
1923 *
24+ * NOTE: `team_id` is required if `serviceKey` is provided.
25+ *
2026 * This method may throw. To call this non-blocking:
2127 * ```ts
2228 * void sendUsageV2Events(...).catch((e) => console.error(e))
2329 * ```
2430 */
25- export async function sendUsageV2Events (
26- events : UsageV2Event [ ] ,
27- options : UsageV2Options ,
31+ export async function sendUsageV2Events < T extends UsageV2Options > (
32+ events : T extends { serviceKey : string }
33+ ? UsageV2Event [ ]
34+ : ClientUsageV2Event [ ] ,
35+ options : T ,
2836) : Promise < void > {
2937 const baseUrl =
3038 options . environment === "production"
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ export function getTopicName(source: UsageV2Source) {
1313 return `usage_v2.raw_${ source } ` ;
1414}
1515
16- export interface UsageV2Event {
16+ export interface ClientUsageV2Event {
1717 /**
1818 * A unique identifier for the event. Defaults to a random UUID.
1919 * Useful if your service retries sending events.
@@ -27,10 +27,6 @@ export interface UsageV2Event {
2727 * The action of the event. Example: "upload"
2828 */
2929 action : string ;
30- /**
31- * The team ID.
32- */
33- team_id : string ;
3430 /**
3531 * The project ID, if available.
3632 */
@@ -65,3 +61,10 @@ export interface UsageV2Event {
6561 */
6662 [ key : string ] : boolean | number | string | Date | null | undefined ;
6763}
64+
65+ export interface UsageV2Event extends ClientUsageV2Event {
66+ /**
67+ * The team ID.
68+ */
69+ team_id : string ;
70+ }
You can’t perform that action at this time.
0 commit comments