Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## v8.6

* Telemetry statistics page for environments using the Telemetry Server. Please check `README.md`

## v8.5.1

* Fixed undefined variable warning message <!-- [#133](https://github.com/Ente/timetrack/issues/133) -->
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ In step 2, you need to configure the `app.json.sample` within the `api/v1/inc` f
- `demo`: If set to `true`, demo credentials are shown on the login page. Useful for demo installations.
- `telemetry`: Enable/disable telemetry (Default: `enabled` - **PLEASE DISABLE IF NEEDED**)
- `telemetry_server_url`: Full server url to telemetry upload
- `telemetryServer`: Enables/disables the Server Telemetry Statistics page

#### **SMTP section**

Expand Down Expand Up @@ -254,6 +255,23 @@ To upload a new theme, simply place it into the `/assets/css` folder.

The theme the user selected is saved as a cookie, meaning it is only selected on the current device. On mobile or on another device, the user has to set the desired theme again.

## Run as Telemetry server

Basically, there are only a few steps to do

1. Navigate to the telemetry server directory: `cd api/v1/class/telemetry/server`
2. Start server: `nohup php -S 0.0.0.0:8888 server.php > telemetry.log 2>&1 &`
3. Set `telemetryServer` inside app.json `general` section to `true`.
4. Check received telemetry data on the "Server Telemetry" page.

## Change Telemetry server URL for managed environments

If you want all of your TimeTrack instances to point to your telemetry server instance, you need to change the app.json `general` `telemetry_server_url` attribute to your URL.
Also make sure the `telemetry` attribute is set to `"enabled"`.

To check if all worked simply visit the Settings page using an admin account. Check the checkbox within the Telemetry section at the bottom of the page and click the Submit button.
On your server timetrack instance you need to visit the "Server Telemetry" page to check if you received the new/updated telemetry data.

## Updates

TimeTrack has to be updated in two ways: database and application.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.5.1
8.6
3 changes: 2 additions & 1 deletion api/v1/class/i18n/suite/nav/snippets_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"a_sickness": "Alle Krankheiten",
"a_vacation": "Alle Urlaube",
"a_plugins": "Plugins",
"a_projects": "Projektmanagement"
"a_projects": "Projektmanagement",
"a_serverTelemetry": "Server-Telemetrie"
}
3 changes: 2 additions & 1 deletion api/v1/class/i18n/suite/nav/snippets_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"a_sickness": "Sickness reports",
"a_vacation": "Vacation reports",
"a_plugins": "Plugins",
"a_projects": "Projects management"
"a_projects": "Projects management",
"a_serverTelemetry": "Server Telemetry"
}
3 changes: 2 additions & 1 deletion api/v1/class/i18n/suite/nav/snippets_NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"a_sickness": "Alle ziekten",
"a_vacation": "Alle vakanties",
"a_plugins": "Plug-ins",
"a_projects": "Projects management"
"a_projects": "Projects management",
"a_serverTelemetry": "Server Telemetry"
}
3 changes: 2 additions & 1 deletion api/v1/class/i18n/suite/status/snippets_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"plugins_disabled": "Fehler: Das Plugin-System ist deaktiviert. Bitte wende dich an deinen Administrator!",
"telemetry_sent": "Hinweis: Telemetriedaten wurden erfolgreich gesendet!",
"telemetry_disabled": "Hinweis: Telemetriedaten wurden nicht gesendet!",
"success": "Hinweis: Die Aktion wurde erfolgreich ausgeführt!"
"success": "Hinweis: Die Aktion wurde erfolgreich ausgeführt!",
"telemetryServer_disabled": "Hinweis: Die Serverfunktion der Telemetry ist derzeit deaktiviert!"
}
3 changes: 2 additions & 1 deletion api/v1/class/i18n/suite/status/snippets_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"plugins_disabled": "Error: The plugin system is disabled. Please contact your administrator!",
"telemetry_sent": "Note: Telemetry data sent successfully!",
"telemetry_disabled": "Note: Telemetry data not sent!",
"success": "Note: The action was completed successfully!"
"success": "Note: The action was completed successfully!",
"telemetryServer_disabled": "Note: The server telemetry functionality is currently disabled!"
}
3 changes: 2 additions & 1 deletion api/v1/class/telemetry/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
Make sure your clients point to a specific client for the telemetry server.
Install TimeTrack on that server and start the telemetry server with `cd path/to/timetrack/api/v1/class/telemetry/server && php -S 0.0.0.0:8888 server.php`

Inside DB check the results within the `telemetry_server` table. A GUI is comming soon.
Inside DB check the results within the `telemetry_server` table. Set `telemetryServer` var within app.json `general` section to `true`.
A new entry called Server Telemetry will appear within the Navigation bar.
63 changes: 63 additions & 0 deletions api/v1/class/telemetry/telemetry.arbeit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,69 @@ public function isTelemetryEnabled(): bool
return isset($ini["general"]["telemetry"]) && $ini["general"]["telemetry"] === "enabled";
}

public function isTelemetryServerEnabled(): bool
{
$ini = $this->get_app_ini();
return isset($ini["general"]["telemetryServer"]) && $ini["general"]["telemetryServer"] == true;
}

