@@ -15,6 +15,7 @@ import {
1515 getWalletConnections ,
1616 getWalletUsers ,
1717} from "@/api/analytics" ;
18+ import { getAuthToken } from "@/api/auth-token" ;
1819import { getTeamBySlug } from "@/api/team/get-team" ;
1920import type {
2021 DurationId ,
@@ -28,6 +29,7 @@ import type {
2829 UserOpStats ,
2930 WalletStats ,
3031} from "@/types/analytics" ;
32+ import { loginRedirect } from "@/utils/redirects" ;
3133import { PieChartCard } from "../../../../components/Analytics/PieChartCard" ;
3234import { TotalSponsoredChartCardUI } from "../../_components/TotalSponsoredCard" ;
3335import { TransactionsChartCardWithChainMapping } from "../../_components/transaction-card-with-chain-mapping" ;
@@ -53,6 +55,12 @@ export default async function TeamOverviewPage(props: {
5355 props . searchParams ,
5456 ] ) ;
5557
58+ const authToken = await getAuthToken ( ) ;
59+
60+ if ( ! authToken ) {
61+ loginRedirect ( `/team/${ params . team_slug } /~/analytics` ) ;
62+ }
63+
5664 const team = await getTeamBySlug ( params . team_slug ) ;
5765
5866 if ( ! team ) {
@@ -91,6 +99,7 @@ export default async function TeamOverviewPage(props: {
9199 fallback = { < LoadingChartState className = "h-[458px] border" /> }
92100 >
93101 < AsyncTeamHighlightsCard
102+ authToken = { authToken }
94103 selectedChartQueryParam = "appHighlights"
95104 interval = { interval }
96105 range = { range }
@@ -108,7 +117,11 @@ export default async function TeamOverviewPage(props: {
108117 fallback = { < LoadingChartState className = "h-[431px] border" /> }
109118 searchParamsUsed = { [ "from" , "to" ] }
110119 >
111- < AsyncWalletDistributionCard range = { range } teamId = { team . id } />
120+ < AsyncWalletDistributionCard
121+ range = { range }
122+ teamId = { team . id }
123+ authToken = { authToken }
124+ />
112125 </ ResponsiveSuspense >
113126
114127 < ResponsiveSuspense
@@ -118,6 +131,7 @@ export default async function TeamOverviewPage(props: {
118131 < AsyncAuthMethodDistributionCard
119132 range = { range }
120133 teamId = { team . id }
134+ authToken = { authToken }
121135 />
122136 </ ResponsiveSuspense >
123137 </ div >
@@ -133,6 +147,7 @@ export default async function TeamOverviewPage(props: {
133147 >
134148 < AsyncTransactionsChartCard
135149 selectedChartQueryParam = "client_transactions"
150+ authToken = { authToken }
136151 interval = { interval }
137152 range = { range }
138153 selectedChart = {
@@ -149,6 +164,7 @@ export default async function TeamOverviewPage(props: {
149164 searchParamsUsed = { [ "from" , "to" , "interval" , "userOpUsage" ] }
150165 >
151166 < AsyncTotalSponsoredCard
167+ authToken = { authToken }
152168 selectedChartQueryParam = "userOpUsage"
153169 interval = { interval }
154170 range = { range }
@@ -173,21 +189,28 @@ async function AsyncTeamHighlightsCard(props: {
173189 interval : "day" | "week" ;
174190 selectedChart : string | undefined ;
175191 selectedChartQueryParam : string ;
192+ authToken : string ;
176193} ) {
177194 const [ walletUserStatsTimeSeries , universalBridgeUsage ] =
178195 await Promise . allSettled ( [
179- getWalletUsers ( {
180- from : props . range . from ,
181- period : props . interval ,
182- teamId : props . teamId ,
183- to : props . range . to ,
184- } ) ,
185- getUniversalBridgeUsage ( {
186- from : props . range . from ,
187- period : props . interval ,
188- teamId : props . teamId ,
189- to : props . range . to ,
190- } ) ,
196+ getWalletUsers (
197+ {
198+ from : props . range . from ,
199+ period : props . interval ,
200+ teamId : props . teamId ,
201+ to : props . range . to ,
202+ } ,
203+ props . authToken ,
204+ ) ,
205+ getUniversalBridgeUsage (
206+ {
207+ from : props . range . from ,
208+ period : props . interval ,
209+ teamId : props . teamId ,
210+ to : props . range . to ,
211+ } ,
212+ props . authToken ,
213+ ) ,
191214 ] ) ;
192215
193216 if (
@@ -216,13 +239,17 @@ async function AsyncTeamHighlightsCard(props: {
216239async function AsyncWalletDistributionCard ( props : {
217240 teamId : string ;
218241 range : Range ;
242+ authToken : string ;
219243} ) {
220- const walletConnections = await getWalletConnections ( {
221- from : props . range . from ,
222- period : "all" ,
223- teamId : props . teamId ,
224- to : props . range . to ,
225- } ) . catch ( ( ) => undefined ) ;
244+ const walletConnections = await getWalletConnections (
245+ {
246+ from : props . range . from ,
247+ period : "all" ,
248+ teamId : props . teamId ,
249+ to : props . range . to ,
250+ } ,
251+ props . authToken ,
252+ ) . catch ( ( ) => undefined ) ;
226253
227254 return walletConnections && walletConnections . length > 0 ? (
228255 < WalletDistributionCard data = { walletConnections } />
@@ -237,13 +264,17 @@ async function AsyncWalletDistributionCard(props: {
237264async function AsyncAuthMethodDistributionCard ( props : {
238265 teamId : string ;
239266 range : Range ;
267+ authToken : string ;
240268} ) {
241- const inAppWalletUsage = await getInAppWalletUsage ( {
242- from : props . range . from ,
243- period : "all" ,
244- teamId : props . teamId ,
245- to : props . range . to ,
246- } ) . catch ( ( ) => undefined ) ;
269+ const inAppWalletUsage = await getInAppWalletUsage (
270+ {
271+ from : props . range . from ,
272+ period : "all" ,
273+ teamId : props . teamId ,
274+ to : props . range . to ,
275+ } ,
276+ props . authToken ,
277+ ) . catch ( ( ) => undefined ) ;
247278
248279 return inAppWalletUsage && inAppWalletUsage . length > 0 ? (
249280 < AuthMethodDistributionCard data = { inAppWalletUsage } />
@@ -261,21 +292,28 @@ async function AsyncTransactionsChartCard(props: {
261292 interval : "day" | "week" ;
262293 selectedChart : string | undefined ;
263294 selectedChartQueryParam : string ;
295+ authToken : string ;
264296} ) {
265297 const [ clientTransactionsTimeSeries , clientTransactions ] =
266298 await Promise . allSettled ( [
267- getClientTransactions ( {
268- from : props . range . from ,
269- period : props . interval ,
270- teamId : props . teamId ,
271- to : props . range . to ,
272- } ) ,
273- getClientTransactions ( {
274- from : props . range . from ,
275- period : "all" ,
276- teamId : props . teamId ,
277- to : props . range . to ,
278- } ) ,
299+ getClientTransactions (
300+ {
301+ from : props . range . from ,
302+ period : props . interval ,
303+ teamId : props . teamId ,
304+ to : props . range . to ,
305+ } ,
306+ props . authToken ,
307+ ) ,
308+ getClientTransactions (
309+ {
310+ from : props . range . from ,
311+ period : "all" ,
312+ teamId : props . teamId ,
313+ to : props . range . to ,
314+ } ,
315+ props . authToken ,
316+ ) ,
279317 ] ) ;
280318
281319 return clientTransactionsTimeSeries . status === "fulfilled" &&
@@ -301,20 +339,27 @@ async function AsyncTotalSponsoredCard(props: {
301339 interval : "day" | "week" ;
302340 selectedChart : string | undefined ;
303341 selectedChartQueryParam : string ;
342+ authToken : string ;
304343} ) {
305344 const [ userOpUsageTimeSeries , userOpUsage ] = await Promise . allSettled ( [
306- getUserOpUsage ( {
307- from : props . range . from ,
308- period : props . interval ,
309- teamId : props . teamId ,
310- to : props . range . to ,
311- } ) ,
312- getUserOpUsage ( {
313- from : props . range . from ,
314- period : "all" ,
315- teamId : props . teamId ,
316- to : props . range . to ,
317- } ) ,
345+ getUserOpUsage (
346+ {
347+ from : props . range . from ,
348+ period : props . interval ,
349+ teamId : props . teamId ,
350+ to : props . range . to ,
351+ } ,
352+ props . authToken ,
353+ ) ,
354+ getUserOpUsage (
355+ {
356+ from : props . range . from ,
357+ period : "all" ,
358+ teamId : props . teamId ,
359+ to : props . range . to ,
360+ } ,
361+ props . authToken ,
362+ ) ,
318363 ] ) ;
319364
320365 return userOpUsageTimeSeries . status === "fulfilled" &&
0 commit comments