RUM JavaScript API - 1.345.1
    Preparing search index...

    Interface UserActionsExperimental

    interface UserActions {
        current: UserActionTracker;
        create(this: void, options: UserActionStartOptions): UserActionTracker;
        setAutomaticDetection(this: void, automaticDetection: boolean): void;
        subscribe(
            this: void,
            subscriber: (userAction: UserActionTracker) => void,
        ): () => void;
    }
    Index

    Methods

    • Experimental

      Creates a new controllable user action.

      Parameters

      • this: void
      • options: UserActionStartOptions

        An options object to configure the user action.

        Options to create a user action with.

        • Optional ExperimentalcompleteAutomatically?: boolean

          Automatically completes the user action upon timeout, page hide or when new user action is detected.

          default: false

        • ExperimentalcustomName: string

          A human-readable custom name to identify the user action.

        • Optional ExperimentalcustomTrackers?: UserActionActivityTrackerRegistration[]

          Custom activity tracker registrations applied at action start. Each entry pairs a tracker name (surfaced in diagnostics) with a create function the agent invokes with an activity context. notifyActivity() extends the quiet window without blocking completion; block() keeps the tracker blocked until release() is called. block() and release() are idempotent per tracker. Equivalent to calling UserActionTracker.registerCustomTracker with each (name, create) pair immediately after creation.

        • Optional ExperimentalstartTime?: number

          The unix timestamp indicating when the user action should start. Future timestamps are not supported - use current or past timestamps.

      Returns UserActionTracker

      An UserActionTracker object that can be started and completed, or undefined if the user action module is not enabled.

      const userAction = dynatrace.userActions.create({ customName: "My Action", completeAutomatically: false });
      const unsubscribe = userAction.subscribe(currentUserAction => {
      console.log(`User action would have been completed due to ${currentUserAction.completeReason}`, event);
      });
      // execute user actions
      userAction.complete();
      unsubscribe();
    • Experimental

      Controls automatic user action detection. Useful in case it interferes with manual user action handling.

      Disabling automatic detection only prevents future automatic user actions from being created. It does not complete, interrupt, or otherwise affect the currently active user action.

      Parameters

      • this: void
      • automaticDetection: boolean

        If false, pauses creation of future automatic user actions; otherwise resumes it.

      Returns void

      dynatrace.userActions?.setAutomaticDetection(false);

      async function handleClick(router) {
      const userAction = dynatrace.userActions?.create({ customName: "Handle click" });
      // This would normally create an automatic user action that interrupts this manual user action.
      await router.redirect("home");
      userAction.complete();
      }
    • Experimental

      Subscribes to user actions.

      Parameters

      • this: void
      • subscriber: (userAction: UserActionTracker) => void

        A callback function that is called whenever Dynatrace creates a new user action.

      Returns () => void

      An unsubscriber function to remove the subscription.

      const unsubscribe = dynatrace.userActions?.subscribe(userAction => {
      // Disable automatic userAction completion
      userAction.completeAutomatically = false;
      // Execute some requests or mutations, then complete the user action
      userAction.complete();
      });
      // Some time later if you don't want to listen to userActions anymore
      unsubscribe();

    Properties

    The current user action, or undefined if no user action is in progress.

    async function postMessageChannel(message, channel) {
    const currentUserAction = dynatrace.userActions?.current;
    if (currentUserAction) {
    currentUserAction.completeAutomatically = false;
    }
    const response = await channel.send(message);
    currentUserAction?.complete();
    return response;
    }