import { datadogRum } from '@datadog/browser-rum'; import { bundleState } from './bundle-state'; import { getSharedImpl } from './get-shared'; import type { RumUser } from './shared-impl'; export type { RumUser } from './shared-impl'; /** * Sets the session user on the Datadog RUM SDK. * * - **SDK initialized via `init`**: only the bundle whose `init` call * initialized the SDK may set the user; calls from any other bundle are * silent no-ops. * - **SDK initialized directly via `datadogRum.init`**: no gating is applied. * - **Neither initialized**: no-op. */ export function setUser(user: RumUser): void { if (bundleState.isSdkInitializer) { datadogRum.setUser(user); return; } if (!getSharedImpl() && datadogRum.getInitConfiguration()) { datadogRum.setUser(user); } }