public function getServerTelemetryData(): array
{
$stmt = $this->db->sendQuery("SELECT * FROM telemetry_server ORDER BY id DESC");
$stmt->execute();
return $stmt->fetchAll(\PDO::FETCH_ASSOC) ?: [];
}


public function renderServerTelemetryHTML(): void
{
$rows = $this->getServerTelemetryData();

if (empty($rows)) {
echo "<p>{$this->i18n['no_data']}</p>";
return;
}

$columns = [
"instance_uuid",
"time_track_version",
"api_version",
"php_version",
"os_version_and_name",
"total_plugins",
"total_users",
"total_worktimes",
"api_calls_total",
"created_at",
"updated_at"
];

$html = '<div style="overflow-x:auto; width:100%;">';

$html .= "<table class='v8-table'><thead><tr>";

foreach ($columns as $col) {
$html .= "<th>" . htmlspecialchars($col) . "</th>";
}

$html .= "</tr></thead><tbody>";

foreach ($rows as $row) {
$html .= "<tr>";

foreach ($columns as $col) {
$value = $row[$col] ?? "-";
$html .= "<td>" . htmlspecialchars((string)$value) . "</td>";
}

$html .= "</tr>";
}

$html .= "</tbody></table></div>";

echo $html;
}



public function sendRequest($data)
Expand Down
3 changes: 2 additions & 1 deletion api/v1/inc/app.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"force_theme": false,
"demo": false,
"telemetry": "disabled",
"telemetry_server_url": "https://telemetry.openducks.org/timetrack/submit"
"telemetry_server_url": "https://telemetry.openducks.org/timetrack/submit",
"telemetryServer": false
},
"mysql": {
"db_host": "db",
Expand Down
3 changes: 3 additions & 0 deletions assets/gui/standard_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<a href="http://<?= $base_url ?>/suite/admin/worktime/sick/all.php"><?= $lang["a_sickness"]; ?></a>
<a href="http://<?= $base_url ?>/suite/admin/worktime/vacation/all.php"><?= $lang["a_vacation"]; ?></a>
<a href="http://<?= $base_url ?>/suite/admin/projects/admin.php"><?= $lang["a_projects"]; ?></a>
<?php if($ini["general"]["telemetryServer"] == true) : ?>
<a href="http://<?= $base_url ?>/suite/admin/users/serverTelemetry.php"><?= $lang["a_serverTelemetry"] ?></a>
<?php endif; ?>
<span class="nav-version">ADMIN | <?= htmlspecialchars($v); ?></span>
<?php endif; ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "TimeTrack is a PHP-written time recording tool for small businesses",
"type": "software",
"license": "GNU GPL",
"version": "8.5.1",
"version": "8.6",
"authors": [
{
"name": "Bryan Boehnke-Avan",
Expand Down
3 changes: 0 additions & 3 deletions suite/admin/users/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@
<main style="max-width: 1080px; margin: 0 auto; padding: 2rem;">
<h1><?= $language["title"]; ?></h1>

<!-- Einleitung -->
<div class="card v8-bordered" style="margin-bottom: 2rem;">
<p><?= $language["p1"]; ?></p>
</div>

<!-- Nutzerliste -->
<div class="card v8-bordered" style="margin-bottom: 2rem;" id="userlist">
<h2><?= $language["title"]; ?></h2>
<div class="table-wrapper">
Expand All @@ -60,7 +58,6 @@
</div>
</div>

<!-- Benutzer hinzufügen -->
<div class="card v8-bordered" style="text-align: center;">
<h2><?= $language["add_user"]; ?></h2>

Expand Down
54 changes: 54 additions & 0 deletions suite/admin/users/serverTelemetry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
session_start();
require $_SERVER["DOCUMENT_ROOT"] . "/api/v1/inc/arbeit.inc.php";
use Arbeitszeit\Arbeitszeit;
$arbeit = new Arbeitszeit;
$ini = $arbeit->get_app_ini();
$base_url = $ini["general"]["base_url"];

$arbeit->auth()->login_validation();
if(!$arbeit->benutzer()->is_admin($arbeit->benutzer()->get_user($_SESSION["username"]))){
header("Location: http://{$base_url}/suite/?" . $arbeit->statusMessages()->URIBuilder("noperms"));
}
$add_style = "";

if(!$arbeit->telemetry()->isTelemetryServerEnabled()){
$arbeit->statusMessages()->redirect("telemetryServer_disabled");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Server Telemetry | <?= $ini["general"]["app_name"]; ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&family=JetBrains+Mono&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?= $arbeit->benutzer()->loadUserTheme(); ?>?v=1">
</head>

<body>
<div class="animated-bg"></div>

<?php include $_SERVER["DOCUMENT_ROOT"] . "/assets/gui/standard_nav.php"; ?>

<main style="max-width: 1080px; margin: 0 auto; padding: 2rem;">
<h1>Server Telemetry</h1>

<div class="card v8-bordered" style="margin-bottom: 2rem;">
<p>On this page you can see all of the received telemetry for your servers.</p>
</div>

<div class="card v8-bordered" style="margin-bottom: 2rem;" id="userlist">
<h2>Statistics</h2>
<div class="table-wrapper">
<?php $arbeit->telemetry()->renderServerTelemetryHTML(); ?>
</div>
</div>


</main>

<?php include $_SERVER["DOCUMENT_ROOT"] . "/assets/gui/standard_footer.php"; ?>
</body>
</html>
Loading