Skip to content

Commit 1bdcd9e

Browse files
committed
feat(sdk): configure analytics url
1 parent 7a9713e commit 1bdcd9e

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

.changeset/red-garlics-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Enable configuring the analytics endpoint

apps/playground-web/src/lib/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ setThirdwebDomains({
88
storage: process.env.NEXT_PUBLIC_STORAGE_URL,
99
bundler: process.env.NEXT_PUBLIC_BUNDLER_URL,
1010
pay: process.env.NEXT_PUBLIC_PAY_URL,
11+
analytics: process.env.NEXT_PUBLIC_ANALYTICS_URL,
1112
});
1213

1314
const isDev =

packages/thirdweb/src/analytics/track/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import type { ThirdwebClient } from "../../client/client.js";
2+
import { getThirdwebBaseUrl } from "../../utils/domains.js";
23
import { getClientFetch } from "../../utils/fetch.js";
34
import { stringify } from "../../utils/json.js";
45
import type { Ecosystem } from "../../wallets/in-app/core/wallet/types.js";
56

6-
const ANALYTICS_ENDPOINT = "https://c.thirdweb.com/event";
7-
87
/**
98
* @internal
109
*/
@@ -23,7 +22,7 @@ export async function track({
2322
...data,
2423
};
2524

26-
return fetch(ANALYTICS_ENDPOINT, {
25+
return fetch(`${getThirdwebBaseUrl("analytics")}/event`, {
2726
method: "POST",
2827
body: stringify(event),
2928
}).catch(() => {});

packages/thirdweb/src/utils/domains.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ type DomainOverrides = {
2929
* @default "bundler.thirdweb.com"
3030
*/
3131
bundler?: string;
32+
/**
33+
* The base URL for the analytics server.
34+
* @default "c.thirdweb.com"
35+
*/
36+
analytics?: string;
3237
};
3338

3439
export const DEFAULT_RPC_URL = "rpc.thirdweb.com";
@@ -37,6 +42,7 @@ const DEFAULT_IN_APP_WALLET_URL = "embedded-wallet.thirdweb.com";
3742
const DEFAULT_PAY_URL = "pay.thirdweb.com";
3843
const DEFAULT_STORAGE_URL = "storage.thirdweb.com";
3944
const DEFAULT_BUNDLER_URL = "bundler.thirdweb.com";
45+
const DEFAULT_ANALYTICS_URL = "c.thirdweb.com";
4046

4147
let domains: { [k in keyof DomainOverrides]-?: string } = {
4248
rpc: DEFAULT_RPC_URL,
@@ -45,6 +51,7 @@ let domains: { [k in keyof DomainOverrides]-?: string } = {
4551
pay: DEFAULT_PAY_URL,
4652
storage: DEFAULT_STORAGE_URL,
4753
bundler: DEFAULT_BUNDLER_URL,
54+
analytics: DEFAULT_ANALYTICS_URL,
4855
};
4956

5057
/**
@@ -58,6 +65,7 @@ export const setThirdwebDomains = (DomainOverrides: DomainOverrides) => {
5865
pay: DomainOverrides.pay ?? DEFAULT_PAY_URL,
5966
storage: DomainOverrides.storage ?? DEFAULT_STORAGE_URL,
6067
bundler: DomainOverrides.bundler ?? DEFAULT_BUNDLER_URL,
68+
analytics: DomainOverrides.analytics ?? DEFAULT_ANALYTICS_URL,
6169
};
6270
};
6371

0 commit comments

Comments
 (0)