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: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ Support for academic software is dependant on evidence of impact. Without eviden

Information is collected when a simulation, ensemble or test suite run have completed.

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/).
The [TelemetryDeck](https://telemetrydeck.com/) service is used to store telemetry data.
All data is sent to their [Ingest API v2](https://telemetrydeck.com/docs/ingest/v2) endpoint of https://nom.telemetrydeck.com/v2/. 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 hardware identifiers but we do generate a random user identifier. This identifier is salted and hashed by Telemetry deck.

Expand Down
2 changes: 1 addition & 1 deletion include/flamegpu/io/Telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void suppressNotice();
/*
* The remote endpoint which telemetry is pushed to.
*/
constexpr static char TELEMETRY_ENDPOINT[] = "https://nom.telemetrydeck.com/v1/";
constexpr static char TELEMETRY_ENDPOINT[] = "https://nom.telemetrydeck.com/v2/";

/**
* Generates the telemetry data packet as a string.
Expand Down
45 changes: 22 additions & 23 deletions src/flamegpu/io/Telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,35 +208,32 @@ std::string Telemetry::generateData(std::string event_name, std::map<std::string
payload_items["Visualisation"] = "false";
#endif

// create the payload
std::string payload = "";
bool first = true;
// iterate payload to generate the payload array
// create the payload dictionary by iterating items.
std::string payload = "{";
for (const auto& [key, value] : payload_items) {
std::string item_str;
if (!first)
item_str = ",\"" + key + ":" + value + "\"";
else
item_str = "\"" + key + ":" + value + "\"";
std::string item_str = "\"" + key + "\":\"" + value + "\",";
payload.append(item_str);
first = false;
}
// Remove the trailing comma
payload.pop_back();
// Close the json object
payload.append("}");

// create the telemetry json package
std::string telemetry_data = R"json(
[{
"isTestMode": "$TEST_MODE",
"appID": "$APP_ID",
"clientUser": "$TELEMETRY_RANDOM_ID",
"sessionID": "",
"type" : "$EVENT_TYPE",
"payload" : [$PAYLOAD]
"isTestMode": "$TEST_MODE",
"payload" : $PAYLOAD
}])json";
// "sessionID" is not set, and optional in v2
// update the placeholders
telemetry_data.replace(telemetry_data.find(var_testmode), var_testmode.length(), testmode);
telemetry_data.replace(telemetry_data.find(var_appID), var_appID.length(), appID);
telemetry_data.replace(telemetry_data.find(var_telemetryRandomID), var_telemetryRandomID.length(), telemetryRandomID);
telemetry_data.replace(telemetry_data.find(var_eventName), var_eventName.length(), event_name);
telemetry_data.replace(telemetry_data.find(var_testmode), var_testmode.length(), testmode);
telemetry_data.replace(telemetry_data.find(var_payload), var_payload.length(), payload);
// Remove newlines and replace with space
telemetry_data.erase(std::remove(telemetry_data.begin(), telemetry_data.end(), '\n'), telemetry_data.end());
Expand All @@ -246,12 +243,6 @@ std::string Telemetry::generateData(std::string event_name, std::map<std::string
telemetry_data.erase(std::remove_if(telemetry_data.begin(), telemetry_data.end(), [](char c) {
return std::isspace(static_cast<unsigned char>(c));
}), telemetry_data.end());
// Use escape characters
size_t pos = 0;
while ((pos = telemetry_data.find("\"", pos)) != std::string::npos) {
telemetry_data.replace(pos, 1, "\\\"");
pos += 2;
}
return telemetry_data;
}

Expand All @@ -270,15 +261,23 @@ bool Telemetry::sendData(std::string telemetry_data) {
#else
null = "/dev/null";
#endif

// Escape quotes, which surround the data payload when passed to curl.
size_t pos = 0;
while ((pos = telemetry_data.find("\"", pos)) != std::string::npos) {
telemetry_data.replace(pos, 1, "\\\"");
pos += 2;
}

std::stringstream curl_command;
curl_command << "curl";
curl_command << " -s";
curl_command << " -o " << null;
curl_command << " --connect-timeout " << std::to_string(CURL_CONNECT_TIMEOUT);
curl_command << " --max-time " << std::to_string(CURL_MAX_TIME);
curl_command << " -X POST \"" << std::string(TELEMETRY_ENDPOINT) << "\"";
curl_command << " -H \"Content-Type: application/json; charset=utf-8\"";
curl_command << " --data-raw \"" << telemetry_data + "\"";
curl_command << " -X POST '" << std::string(TELEMETRY_ENDPOINT) << "'";
curl_command << " -H 'Content-Type: application/json; charset=utf-8'";
curl_command << " --data-raw \"" << telemetry_data << "\"";
curl_command << " > " << null << " 2>&1";
// capture the return value
if (std::system(curl_command.str().c_str()) != EXIT_SUCCESS) {
Expand Down
2 changes: 1 addition & 1 deletion src/flamegpu/simulation/CUDAEnsemble.cu
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ unsigned int CUDAEnsemble::simulate(const RunPlanVector& plans) {
if (telemetrySuccess) {
fprintf(stdout, "Telemetry packet sent to '%s' json was: %s\n", flamegpu::io::Telemetry::TELEMETRY_ENDPOINT, telemetry_data.c_str());
} else {
fprintf(stderr, "Warning: Usage statistics for CUDAEnsemble failed to send.\n");
fprintf(stderr, "Warning: Usage statistics for CUDAEnsemble failed to send with json: %s\n", telemetry_data.c_str());
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/flamegpu/simulation/CUDASimulation.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ void CUDASimulation::simulate() {
if (telemetrySuccess) {
fprintf(stdout, "Telemetry packet sent to '%s' json was: %s\n", flamegpu::io::Telemetry::TELEMETRY_ENDPOINT, telemetry_data.c_str());
} else {
fprintf(stderr, "Warning: Usage statistics for CUDASimulation failed to send.\n");
fprintf(stderr, "Warning: Usage statistics for CUDASimulation failed to send with json: %s\n", telemetry_data.c_str());
}
}
} else {
Expand Down