Documentation

Linux SDK.

Windows, screens, clicks, opens, links and crashes from your GTK or Qt app, linked to the same people as your site.

Linux

How the Linux SDK works

One setup call in a GTK or Qt app captures its windows, screens, clicks, opens, links and crashes. It sends the same events, people and sessions as your site's snippet, so an app and a site land in the same reports.

SettingValue
Librariesmode_gtk4, mode_gtk3 or mode_qt on the Mode C core, library mode-linux
HostYour project's tracking hostname, such as https://m.example.com, from Setup
KeyYour project's public ingest key (mpk_), safe to ship inside an app
ToolkitsGTK 4 and GTK 3, Qt 6 and Qt 5, Qt Widgets and QML
DeliveryA queue kept on disk, sent in batches of up to 50, retried with the same event ids so nothing is counted twice
Linux

Install

Download the C core and the layer for your toolkit from Mode, and add both to your CMake build.

shell
curl -fsSLO https://gotmode.com/sdk/c/0.2.0/mode-metrics-c-0.2.0.zip
curl -fsSLO https://gotmode.com/sdk/c/0.1.0/mode-metrics-gtk-0.1.0.zip   # or mode-metrics-qt-0.1.0.zip for Qt
echo "a8206287778d87d14fe34ae4303b5b19eb7db322909b56589b6c72a37f191f59  mode-metrics-c-0.2.0.zip
0fdd7df96730d66e2dcf12ceb549dd6924c59698a632953c05823687b137ad34  mode-metrics-gtk-0.1.0.zip" | shasum -a 256 -c
unzip mode-metrics-c-0.2.0.zip && unzip mode-metrics-gtk-0.1.0.zip
cmake
add_subdirectory(path/to/mode-metrics-c-0.2.0)     # the core
add_subdirectory(path/to/mode-metrics-gtk-0.1.0)   # or mode-metrics-qt-0.1.0
target_link_libraries(myapp PRIVATE mode_gtk4)   # mode_gtk3 or mode_qt

For Qt 5, set MODE_QT_MAJOR to 5 before adding the Qt layer. Each layer is a package of its own on the core, so an app builds only its toolkit.

FileVersionSHA-256
mode-metrics-c-0.2.0.zip0.2.0a8206287778d87d14fe34ae4303b5b19eb7db322909b56589b6c72a37f191f59
mode-metrics-gtk-0.1.0.zip0.1.00fdd7df96730d66e2dcf12ceb549dd6924c59698a632953c05823687b137ad34
mode-metrics-qt-0.1.0.zip0.1.0940c946c4b3089d7b7262bf7c82197d55ce9e3605fdba71386b5cba42812550f

The GTK layer needs GLib, GIO and GTK, which your app already has. The Qt layer needs QtCore, QtGui and QtWidgets, and uses QtQuick and QtDBus when they are installed. With libcurl the SDK sends on a thread of its own and compresses with zlib.

Linux

Setup

Call the setup once. Everything in What is captured automatically starts from that call.

c
/* GTK, in your GApplication's startup handler */
#include "mode_gtk.h"

static void on_startup(GApplication *app, gpointer data) {
  mode_gtk_options o;
  mode_gtk_options_defaults(&o);
  o.key = "YOUR_INGEST_KEY";
  o.host = "https://m.example.com";
  o.app_version = "2.3.0";
  o.scheme = "myapp";
  mode_gtk_setup(GTK_APPLICATION(app), &o);
}
cpp
// Qt, once the QApplication or QGuiApplication exists
#include "ModeMetrics.h"

QApplication app(argc, argv);
ModeMetrics::Options o;
o.appVersion = "2.3.0";
o.scheme = "myapp";
ModeMetrics::setup("YOUR_INGEST_KEY", "https://m.example.com", o);

A GTK app without a GtkApplication passes NULL. The app id names the data folder, ~/.local/state/mode-metrics/{app id}. GTK reads it from the application, Qt from the desktop file name or the organization domain and application name, unless you set it. scheme is your app's own link scheme.

Linux

Events, people and groups

The setup returns the client, and every call of the C core works on it. Properties are JSON text.

c
mode_client *mode = mode_gtk_client();   /* ModeMetrics::client() in Qt */
mode_capture(mode, "order_placed", "{\"total\":49}");
mode_identify(mode, "user_42", "{\"plan\":\"pro\"}", NULL);   /* after sign in */
mode_group(mode, "company", "acme", NULL);
mode_register(mode, "{\"edition\":\"pro\"}");   /* on every event */
mode_reset(mode);                                   /* on sign out */

Also mode_alias, mode_set_person_properties, mode_unset_person_properties, mode_register_once, mode_register_for_session, mode_unregister and mode_flush. Every call is safe from any thread and none waits on the network. A different user signing in on the same computer becomes a new person, never a merge. An empty id or a placeholder such as null or anonymous is dropped.

Linux

What is captured automatically

Every event below arrives with no code beyond the setup. Turn a part off with the autocapture bits, or from your project's settings.

EventWhen
$app_installed, $app_updated, $app_openedThe first start, a new version, the first window shown with its launch time
$app_backgroundedNo window of the app has had focus for a second, and $app_opened when one has it again
$app_quitThe app quits, then what is queued is sent, waiting at most 2 seconds
$window_opened, $window_closed, $window_focus, $window_blurEvery window, named by its widget or object name or its type
$screenGTK stack and notebook pages, Qt stacked widget and tab widget pages, QML StackView items, and the window when nothing in it names a page
$click, $rage_clickClicks and key presses on buttons, toggles, check and radio buttons, switches, menus, tabs, combo boxes, sliders, lists and text fields, and in QML the control under the pointer, with its type, text, path, name, accessible name and role
$deep_link_openedA link in your scheme starts the app, or reaches a running GTK app
$system_suspend, $system_resume, $system_lock, $system_unlockThe computer sleeps, wakes, locks and unlocks, read from logind and the screensaver
$exceptionA fatal signal, a run that ended without quitting, and in Qt an uncaught C++ exception and qFatal, sent on the next start in the session they ended

The first event of each session carries the device (kernel release, pixel ratio, dark mode, reduced motion, toolkit and version, languages, memory and cores), never a host name, user name or machine id. Every crash handler hands the signal on to the one installed before it, so KDE's crash handler, breakpad and your own keep working.

Linux

Text and privacy

A clicked control's text is scrubbed of emails and long numbers and cut to 80 characters. A text field never sends its text.

A click on an entry, text view, spin button or password field is a $click with role textbox and nothing typed. Set mask_text (maskText in Qt) to leave every control's text out. Window titles are scrubbed the same way. A link that opens the app loses sign in tokens, codes, passwords, keys and signatures, and an email address becomes [email].

Linux

Feature flags

Flags load at start and whenever the person changes.

c
if (mode_is_feature_enabled(mode, "new-checkout")) show_new_checkout();
char *price = mode_get_flag_payload(mode, "price-test");
mode_free(price);
Linux

Delivery

Events wait on disk and are sent in batches, so nothing is lost offline and nothing is counted twice.

SettingValue
BatchesA second after an event, at once at 50 events, when the app goes to the background and when it quits
QueueUp to 1,000 events kept on disk
RetriesFrom 1 second to 5 minutes, with the same event ids
SessionsEnd after 30 minutes with no activity or 24 hours. Focus, sleep and lock never start or extend one

Let AI run your marketing.

Mode Agent does the daily work. You approve the spend.

Get early access