From 52f15961fec4e2cfbc56d4a53804276618b759ec Mon Sep 17 00:00:00 2001
From: Mondus
Date: Wed, 20 Nov 2024 12:07:42 +0000
Subject: [PATCH 1/9] Added User ID to telemetry
---
README.md | 2 +-
include/flamegpu/io/Telemetry.h | 18 +++++++
src/flamegpu/io/Telemetry.cpp | 96 ++++++++++++++++++++++++++++++++-
3 files changed, 114 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a25f4959d..d4edfd658 100644
--- a/README.md
+++ b/README.md
@@ -328,7 +328,7 @@ Information is collected when a simulation, ensemble or test suite run have comp
The [TelemetryDeck](https://telemetrydeck.com/) service is used to store telemetry data.
All data is sent to their API endpoint of https://nom.telemetrydeck.com/v1/ via https. For more details please review the [TelmetryDeck privacy policy](https://telemetrydeck.com/privacy/).
-We do not collect any personal data such as usernames, email addresses or machine identifiers.
+We do not collect any personal data such as usernames, email addresses or hardware identifiers but we do generate a random user identifier. This identifier is salted and hashed by Telemetry deck.
More information can be found in the [FLAMEGPU documentation](https://docs.flamegpu.com/guide/telemetry).
diff --git a/include/flamegpu/io/Telemetry.h b/include/flamegpu/io/Telemetry.h
index 1b6c87481..a99e39147 100644
--- a/include/flamegpu/io/Telemetry.h
+++ b/include/flamegpu/io/Telemetry.h
@@ -84,6 +84,24 @@ static void encourageUsage();
* @return if telemetry is currently in test mode or not.
*/
static bool isTestMode();
+
+/**
+ * Gets a cross platform location for storing user configuration data. Required to store a per user Id. On windows this uses the AppData folder (CSIDL_APPDATA) and in Linux this uses XDG_CONFIG_HOME.
+ * @return Root directory for storing configuration files
+ */
+static std::string getConfigDirectory();
+
+/**
+ * Generates a randomised 36 character alphanumeric string for use as a User Id.
+ * @return A 36 character randomised alphanumeric string
+ */
+static std::string generateRandomId();
+
+/**
+ * Obtains a unique user Id. If a configuration file (flamegpu_user.cfg) exists this will be loaded from disk otherwise it will be generated and stored in the configuration location. If the configuration location is not writeable a new user Id will be generated each time. The user Id will be further obfuscated by Telemetry Deck which will salt and hash the Id.
+ * @return A 36 character randomised alphanumeric string representing a unique user Id
+ */
+static std::string getUserId();
};
} // namespace io
} // namespace flamegpu
diff --git a/src/flamegpu/io/Telemetry.cpp b/src/flamegpu/io/Telemetry.cpp
index e298cb136..a37df1a18 100644
--- a/src/flamegpu/io/Telemetry.cpp
+++ b/src/flamegpu/io/Telemetry.cpp
@@ -6,11 +6,22 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
#include
#include