2af0d8650b
Route normal play closes (end/switch/stop) and all shares through a same-origin HttpClient POST so privacy-hardened browsers stop blocking them; keep sendBeacon for the tab-unload edge. Rename the JS module off telemetry/beacon to session/ lifecycle so the retained fallback isn't name-matched. No new data or identifiers.
88 lines
4.6 KiB
C#
88 lines
4.6 KiB
C#
using DeepDrftPublic.Client.Clients;
|
|
using DeepDrftPublic.Client.Common;
|
|
using DeepDrftPublic.Client.Services;
|
|
using DeepDrftPublic.Client.ViewModels;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace DeepDrftPublic.Client;
|
|
|
|
public static class Startup
|
|
{
|
|
public static void ConfigureDomainServices(IServiceCollection services)
|
|
{
|
|
// Theme Support
|
|
services.AddScoped<DarkModeSettings>();
|
|
services.AddScoped<DarkModeCookieService>();
|
|
|
|
// Public-site listener settings (Phase 18 wave 18.6). PublicSiteSettings is the generalized,
|
|
// prerender-seeded preference object (today: streaming quality); SettingsCookieService writes the
|
|
// 365-day cookie at runtime. Same scoped lifetime + cookie seam as the dark-mode pair above, so the
|
|
// preference survives SPA nav within a session and seeds the next visit's prerender.
|
|
services.AddScoped<PublicSiteSettings>();
|
|
services.AddScoped<SettingsCookieService>();
|
|
|
|
// Track Client. The HTTP-backed ITrackDataService is used by both WASM and SSR
|
|
// prerender — both call DeepDrftAPI over the "DeepDrft.API" client.
|
|
services.AddScoped<TrackClient>();
|
|
services.AddScoped<ITrackDataService, TrackClientDataService>();
|
|
|
|
// Release read surface (Phase 9). Same HTTP posture as the track client — both
|
|
// WASM and SSR prerender call DeepDrftAPI over the "DeepDrft.API" client.
|
|
services.AddScoped<ReleaseClient>();
|
|
services.AddScoped<IReleaseDataService, ReleaseClientDataService>();
|
|
services.AddScoped<ReleaseDetailViewModel>();
|
|
services.AddScoped<CutDetailViewModel>();
|
|
services.AddScoped<FramePlayerViewModel>();
|
|
|
|
// Home hero stats read surface — same HTTP posture as the track/release clients.
|
|
services.AddScoped<StatsClient>();
|
|
services.AddScoped<IStatsDataService, StatsClientDataService>();
|
|
|
|
// Waveform visualizer controls — scoped so the eight slider positions persist across navigation
|
|
// within a session and reset on a fresh page load (see WaveformVisualizerControlState).
|
|
services.AddScoped<WaveformVisualizerControlState>();
|
|
|
|
// Phase 16 anonymous telemetry (client side), transport-resilience split. IEventPoster is the
|
|
// first-party HttpClient POST used for normal play closes (end/switch/stop) and every share — a
|
|
// same-origin fetch that privacy/tracking heuristics don't name-match. BeaconInterop wraps
|
|
// sendBeacon and is retained only for the tab-unload edge. The play sink picks the arm; the share
|
|
// tracker is fetch-only. The play tracker itself is NOT registered — the player is not
|
|
// DI-registered, so AudioPlayerProvider constructs the tracker and attaches it. ShareTracker is
|
|
// scoped so its per-(target,channel) debounce memory lives for the session. AnonIdProvider (wave
|
|
// 16.3) caches the first-party localStorage listener id; scoped so the cache lives for the session,
|
|
// warmed when a surface goes interactive (the player provider, the share popover).
|
|
services.AddScoped<IEventPoster, HttpEventPoster>();
|
|
services.AddScoped<BeaconInterop>();
|
|
services.AddScoped<IAnonIdProvider, AnonIdProvider>();
|
|
services.AddScoped<IPlayEventSink, BeaconPlayEventSink>();
|
|
services.AddScoped<ShareTracker>();
|
|
|
|
// Phase 22 SEO defaults — non-secret brand constants (canonical origin, site name, default share
|
|
// image, social links). Singleton: stateless config, identical in the server-prerender and WASM
|
|
// passes (this method runs in both), which is what makes SeoHead's double-render output identical.
|
|
services.AddSingleton(new SeoOptions());
|
|
|
|
// Environment-gated robots bridge. Scoped + [PersistentState] like DarkModeSettings: the server
|
|
// seeds IsProduction during prerender and it rounds to the WASM pass, so SeoHead resolves the same
|
|
// default robots in both render passes (non-production → noindex,nofollow, keeping beta uncrawled).
|
|
services.AddScoped<SeoEnvironment>();
|
|
}
|
|
|
|
public static void ConfigureApiHttpClient(IServiceCollection services, string baseAddress)
|
|
{
|
|
services.AddHttpClient("DeepDrft.API", client =>
|
|
{
|
|
client.BaseAddress = new Uri(baseAddress);
|
|
});
|
|
}
|
|
|
|
public static void ConfigureContentServices(IServiceCollection services, string contentApiUrl)
|
|
{
|
|
services.AddHttpClient("DeepDrft.Content", client =>
|
|
{
|
|
client.BaseAddress = new Uri(contentApiUrl);
|
|
});
|
|
services.AddScoped<TrackMediaClient>();
|
|
services.AddScoped<AudioInteropService>();
|
|
}
|
|
} |