Skip to content

Conversation

VipinDevelops
Copy link
Member

@VipinDevelops VipinDevelops commented Aug 28, 2025

Description

this PR invert the tracking logic we have for pages

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features

    • Page visits are now tracked by default when viewing a page, ensuring recent activity and analytics update automatically without extra settings.
  • Refactor

    • Simplified page data fetching by making visit-tracking optional with a sensible default, reducing the need for explicit parameters and streamlining calls.

@VipinDevelops VipinDevelops added 🐛bug Something isn't working ✍️editor labels Aug 28, 2025
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

Walkthrough

The backend now defaults track_visit to true in PageViewSet.retrieve. The web store’s fetchPageDetails signature changes to accept an optional options object and defaults trackVisit to true. The page component stops passing the options object, relying on the new default behavior.

Changes

Cohort / File(s) Summary
Backend: visit tracking default
apps/api/plane/app/views/page/base.py
Default track_visit parsed from query now evaluates to true when absent; visit task enqueued by default. No public API signature changes.
Web store: API signature + defaulting
apps/web/core/store/pages/project-page.store.ts
fetchPageDetails now takes options?: { trackVisit?: boolean }; derives trackVisit from options and passes trackVisit ?? true to service. Interface and implementation updated accordingly.
Web page: caller simplification
apps/web/app/(all)/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/[pageId]/page.tsx
SWR fetcher now calls fetchPageDetails(workspaceSlug, projectId, pageId) without { trackVisit: true }, relying on store default.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant P as PageDetailsPage (SWR)
  participant S as ProjectPageStore
  participant API as Page API
  participant Q as recent_visited_task Queue

  U->>P: Navigate to Page Details
  P->>S: fetchPageDetails(wsSlug, projectId, pageId)
  Note right of S: Derive trackVisit = options?.trackVisit ?? true
  S->>API: GET /pages/{pageId}?track_visit=true
  alt 200 OK
    API-->>S: Page data
    API-->>Q: Enqueue recent_visited_task
    S-->>P: Page data
    P-->>U: Render page
  else Error
    API-->>S: Error
    S-->>P: Propagate error
    P-->>U: Show error state
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

requires approval

Suggested reviewers

  • pablohashescobar

Poem

A hop, a skip, a tracked-page view,
The queue goes boing with something new.
Defaults aligned, less code to glue—
I nudge my whiskers: "True is true!"
Carrots cached; the task hops through. 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore-update_track_page_logic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@VipinDevelops VipinDevelops changed the title fix : invert tracking logic [WIKI-556] fix : invert tracking logic Aug 28, 2025
Copy link

makeplane bot commented Aug 28, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/plane/app/views/page/base.py (1)

198-227: Fix None-check ordering to prevent AttributeError when page doesn’t exist.

page is dereferenced in the guest-permission gate before verifying it isn’t None. If pk is invalid (or filtered out by get_queryset()), this will raise.

     def retrieve(self, request, slug, project_id, pk=None):
         page = self.get_queryset().filter(pk=pk).first()
         project = Project.objects.get(pk=project_id)
         track_visit = request.query_params.get("track_visit", "true").strip().lower() == "true"
 
         """
         if the role is guest and guest_view_all_features is false and owned by is not
         the requesting user then dont show the page
         """
 
-        if (
+        if page is None:
+            return Response(
+                {"error": "Page not found"}, status=status.HTTP_404_NOT_FOUND
+            )
+
+        if (
             ProjectMember.objects.filter(
                 workspace__slug=slug,
                 project_id=project_id,
                 member=request.user,
                 role=5,
                 is_active=True,
             ).exists()
             and not project.guest_view_all_features
-            and not page.owned_by == request.user
+            and page.owned_by != request.user
         ):
             return Response(
                 {"error": "You are not allowed to view this page"},
                 status=status.HTTP_400_BAD_REQUEST,
             )
 
-        if page is None:
-            return Response(
-                {"error": "Page not found"}, status=status.HTTP_404_NOT_FOUND
-            )
-        else:
+        else:
             issue_ids = PageLog.objects.filter(
                 page_id=pk, entity_name="issue"
             ).values_list("entity_identifier", flat=True)
             data = PageDetailSerializer(page).data
             data["issue_ids"] = issue_ids
             if track_visit:
                 recent_visited_task.delay(
                     slug=slug,
                     entity_name="page",
                     entity_identifier=pk,
                     user_id=request.user.id,
                     project_id=project_id,
                 )
             return Response(data, status=status.HTTP_200_OK)
🧹 Nitpick comments (2)
apps/api/plane/app/views/page/base.py (1)

201-201: Default-on tracking implemented; trim input to avoid false negatives.

Safer to tolerate incidental whitespace in the query param.

-        track_visit = request.query_params.get("track_visit", "true").lower() == "true"
+        track_visit = request.query_params.get("track_visit", "true").strip().lower() == "true"
apps/web/core/store/pages/project-page.store.ts (1)

247-260: Prefer explicit parameters over variadic tuple for readability and DX.

Using (...args: Parameters<IProjectPageStore["fetchPageDetails"]>) obscures the method signature at call sites and hampers inline docs. Keep the explicit signature and default trackVisit via destructuring.

-  fetchPageDetails = async (...args: Parameters<IProjectPageStore["fetchPageDetails"]>) => {
-    const [workspaceSlug, projectId, pageId, options] = args;
-    const { trackVisit } = options || {};
+  fetchPageDetails = async (
+    workspaceSlug: string,
+    projectId: string,
+    pageId: string,
+    options?: { trackVisit?: boolean }
+  ) => {
+    const { trackVisit = true } = options || {};
@@
-      const page = await this.service.fetchById(workspaceSlug, projectId, pageId, trackVisit ?? true);
+      const page = await this.service.fetchById(workspaceSlug, projectId, pageId, trackVisit);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e144ce8 and 683b8cb.

📒 Files selected for processing (3)
  • apps/api/plane/app/views/page/base.py (1 hunks)
  • apps/web/app/(all)/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/[pageId]/page.tsx (1 hunks)
  • apps/web/core/store/pages/project-page.store.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and lint web apps
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
apps/web/core/store/pages/project-page.store.ts (2)

52-57: API shape change to optional options is sensible and backward compatible.

Calls that previously passed { trackVisit: ... } continue to work; omitting the arg now defaults to tracking. Looks good.


247-260: No boolean 4th-arg or missing trackVisit calls found—ready to merge.

apps/web/app/(all)/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/[pageId]/page.tsx (1)

59-63: Fetcher call simplified to rely on default tracking.

Matches the store/API defaults; no functional regressions expected.

@pushya22 pushya22 merged commit 7a43137 into preview Aug 28, 2025
6 of 10 checks passed
@pushya22 pushya22 deleted the chore-update_track_page_logic branch August 28, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants