@@ -50,7 +50,7 @@ async function getRetentionDays(orgId: string): Promise<number> {
5050 const response = await axios . get (
5151 `${
5252 config . getRawConfig ( ) . managed ?. endpoint
53- } /api/v1/hybrid/org/: orgId/get-retention-days`,
53+ } /api/v1/hybrid/org/${ orgId } /get-retention-days`,
5454 await tokenManager . getAuthHeader ( )
5555 ) ;
5656 return response . data . data . days ;
@@ -73,9 +73,7 @@ async function getRetentionDays(orgId: string): Promise<number> {
7373
7474async function sendQueuedLogs ( ) {
7575 await axios . post (
76- `${
77- config . getRawConfig ( ) . managed ?. endpoint
78- } /api/v1/hybrid/org/:orgId/logs/batch`,
76+ `${ config . getRawConfig ( ) . managed ?. endpoint } /api/v1/hybrid/logs/batch` ,
7977 {
8078 logs : logQueue
8179 } ,
@@ -193,11 +191,6 @@ export async function logRequestAudit(
193191 } ;
194192
195193 logQueue . push ( payload ) ;
196-
197- if ( logQueue . length >= 25 ) {
198- await sendQueuedLogs ( ) ;
199- logQueue = [ ] ;
200- }
201194 } catch ( error ) {
202195 logQueue = [ ] ; // clear queue on error to prevent buildup
203196 if ( axios . isAxiosError ( error ) ) {
@@ -214,3 +207,15 @@ export async function logRequestAudit(
214207 }
215208 }
216209}
210+
211+ // set a periodic flush of the log queue every 30 seconds
212+ setInterval ( async ( ) => {
213+ if ( logQueue . length > 0 ) {
214+ try {
215+ await sendQueuedLogs ( ) ;
216+ logQueue = [ ] ;
217+ } catch ( error ) {
218+ logger . error ( "Error sending queued logs:" , error ) ;
219+ }
220+ }
221+ } , 30000 ) ;
0 commit comments