Skip to content

Feat(ee): page analytics - #2391

Draft
salihudickson wants to merge 8 commits into
mainfrom
feat/page-analytics
Draft

Feat(ee): page analytics#2391
salihudickson wants to merge 8 commits into
mainfrom
feat/page-analytics

Conversation

@salihudickson

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_views table 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 including view_date. With per-day stats, this would prevent having more than one row per (workspace,page,identity) across all dates (and also fails if user_id is missing). Consider making the uniqueness per day by including view_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();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants