RUM JavaScript API - 1.345.1
    Preparing search index...

    Function addEventModifier

    • Async wrapper for dynatrace.addEventModifier.

      Parameters

      • eventModifier: (jsonEvent: Readonly<JSONEvent>, eventContext?: EventContext) => JSONEvent

        The modifier function to modify a given (readonly) JSONEvent. It receives an optional context depending on the type of event, if available. The returned event must be a new object, otherwise modification will be ignored.

      • timeout: number = DEFAULT_AGENT_TIMEOUT

        Timeout in milliseconds to wait for the RUM JavaScript to be available (default: 10000)

      Returns Promise<() => void>

      A promise that resolves to the unsubscriber function to turn off event modification.

      A DynatraceError if the RUM JavaScript is not available within the timeout, or the namespace is overridden with an incompatible object

      import { addEventModifier } from '@dynatrace/rum-javascript-sdk/api/promises';

      const unsubscribe = await addEventModifier((event) => ({
      ...event,
      'event_properties.environment': 'production'
      }));