Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(demo): remove the legacy /demo page (#113390)

Tom Piccirello5e42afe876d7
diff --git a/playwright/e2e/toolbar.spec.ts b/playwright/e2e/toolbar.spec.ts
index 2c7b4c2460bf..ee33d620d2bf 100644
--- a/playwright/e2e/toolbar.spec.ts
+++ b/playwright/e2e/toolbar.spec.ts
@@ -1,5 +1,25 @@
import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
+// The toolbar launches on a customer's site, so the test serves a stand-in for one: a bare page with
+// the posthog-js snippet. Playwright serves it on the app origin, so the page loads posthog-js and the
+// toolbar bundle from the app's /static/. posthog-js opens the toolbar only when the token in the launch
+// link matches the token the page initializes with, so the page must use the project's real token.
+const TOOLBAR_HOST_PATH = '/toolbar-e2e-host'
+
+function toolbarHostPage(apiToken: string): string {
+ return `<!doctype html>
+<html>
+ <head>
+ <script src="/static/array.js"></script>
+ </head>
+ <body>
+ <script>
+ posthog.init(${JSON.stringify(apiToken)}, { api_host: window.location.origin })
+ </script>
+ </body>
+</html>`
+}
+
test.describe('Toolbar', () => {
let workspace: PlaywrightWorkspaceSetupResult | null = null
@@ -11,12 +31,22 @@ test.describe('Toolbar', () => {
await playwrightSetup.login(page, workspace!)
})
- test('Toolbar loads', async ({ page }) => {
+ test('Toolbar loads', async ({ page, request }) => {
+ const team = await request.get(`/api/environments/${workspace!.team_id}/`, {
+ headers: { Authorization: `Bearer ${workspace!.personal_api_key}` },
+ })
+ expect(team.ok()).toBe(true)
+ const apiToken: string = (await team.json()).api_token
+ await page.route(
+ (url) => url.pathname === TOOLBAR_HOST_PATH,
+ (route) => route.fulfill({ contentType: 'text/html', body: toolbarHostPage(apiToken) })
+ )
+
await page.goToMenuItem('toolbar')
await page.getByText('Add authorized URL').click()
const loc = await page.evaluate(() => window.location)
- await page.locator('[data-attr="url-input"]').fill(`http://${loc.host}/demo`)
+ await page.locator('[data-attr="url-input"]').fill(`http://${loc.host}${TOOLBAR_HOST_PATH}`)
await page.locator('[data-attr="url-save"]').click()
const href = await page.locator('[data-attr="toolbar-open"]').first().getAttribute('href')
diff --git a/posthog/templates/demo.html b/posthog/templates/demo.html
deleted file mode 100644
index c310d4c4a016..000000000000
--- a/posthog/templates/demo.html
+++ /dev/null
@@ -1,230 +0,0 @@
-<html lang="en">
- <head>
- <title>Hogflix</title>
- <script src="/static/array.js"></script>
- <link rel="stylesheet"
- href="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.css" />
- <script src="https://cdn.jsdelivr.net/npm/rrweb@latest/dist/rrweb.min.js"></script>
- <link rel="stylesheet" href="https://unpkg.com/mvp.css">
- <style>
- :root {
- --color: #e9130c !important;
- --color-accent: #118bee15 !important;
- --color-bg: rgb(37, 37, 37) !important;
- --color-bg-secondary: #e9e9e9 !important;
- --color-secondary: #fa0303 !important;
- --color-secondary-accent: #eb1c1c0b !important;
- --color-shadow: #a8a8a8 !important;
- --color-text: rgb(231, 231, 231) !important;
- --color-text-secondary: rgb(212, 212, 212) !important;
- }
-
- video {
- max-width: 600px !important;
- margin: auto;
- display: block;
- }
-
- input {
- background-color: rgb(59, 59, 59);
- border-color: rgb(54, 54, 54);
- color: #fff;
- }
- </style>
- </head>
- <body>
- <script nonce="{{ request.csp_nonce }}">
- posthog.init('{{api_token}}', {
- api_host: window.location.origin,
- loaded: (posthog) => {
- posthog.onFeatureFlags(() => {
- if (posthog.isFeatureEnabled('sign-up-cta') && document.getElementById('sign-up-cta')) {
- document.getElementById('sign-up-cta').innerText = 'Get started now'
- }
- })
- },
- })
- </script>
- <main>
- <header>
- <article>
- <aside>
- <p>Welcome to the PostHog demo environment!</p>
- <small>By going through this demo you can simulate a user going through a signup funnel.</small>
- <p></p>
- </aside>
- </article>
- <nav>
- <a href="/demo" style='color: rgb(197, 197, 197)'>
- <h3>Hogflix</h3>
- </a>
- <ul>
- <li><a href="/demo/1">Sign Up</a></li>
- <li><a href="/demo/2">Payment</a></li>
- <li><a href="/demo/3">Movies</a></li>
- </ul>
- </nav>
- </header>
- {% if request.path == '/demo' %}
- <header>
- <h1>Welcome to Hogflix</h1>
- <p>The one-stop shop for all your hedgehog movies.</p>
- <br>
- <a href='/demo/1' id='sign-up'>
- <button id='sign-up-cta' data-attr="sign-up-button">Sign up</button>
- </a>
- </header>
- {% endif %}
- {% if request.path == '/demo/1' %}
- <section>
- <form action='/demo/2'>
- <h1>Sign Up</h1>
- <label>Username</label>
- <input class='form-control' type='text' name='username' />
- <label>Password</label>
- <input class='form-control' type='password' name='password' />
- <button type='submit'>Sign up!</button>
- </form>
- </section>
- {% endif %}
- {% if request.path == '/demo/2' %}
- <section>
- <form action='/demo/3'>
- <h1>Pay for Hogflix</h1>
- <label>Credit card number</label>
- <input class='form-control'
- type='text'
- name='creditcard'
- placeholder='4000 0000 0000 0000' />
- <button type='submit'>Pay $10!</button>
- </section>
- {% endif %}
- {% if request.path == '/demo/3' %}
- <section style="margin-top: -100px">
- <header>
- <h1>Watch some Flix!</h1>
- </header>
- <aside>
- <img src='https://m.media-amazon.com/images/M/MV5BNDc1ZTlmOWUtNDY2YS00OGU5LTg2MTYtYTk2MmQzMGE2NzUwXkEyXkFqcGdeQXVyODkzNTgxMDg@._V1_SY1000_CR0,0,675,1000_AL_.jpg'
- class='card-img-top' />
- <div class='card-body'>
- <h5 class='card-title'>Sonic The Hedgehog (2020)</h5>
- <p class='card-text'>
- Based on the global blockbuster videogame franchise from Sega, SONIC THE
- HEDGEHOG tells the story of the world's speediest hedgehog as he embraces his new home on Earth.
- </p>
- <a href='https://netflix.com' target="_blank">
- <button>Watch now!</button>
- </a>
- </div>
- </aside>
- <aside>
- <img src='https://m.media-amazon.com/images/M/MV5BMTc0Mzg3OTQyN15BMl5BanBnXkFtZTcwODA2OTc4NQ@@._V1_SY1000_CR0,0,677,1000_AL_.jpg'
- class='card-img-top' />
- <div class='card-body'>
- <h5 class='card-title'>The Hedgehog (2009)</h5>
- <p class='card-text'>
- While planning her suicide, a precocious 11-year-old (Garance Le Guillermic)
- befriends a new neighbor (Togo Igawa) and a prickly recluse (Josiane Balasko).
- </p>
- <a href='https://netflix.com' target="_blank">
- <button>Watch now!</button>
- </a>
- </div>
- </aside>
- <aside>
- <img src='https://posthog-static-files.s3.us-east-2.amazonaws.com/Product-Assets/Big_buck_bunny_poster_big.jpg'
- class='card-img-top' />
- <div class='card-body'>
- <br />
- <h5 class='card-title'>Big Buck Bunny (2008)</h5>
- <p class='card-text'>
- A large and lovable rabbit deals with three tiny bullies, led by a flying
- squirrel, who are determined to squelch his happiness.
- </p>
- <a href='/demo/4'>
- <button>Watch now!</button>
- </a>
- </div>
- </aside>
- </section>
- {% endif %}
- {% if request.path == '/demo/4' %}
- <section style="margin-top: -100px">
- <header>
- <h1>Now Playing: Big Buck Bunny</h1>
- </header>
- <figure>
- <div>
- <video id="my-video"
- class="video-js"
- controls
- preload="auto"
- data-setup="{}">
- <source src="https://posthog-static-files.s3.us-east-2.amazonaws.com/Product-Assets/BigBuckBunny.mp4"
- type="video/mp4" />
- <p class="vjs-no-js">
- To view this video please enable JavaScript, and consider upgrading to a
- web
- browser that supports HTML5 video
- </p>
- </video>
- </div>
- </figure>
- <br>
- </section>
- <section>
- <aside>
- <div>
- <h2>Reviews</h2>
- </div>
- <div class="row" style="width:100%;">
- <p><em>This movie was so great.</em></p>
- </div>
- <div class="row" style="width:100%;">
- <p><em>The best thing I have ever seen.</em></p>
- </div>
- <div class="row" style="width:100%;">
- <p id="new-review">
- <em></em>
- </p>
- </div>
- </aside>
- <aside>
- <h2>Leave a review</h2>
- <textarea class='form-control'
- type='text'
- name='review'
- id="review-text"
- placeholder='What did you think?'></textarea>
- <br />
- <a id='submit-review' style="cursor: pointer;">Submit Review</a>
- </aside>
- </section>
- <section>
- <div class="row">&nbsp;</div>
- <br />
- <br />
- </section>
- <section class="copyright" style="margin-top:400px; font-size:12px;">
- Big Buck Bunny - (c) copyright Blender
- Foundation | peach.blender.org - [1], CC BY 3.0, https://commons.wikimedia.org/w/index.php?curid=3748497
- </section>
- {% endif %}
- </main>
- <script nonce="{{ request.csp_nonce }}">
-
- if (document.getElementById('submit-review')) {
- document.getElementById('submit-review').addEventListener('click', () => {
- document.getElementById('new-review').innerText = document.getElementById('review-text').value
- })
- }
-
- if (document.getElementById('my-video')) {
- document.getElementById('my-video').addEventListener('play', () => {
- posthog.capture('played_movie', { title: "Big Buck Bunny" })
- })
- }
- </script>
- </body>
-</html>
diff --git a/posthog/urls.py b/posthog/urls.py
index d84bfbe16ec4..b860b06813b9 100644
--- a/posthog/urls.py
+++ b/posthog/urls.py
@@ -47,7 +47,6 @@ from products.customer_analytics.backend.presentation.views.internal import (
InternalAccountCustomPropertiesView as CustomerAnalyticsInternalAccountCustomPropertiesView,
InternalAccountView as CustomerAnalyticsInternalAccountView,
)
-from products.demo.backend.facade.api import demo_route
from products.early_access_features.backend.api import early_access_features
from products.messaging.backend.api.customerio_webhook import CustomerIOWebhookView
from products.messaging.backend.api.push_subscriptions import push_subscriptions
@@ -304,7 +303,6 @@ urlpatterns = [
sharing.SharingViewerPageViewSet.as_view({"get": "retrieve"}),
),
path("site_app/<int:id>/<str:token>/<str:hash>/", site_app.get_site_app),
- re_path(r"^demo.*", login_required(demo_route)),
path("", include((oauth2_urls, "oauth2_provider"), namespace="oauth2_provider")),
# ingestion
# NOTE: When adding paths here that should be public make sure to update ALWAYS_ALLOWED_ENDPOINTS in middleware.py
diff --git a/posthog/utils.py b/posthog/utils.py
index dadccf16c90d..53787274ec3c 100644
--- a/posthog/utils.py
+++ b/posthog/utils.py
@@ -66,9 +66,8 @@ from products.feature_flags.backend.persisted_flags import get_dynamic_persisted
tracer = trace.get_tracer(__name__)
-# Cardinality is bounded: render_template is only called with the literal template
-# names "index.html", "demo.html", and "render_query.html" — 3 templates × 2 auth
-# states = 6 series total.
+# Cardinality is bounded because every render_template caller passes a literal template
+# name, so each template adds one series per auth state.
TEMPLATE_CONTEXT_DURATION_HISTOGRAM = Histogram(
"posthog_template_context_duration_seconds",
"Time spent building the SPA template context (get_context_for_template).",
diff --git a/products/demo/backend/facade/api.py b/products/demo/backend/facade/api.py
index 83a7fca62b83..c5ecaab4be00 100644
--- a/products/demo/backend/facade/api.py
+++ b/products/demo/backend/facade/api.py
@@ -1,9 +1,9 @@
"""Public facade for the demo product.
Core (`posthog/`, `ee/`) generates demo/simulation data only through the surface exposed
-here — signup, the demo celery tasks, the `generate_demo_data`/`setup_dev`/eval tooling,
-and the `demo_route` view. The matrix scenario classes cross the boundary as objects core
-instantiates; the data-generation helpers are thin functions over the product's logic.
+here — signup, the demo celery tasks, and the `generate_demo_data`/`setup_dev`/eval
+tooling. The matrix scenario classes cross the boundary as objects core instantiates; the
+data-generation helpers are thin functions over the product's logic.
"""
from __future__ import annotations
@@ -17,7 +17,6 @@ from products.demo.backend.logic.legacy import (
ORGANIZATION_NAME,
TEAM_NAME,
create_demo_data as _create_demo_data,
- demo_route,
)
from products.demo.backend.logic.matrix import Matrix, MatrixManager
from products.demo.backend.logic.matrix.persons_db_sync import (
@@ -71,7 +70,6 @@ __all__ = [
"MatrixManager",
"SpikeGPTMatrix",
"create_demo_data",
- "demo_route",
"get_group_type_mapping_count",
"infer_taxonomy_for_team",
"seed_dev_dashboard_templates",
diff --git a/products/demo/backend/logic/legacy/__init__.py b/products/demo/backend/logic/legacy/__init__.py
index b434f6c74385..bad8efdf8912 100644
--- a/products/demo/backend/logic/legacy/__init__.py
+++ b/products/demo/backend/logic/legacy/__init__.py
@@ -1,9 +1,4 @@
-from typing import cast
-
-from django.http import HttpRequest
-
-from posthog.models import Team, User
-from posthog.utils import render_template
+from posthog.models import Team
from .app_data_generator import AppDataGenerator
from .insight_variables_data_generator import InsightVariablesDataGenerator
@@ -14,12 +9,6 @@ ORGANIZATION_NAME = "Hogflix"
TEAM_NAME = "Hogflix Demo App"
-def demo_route(request: HttpRequest):
- user = cast(User, request.user) # The user must be logged in because of login_required()
- project_api_token = user.team.api_token if user.team is not None else None
- return render_template("demo.html", request=request, context={"api_token": project_api_token})
-
-
def create_demo_data(team: Team, dashboards=True):
WebDataGenerator(team, n_people=40).create(dashboards=dashboards)
AppDataGenerator(team, n_people=100).create(dashboards=dashboards)
diff --git a/products/model_crossing_uses_baseline.txt b/products/model_crossing_uses_baseline.txt
index 48f5a2f62b23..31c6339777d1 100644
--- a/products/model_crossing_uses_baseline.txt
+++ b/products/model_crossing_uses_baseline.txt
@@ -187,7 +187,6 @@ data_quality.TeamDataQualityConfig products.data_quality.backend.facade.api.get_
data_quality.TeamDataQualityConfig products.data_quality.backend.facade.api.set_gate_materialization_on_checks facade-returns 1
data_warehouse.ManagedWarehouseBackfillPartition products.data_warehouse.backend.facade.backfill_status.stale_running_partitions facade-returns 1
django.Exists products.dashboards.backend.facade.api.insight_has_listed_tile facade-returns 1
-django.HttpRequest products.demo.backend.facade.api.demo_route facade-accepts(request) 1
django.HttpRequest products.notebooks.backend.facade.sql_v2.notebook_sql_v2_data_plane facade-accepts(request) 1
django.HttpRequest products.notebooks.backend.facade.sql_v2.notebook_sql_v2_data_plane_status facade-accepts(request) 1
django.HttpResponse products.notebooks.backend.facade.sql_v2.notebook_sql_v2_data_plane facade-returns 1