mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 17:53:55 +08:00
This commit adds a new parallel page view counting system that uses `fetch` with `keepalive: true` to POST to a dedicated `/srv/pv` endpoint, gated behind the `use_beacon_for_browser_page_views` site setting.
Unlike the existing deferred tracking (which piggybacks on AJAX headers), the beacon approach sends page view data directly as a JSON body. Both systems run simultaneously when the setting is enabled to allow comparing counts before fully migrating.
Key details:
* New middleware endpoint `POST /srv/pv` short-circuits with 204
* Dedicated `ApplicationRequest` counters (`*_beacon`) track beacon page views separately from the existing browser page view counters
* A separate `:beacon_browser_pageview` DiscourseEvent avoids double-firing with the existing `:browser_pageview` event
* On Ember route transitions, `routeDidChange` sends the beacon. For non-Ember pages (e.g. `/pub/*`), `pageview.js` handles it
Internal topic: t/179398.
22 lines
1.3 KiB
Text
Vendored
22 lines
1.3 KiB
Text
Vendored
<meta name="generator" content="Discourse <%= Discourse::VERSION::STRING %> - https://github.com/discourse/discourse version <%= Discourse.git_version %>">
|
|
<%- if SiteSetting.site_favicon_url.present? %>
|
|
<link rel="icon" type="image/png" href="<%=SiteSetting.site_favicon_url%>">
|
|
<%- end %>
|
|
<% site_apple_touch_icon_url = SiteSetting.site_apple_touch_icon_url %>
|
|
<%- if site_apple_touch_icon_url.present? %>
|
|
<link rel="apple-touch-icon" type="image/png" href="<%= ::UrlHelper.absolute(site_apple_touch_icon_url) %>">
|
|
<%- end %>
|
|
<%= discourse_theme_color_meta_tags %>
|
|
<%= discourse_color_scheme_meta_tag %>
|
|
<%# viewport is updated further in instance-initializers/viewport-setup.js %>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
|
|
<%- if Discourse.base_path.present? %>
|
|
<meta name="discourse-base-uri" content="<%= Discourse.base_path %>">
|
|
<% end %>
|
|
<%= canonical_link_tag %>
|
|
<%= render_sitelinks_search_tag %>
|
|
<%= discourse_pageview_tracking_meta_tags %>
|
|
<% if SiteSetting.google_site_verification_token.present? %>
|
|
<meta name="google-site-verification" content="<%= SiteSetting.google_site_verification_token %>">
|
|
<% end %>
|
|
<link rel="search" type="application/opensearchdescription+xml" href="<%= Discourse.base_url %>/opensearch.xml" title="<%= SiteSetting.title %> Search">
|