[WIKI-556] chore: disable tracking of page hover (#7650)

* chore: disable tracking of page hover

* chore: add track check for page feth

* chore: make track check mandatory

* chore: update track format

---------

Co-authored-by: VipinDevelops <vipinchaudhary1809@gmail.com>
This commit is contained in:
Bavisetti Narayan 2025-08-28 20:02:44 +05:30 committed by GitHub
parent ba7303b7af
commit e144ce8cf2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 13 deletions

View file

@ -198,6 +198,7 @@ class PageViewSet(BaseViewSet):
def retrieve(self, request, slug, project_id, pk=None): def retrieve(self, request, slug, project_id, pk=None):
page = self.get_queryset().filter(pk=pk).first() page = self.get_queryset().filter(pk=pk).first()
project = Project.objects.get(pk=project_id) project = Project.objects.get(pk=project_id)
track_visit = request.query_params.get("track_visit", "false").lower() == "true"
""" """
if the role is guest and guest_view_all_features is false and owned by is not if the role is guest and guest_view_all_features is false and owned by is not
@ -230,13 +231,14 @@ class PageViewSet(BaseViewSet):
).values_list("entity_identifier", flat=True) ).values_list("entity_identifier", flat=True)
data = PageDetailSerializer(page).data data = PageDetailSerializer(page).data
data["issue_ids"] = issue_ids data["issue_ids"] = issue_ids
recent_visited_task.delay( if track_visit:
slug=slug, recent_visited_task.delay(
entity_name="page", slug=slug,
entity_identifier=pk, entity_name="page",
user_id=request.user.id, entity_identifier=pk,
project_id=project_id, user_id=request.user.id,
) project_id=project_id,
)
return Response(data, status=status.HTTP_200_OK) return Response(data, status=status.HTTP_200_OK)
@allow_permission([ROLE.ADMIN], model=Page, creator=True) @allow_permission([ROLE.ADMIN], model=Page, creator=True)

View file

@ -58,7 +58,10 @@ const PageDetailsPage = observer(() => {
const { error: pageDetailsError } = useSWR( const { error: pageDetailsError } = useSWR(
workspaceSlug && projectId && pageId ? `PAGE_DETAILS_${pageId}` : null, workspaceSlug && projectId && pageId ? `PAGE_DETAILS_${pageId}` : null,
workspaceSlug && projectId && pageId workspaceSlug && projectId && pageId
? () => fetchPageDetails(workspaceSlug?.toString(), projectId?.toString(), pageId.toString()) ? () =>
fetchPageDetails(workspaceSlug?.toString(), projectId?.toString(), pageId.toString(), {
trackVisit: true,
})
: null, : null,
{ {
revalidateIfStale: true, revalidateIfStale: true,

View file

@ -23,8 +23,12 @@ export class ProjectPageService extends APIService {
}); });
} }
async fetchById(workspaceSlug: string, projectId: string, pageId: string): Promise<TPage> { async fetchById(workspaceSlug: string, projectId: string, pageId: string, trackVisit: boolean): Promise<TPage> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/`) return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/pages/${pageId}/`, {
params: {
track_visit: trackVisit,
},
})
.then((response) => response?.data) .then((response) => response?.data)
.catch((error) => { .catch((error) => {
throw error?.response?.data; throw error?.response?.data;

View file

@ -49,7 +49,12 @@ export interface IProjectPageStore {
projectId: string, projectId: string,
pageType?: TPageNavigationTabs pageType?: TPageNavigationTabs
) => Promise<TPage[] | undefined>; ) => Promise<TPage[] | undefined>;
fetchPageDetails: (workspaceSlug: string, projectId: string, pageId: string) => Promise<TPage | undefined>; fetchPageDetails: (
workspaceSlug: string,
projectId: string,
pageId: string,
{ trackVisit }: { trackVisit: boolean }
) => Promise<TPage | undefined>;
createPage: (pageData: Partial<TPage>) => Promise<TPage | undefined>; createPage: (pageData: Partial<TPage>) => Promise<TPage | undefined>;
removePage: (pageId: string) => Promise<void>; removePage: (pageId: string) => Promise<void>;
movePage: (workspaceSlug: string, projectId: string, pageId: string, newProjectId: string) => Promise<void>; movePage: (workspaceSlug: string, projectId: string, pageId: string, newProjectId: string) => Promise<void>;
@ -239,7 +244,12 @@ export class ProjectPageStore implements IProjectPageStore {
* @description fetch the details of a page * @description fetch the details of a page
* @param {string} pageId * @param {string} pageId
*/ */
fetchPageDetails = async (workspaceSlug: string, projectId: string, pageId: string) => { fetchPageDetails = async (
workspaceSlug: string,
projectId: string,
pageId: string,
{ trackVisit }: { trackVisit: boolean }
) => {
try { try {
if (!workspaceSlug || !projectId || !pageId) return undefined; if (!workspaceSlug || !projectId || !pageId) return undefined;
@ -249,7 +259,7 @@ export class ProjectPageStore implements IProjectPageStore {
this.error = undefined; this.error = undefined;
}); });
const page = await this.service.fetchById(workspaceSlug, projectId, pageId); const page = await this.service.fetchById(workspaceSlug, projectId, pageId, trackVisit);
runInAction(() => { runInAction(() => {
if (page?.id) { if (page?.id) {