Skip to main content
Events dispatch through consent-derived sinks, so firing one is always safe, and you never check consent first.

analytics/analytics-provider

@replohq/sdk/analytics/analytics-provider

useAnalytics

Returns the AnalyticsSink from the nearest AnalyticsProvider. Throws if used outside of an AnalyticsProvider.

useAnalyticsOptional

Returns the AnalyticsSink if an AnalyticsProvider is present, or null otherwise. Does not throw — safe to use in components that may render with or without analytics.
Also exported

analytics/hooks/use-product-viewed-analytics

@replohq/sdk/analytics/hooks/use-product-viewed-analytics

useProductViewedAnalytics

Fires a productViewed analytics event when the product or selected variant changes. Deduplicates by product+variant ID so the same combination is only tracked once per component lifecycle.