File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ interface UsageEventSchema extends Omit<UsageEvent, "action"> {
54
54
action : UsageEventTxActionEnum ;
55
55
}
56
56
57
+ const URLS_LIST_TO_NOT_REPORT_USAGE = new Set ( [
58
+ "/" ,
59
+ "/favicon.ico" ,
60
+ "/" ,
61
+ "/system/health" ,
62
+ "/json" ,
63
+ ] ) ;
64
+
57
65
const createHeaderForRequest = ( input : CreateHeaderForRequestParams ) => {
58
66
return {
59
67
"Content-Type" : "application/json" ,
@@ -71,6 +79,10 @@ export const withServerUsageReporting = (server: FastifyInstance) => {
71
79
return ;
72
80
}
73
81
82
+ if ( URLS_LIST_TO_NOT_REPORT_USAGE . has ( reply . request . routerPath ) ) {
83
+ return ;
84
+ }
85
+
74
86
const derivedClientId = deriveClientId ( env . THIRDWEB_API_SECRET_KEY ) ;
75
87
const headers = createHeaderForRequest ( {
76
88
clientId : derivedClientId ,
@@ -84,10 +96,6 @@ export const withServerUsageReporting = (server: FastifyInstance) => {
84
96
? await getChainIdFromChain ( requestParams . chain )
85
97
: "" ;
86
98
87
- if ( reply . request . routerPath === "" || ! reply . request . routerPath ) {
88
- return ;
89
- }
90
-
91
99
const requestBody : UsageEventSchema = {
92
100
source : "engine" ,
93
101
action : UsageEventTxActionEnum . APIRequest ,
Original file line number Diff line number Diff line change 1
1
import cron from "node-cron" ;
2
2
import { getConfig } from "../../utils/cache/getConfig" ;
3
+ import { logger } from "../../utils/logger" ;
3
4
import { updateMinedTx } from "../tasks/updateMinedTx" ;
4
5
import { updateMinedUserOps } from "../tasks/updateMinedUserOps" ;
5
6
6
7
let task : cron . ScheduledTask ;
8
+ let minedTxStarted = false ;
7
9
export const minedTxListener = async ( ) => {
8
10
const config = await getConfig ( ) ;
9
11
@@ -16,7 +18,17 @@ export const minedTxListener = async () => {
16
18
}
17
19
18
20
task = cron . schedule ( config . minedTxListenerCronSchedule , async ( ) => {
19
- await updateMinedTx ( ) ;
20
- await updateMinedUserOps ( ) ;
21
+ if ( ! minedTxStarted ) {
22
+ minedTxStarted = true ;
23
+ await updateMinedTx ( ) ;
24
+ await updateMinedUserOps ( ) ;
25
+ minedTxStarted = false ;
26
+ } else {
27
+ logger ( {
28
+ service : "worker" ,
29
+ level : "warn" ,
30
+ message : "Mined tx listener already running, skipping" ,
31
+ } ) ;
32
+ }
21
33
} ) ;
22
34
} ;
You can’t perform that action at this time.
0 commit comments