Skip to content

feat: Demo project - #572

Merged
Blaumaus merged 5 commits into
mainfrom
demo-dashboard
Jun 13, 2026
Merged

feat: Demo project#572
Blaumaus merged 5 commits into
mainfrom
demo-dashboard

Conversation

@Blaumaus

@Blaumaus Blaumaus commented Jun 13, 2026

Copy link
Copy Markdown
Member

Changes

If applicable, please describe what changes were made in this pull request.

Community Edition support

  • Your feature is implemented for the Swetrix Community Edition
  • This PR only updates the Cloud (Enterprise) Edition code (e.g. Paddle webhooks, blog, payouts, etc.)

Database migrations

  • Clickhouse / MySQL migrations added for this PR
  • No table schemas changed in this PR

Documentation

  • You have updated the documentation according to your PR
  • This PR did not change any publicly documented endpoints

Summary by CodeRabbit

  • New Features

    • Public demo route (/demo) with auto-generated synthetic analytics (sessions, replays, events, experiments, feature flags), configurable via new environment flags, and demo controls in the UI.
    • Demo data seeded on startup, refreshed every 30 minutes, and runnable manually.
  • Bug Fixes

    • Corrected hero component fallback to show the intended variant.
  • Chores

    • Adjusted ClickHouse client settings and various routing/paths to support the demo experience.

@Blaumaus Blaumaus self-assigned this Jun 13, 2026
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Blaumaus, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 3 minutes and 33 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51793e34-6b76-45c4-aee6-a0eace638cbf

📥 Commits

Reviewing files that changed from the base of the PR and between 61aac41 and d4bf232.

📒 Files selected for processing (1)
  • backend/apps/cloud/src/demo-data/demo-data.service.ts
📝 Walkthrough

Walkthrough

This pull request adds deterministic backend demo-data generation (with S3 replay discovery, ClickHouse batching, and Redis locking), registers a DemoDataModule, and introduces a first-class /demo project route plus projectPath/projectSettingsPath wiring across frontend pages and components.

Changes

Demo Analytics Generation & Frontend Routing

