@@ -15,6 +15,7 @@ import {
15
15
getWalletConnections ,
16
16
getWalletUsers ,
17
17
} from "@/api/analytics" ;
18
+ import { getAuthToken } from "@/api/auth-token" ;
18
19
import { getTeamBySlug } from "@/api/team/get-team" ;
19
20
import type {
20
21
DurationId ,
@@ -28,6 +29,7 @@ import type {
28
29
UserOpStats ,
29
30
WalletStats ,
30
31
} from "@/types/analytics" ;
32
+ import { loginRedirect } from "@/utils/redirects" ;
31
33
import { PieChartCard } from "../../../../components/Analytics/PieChartCard" ;
32
34
import { TotalSponsoredChartCardUI } from "../../_components/TotalSponsoredCard" ;
33
35
import { TransactionsChartCardWithChainMapping } from "../../_components/transaction-card-with-chain-mapping" ;
@@ -53,6 +55,12 @@ export default async function TeamOverviewPage(props: {
53
55
props . searchParams ,
54
56
] ) ;
55
57
58
+ const authToken = await getAuthToken ( ) ;
59
+
60
+ if ( ! authToken ) {
61
+ loginRedirect ( `/team/${ params . team_slug } /~/analytics` ) ;
62
+ }
63
+
56
64
const team = await getTeamBySlug ( params . team_slug ) ;
57
65
58
66
if ( ! team ) {
@@ -91,6 +99,7 @@ export default async function TeamOverviewPage(props: {
91
99
fallback = { < LoadingChartState className = "h-[458px] border" /> }
92
100
>
93
101
< AsyncTeamHighlightsCard
102
+ authToken = { authToken }
94
103
selectedChartQueryParam = "appHighlights"
95
104
interval = { interval }
96
105
range = { range }
@@ -108,7 +117,11 @@ export default async function TeamOverviewPage(props: {
108
117
fallback = { < LoadingChartState className = "h-[431px] border" /> }
109
118
searchParamsUsed = { [ "from" , "to" ] }
110
119
>
111
- < AsyncWalletDistributionCard range = { range } teamId = { team . id } />
120
+ < AsyncWalletDistributionCard
121
+ range = { range }
122
+ teamId = { team . id }
123
+ authToken = { authToken }
124
+ />
112
125
</ ResponsiveSuspense >
113
126
114
127
< ResponsiveSuspense
@@ -118,6 +131,7 @@ export default async function TeamOverviewPage(props: {
118
131
< AsyncAuthMethodDistributionCard
119
132
range = { range }
120
133
teamId = { team . id }
134
+ authToken = { authToken }
121
135
/>
122
136
</ ResponsiveSuspense >
123
137
</ div >
@@ -133,6 +147,7 @@ export default async function TeamOverviewPage(props: {
133
147
>
134
148
< AsyncTransactionsChartCard
135
149
selectedChartQueryParam = "client_transactions"
150
+ authToken = { authToken }
136
151
interval = { interval }
137
152
range = { range }
138
153
selectedChart = {
@@ -149,6 +164,7 @@ export default async function TeamOverviewPage(props: {
149
164
searchParamsUsed = { [ "from" , "to" , "interval" , "userOpUsage" ] }
150
165
>
151
166
< AsyncTotalSponsoredCard
167
+ authToken = { authToken }
152
168
selectedChartQueryParam = "userOpUsage"
153
169
interval = { interval }
154
170
range = { range }
@@ -173,21 +189,28 @@ async function AsyncTeamHighlightsCard(props: {
173
189
interval : "day" | "week" ;
174
190
selectedChart : string | undefined ;
175
191
selectedChartQueryParam : string ;
192
+ authToken : string ;
176
193
} ) {
177
194
const [ walletUserStatsTimeSeries , universalBridgeUsage ] =
178
195
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
+ ) ,
191
214
] ) ;
192
215
193
216
if (
@@ -216,13 +239,17 @@ async function AsyncTeamHighlightsCard(props: {
216
239
async function AsyncWalletDistributionCard ( props : {
217
240
teamId : string ;
218
241
range : Range ;
242
+ authToken : string ;
219
243
} ) {
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 ) ;
226
253
227
254
return walletConnections && walletConnections . length > 0 ? (
228
255
< WalletDistributionCard data = { walletConnections } />
@@ -237,13 +264,17 @@ async function AsyncWalletDistributionCard(props: {
237
264
async function AsyncAuthMethodDistributionCard ( props : {
238
265
teamId : string ;
239
266
range : Range ;
267
+ authToken : string ;
240
268
} ) {
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 ) ;
247
278
248
279
return inAppWalletUsage && inAppWalletUsage . length > 0 ? (
249
280
< AuthMethodDistributionCard data = { inAppWalletUsage } />
@@ -261,21 +292,28 @@ async function AsyncTransactionsChartCard(props: {
261
292
interval : "day" | "week" ;
262
293
selectedChart : string | undefined ;
263
294
selectedChartQueryParam : string ;
295
+ authToken : string ;
264
296
} ) {
265
297
const [ clientTransactionsTimeSeries , clientTransactions ] =
266
298
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
+ ) ,
279
317
] ) ;
280
318
281
319
return clientTransactionsTimeSeries . status === "fulfilled" &&
@@ -301,20 +339,27 @@ async function AsyncTotalSponsoredCard(props: {
301
339
interval : "day" | "week" ;
302
340
selectedChart : string | undefined ;
303
341
selectedChartQueryParam : string ;
342
+ authToken : string ;
304
343
} ) {
305
344
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
+ ) ,
318
363
] ) ;
319
364
320
365
return userOpUsageTimeSeries . status === "fulfilled" &&
0 commit comments