Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/red-garlics-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Enable configuring the analytics endpoint
1 change: 1 addition & 0 deletions apps/playground-web/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ setThirdwebDomains({
storage: process.env.NEXT_PUBLIC_STORAGE_URL,
bundler: process.env.NEXT_PUBLIC_BUNDLER_URL,
pay: process.env.NEXT_PUBLIC_PAY_URL,
analytics: process.env.NEXT_PUBLIC_ANALYTICS_URL,
});

const isDev =
Expand Down
5 changes: 2 additions & 3 deletions packages/thirdweb/src/analytics/track/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { ThirdwebClient } from "../../client/client.js";
import { getThirdwebBaseUrl } from "../../utils/domains.js";
import { getClientFetch } from "../../utils/fetch.js";
import { stringify } from "../../utils/json.js";
import type { Ecosystem } from "../../wallets/in-app/core/wallet/types.js";

const ANALYTICS_ENDPOINT = "https://c.thirdweb.com/event";

/**
* @internal
*/
Expand All @@ -23,7 +22,7 @@ export async function track({
...data,
};

return fetch(ANALYTICS_ENDPOINT, {
return fetch(`${getThirdwebBaseUrl("analytics")}/event`, {
method: "POST",
body: stringify(event),
}).catch(() => {});
Expand Down
8 changes: 8 additions & 0 deletions packages/thirdweb/src/utils/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
* @default "bundler.thirdweb.com"
*/
bundler?: string;
/**
* The base URL for the analytics server.
* @default "c.thirdweb.com"
*/
analytics?: string;
};

export const DEFAULT_RPC_URL = "rpc.thirdweb.com";
Expand All @@ -37,6 +42,7 @@
const DEFAULT_PAY_URL = "pay.thirdweb.com";
const DEFAULT_STORAGE_URL = "storage.thirdweb.com";
const DEFAULT_BUNDLER_URL = "bundler.thirdweb.com";
const DEFAULT_ANALYTICS_URL = "c.thirdweb.com";

let domains: { [k in keyof DomainOverrides]-?: string } = {
rpc: DEFAULT_RPC_URL,
Expand All @@ -45,6 +51,7 @@
pay: DEFAULT_PAY_URL,
storage: DEFAULT_STORAGE_URL,
bundler: DEFAULT_BUNDLER_URL,
analytics: DEFAULT_ANALYTICS_URL,
};

/**
Expand All @@ -58,6 +65,7 @@
pay: DomainOverrides.pay ?? DEFAULT_PAY_URL,
storage: DomainOverrides.storage ?? DEFAULT_STORAGE_URL,
bundler: DomainOverrides.bundler ?? DEFAULT_BUNDLER_URL,
analytics: DomainOverrides.analytics ?? DEFAULT_ANALYTICS_URL,

Check warning on line 68 in packages/thirdweb/src/utils/domains.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/utils/domains.ts#L68

Added line #L68 was not covered by tests
};
};

Expand Down
Loading