using Microsoft.JSInterop; namespace Shared.Services; public class AnalyticsService { private readonly IJSRuntime _jsRuntime; public AnalyticsService(IJSRuntime jsRuntime) { _jsRuntime = jsRuntime; } public async ValueTask TrackPageView(string path) { await _jsRuntime.InvokeVoidAsync("trackPageView", path); } public async ValueTask TrackEvent(string eventName, object? eventData = null) { if (eventData != null) await _jsRuntime.InvokeVoidAsync("gtag", "event", eventName, eventData); else await _jsRuntime.InvokeVoidAsync("gtag", "event", eventName); } }