# Should we start collecting software usage data?

**URL:** <https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873>\
**Category:** Development\
**Created:** [July 29, 2023, 7:52pm UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873 "2023-07-29T19:52:39Z")\
**Posts on this page:** 5\
**Page:** 5

<div class="post-metadata">

**Author:** ![BerDom.Ing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/berdom.ing/32/69496_2.png) [@BerDom.Ing](https://discourse.slicer.org/u/BerDom.Ing)\
**Post date:** [September 26, 2024, 7:55pm UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873/81 "2024-09-26T19:55:05Z")

</div>

I want to do a pull request to [Slicer/SlicerTelemetry](https://github.com/Slicer/SlicerTelemetry), the repository is empty and i cant fork it, i need to fork it to do the pull request

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [September 27, 2024, 2:44pm UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873/82 "2024-09-27T14:44:21Z")

</div>

I’ve added a few files. You should be able to fork the repository now.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [October 29, 2024, 11:41pm UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873/83 "2024-10-29T23:41:14Z")

</div>

I would be nice if this extension arrived on the new stable release 🙂

---

<div class="post-metadata">

**Author:** ![BerDom.Ing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/berdom.ing/32/69496_2.png) [@BerDom.Ing](https://discourse.slicer.org/u/BerDom.Ing)\
**Post date:** [November 25, 2024, 7:03pm UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873/84 "2024-11-25T19:03:40Z")

</div>

Hello everyone,

I’d like to share my progress on the development of the telemetry extension for Slicer 3D.  
Here is what you need to know:

**For End Users:**

When there is data to be uploaded to the server this dialog will show up:

 ![SendToServerPopUp](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d9c88b020a379b0becc2a162a6b40508f54dc9b.png)

Including the raw data

 ![seeRawData](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/0/2062ce75dda80c908d2890284491b0889241332f.png)

And a visualization of the data collected

 ![dataVisualization](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/7/87905993adbf73234dfc8646e9d96135b250771c.png)

The data used in the following images was generated randomly to test the frontend.

 ![mapAndTimeLine](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/7/872ed38a4babe2322eb342dea3e7ce61031bc6b1.png)  
 ![ComponentAndEvent](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/9/b94686ee69d656d7e217e31848867954b4ff278c.png)

You can also select which extensions are allowed to collect information on the Telemetry Extension

 ![selectExtensions](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/5/45cba3bc57e5becd80ed1a60451459ba711f1013.png)

The default configuration is asked on slicer start just once.

 ![installedExtensionsPermission](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/b/5bbd271dc99b17f8860ff1f5243e642768d4e16e.png)

#### For Slicer Developers:

#### Telemetry Extension Workflow

The **Telemetry Extension** is designed to log, organize, and upload usage data. Here’s a breakdown of its components and functionality:

1. **Logging Events in Extensions:**

- To log an event from an extension, use the following code snippet:

_slicer.app.logUsageEvent(“Component”, “Event”)._

- This emits a _usageEventLogged_ signal.
- The signal is connected to the _onUsageEventLogged_ function, which processes the event.

1. **Event Logging with** _onUsageEventLogged(component, event)_:

- This method saves incoming events into a _.csv_ file.
- It verifies whether the event’s source component belongs to one of three categories:
  - **enabledExtensions:** Telemetry is explicitly enabled.
  - **disabledExtensions:** Telemetry is explicitly disabled.
  - **defaultExtensions:** Telemetry depends on a default setting (e.g., whether telemetry is enabled by default for new installations).

- Only events from components with enabled telemetry (or default-enabled settings) are saved.
- The method also:
  - **Adds timestamps** to each event.
  - **Groups events by occurrence per day** for aggregation and easier analysis.

**Extension Installation:**

- When an extension is installed, it is automatically added to the defaultExtensions category.

**Data Upload Prompt:**

- A prompt asking for permission to upload data appears only if the following conditions are met:
  - More than **7 days** have passed since the last upload.
  - There is data in the _.csv_ file waiting to be uploaded.

- If the user selects “Do not show again,” the preference is saved, and the prompt will not appear again.

**Uploading and Request Handling:**

- Functions like _weeklyUsageUpload_ and _handleQtReply_ use **QNetworkAccessManager** for asynchronous handling of HTTP requests and responses. This avoids blocking the main application, unlike synchronous libraries such as _requests_.

#### Server-Side Implementation

The server is implemented using **Flask** and performs the following tasks:

1. **Geolocation Mapping:**

- The _get\_location\_from\_ip_ function:
  - Extracts the **country, country code,** and **city** based on the IP address in a POST request.
  - Uses the **GeoIP2 database** for geolocation mapping.
  - This data is appended to the event details (e.g., component, event, date, and aggregated times).

1. **Data Conversion:**

- The _convert\_alpha2\_to\_alpha3_ function:
  - Converts two-letter country codes (ISO Alpha-2) to three-letter codes (ISO Alpha-3) for compatibility with the frontend.

1. **Data Handling:**

- Event data from POST requests is appended to a _data.csv_ file located in the _static_ folder.
- This _.csv_ file is used by the frontend for generating statistics.

1. **Frontend Hosting:**

- The Flask application serves the frontend content, also stored in the _static_ folder.

#### Nginx Server

- An **Nginx server** is used as a reverse proxy for the Flask application, offering several advantages:
  - Handles incoming traffic and forwards it to the Flask application.
  - Efficiently manages a high volume of concurrent connections.
  - Provides faster response times and a smoother user experience compared to Flask handling requests directly.

#### Frontend Visualization

The frontend provides a user-friendly interface for visualizing telemetry data:

1. **Charts with _stats.js_** :

- Uses **D3.js** and **Crossfilter** libraries to:
  - Create interactive charts.
  - Establish linkages between dimensions, allowing charts to filter and update based on user interactions.

1. **World Map:**

- The map, defined in _world.geojson:_
  - Is an SVG file containing country names and codes.
  - Links to the event data for geographic visualization.

Thank you for taking the time to read about my progress. I welcome any feedback or suggestions from the community as I continue to develop this Slicer 3D extension!

Best regards,  
Bernardo Dominguez

---

<div class="post-metadata">

**Author:** ![BerDom.Ing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/berdom.ing/32/69496_2.png) [@BerDom.Ing](https://discourse.slicer.org/u/BerDom.Ing)\
**Post date:** [April 22, 2025, 1:42am UTC](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873/85 "2025-04-22T01:42:52Z")

</div>

Here is a demo of the front end handling 1 million rows of generated (not real) data. It’s hosted on Amazon Lightsail with a dynamic IP [http://44.204.140.26/](http://44.204.140.26/) (it may change). To skip the loading, go to 00:46.

[Previous page](https://discourse.slicer.org/t/should-we-start-collecting-software-usage-data/30873.md?page=4)
