Skip to main content

initLogRocket()

function initLogRocket(options?: IOptions & {
appId?: string;
isReact?: boolean;
}): void;

Initialize LogRocket with optional OneTrust integration

This function handles LogRocket initialization with support for OneTrust consent management. The initialization behavior depends on the window.hasOneTrust flag and consent banner state:

  • If window.hasOneTrust is true and the consent banner hasn't been seen, waits for 'OTConsentApplied' event (until user interacts with banner)
  • If window.hasOneTrust is true and the banner was already seen, initializes immediately
  • If window.hasOneTrust is false or undefined, LogRocket initializes immediately
  • Prevents duplicate initialization by checking window.emui.isLogRocketInitialized

Parameters

options?

IOptions & { appId?: string; isReact?: boolean; }

LogRocket initialization options

Returns

void

Examples

// With OneTrust (when window.hasOneTrust is true)
initLogRocket({
appId: 'your-project/your-app',
isReact: true,
rootHostname: '.ice.com',
childDomains: ['https://your-child-domain.com'],
parentDomain: 'https://your-parent-domain.com',
});
// Without OneTrust (when window.hasOneTrust is false/undefined)
initLogRocket({
appId: 'your-project/your-app',
});