Skip to content

Commit 6bd9683

Browse files
committed
chore: Allow optional includeUsage (default: true) (#5477)
<!-- start pr-codex --> ## PR-Codex overview This PR introduces an optional `includeUsage` parameter to the `CoreServiceConfig` type and updates API URL construction to utilize this parameter, defaulting to `true`. This allows for more flexible API calls regarding usage data. ### Detailed summary - Added optional `includeUsage` parameter to `CoreServiceConfig`. - Updated `fetchKeyMetadataFromApi` to use `includeUsage` in the API URL. - Updated `fetchAccountFromApi` to use `includeUsage` in the API URL for both wallet and account endpoints. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 17488b8 commit 6bd9683

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

.changeset/gold-pumpkins-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
chore: Allow optional includeUsage (default: true)

packages/service-utils/src/core/api.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type CoreServiceConfig = {
2020
serviceApiKey: string;
2121
serviceAction?: string;
2222
useWalletAuth?: boolean;
23+
includeUsage?: boolean;
2324
};
2425

2526
type Usage = {
@@ -85,8 +86,8 @@ export async function fetchKeyMetadataFromApi(
8586
clientId: string,
8687
config: CoreServiceConfig,
8788
): Promise<ApiResponse> {
88-
const { apiUrl, serviceScope, serviceApiKey } = config;
89-
const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=true`;
89+
const { apiUrl, serviceScope, serviceApiKey, includeUsage = true } = config;
90+
const url = `${apiUrl}/v1/keys/use?clientId=${clientId}&scope=${serviceScope}&includeUsage=${includeUsage}`;
9091
const response = await fetch(url, {
9192
method: "GET",
9293
headers: {
@@ -111,10 +112,10 @@ export async function fetchAccountFromApi(
111112
config: CoreServiceConfig,
112113
useWalletAuth: boolean,
113114
): Promise<ApiAccountResponse> {
114-
const { apiUrl, serviceApiKey } = config;
115+
const { apiUrl, serviceApiKey, includeUsage = true } = config;
115116
const url = useWalletAuth
116-
? `${apiUrl}/v1/wallet/me?includeUsage=true`
117-
: `${apiUrl}/v1/account/me?includeUsage=true`;
117+
? `${apiUrl}/v1/wallet/me?includeUsage=${includeUsage}`
118+
: `${apiUrl}/v1/account/me?includeUsage=${includeUsage}`;
118119
const response = await fetch(url, {
119120
method: "GET",
120121
headers: {

0 commit comments

Comments
 (0)