Feat(ee): page analytics - #2391
Draft
salihudickson wants to merge 8 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new “Page analytics” (EE) feature surface, including initial server-side wiring for tracking page views and a client settings page to display aggregated workspace analytics.
Changes:
- Registers a dedicated Bull queue and job constants for page-view tracking/cleanup.
- Introduces a page-view integration contract (noop by default) and wires
track()calls into page and share page-info endpoints. - Adds DB types + migration scaffolding for a
page_viewstable and adds an EE client settings page with queries/services for analytics endpoints.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/server/src/integrations/queue/queue.module.ts | Registers a new Bull queue for page-view jobs. |
| apps/server/src/integrations/queue/constants/queue.constants.ts | Adds queue/job enum entries for page-view tracking and cleanup. |
| apps/server/src/integrations/page-view/page-view.service.ts | Defines the page-view tracking service contract and noop implementation. |
| apps/server/src/integrations/page-view/page-view.module.ts | Exposes the noop page-view service as a global module. |
| apps/server/src/database/types/entity.types.ts | Adds Kysely entity aliases for PageViews. |
| apps/server/src/database/types/db.d.ts | Adds the PageViews table type and DB mapping. |
| apps/server/src/database/migrations/20260809T000000-page-views.ts | Adds the page_views table migration and indices. |
| apps/server/src/core/share/share.controller.ts | Tracks page views for public share page-info requests. |
| apps/server/src/core/page/page.controller.ts | Tracks page views on page info fetch. |
| apps/server/src/core/casl/interfaces/workspace-ability.type.ts | Introduces a CASL subject for page analytics. |
| apps/server/src/core/casl/abilities/workspace-ability.factory.ts | Grants workspace owners manage access to the page analytics subject. |
| apps/server/src/common/features.ts | Adds a PAGE_ANALYTICS feature flag identifier. |
| apps/server/src/app.module.ts | Registers the noop page-view module into the app. |
| apps/client/src/ee/page-view/types/page-view-analytics.types.ts | Adds shared client types for analytics responses. |
| apps/client/src/ee/page-view/services/page-view-analytics-service.ts | Adds client API calls for analytics endpoints. |
| apps/client/src/ee/page-view/queries/page-view-analytics-query.ts | Adds react-query hooks for analytics data. |
| apps/client/src/ee/page-view/pages/page-view-analytics.tsx | Adds the “Page analytics” settings page UI. |
| apps/client/src/ee/features.ts | Adds a client-side PAGE_ANALYTICS feature flag identifier. |
| apps/client/src/components/settings/settings-sidebar.tsx | Adds settings sidebar entry + prefetch hook for page analytics. |
| apps/client/src/components/settings/settings-queries.tsx | Adds a prefetch routine for page analytics queries. |
| apps/client/src/App.tsx | Adds routing for the analytics settings page. |
Suppressed comments (1)
apps/server/src/database/migrations/20260809T000000-page-views.ts:45
- The unique index currently uses
COALESCE(user_id::text, visitor_id)without includingview_date. With per-day stats, this would prevent having more than one row per (workspace,page,identity) across all dates (and also fails ifuser_idis missing). Consider making the uniqueness per day by includingview_date.
await sql`
CREATE UNIQUE INDEX IF NOT EXISTS
uq_page_views_workspace_page_identity
ON page_views (
workspace_id,
page_id,
COALESCE(user_id::text, visitor_id)
)
`.execute(db);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+21
| .addColumn('space_id', 'uuid', (col) => | ||
| col.references('spaces.id').onDelete('cascade'), | ||
| ) | ||
| .addColumn('visitor_id', 'varchar', (col) => col.notNull()) | ||
| .addColumn('view_date', 'varchar', (col) => col.notNull()) | ||
| .addColumn('hits', 'int8', (col) => col.notNull().defaultTo(1)) |
Comment on lines
+79
to
+85
| void this.pageViewService.track({ | ||
| pageId: shareData.page.id, | ||
| workspaceId: workspace.id, | ||
| spaceId: shareData.page.spaceId, | ||
| shareId: shareData.share.id, | ||
| userId: null, | ||
| }); |
Comment on lines
14
to
17
| API = 'api_key', | ||
| Audit = 'audit', | ||
| PageAnalytics = "page_analytics" | ||
| } |
Comment on lines
+106
to
+112
| const handleRangeChange = (value: RangePreset) => { | ||
| if (value) { | ||
| setRangePreset(value); | ||
| resetTopPagesCursor(); | ||
| resetDailyCursor(); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes: https://github.com/docmost/issue-tracker/issues/2