Count page views once per load and skip known bots.

Stop auto-counting list APIs and homepage sliders, track static pages via pageKey, and add store-specials AI list matching.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Alireza Hassani
2026-09-16 17:33:44 +03:30
co-authored by Cursor
parent 6517877bed
commit b7ca306097
23 changed files with 688 additions and 85 deletions
+3 -10
View File
@@ -14,7 +14,6 @@ import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { RequireBusinessPermission } from '../auth/decorators/require-business-permission.decorator';
import { BusinessPermissionGuard } from '../auth/guards/business-permission.guard';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { WebsiteAnalyticsService } from '../website-analytics/website-analytics.service';
import {
CreateWebsiteSliderDto,
ListWebsiteSlidersDto,
@@ -24,17 +23,11 @@ import { WebsiteSlidersService } from './website-sliders.service';
@Controller('tenants/:host/website/sliders')
export class PublicWebsiteSlidersController {
constructor(
private readonly service: WebsiteSlidersService,
private readonly analytics: WebsiteAnalyticsService,
) {}
constructor(private readonly service: WebsiteSlidersService) {}
@Get()
async list(@Param('host') host: string) {
const result = await this.service.listPublic(host);
// Homepage signal: Meshkee storefronts load sliders on the home page.
this.analytics.trackPublicPage(host, 'home');
return result;
list(@Param('host') host: string) {
return this.service.listPublic(host);
}
}
@@ -3,6 +3,7 @@ import {
Controller,
Delete,
Get,
Headers,
Param,
Patch,
Post,
@@ -34,11 +35,23 @@ export class PublicWebsiteStaticImagesController {
async list(
@Param('host') host: string,
@Query() query: PublicWebsiteStaticImagesQueryDto,
@Headers('user-agent') userAgent?: string,
) {
const result = await this.service.listPublic(host, query.pageKey);
const pageKey = query.pageKey?.trim() || 'home';
if (pageKey === 'home') {
this.analytics.trackPublicPage(host, 'home');
const pageKey = query.pageKey?.trim();
// Only count when the storefront loads a specific page's slots (home / about / contact / …).
if (pageKey) {
if (pageKey === 'home') {
this.analytics.trackPublicPage(host, 'home', null, undefined, userAgent);
} else {
this.analytics.trackPublicPage(
host,
'static_page',
null,
`/${pageKey}`,
userAgent,
);
}
}
return result;
}