Skip to content

Commit 65244c1

Browse files
authored
Merge branch 'main' into cursor/deprecate-modular-contracts-from-explore-d408
2 parents be9dade + f3234c3 commit 65244c1

File tree

551 files changed

+11186
-8144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

551 files changed

+11186
-8144
lines changed

.changeset/dirty-candies-shop.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+
fix engine server wallet usage with session keys

apps/dashboard/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ NEXT_PUBLIC_TYPESENSE_CONTRACT_API_KEY=
3737

3838
# posthog API key
3939
# - not required for prod/staging
40-
NEXT_PUBLIC_POSTHOG_API_KEY="ignored"
40+
NEXT_PUBLIC_POSTHOG_KEY=""
4141

4242
# Stripe Customer portal
4343
NEXT_PUBLIC_STRIPE_KEY=

apps/dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"papaparse": "^5.5.3",
5656
"pluralize": "^8.0.0",
5757
"posthog-js": "1.256.1",
58+
"posthog-node": "^5.4.0",
5859
"prettier": "3.6.2",
5960
"qrcode": "^1.5.3",
6061
"react": "19.1.0",
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import "server-only";
2+
import { PostHog } from "posthog-node";
3+
4+
let posthogServer: PostHog | null = null;
5+
6+
function getPostHogServer(): PostHog | null {
7+
if (!posthogServer && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
8+
posthogServer = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
9+
host: "https://us.i.posthog.com",
10+
});
11+
}
12+
return posthogServer;
13+
}
14+
15+
/**
16+
* Check if a feature flag is enabled for a specific user
17+
* @param flagKey - The feature flag key
18+
* @param userEmail - The user's email address for filtering
19+
*/
20+
export async function isFeatureFlagEnabled(
21+
flagKey: string,
22+
userEmail?: string,
23+
): Promise<boolean> {
24+
// For localdev environments where Posthog is not running, enable all feature flags.
25+
if (!posthogServer) {
26+
return true;
27+
}
28+
29+
try {
30+
const client = getPostHogServer();
31+
if (client && userEmail) {
32+
const isEnabled = await client.isFeatureEnabled(flagKey, userEmail, {
33+
personProperties: {
34+
email: userEmail,
35+
},
36+
});
37+
if (isEnabled !== undefined) {
38+
return isEnabled;
39+
}
40+
}
41+
} catch (error) {
42+
console.error(`Error checking feature flag ${flagKey}:`, error);
43+
}
44+
return false;
45+
}

apps/dashboard/src/@/api/analytics.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import type {
1212
UserOpStats,
1313
WalletStats,
1414
WalletUserStats,
15+
WebhookLatencyStats,
16+
WebhookRequestStats,
17+
WebhookSummaryStats,
1518
} from "@/types/analytics";
1619
import { getAuthToken } from "./auth-token";
1720
import { getChains } from "./chain";
@@ -482,6 +485,60 @@ export async function getEngineCloudMethodUsage(
482485
return json.data as EngineCloudStats[];
483486
}
484487

488+
export async function getWebhookSummary(
489+
params: AnalyticsQueryParams & { webhookId: string },
490+
): Promise<{ data: WebhookSummaryStats[] } | { error: string }> {
491+
const searchParams = buildSearchParams(params);
492+
searchParams.append("webhookId", params.webhookId);
493+
494+
const res = await fetchAnalytics(
495+
`v2/webhook/summary?${searchParams.toString()}`,
496+
);
497+
if (!res.ok) {
498+
const reason = await res.text();
499+
return { error: reason };
500+
}
501+
502+
return (await res.json()) as { data: WebhookSummaryStats[] };
503+
}
504+
505+
export async function getWebhookRequests(
506+
params: AnalyticsQueryParams & { webhookId?: string },
507+
): Promise<{ data: WebhookRequestStats[] } | { error: string }> {
508+
const searchParams = buildSearchParams(params);
509+
if (params.webhookId) {
510+
searchParams.append("webhookId", params.webhookId);
511+
}
512+
513+
const res = await fetchAnalytics(
514+
`v2/webhook/requests?${searchParams.toString()}`,
515+
);
516+
if (!res.ok) {
517+
const reason = await res.text();
518+
return { error: reason };
519+
}
520+
521+
return (await res.json()) as { data: WebhookRequestStats[] };
522+
}
523+
524+
export async function getWebhookLatency(
525+
params: AnalyticsQueryParams & { webhookId?: string },
526+
): Promise<{ data: WebhookLatencyStats[] } | { error: string }> {
527+
const searchParams = buildSearchParams(params);
528+
if (params.webhookId) {
529+
searchParams.append("webhookId", params.webhookId);
530+
}
531+
const res = await fetchAnalytics(
532+
`v2/webhook/latency?${searchParams.toString()}`,
533+
);
534+
if (!res.ok) {
535+
const reason = await res.text();
536+
return { error: reason };
537+
}
538+
539+
return (await res.json()) as { data: WebhookLatencyStats[] };
540+
}
541+
485542
export async function getInsightChainUsage(
486543
params: AnalyticsQueryParams,
487544
): Promise<{ data: InsightChainStats[] } | { errorMessage: string }> {

apps/dashboard/src/@/api/chain.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
11
import "server-only";
22
import type { ChainMetadata } from "thirdweb/chains";
33
import { NEXT_PUBLIC_THIRDWEB_API_HOST } from "@/constants/public-envs";
4-
import { API_SERVER_SECRET } from "@/constants/server-envs";
54
import type { ChainService } from "@/types/chain";
65

7-
export async function getGasSponsoredChains() {
8-
if (!API_SERVER_SECRET) {
9-
throw new Error("API_SERVER_SECRET is not set");
10-
}
11-
const res = await fetch(
12-
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains/gas-sponsored`,
13-
{
14-
headers: {
15-
"Content-Type": "application/json",
16-
"x-service-api-key": API_SERVER_SECRET,
17-
},
18-
next: {
19-
revalidate: 15 * 60, //15 minutes
20-
},
21-
},
22-
);
23-
24-
if (!res.ok) {
25-
console.error(
26-
"Failed to fetch gas sponsored chains",
27-
res.status,
28-
res.statusText,
29-
);
30-
res.body?.cancel();
31-
return [];
32-
}
33-
34-
try {
35-
return (await res.json()).data as number[];
36-
} catch (e) {
37-
console.error("Failed to parse gas sponsored chains", e);
38-
return [];
39-
}
40-
}
41-
426
export function getChains() {
437
return fetch(
448
`${NEXT_PUBLIC_THIRDWEB_API_HOST}/v1/chains`,

0 commit comments

Comments
 (0)