RUM Classic JavaScript API
    Preparing search index...

    Type Alias dtrum

    type dtrum = {
        actionName(actionName: string, actionId?: number): ActionNameResult;
        addActionProperties(
            parentActionId: number,
            javaLong?: PropertyMap<number>,
            date?: PropertyMap<Date>,
            shortString?: PropertyMap<string>,
            javaDouble?: PropertyMap<number>,
        ): PropertiesSendingReport;
        addEnterActionListener(
            listener: (
                actionId: number,
                starttime: number,
                isRootAction: boolean,
                element?: string | EventTarget,
            ) => void,
        ): void;
        addLeaveActionListener(
            listener: (
                actionId: number,
                stoptime: number,
                isRootAction: boolean,
            ) => void,
        ): void;
        addPageLeavingListener(listener: (unloadRunning: boolean) => void): void;
        addVisitTimeoutListener(
            listener: (visitId: string, newVisitAfterTimeout: boolean) => void,
        ): void;
        beginUserInput(
            domNode: string | HTMLElement,
            type: string,
            addInfo?: string,
            validTime?: number,
        ): DtRumUserInput;
        disable(): void;
        disablePersistentValues(remember: boolean): void;
        disableSessionReplay(): void;
        enable(): void;
        enableAutomaticPageDetection(): void;
        enableManualPageDetection(): void;
        enablePersistentValues(): void;
        enableSessionReplay(ignoreCostControl: boolean): void;
        endSession(): void;
        endUserInput(userInputObject: DtRumUserInput): void;
        enterAction(
            actionName: string,
            actionType?: string,
            startTime?: number,
            sourceUrl?: string,
        ): number;
        enterXhrAction(type: string, xmode?: 0 | 1 | 3, xhrUrl?: string): number;
        enterXhrCallback(actionId: number): void;
        getAndEvaluateMetaData(): MetaData[];
        identifyUser(value: string): void;
        incrementOnLoadEndMarkers(): void;
        leaveAction(actionId: number, stopTime?: number, startTime?: number): void;
        leaveXhrAction(actionId: number, stopTime?: number): void;
        leaveXhrCallback(actionId: number): void;
        markAsErrorPage(responseCode: number, message: string): boolean;
        markXHRFailed(
            responseCode: number,
            message: string,
            parentActionId?: number,
        ): boolean;
        now(): number;
        removeEnterActionListener(
            listener: (
                actionId: number,
                starttime: number,
                isRootAction: boolean,
                element?: string | EventTarget,
            ) => void,
        ): void;
        removeLeaveActionListener(
            listener: (
                actionId: number,
                stoptime: number,
                isRootAction: boolean,
            ) => void,
        ): void;
        reportCustomError(
            key: string,
            value: string,
            hint?: string,
            parentingInfo?: number | boolean,
        ): void;
        reportError(error: string | Error, parentActionId?: number): void;
        sendBeacon(
            forceSync: boolean,
            sendPreview: boolean,
            killUnfinished: boolean,
        ): void;
        sendSessionProperties(
            javaLongOrObject?: PropertyObject | PropertyMap<number>,
            date?: PropertyMap<Date>,
            shortString?: PropertyMap<string>,
            javaDouble?: PropertyMap<number>,
        ): PropertiesSendingReport;
        setAutomaticActionDetection(enabled: boolean): void;
        setLoadEndManually(): void;
        setPage(newPage: { group?: string; name: string }): number;
        signalLoadEnd(): void;
        signalOnLoadEnd(): void;
        signalOnLoadStart(): void;
    }
    Index

    Actions

    • Sets the name of the currently active action, or the action corresponding to the provided ID.

      Parameters

      • actionName: string

        The new name for the action.

      • OptionalactionId: number

        The ID of the action to update. If omitted, the currently active action is updated.

      Returns ActionNameResult

      An ActionNameResult indicating whether the update was successful.

    • Attaches a listener that is called while entering an action.
      Remove the listener if not needed, or filter actions using addActionProperties to prevent sending the same action property for every action. Use this method to hook into the automatic action creation event to influence related concepts such as action naming or action properties.

      Parameters

      • listener: (
            actionId: number,
            starttime: number,
            isRootAction: boolean,
            element?: string | EventTarget,
        ) => void

        The callback function to be triggered when an action is entered.

          • (
                actionId: number,
                starttime: number,
                isRootAction: boolean,
                element?: string | EventTarget,
            ): void
          • Parameters

            • actionId: number

              The ID of the action being entered.

            • starttime: number

              The start time of the action.

            • isRootAction: boolean

              Indicates if the action is a root action.

            • Optionalelement: string | EventTarget

              The element that initiated the event.

            Returns void

      Returns void

    • Attaches a listener that is called when leaving an action.
      Remove the listener if not needed, or filter actions using addActionProperties to prevent sending the same action property for every action. Use this method to hook into the out-of-the-box action closing event.

      Parameters

      • listener: (actionId: number, stoptime: number, isRootAction: boolean) => void

        The callback function to be triggered when an action is left.

          • (actionId: number, stoptime: number, isRootAction: boolean): void
          • Parameters

            • actionId: number

              The ID of the action being left.

            • stoptime: number

              The end time of the action.

            • isRootAction: boolean

              Indicates if the action is a root action.

            Returns void

      Returns void

    • Indicates the start of a user input. Every user input must be concluded by calling endUserInput. RUM JavaScript checks for an active user input when an XHR call or a page load occurs. If a user input is active, that input is marked as having triggered the user action. Use this method when a user input is not automatically detected by RUM JavaScript.

      Parameters

      • domNode: string | HTMLElement

        The DOM node (or a string identifier) that triggered the action (e.g., a button). Determines the caption for the resulting action.

      • type: string

        The type of action (e.g., 'click', 'keypress', 'scroll').

      • OptionaladdInfo: string

        Optional additional information about the user input (e.g., key, mouse button, etc.).

      • OptionalvalidTime: number

        The duration (in milliseconds) for which this user input should remain valid.

      Returns DtRumUserInput

      An object containing information about the user input.

    • Enters a new custom action. Use this method to create a custom action.
      This method must be called before leaveAction, which closes the custom action.

      Parameters

      • actionName: string

        The name of the action.

      • OptionalactionType: string

        DEPRECATED: This parameter is not used anymore and has no effect if provided.

      • OptionalstartTime: number

        The timestamp in milliseconds. If falsy, the current time is used.

      • OptionalsourceUrl: string

        The source URL for the action.

      Returns number

      The ID of the created action, or 0 if the action was not created.

    • Extends or initiates actions. Use this method when you want to extend an active Load or XHR action with an unlinked XHR call, i.e., an action. It is particularly useful when the XHR call is asynchronous and cannot be automatically correlated with an action, which might otherwise cause the action to close prematurely, leading to inaccurate metrics (such as user action duration). This method must be called before leaveXhrAction.

      Parameters

      • type: string

        Optional information about the type of XHR (e.g., framework name).

      • Optionalxmode: 0 | 1 | 3

        XHR action creation mode:
        0 ... Extend only running XHR actions.
        1 ... Extend any running action.
        3 ... Start an action if a user input is present.

      • OptionalxhrUrl: string

        The URL of the requested resource. This argument should always be provided. If omitted, the request will appear as "/undefined" in the waterfall.

      Returns number

      The ID of the XHR action.

    • Indicates that an XHR callback is active (e.g., XMLHttpRequest onreadystatechange) and links subsequently triggered XHR actions to this callback. For example, if an XHR callback adds a script tag to your page and triggers another XHR call, that call would not automatically be added to the current action. Calling this method allows the subsequent XHR call to be linked to its initial action. The XHR callback must be concluded with leaveXhrCallback.

      Parameters

      • actionId: number

        The ID of the action to which the callback belongs.

      Returns void

    • Instructs RUM JavaScript to wait for an additional call to signalOnLoadEnd before closing the 'onload' action. Note: The load action will only use the provided load end event correctly if signalOnLoadEnd is called afterward.

      Returns void

    • Leaves an action that was previously created using enterAction. Use this method to set the load end event for a custom action and complete its creation. This method must be called after enterAction.

      Parameters

      • actionId: number

        The ID of the action to leave. This must be the value returned by enterAction.

      • OptionalstopTime: number

        The timestamp in milliseconds. Providing a stop time will force the action to stop and prevent the visually complete module from extending it.

      • OptionalstartTime: number

        Optional start time in milliseconds (necessary if the start time should be modified). Note that the start time must not be more than an hour in the past; otherwise it is ignored.

      Returns void

    • Indicates the end of an XHR action.

      Parameters

      • actionId: number

        The ID of the XHR action.

      • OptionalstopTime: number

        The stop time of the XHR action in milliseconds.

      Returns void

    • Indicates the end of an XHR callback.

      Parameters

      • actionId: number

        The ID of the action to which the callback belongs.

      Returns void

    • Removes a previously attached listener that detects the enter action event.

      Parameters

      • listener: (
            actionId: number,
            starttime: number,
            isRootAction: boolean,
            element?: string | EventTarget,
        ) => void

        The reference to the listener to be removed.

      Returns void

    • Removes a previously attached listener that detects the leave action event.

      Parameters

      • listener: (actionId: number, stoptime: number, isRootAction: boolean) => void

        The callback function to be removed.

          • (actionId: number, stoptime: number, isRootAction: boolean): void
          • Parameters

            • actionId: number

              The ID of the action being left.

            • stoptime: number

              The end time of the action.

            • isRootAction: boolean

              Indicates if the action is a root action.

            Returns void

      Returns void

    • Enables or disables automatic action detection. Use this method when you want to manually instrument your application.

      Parameters

      • enabled: boolean

        Specifies whether automatic action detection should be enabled or disabled.

      Returns void

    • Prevents RUM JavaScript from automatically detecting the load end event. The load end event must be explicitly set using signalLoadEnd. Call this method immediately after injecting RUM JavaScript.

      Returns void

    • Indicates the start of a load action. Frameworks often have their own load callback functions, and this method can be used when a framework begins loading before the 'DOMContentLoaded' event.

      Returns void

    Custom Reporting

    • Adds custom action properties to the currently active action.
      Only accepts valid java long, java double (as a string representation), Date objects, and short strings with a maximum length of 100-1000 characters (as configured under Application Settings).
      Action properties must be defined under Application settings and use a lowercase key.

      Parameters

      • parentActionId: number

        The ID of the action.

      • OptionaljavaLong: PropertyMap<number>

        A JSON object containing key-value pairs of valid numbers. The values must be within the range -9223372036854776000 to 9223372036854776000.

      • Optionaldate: PropertyMap<Date>

        A JSON object containing key-value pairs of JavaScript Date objects.

      • OptionalshortString: PropertyMap<string>

        A JSON object containing key-value pairs of strings. Each string must be less than 100 characters.

      • OptionaljavaDouble: PropertyMap<number>

        A JSON object containing key-value pairs of valid floating point numbers. The values must be within the range -1.7976931348623157e+308 to 1.7976931348623157e+308.

      Returns PropertiesSendingReport

      A status report about the properties passed to the function. This report contains information about any failed properties with the reason for failure, as well as details of properties that were sent successfully, and a summary message regarding the total number of failed properties.

    • Re-enables automatic page detection after manual detection was enabled via enableManualPageDetection. Once this method is called, RUM JavaScript will resume automatically detecting page and page group names.

      Returns void

    • Enables manual page detection. Once this method is called, RUM JavaScript will stop automatically detecting page and page group names and will only use the values provided via setPage. It is recommended to call this as early as possible. To resume automatic detection, call enableAutomaticPageDetection.

      Returns void

    • Retrieves and evaluates metadata for the page, which can be used for troubleshooting RUM monitoring.

      Returns MetaData[]

      An array of metadata objects, each containing an id, type, expression, the captured value, and an optional failure reason.

    • Sets the user tag, which is used to identify individual users across different browsers, devices, and sessions.

      Parameters

      • value: string

        The username. This can be a name, user ID, or email address.

      Returns void

    • Reports the HTTP status code and a custom message for the response of the current page. For example, use this method to mark your 404 pages that respond with an HTTP status code of 200. This method must be called before the page's onload event finishes; otherwise, the information will be discarded.

      Parameters

      • responseCode: number

        The HTTP status code to set.

      • message: string

        An additional informational message.

      Returns boolean

      Returns false if the values were incorrect or the method was called too late; otherwise, returns true.

    • Reports the HTTP status code and an additional message for the response of the current XHR action. For example, use this method when the HTTP status code of your XHR response is 200, but the server's result indicates a failed request. This method must be called before the XHR action finishes and all listeners have been invoked.

      Parameters

      • responseCode: number

        The HTTP status code of the current XHR action.

      • message: string

        An additional informational message.

      • OptionalparentActionId: number

        The optional ID of the action to mark as failed. If not provided, the currently open action is used.

      Returns boolean

      Returns false if the values were incorrect or the method was called too late; otherwise, returns true.

    • Reports custom errors to Dynatrace. Use this method to capture custom errors, such as form validation errors, that are defined in Application settings.

      Parameters

      • key: string

        The key of the error (e.g., 'validation error').

      • value: string

        The error value (e.g., 'Email validation failed').

      • Optionalhint: string

        An optional hint to identify the issue, such as the content of the input element that triggered the error.

      • OptionalparentingInfo: number | boolean

        Defines how the custom error should be attached. When a number is provided, the error is attached to the specified open action. When a boolean is provided and true, it is attached to the currently active action.

      Returns void

    • Reports an error to Dynatrace. Use this method when you catch errors in your application code and want to propagate them to Dynatrace, rather than handling them solely with your own logging. If the error is managed by your application, it will not be handled by the global JavaScript onerror event handler, which Dynatrace uses to automatically capture JavaScript errors.

      Parameters

      • error: string | Error

        The error to report. Any standard browser error object is supported. If the error does not include a stack trace, the RUM JavaScript monitoring code will attempt to generate one. Alternatively, you can provide your own object with the following properties: 'message', 'file', 'line', 'column', and 'stack'. The 'message' property is required; all other properties are optional.

      • OptionalparentActionId: number

        The parent action ID. If not provided or null, the error is added to the current action.

      Returns void

    • Sends session properties on a beacon currently only accepts valid java long, java double (as a string representation), Date objects, and short strings of a maximum length of 100-1000 characters (as configured under Application Settings).
      NOTE: session properties need to have a lower case key!

      Make sure to first define session properties under Application settings before making this API call.

      Parameters

      • OptionaljavaLongOrObject: PropertyObject | PropertyMap<number>

        A JSON object containing key-value pairs of valid numbers. The values must be within the range -9223372036854776000 to 9223372036854776000.

      • Optionaldate: PropertyMap<Date>

        A JSON object containing key-value pairs of JavaScript Date objects.

      • OptionalshortString: PropertyMap<string>

        A JSON object containing key-value pairs of strings. Each string must be less than 100 characters.

      • OptionaljavaDouble: PropertyMap<number>

        A JSON object containing key-value pairs of valid floating point numbers. The values must be within the range -1.7976931348623157e+308 to 1.7976931348623157e+308.

      Returns PropertiesSendingReport

      A status report about the properties passed to the function. This report contains information about any failed properties with the reason for failure, as well as details of properties that were sent successfully, and a summary message regarding the total number of failed properties.

      addActionProperties is related and works similarly.

    • Starts a new page view and reports it to the Dynatrace server.

      Parameters

      • newPage: { group?: string; name: string }
        • Optionalgroup?: string

          The group of the new view, recommended to include dynamic placeholders of the view name. For example, if the view name is "/books/123", the view group should be "books/:bookId" or similar. If null or undefined, the Dynatrace server calculates the group based on the name.

        • name: string

          The name of the new view, typically matching the location.pathname or location.hash.

      Returns number

      A negative number if starting the new page failed, or a positive number if the new page was started successfully.

      • -2: The page is being set while manual page detection is inactive (perhaps enableManualPageDetection was not called).
      • -1: The new page is the same as the previous one.
      • 1: The new page started successfully.
      • 2: The new page started during onload, meaning it is cached and will be sent with the load action.

    Lifecycle

    • Adds a listener that is called when the user is leaving the page, before the RUM monitoring beacon is sent. Use this method to hook into the page unload event.

      Parameters

      • listener: (unloadRunning: boolean) => void

        A function that will be called in case the user leaves the page.

          • (unloadRunning: boolean): void
          • Parameters

            • unloadRunning: boolean

              A boolean that is true if the page is currently being dismissed.

            Returns void

      Returns void

    • Adds a listener that is triggered when the current visit times out and before a new visit ID is generated.

      Parameters

      • listener: (visitId: string, newVisitAfterTimeout: boolean) => void

        The listener function to add, which receives the current visit ID and a boolean indicating if a new visit will start due to timeout.

          • (visitId: string, newVisitAfterTimeout: boolean): void
          • Parameters

            • visitId: string

              The timed out visit ID.

            • newVisitAfterTimeout: boolean

              True if a new visit will start due to timeout.

            Returns void

      Returns void

    • Disables RUM JavaScript and removes all cookies if it was previously enabled with enable, thereby activating the opt-in mode. Use this method along with a user consent tool to disable RUM monitoring when consent is not provided.

      Returns void

      enable

    • Removes all persistent values and disables any functionality that would recreate them. Note that this must be called on every page, as it erases persistent RUM monitoring data, including the information that prevents persistent data from being stored.
      Use this method when you want to disable monitoring of returning users. For more information, see cookie storage.

      Parameters

      • remember: boolean

        If true, the configuration state is saved in local storage so that it persists across page loads.

      Returns void

    • Disables session replay.

      Returns void

    • Enables RUM JavaScript if it was previously disabled via the opt-in mode. Use this method in conjunction with a user consent tool to enable RUM monitoring once consent has been provided.

      Returns void

    • Re-enables persistent values if they were previously disabled by calling disablePersistentValues. Use this method when you want to resume monitoring returning users.

      Returns void

    • Enables session replay.

      Parameters

      • ignoreCostControl: boolean

        If true, enables session replay regardless of the cost control configuration.

      Returns void

    • Immediately ends the current session.

      Returns void

    • Forces the sending of a beacon to ensure actions are not lost. For example, use this method before a window unload event by adding a addPageLeavingListener.

      Parameters

      • forceSync: boolean

        DEPRECATED: This parameter is not used anymore and has no effect if provided.

      • sendPreview: boolean

        Forces the sending of preview beacons containing actions that have not yet been closed.

      • killUnfinished: boolean

        Terminates unfinished actions and sends them immediately. Handle with care, as actions might be inaccurate.

      Returns void

    Utilities

    • Returns the current time in milliseconds using the most accurate method available.

      Returns number

      The current time in milliseconds.