v0.7.0
Cookie consent for analytics through Google Tag Manager, terms and privacy policy accepted at sign-up and again when they change, a light and dark theme switch, and a preferences record for each user.
Changes to know about
ContentSourceshas aScriptslist (Security/SecurityHeaders.cs), the origins added toscript-src. Code that createsContentSourcesitself passes it first.- A new
/api/consent/optionsendpoint (every app), which every page asks for. Unit tests of the client get its answer fromsrc/test/server.ts(analytics off) unless they set their own. - The footer has a theme switch, links to the terms and privacy policy when they're set, and a Cookie settings button when analytics is on.
Layoutrenders the cookie banner. - Dark mode can be chosen:
index.css'sdarkvariant applies with adarkclass on<html>, or when the device is in dark mode and there's nolightclass.root.tsxadds a small inline script that sets the class before the page paints; the production CSP allows it by its hash, like the build's other inline scripts. Pages that follow the device's setting look the same as before. - A new
/api/legal/optionsendpoint (every app), which every page asks for, like the cookie settings (unit tests get "no terms" fromsrc/test/server.ts). - With accounts and terms set,
POST /api/auth/registerneedsacceptedTermsVersion. WithoutLegal__TermsUrlorLegal__PrivacyUrl, nothing changes. - With accounts, a
UserPreferencesrecord per user (Identity/UserPreferences.cs), stored as JSON: a Marten document, or with EF Core aUserPreferencestable (new migration) with onejsonbcolumn. It's in the data export aspreferencesand deleted with the account.
Projects created from earlier versions don't change: a template update only affects new projects.
New
- Analytics and cookie consent (every app), off until
Analytics__GoogleTagManagerIdis set:- A banner with Accept all, Reject all and Choose (Necessary, Analytics, Marketing), and Cookie settings in the footer to change the choice later.
- Tag Manager loads only after the visitor accepts analytics or marketing cookies. Their choice is passed on with Consent Mode (
analytics_storage,ad_storage,ad_user_data,ad_personalization). - The choice is kept in a
cookie_consentcookie for six months. RaisingAnalytics__ConsentVersionasks everyone again. - With accounts, the choice is also saved in the person's preferences (
PUT /api/account/consent), so other devices don't ask again and there's a record of what each person agreed to. - Tags' origins are allowed in the Content-Security-Policy from configuration:
Analytics__ConnectOrigins(data and pixels) andAnalytics__ScriptOrigins(scripts, kept narrow). Malformed settings stop the app at startup. - No vendor code:
docs/analytics.mdcovers adding Google Analytics 4, Datadog RUM and Rollbar, what the policy blocks (Custom HTML tags, Custom JavaScript variables), and why server-side telemetry needs no consent.
- User preferences (accounts): one record per user for preferences such as the cookie choice, theme or language, read with
GET /api/account/preferences. A new preference is a new property with a default, and needs no migration. See the generated app'sdocs/accounts.md#preferences. - Terms and privacy policy (
Legal__TermsUrl,Legal__PrivacyUrl,Legal__Version): footer links in every app. With accounts, an "I agree" checkbox at sign-up (checked by the API), the accepted version and time saved in the user's preferences, and an "Accept our terms" prompt after sign-in for people who signed up with Google or GitHub, were invited, or accepted an older version. Links are checked at startup: a path or an http(s) address, neverjavascript:. - A theme switch in the footer: System (the default, following the device), Light or Dark, remembered by the browser and, with accounts, saved in the user's preferences so it follows them to other devices. No flash of the wrong colours on pre-rendered pages.
- A Preferences section in Settings (accounts): the theme, the cookie choice with a Cookie settings button, and the date the terms were accepted.
ThemeSelecttakes an optionalid, for a visible label.