fix(analytics, prescription, hydration): filter out admin/static asset requests from view counter, support guest prescription upload with fallback UI, and unify Hero component fallbacks with database defaults
Deploy Canina / deploy (push) Waiting to run
Deploy Canina / deploy (push) Waiting to run
This commit is contained in:
1 parent
3e21aefbf1
commit
b617331683
7 files changed
+41
-28
No files matched your search
@@ -77,9 +77,19 @@ export class AppModule implements NestModule {
|
||||
consumer
|
||||
.apply((req: any, res: any, next: () => void) => {
|
||||
MetricsController.incrementRequestCount();
|
||||
// Increment daily visits counter in Redis (fire-and-forget)
|
||||
const todayKey = `visits:${new Date().toISOString().split('T')[0]}`;
|
||||
this.redisService.incr(todayKey, 86400).catch(() => {}); // TTL = 24h
|
||||
|
||||
const url: string = req.originalUrl || req.url || '';
|
||||
const method: string = req.method || '';
|
||||
|
||||
// Exclude options, admin panel requests, static assets, and health metrics from visit counter
|
||||
const isAdminPath = url.includes('/admin') || url.includes('/api/admin');
|
||||
const isStaticAsset = url.match(/\.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?|map)$/i);
|
||||
const isIgnoredMethod = method === 'OPTIONS' || method === 'HEAD';
|
||||
|
||||
if (!isAdminPath && !isStaticAsset && !isIgnoredMethod) {
|
||||
const todayKey = `visits:${new Date().toISOString().split('T')[0]}`;
|
||||
this.redisService.incr(todayKey, 86400).catch(() => {});
|
||||
}
|
||||
next();
|
||||
})
|
||||
.exclude('metrics')
|
||||
|
||||
Reference in new issue
Block a user