Skip to main content

hasUserConsentedToSessionRecording()

function hasUserConsentedToSessionRecording(): boolean;

Determines whether the user has consented to session recording based on OneTrust configuration and other signals.

This function checks for user consent using multiple strategies, in the following order:

  1. If window.emui.dangerouslyOverrideSessionRecordingConsent is true, force consent ON (test/dev only). Any other value (false, undefined) defers to the normal sources below — false is not a force-disable.
  2. If OneTrust is loaded, checks if window.OnetrustActiveGroups contains the session recording group ID ('C0003').
  3. If OneTrust is not loaded, checks the analyticsConsent query parameter in the current URL.
  4. If running in an iframe, checks the analyticsConsent query parameter in the iframe's src URL.
  5. Defaults to false if no consent can be determined.

Note: When OneTrust is present, the OneTrust consent groups take precedence over URL parameters. The analyticsConsent URL parameter only applies when OneTrust is not loaded.

Returns

boolean

true if the user has consented to session recording, false otherwise.