Skip to content

Commit

Permalink
Remove telemetry logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mysticial committed Nov 25, 2024
1 parent 0f5f097 commit adc552b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ GlobalSettings::GlobalSettings()
)
{
PA_ADD_OPTION(CHECK_FOR_UPDATES);
PA_ADD_OPTION(SEND_ERROR_REPORTS);
PA_ADD_OPTION(STATS_FILE);
PA_ADD_OPTION(ALL_STATS);
PA_ADD_OPTION(WINDOW_SIZE);
Expand Down Expand Up @@ -272,6 +271,10 @@ GlobalSettings::GlobalSettings()

PA_ADD_OPTION(PROCESSOR_LEVEL0);

#ifdef PA_OFFICIAL
PA_ADD_OPTION(SEND_ERROR_REPORTS);
#endif

PA_ADD_OPTION(DEVELOPER_TOKEN);

GlobalSettings::value_changed(this);
Expand Down
1 change: 1 addition & 0 deletions SerialPrograms/Source/CommonFramework/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern const bool IS_BETA_VERSION;
extern const int PROGRAM_VERSION_MAJOR;
extern const int PROGRAM_VERSION_MINOR;
extern const int PROGRAM_VERSION_PATCH;
extern const std::string PROGRAM_VERSION_BASE;
extern const std::string PROGRAM_VERSION;

extern const std::string PROGRAM_NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
#include "Integrations/SleepyDiscordRunner.h"
#include "ProgramNotifications.h"

#ifdef PA_OFFICIAL
#include "../Internal/SerialPrograms/TelemetryURLs.h"
#endif

//#include <iostream>
//using std::cout;
//using std::endl;
Expand Down Expand Up @@ -405,99 +401,15 @@ void send_program_fatal_error_notification(



#ifndef PA_OFFICIAL
void send_program_telemetry(
Logger& logger, bool is_error, Color color,
const ProgramInfo& info,
const std::string& title,
const std::vector<std::pair<std::string, std::string>>& messages,
const std::string& file
){
#ifdef PA_OFFICIAL
if (!GlobalSettings::instance().SEND_ERROR_REPORTS){
return;
}

// Rate limit the telemetry to 10/hour.
static std::mutex lock;
static std::set<WallClock> sends;
{
std::lock_guard<std::mutex> lg(lock);

WallClock now = current_time();
WallClock threshold = now - std::chrono::minutes(1);
while (!sends.empty()){
auto iter = sends.begin();
if (*iter > threshold){
break;
}
sends.erase(iter);
}
if (sends.size() >= 10){
logger.log("Error report suppressed due to rate limit.", COLOR_RED);
return;
}
sends.insert(now);
}


bool hasFile = !file.empty();
std::shared_ptr<PendingFileSend> pending = !hasFile
? nullptr
: std::shared_ptr<PendingFileSend>(new PendingFileSend(file, GlobalSettings::instance().SAVE_DEBUG_IMAGES));

JsonArray embeds;
{
JsonObject embed;
embed["title"] = title;
if (color){
embed["color"] = (uint32_t)color & 0xffffff;
}

JsonArray fields;
{
JsonObject field;
field["name"] = PreloadSettings::instance().DEVELOPER_MODE
? PROGRAM_NAME + " (" + PROGRAM_VERSION + "-dev)"
: PROGRAM_NAME + " (" + PROGRAM_VERSION + ")";
field["value"] = info.program_name.empty() ? "(unknown)" : info.program_name;
fields.push_back(std::move(field));
}
for (const auto& item : messages){
JsonObject field;
field["name"] = item.first;
field["value"] = item.second;
if (!item.first.empty() && !item.second.empty()){
fields.push_back(std::move(field));
}
}
embed["fields"] = std::move(fields);

if (hasFile){
JsonObject image;
image["url"] = "attachment://" + pending->filename();
embed["image"] = std::move(image);
}
embeds.push_back(std::move(embed));
}

JsonObject jsonContent;
// jsonContent["content"] = "asdf";
jsonContent["embeds"] = std::move(embeds);

std::string url = is_error
? flip(ERROR_REPORTING_URL, sizeof(ERROR_REPORTING_URL))
: flip(TELEMETRY_URL, sizeof(TELEMETRY_URL));

using namespace Integration::DiscordWebhook;

DiscordWebhookSender& sender = DiscordWebhookSender::instance();
if (hasFile){
sender.send_json(logger, QString::fromStdString(url), std::chrono::milliseconds(0), jsonContent, pending);
}else{
sender.send_json(logger, QString::fromStdString(url), std::chrono::milliseconds(0), jsonContent, nullptr);
}
){}
#endif
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
#endif

//#include <opencv2/core.hpp>
#include <random>


#include <iostream>
Expand Down Expand Up @@ -243,7 +244,14 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco
using namespace NintendoSwitch::PokemonSwSh::MaxLairInternal;


std::random_device rndsource;
std::minstd_rand rndgen(rndsource());
std::uniform_real_distribution<double> dist(0, 1.0);

cout << dist(rndgen) << endl;
cout << dist(rndgen) << endl;
cout << dist(rndgen) << endl;
cout << dist(rndgen) << endl;

#if 0
PokemonSV::DateSeed data = PokemonSV::ItemPrinter::calculate_seed_prizes(2346161588);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,13 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&

// SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);

// VideoSnapshot image = feed.snapshot();
ImageRGB32 image("screenshot-20241124-135028529403.png");
VideoSnapshot image = feed.snapshot();
// ImageRGB32 image("screenshot-20241124-135028529403.png");

DateReader date_reader;
date_reader.make_overlays(overlays);
auto date = date_reader.read_date(logger, std::make_shared<ImageRGB32>(std::move(image)));
auto date = date_reader.read_date(logger, image);
// auto date = date_reader.read_date(logger, std::make_shared<ImageRGB32>(std::move(image)));
cout << "year = " << (int)date.second.year << endl;
cout << "month = " << (int)date.second.month << endl;
cout << "day = " << (int)date.second.day << endl;
Expand Down

0 comments on commit adc552b

Please sign in to comment.