Layer / File(s) Summary
S3 replay object listing
backend/apps/cloud/src/analytics/session-replay-s3.service.ts
SessionReplayS3Service gains RFC3986 query encoding, XML entity decoding, AWS4 canonical query construction, and paginated ListObjectsV2 listObjects(prefix) to discover replay chunk keys.
Demo module wiring & env
backend/apps/cloud/src/demo-data/demo-data.module.ts, backend/apps/cloud/src/task-manager/task-manager.module.ts, backend/.env.example, backend/apps/cloud/src/common/integrations/clickhouse.ts
Registers DemoDataModule and SessionReplayS3Service, imports module into TaskManagerModule, adds DEMO_DATA_ENABLED and DEMO_REPLAY_OBJECT_PREFIX env entries, and disables ClickHouse expression compilation in client settings.
Demo data types & seeds
backend/apps/cloud/src/demo-data/demo-data.service.ts (lines 1–777)
Adds TypeScript types and large seed datasets for geos, traffic sources, client profiles, templates, goals/funnels/flags/experiments, and project-view seeds.
Generation orchestration & locking
backend/apps/cloud/src/demo-data/demo-data.service.ts (lines 779–885, 2158–2219)
Lifecycle entrypoints (OnModuleInit/cron/manual), Redis lock acquisition with heartbeat and token-checked release, ClickHouse batching (5k JSONEachRow), and lock maintenance are implemented.
Demo configuration persistence
backend/apps/cloud/src/demo-data/demo-data.service.ts (lines 891–1193)
Upserts demo project configuration: ensures demo project, enables USD revenue sync, and writes goals, funnels, annotations, project views/custom events, feature flags and experiments/variants.
Session & event generation
backend/apps/cloud/src/demo-data/demo-data.service.ts (lines 1194–2156)
Deterministically generates sessions, journeys, pageviews, performance, custom events, revenue rows, errors/captchas, feature-flag evaluations, experiment exposures, and session replay chunk rows discovered from S3; writes stable-ordered batches to ClickHouse.
Persistence helpers
backend/apps/cloud/src/demo-data/demo-data.service.ts (lines 2158–2257)
ClickHouse persistence batching helpers and deterministic utilities (LCG RNG, weighted pick, percentHash, clamping, integer helpers).
Demo route & constants
web/app/routes/demo.tsx, web/app/utils/routes.ts, web/app/lib/constants/index.ts
Adds /demo route, DEMO_PROJECT_ID, delegates loader/action/meta/links to projects.$id with forced demo params, and updates LIVE_DEMO_URL and tab-specific demo URLs to /demo.
Project context: projectPath/projectSettingsPath
web/app/providers/CurrentProjectProvider.tsx
Provider accepts optional projectPath, resolves projectPath/projectSettingsPath, uses projectPath for stored-password and submit actions, and exposes both via context.
Component migrations
web/app/pages/Project/View/ViewProject.tsx, web/app/pages/Project/tabs/* (AskAI, Errors, Funnels, Profiles, Sessions, Traffic, SEO)
Consumers now read projectPath from useCurrentProject() and use it for navigation targets, form actions, and dashboard links; AskAI/AIChart threaded with optional projectPath.
UI & docs adjustments
web/app/App.tsx, web/app/routes/_index.tsx, web/app/routes/projects.$id.tsx, web/app/routes/google-analytics-alternative.tsx, README.md
Header/footer suppressed on /demo; hero fallback fixed; projects.$id loader redirects legacy demo project id to /demo; localized demo iframe sources and README demo link updated.

Possibly related PRs

  • Swetrix/swetrix#519: Updates header/footer path checking — overlaps header/footer decision code.
  • Swetrix/swetrix#548: Refactors FunnelsView fetcher interactions — overlaps funnel submit/action handling.
  • Swetrix/swetrix#552: Modifies landing hero/live-demo preview logic — related hero and demo iframe changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 I hopped through seeds and rows tonight,
I signed S3 lists by moonlit byte,
A demo path to wander through,
With generated sessions, tried and true —
Come play, the demo’s set alight!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description follows the template structure and properly marks applicable checkboxes, but fails to describe what changes were made (the 'Changes' section is empty). Complete the 'Changes' section in the PR description with a summary of backend demo-data generation service, environment variables, and frontend demo routing updates.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Demo project' directly aligns with the changeset, which implements a comprehensive demo project feature with backend data generation and frontend routing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch demo-dashboard

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread backend/apps/cloud/src/analytics/session-replay-s3.service.ts Fixed
…nescaping'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/apps/cloud/src/analytics/session-replay-s3.service.ts`:
- Around line 50-56: The decodeXmlValue function currently replaces &amp; before
other entities causing sequences like &amp;lt; to be double-unescaped; update
decodeXmlValue to replace the named entities (&lt;, &gt;, &quot;, &apos;) first
and only then replace &amp; so that encoded sequences like &amp;lt; remain &lt;
rather than becoming <, preserving listed object keys and continuation tokens;
locate the decodeXmlValue arrow function and reorder the .replace calls
accordingly.

In `@backend/apps/cloud/src/demo-data/demo-data.service.ts`:
- Around line 41-42: The fixed LOCK_TTL_SECONDS constant allows the distributed
lock to expire mid-run (especially with BACKFILL_DAYS work), causing overlapping
generators; change the approach so the lock is either (a) renewed/heartbeated
periodically while the long-running generator/backfill work executes or (b)
allocated with an adaptive TTL computed from BACKFILL_DAYS/estimated work time
and extended before expiry; implement the renewal logic in the generator
execution path that currently uses LOCK_TTL_SECONDS (the code that
acquires/releases the distributed lock around the backfill/multi-table insert
routine) so the lock is refreshed until the run completes and only released when
fully finished.
- Around line 820-833: The redis.set call that attempts to acquire the lock
(using randomUUID(), LOCK_KEY, LOCK_TTL_SECONDS) is outside the existing try and
can throw an unhandled rejection; move the lock acquisition into the try block
or wrap the redis.set call in its own try/catch inside generateDemoData so any
Redis errors are caught and handled (log via the service logger and return
early) instead of escaping the method. Ensure the token value remains available
for release logic in the existing try/finally and do not change the lock
semantics (EX, NX) when moving the call.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5d79539-b7a8-4eb5-b2d3-c2d904e625f5

📥 Commits

Reviewing files that changed from the base of the PR and between 52f963b and 7b00eb5.

📒 Files selected for processing (22)
  • backend/.env.example
  • backend/apps/cloud/src/analytics/session-replay-s3.service.ts
  • backend/apps/cloud/src/common/integrations/clickhouse.ts
  • backend/apps/cloud/src/demo-data/demo-data.module.ts
  • backend/apps/cloud/src/demo-data/demo-data.service.ts
  • backend/apps/cloud/src/task-manager/task-manager.module.ts
  • web/app/App.tsx
  • web/app/lib/constants/index.ts
  • web/app/pages/Project/View/ViewProject.tsx
  • web/app/pages/Project/tabs/AskAI/AIChart.tsx
  • web/app/pages/Project/tabs/AskAI/AskAIView.tsx
  • web/app/pages/Project/tabs/Errors/ErrorsView.tsx
  • web/app/pages/Project/tabs/Funnels/FunnelsView.tsx
  • web/app/pages/Project/tabs/Profiles/ProfileDetails.tsx
  • web/app/pages/Project/tabs/SEO/seo-chart-options.ts
  • web/app/pages/Project/tabs/Sessions/SessionDetailView.tsx
  • web/app/pages/Project/tabs/Traffic/TrafficView.tsx
  • web/app/providers/CurrentProjectProvider.tsx
  • web/app/routes/_index.tsx
  • web/app/routes/demo.tsx
  • web/app/routes/projects.$id.tsx
  • web/app/utils/routes.ts

Comment thread backend/apps/cloud/src/analytics/session-replay-s3.service.ts
Comment thread backend/apps/cloud/src/demo-data/demo-data.service.ts
Comment thread backend/apps/cloud/src/demo-data/demo-data.service.ts
@Blaumaus
Blaumaus merged commit ad6f27b into main Jun 13, 2026
9 of 10 checks passed
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