User Activity Monitor

Content Type: Widget
Categories: Utility

Overview

The User Activity Monitor widget enables Mendix developers to detect when users are active, idle, or inactive within a web application and to trigger custom actions automatically based on these states. It now also supports an Initialization Action for any setup logic you want to run as soon as the widget is loaded. This solution is ideal for building features such as inactivity warnings, auto-logout, session analytics, or security notifications.

Documentation

User Activity Monitor – Detect Active, Idle, and Inactive Users in Mendix

Overview

User Activity Monitor is a lightweight and configurable Mendix pluggable widget for detecting active, idle, and inactive user states in Mendix web applications.

The widget allows each state transition to trigger a Mendix action, such as a microflow or nanoflow. This makes it suitable for presence monitoring, inactivity warnings, automatic logout scenarios, security policies, periodic activity updates, and other session-related business logic.

An optional initialization action can also be executed once whenever the widget is mounted. This can be used to mark the current user as active, initialize application-specific presence data, or perform other page startup logic.

The widget runs entirely in the background, renders no user interface, and does not require a page object or data context.

Key Features

Configurable presence detection

Detects and differentiates between active, idle, and inactive states using configurable time intervals.

Heartbeat action

Periodically executes a configured Mendix action while the user is active. This can be used to update a last-seen timestamp, synchronize presence information, or perform application-specific monitoring.

Heartbeat execution stops automatically when the user becomes idle or inactive.

Idle and inactive actions

Executes separate actions when:

  • the user reaches the configured idle threshold;
  • the user remains idle for the additional inactive interval.

Return-to-active action

Executes an action once when the user returns from the idle or inactive state. This can be used to hide inactivity warnings, refresh data, restore application state, or perform security checks.

Initialization action

Optionally executes a Mendix action once when the widget instance is mounted.

Broad activity detection

Recognizes common browser interactions, including:

  • keyboard input;
  • pointer and mouse interaction;
  • touch interaction;
  • wheel activity;
  • page scrolling.

Configurable hidden-tab behavior

The widget can either:

  • continue heartbeat processing while the browser tab is hidden; or
  • pause heartbeats while the tab is hidden or the browser window loses focus.

The default setting preserves the behavior of previous widget versions.

Idle and inactive detection continues even when heartbeat execution is paused.

Mendix action support

Initialization, heartbeat, idle, inactive, and return-to-active events can each invoke a configured Mendix microflow or nanoflow.

Actions are invoked without input parameters.

Resource-efficient execution

The widget uses controlled, self-scheduling timers and prevents the same action from being started again while its previous execution is still running.

This helps avoid overlapping heartbeat calls and unnecessary backend traffic.

Automatic cleanup

Timers and browser event listeners are removed when the widget is unmounted or the page is unloaded, preventing duplicated listeners and obsolete background timers.

No user-interface impact

The widget renders no visible content and can be placed on a page or reusable layout without affecting the application interface.

No data context required

The widget does not require a page parameter, enclosing data view, or business object.

How It Works

Active state

The user remains active while interacting with the application.

While active, the configured heartbeat action is executed periodically according to the Heartbeat Interval. Setting the interval to 0 disables heartbeat execution.

Idle state

When no supported user interaction is detected for the configured Idle Interval, the widget:

  • enters the idle state;
  • executes the Idle Action, if configured;
  • stops heartbeat execution.

Inactive state

After the user has remained idle for the additional Inactive Interval, the widget:

  • enters the inactive state;
  • executes the Inactive Action, if configured.

The Inactive Interval is measured from the moment the user enters the idle state.

Return to active

When activity is detected after the user became idle or inactive, the widget:

  • returns to the active state;
  • executes the Back to Active Action once;
  • resumes heartbeat execution;
  • restarts the idle and inactive timers.

Initialization

The Initialization Action is executed once for each widget mount. Navigation away from the page and returning to it may mount a new widget instance and execute the action again.

Example Configuration

Consider an internal HR application with the following configuration:

  • Heartbeat Interval: 30 seconds
    Updates the current user's last-seen timestamp.
  • Idle Interval: 300 seconds
    Displays an inactivity warning after five minutes without interaction.
  • Inactive Interval: 600 seconds
    Logs the user out after an additional ten minutes in the idle state.
  • Back to Active Action:
    Hides the warning and refreshes sensitive data.
  • Initialization Action:
    Marks the current user as online when the widget is mounted.
  • Hidden-tab behavior:
    Pauses heartbeats when the browser tab is hidden or the browser window loses focus.

Integration Notes

  • Minimum Mendix version: Studio Pro 9.6
  • Supported platform: Mendix web applications
  • Native mobile: Not supported
  • Data context: Not required
  • Visible interface: None
  • Action parameters: Actions are invoked without parameters
  • Multiple instances: Usually one instance per active page or shared layout is sufficient

When placing the widget in a reusable layout, verify that additional page-level instances do not invoke the same actions unnecessarily.

Typical Use Cases

  • Detecting active, idle, and inactive users
  • Automatic logout after prolonged inactivity
  • Displaying inactivity or session-expiration warnings
  • Updating user presence or last-seen information
  • Enforcing security and inactivity policies
  • Refreshing application data when the user returns
  • Clearing or hiding sensitive information
  • Running initialization logic when a page or layout is loaded

Need Context-Aware Time Tracking?

User Activity Monitor tracks general presence states. It does not assign activity time to projects, cases, tickets, pages, or other business contexts.

For durable activity segments, multi-tab coordination, context-aware time measurement, recovery after navigation or reload, and server-side persistence, use Advanced User Activity Monitor.

Releases

Version: 1.2.0
Framework Version: 9.6.0
Release Notes:

Added

- Added configurable hidden-tab behavior.

- Added optional heartbeat pausing when the browser tab is hidden or the browser window loses focus.

- Added pointer, touch, wheel and scroll activity detection.

- Added Studio Pro validation for invalid heartbeat, idle and inactive interval values.


Changed

- Reworked timer management around a single authoritative presence controller.

- Replaced repeating heartbeat intervals with self-scheduling timeouts to prevent overlapping executions.

- Actions are no longer invoked while their previous execution is still running.

- Runtime configuration changes now reschedule the relevant timers without remounting the widget.

- Event listeners now use capture and passive options where appropriate.


Fixed

- Fixed the initialization action potentially executing twice during the initial render.

- Fixed duplicated timers after property or action availability changes.

- Fixed stale callbacks caused by timers retaining outdated widget properties.

- Fixed background pointer events being treated as user activity when hidden-tab pause mode is enabled.

- Fixed timer and event-listener cleanup when the widget is unmounted or the page is unloaded.


Compatibility

- Existing callback properties and their behavior remain available.

- `Continue while hidden` remains the default to preserve compatibility with version 1.1.0.

- The minimum supported Studio Pro version remains 9.6.

- No application model or migration changes are required.

Version: 1.1.0
Framework Version: 9.6.0
Release Notes: A technical issue related to the incorrect handling of interval parameters has been fixed
Version: 1.0.0
Framework Version: 9.6.0
Release Notes: Initial version