Track storefront views via POST /tenants/{domain}/analytics/views, expose business activity API, and add product/website/portfolio/blog 30-day chart types for super-admin selection.
Co-authored-by: Cursor <cursoragent@cursor.com>
19 lines
641 B
SQL
19 lines
641 B
SQL
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'website_view_kind') THEN
|
|
CREATE TYPE website_view_kind AS ENUM ('website', 'product', 'portfolio', 'blog');
|
|
END IF;
|
|
END $$;
|
|
|
|
CREATE TABLE IF NOT EXISTS website_content_views (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
business_id BIGINT NOT NULL REFERENCES businesses (id) ON DELETE CASCADE,
|
|
view_kind website_view_kind NOT NULL,
|
|
entity_id BIGINT,
|
|
page_path TEXT,
|
|
viewed_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_website_content_views_business_kind_time
|
|
ON website_content_views (business_id, view_kind, viewed_at DESC);
|