@equinor/roma-dynatrace-module
v0.1.0
Published
Fusion Framework module abstracting the [Dynatrace RUM JavaScript SDK](https://www.npmjs.com/package/@dynatrace/rum-javascript-sdk). All actions delegate to the SDK's **safe wrapper** APIs, which no-op gracefully when RUM is unavailable.
Readme
@equinor/roma-dynatrace-module
Fusion Framework module abstracting the Dynatrace RUM JavaScript SDK. All actions delegate to the SDK's safe wrapper APIs, which no-op gracefully when RUM is unavailable.
Enable
Framework level (config.ts):
import { enableDynatrace } from '@equinor/roma-dynatrace-module';
enableDynatrace(config);App level — overrides the framework module and can disable user-action tracking:
enableDynatrace(configurator, { disableUserActions: true });When disableUserActions is true, automatic user-action detection is turned off on init and
restored when the module is destroyed.
Set debug: true to log a message describing each skipped action when the RUM agent is not
loaded (e.g. local development). It is off by default to avoid leaking user identifiers into
browser logs.
Usage
import { useDynatrace } from '@equinor/roma-dynatrace-module';
const dt = useDynatrace(); // prefers app module, falls back to framework
dt.identifyUser('[email protected]');
const stop = dt.trackAction({ customName: 'Save form' });
stop?.();
dt.reportError(new Error('boom'));Provider actions: identifyUser, sendEvent, sendSessionProperty, reportError, trackAction,
sendKeyPress, addEventModifier, healthCheck, setUserActionsEnabled.
When the RUM agent is not loaded (typically local development), isAvailable is false and each
action logs an informative [dynatrace] agent not available — skipping "<action>"… message with the
payload it would have reported, instead of failing silently.
Temporary dtrum fallback
Several methods require modular SDK modules that are only present on window.dynatrace when enabled
server-side. Until then they fall back to the legacy window.dtrum API. The bridge lives entirely in
src/lib/dtrum-fallback.ts — delete that file and its imports in provider.ts once the modules are
enabled everywhere.
| Provider method | dtrum fallback |
|-----------------|----------------|
| identifyUser | identifyUser |
| reportError | reportError |
| sendSessionProperty | sendSessionProperties (keys sent as short strings, prefix stripped) |
| trackAction | enterAction / leaveAction |
| setUserActionsEnabled | setAutomaticActionDetection |
No dtrum equivalent (SDK-only): sendEvent (business events), sendKeyPress, addEventModifier,
healthCheck. These no-op + log when window.dynatrace lacks the capability.
Tests
nx test roma-dynatrace-module
