> For the complete documentation index, see [llms.txt](https://wiki.datadike.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.datadike.com/sonar/deploy-operate/productivity-module.md).

# The productivity module

The Windows service installed with the agent that records user activity and enforces access policies: how it gets there, how to check it, what users see.

## What this is and when to use it

The productivity module is a Windows service that the SONAR agent installs next to itself. It has two jobs on the device:

* **It records user activity**: the applications and websites in the foreground, idle time, and each user's sign-in and sign-out. This is the data behind [Users Behavior](https://wiki.datadike.com/sonar/administration/user-activity/users-behavior.md) and [Users Traces](https://wiki.datadike.com/sonar/administration/user-activity/users-traces.md). What it records is listed in [Users Behavior](https://wiki.datadike.com/sonar/administration/user-activity/users-behavior.md#what-the-productivity-module-records).
* **It enforces access policies**: it refuses a sign-in outside the allowed hours, signs out a session when the window ends, warns the user beforehand, and lets the user ask for extra time. See [Access policies](https://wiki.datadike.com/sonar/administration/access/access-policies.md) and [Extension requests](https://wiki.datadike.com/sonar/administration/access/requests.md).

Without it, a Windows device is managed by the agent as usual but reports no user activity and applies no access policy.

On the device it appears as:

| Item         | Value                                                                                                                                      |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Service name | `SonarProductivityService`                                                                                                                 |
| Display name | Sonar Productivity Service                                                                                                                 |
| Description  | Launches and supervises Sonar Productivity workers per active user session.                                                                |
| Executable   | `C:\Program Files\Sonar\productivity.exe`                                                                                                  |
| Account      | Local System                                                                                                                               |
| Processes    | One `productivity.exe` for the service, running as SYSTEM, and one `productivity.exe` in each monitored user session, running as that user |

## Before you start

* A **64-bit (x64) Windows** device that meets the [endpoint requirements](https://wiki.datadike.com/sonar/deploy-operate/requirements.md). The module is not available on Linux or macOS.
* The device can reach the SONAR API address on 443/tcp, over HTTPS and a long-lived secure WebSocket connection. See [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md).
* For the extension request window on the device, the **Microsoft Edge WebView2 Runtime**.
* To assign the device to an access policy, agent **4.2.0** or later.

## Steps

The module is installed by the agent, together with it. There is no separate installer.

1. Open **Agents › Install Agent** and choose the client, site and type.
2. Under the optional features, leave **Sessions** ticked. It is ticked by default in **Install Agent** and unticked by default in a new deployment link — see [Deploy agents at scale](https://wiki.datadike.com/sonar/deploy-operate/mass-deployment.md).
3. Generate the installer and run it on the device as described in [Install the agent on Windows](https://wiki.datadike.com/sonar/deploy-operate/install-agent-windows.md).
4. During the installation, the agent downloads the module from the SONAR server, registers `SonarProductivityService` and starts it.

The choice is made at installation. To add the module to a device installed without **Sessions**, reinstall the agent with the option ticked.

The module is removed with the agent: the agent's uninstaller stops and deletes `SonarProductivityService`. See [Remove agents](https://wiki.datadike.com/sonar/deploy-operate/remove-agents.md).

### Update the module on a device

When a new version of the module is available on the SONAR server, a device gets it on request, without reinstalling the agent:

1. Open **Dashboard › Sysadmin** and select the device.
2. Open its actions menu and choose **Update productivity module**.
3. The device downloads the module from the SONAR server and restarts the `SonarProductivityService`. The **Sonar UEM** icon disappears for a few seconds and comes back.

The item is shown only for Windows devices and needs the permission to edit agents. Every request is recorded in the audit log. When the device cannot take the update, the console says why:

| Message                                                                                             | Meaning                                                            |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| "... is downloading the productivity module. It restarts on its own in a few seconds."              | The update started                                                 |
| "The productivity module is not enabled on this device (the agent was installed without Sessions)." | Reinstall the agent with **Sessions** checked                      |
| "An update of the productivity module is already running on this device."                           | Wait a minute and check the service                                |
| "Unable to contact the agent"                                                                       | The device is offline or out of reach; try again when it is online |

## What you should see

On the device, `SonarProductivityService` in the Services console with the status **Running**.

For the user, in each monitored session, an icon in the Windows notification area. Its tooltip starts with **Sonar UEM** and shows the session's status: **acesso liberado até&#x20;*****HH:MM*** when an access policy applies (with the end of the allowed window), or **sem restrição de horário** when none does. Its menu has:

* the same status line;
* **Solicitar horário adicional de acesso...**, which opens the request window described in [Extension requests](https://wiki.datadike.com/sonar/administration/access/requests.md);
* **Sobre o Sonar UEM**, which shows the user, the session number and the status.

When an access policy applies, the user may also see:

| What                                                                                                      | When                                                                                            |
| --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| Notification **Sessão próxima do encerramento** ("Sua sessão será encerrada em *n* minutos, às *HH:MM*.") | 15 and 5 minutes before the end of the allowed window, when the policy has the notifications on |
| Full-screen **Acesso bloqueado** screen, with the allowed hours, the user and the computer name           | A sign-in outside the allowed hours, for 15 seconds before the session is signed out            |
| Notification **Horário de acesso atualizado**                                                             | The user's allowed hours changed, for example after an approved request                         |
| Notification **Solicitação recusada**                                                                     | A request for extra hours was denied                                                            |

The icon, the notifications and the screens on the device are in Portuguese. Activity recording itself shows nothing to the user.

## How to verify it worked

1. On the device, in PowerShell:

   ```powershell
   Get-Service SonarProductivityService
   ```

   The status must be `Running`.
2. Sign in with a user and open an application. The **Sonar UEM** icon must be in the notification area.
3. A few minutes later, in the console, open **Observability › Users Traces**, pick the device's site and the user: the application must be listed as an **Application** event with the device's hostname.

## Common errors

| Symptom                                                    | Cause                                                                                                                   | Fix                                                                                                                             |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `SonarProductivityService` does not exist                  | The agent was installed without **Sessions**, or the device is not a 64-bit Windows device                              | Reinstall the agent with **Sessions** ticked                                                                                    |
| The service exists but is stopped                          | It was stopped on the device, or an update did not bring it back                                                        | Choose **Update productivity module** for the device, or start it as an administrator: `Start-Service SonarProductivityService` |
| No **Sonar UEM** icon for the user                         | The session is outside the allowed hours of an access policy, or the service is not running                             | Check the policy's hours; check the service                                                                                     |
| The user's activity does not appear in the console         | The module sends its data every one to two and a half minutes, and foreground periods under 10 seconds are not recorded | Wait a few minutes; check that the device reaches the API address on 443/tcp                                                    |
| **Solicitar horário adicional de acesso...** opens nothing | The Microsoft Edge WebView2 Runtime is missing                                                                          | Install the WebView2 Runtime on the device                                                                                      |
| The device is not offered in an access policy              | The agent is older than 4.2.0                                                                                           | Update the agent; see [Update agents](https://wiki.datadike.com/sonar/deploy-operate/agent-updates.md)                          |

## Related pages

* [Install the agent on Windows](https://wiki.datadike.com/sonar/deploy-operate/install-agent-windows.md) — the **Sessions** option
* [Access policies](https://wiki.datadike.com/sonar/administration/access/access-policies.md) — what the module enforces
* [Users Behavior](https://wiki.datadike.com/sonar/administration/user-activity/users-behavior.md) — what the module records
* [Network requirements](https://wiki.datadike.com/sonar/deploy-operate/network-requirements.md)
* [Remove agents](https://wiki.datadike.com/sonar/deploy-operate/remove-agents.md)
