RUM powered by Grail JavaScript API - 1.327.2
    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
      • Optionaloptions: UserActionStartOptions

        An optional options object to configure the user action.

        Options to create a user action with.

        • Optional ExperimentalautoClose?: boolean

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

          default: true

        • Optional Experimentalname?: string

          A human-readable name to identify the user action.

        • 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 finished, or undefined if the user action module is not enabled.

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

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

      Parameters

      • this: void
      • automaticDetection: boolean

        If false, disables automatic user action detection, otherwise enables it.

      Returns void

      dynatrace.userActions?.setAutomaticDetection(false);

      async function handleClick(router) {
      const userAction = dynatrace.userActions?.create({ autoClose: false });
      // this would normally create an user action that would finish this manual user action
      await router.redirect("home");
      userAction.finish();
      }
    • 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.autoClose = false;
      // Execute some requests or mutations, then finish the user action
      userAction.finish();
      });
      // 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.autoClose = false;
    }
    const response = await channel.send(message);
    currentUserAction?.finish();
    return response;
    }