mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Projucer: Removed app reporting
This commit is contained in:
parent
de23ef7b1f
commit
9d69018d97
7 changed files with 7 additions and 200 deletions
|
|
@ -49,8 +49,7 @@ namespace juce
|
|||
static const int millisecondsToDisplaySplash = 2000, splashScreenFadeOutTime = 2000;
|
||||
static const int splashScreenLogoWidth = 123, splashScreenLogoHeight = 63;
|
||||
static uint32 splashDisplayTime = 0;
|
||||
static bool splashHasStartedFading = false, appUsageReported = false;
|
||||
|
||||
static bool splashHasStartedFading = false;
|
||||
|
||||
static Rectangle<float> getLogoArea (Rectangle<float> parentRect)
|
||||
{
|
||||
|
|
@ -59,175 +58,11 @@ static Rectangle<float> getLogoArea (Rectangle<float> parentRect)
|
|||
.removeFromBottom ((float) splashScreenLogoHeight);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
struct ReportingThread;
|
||||
|
||||
struct ReportingThreadContainer : public ChangeListener,
|
||||
public DeletedAtShutdown
|
||||
{
|
||||
ReportingThreadContainer() {}
|
||||
~ReportingThreadContainer() override { clearSingletonInstance(); }
|
||||
|
||||
void sendReport (String, String&, StringPairArray&);
|
||||
void changeListenerCallback (ChangeBroadcaster*) override;
|
||||
|
||||
std::unique_ptr<ReportingThread> reportingThread;
|
||||
|
||||
JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL (ReportingThreadContainer)
|
||||
};
|
||||
|
||||
JUCE_IMPLEMENT_SINGLETON (ReportingThreadContainer)
|
||||
|
||||
//==============================================================================
|
||||
struct ReportingThread : public Thread,
|
||||
private ChangeBroadcaster
|
||||
{
|
||||
ReportingThread (ReportingThreadContainer& container,
|
||||
String& address,
|
||||
String& userAgent,
|
||||
StringPairArray& parameters)
|
||||
: Thread ("JUCE app usage reporting"),
|
||||
threadContainer (container),
|
||||
headers ("User-Agent: " + userAgent)
|
||||
{
|
||||
StringArray postData;
|
||||
|
||||
for (auto& key : parameters.getAllKeys())
|
||||
if (parameters[key].isNotEmpty())
|
||||
postData.add (key + "=" + URL::addEscapeChars (parameters[key], true));
|
||||
|
||||
url = URL (address).withPOSTData (postData.joinIntoString ("&"));
|
||||
|
||||
addChangeListener (&threadContainer);
|
||||
}
|
||||
|
||||
~ReportingThread() override
|
||||
{
|
||||
removeChangeListener (&threadContainer);
|
||||
|
||||
if (webStream != nullptr)
|
||||
webStream->cancel();
|
||||
|
||||
stopThread (2000);
|
||||
}
|
||||
|
||||
void run() override
|
||||
{
|
||||
webStream.reset (new WebInputStream (url, true));
|
||||
webStream->withExtraHeaders (headers);
|
||||
webStream->connect (nullptr);
|
||||
|
||||
sendChangeMessage();
|
||||
}
|
||||
|
||||
private:
|
||||
ReportingThreadContainer& threadContainer;
|
||||
URL url;
|
||||
String headers;
|
||||
std::unique_ptr<WebInputStream> webStream;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
void ReportingThreadContainer::sendReport (String address, String& userAgent, StringPairArray& parameters)
|
||||
{
|
||||
reportingThread.reset (new ReportingThread (*this, address, userAgent, parameters));
|
||||
reportingThread->startThread();
|
||||
}
|
||||
|
||||
void ReportingThreadContainer::changeListenerCallback (ChangeBroadcaster*)
|
||||
{
|
||||
reportingThread.reset();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
JUCESplashScreen::JUCESplashScreen (Component& parent)
|
||||
{
|
||||
ignoreUnused (parent);
|
||||
|
||||
#if JUCE_REPORT_APP_USAGE
|
||||
if (! appUsageReported)
|
||||
{
|
||||
const ScopedTryLock appUsageReportingLock (appUsageReporting);
|
||||
|
||||
if (appUsageReportingLock.isLocked() && ! appUsageReported)
|
||||
{
|
||||
const auto deviceDescription = SystemStats::getDeviceDescription();
|
||||
const auto deviceString = SystemStats::getDeviceIdentifiers().joinIntoString (":");
|
||||
const auto deviceIdentifier = String::toHexString (deviceString.hashCode64());
|
||||
const auto osName = SystemStats::getOperatingSystemName();
|
||||
|
||||
StringPairArray data;
|
||||
|
||||
data.set ("v", "1");
|
||||
data.set ("tid", "UA-19759318-3");
|
||||
data.set ("cid", deviceIdentifier);
|
||||
data.set ("t", "event");
|
||||
data.set ("ec", "info");
|
||||
data.set ("ea", "appStarted");
|
||||
|
||||
data.set ("cd1", SystemStats::getJUCEVersion());
|
||||
data.set ("cd2", osName);
|
||||
data.set ("cd3", deviceDescription);
|
||||
data.set ("cd4", deviceIdentifier);
|
||||
|
||||
String appType, appName, appVersion, appManufacturer;
|
||||
|
||||
#if defined(JucePlugin_Name)
|
||||
appType = "Plugin";
|
||||
appName = JucePlugin_Name;
|
||||
appVersion = JucePlugin_VersionString;
|
||||
appManufacturer = JucePlugin_Manufacturer;
|
||||
#else
|
||||
if (JUCEApplicationBase::isStandaloneApp())
|
||||
{
|
||||
appType = "Application";
|
||||
|
||||
if (auto* app = JUCEApplicationBase::getInstance())
|
||||
{
|
||||
appName = app->getApplicationName();
|
||||
appVersion = app->getApplicationVersion();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
appType = "Library";
|
||||
}
|
||||
#endif
|
||||
|
||||
data.set ("cd5", appType);
|
||||
data.set ("cd6", appName);
|
||||
data.set ("cd7", appVersion);
|
||||
data.set ("cd8", appManufacturer);
|
||||
|
||||
data.set ("an", appName);
|
||||
data.set ("av", appVersion);
|
||||
|
||||
auto agentCPUVendor = SystemStats::getCpuVendor();
|
||||
|
||||
if (agentCPUVendor.isEmpty())
|
||||
agentCPUVendor = "CPU";
|
||||
|
||||
auto agentOSName = osName.replaceCharacter ('.', '_')
|
||||
.replace ("iOS", "iPhone OS");
|
||||
#if JUCE_IOS
|
||||
agentOSName << " like Mac OS X";
|
||||
#endif
|
||||
|
||||
String userAgent;
|
||||
userAgent << "Mozilla/5.0 ("
|
||||
<< deviceDescription << ";"
|
||||
<< agentCPUVendor << " " << agentOSName << ";"
|
||||
<< SystemStats::getDisplayLanguage() << ")";
|
||||
|
||||
ReportingThreadContainer::getInstance()->sendReport ("https://www.google-analytics.com/collect", userAgent, data);
|
||||
|
||||
appUsageReported = true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
ignoreUnused (appUsageReported);
|
||||
#endif
|
||||
|
||||
#if JUCE_DISPLAY_SPLASH_SCREEN
|
||||
if (splashDisplayTime == 0
|
||||
|| Time::getMillisecondCounter() < splashDisplayTime + (uint32) millisecondsToDisplaySplash)
|
||||
|
|
@ -244,10 +79,6 @@ JUCESplashScreen::JUCESplashScreen (Component& parent)
|
|||
}
|
||||
}
|
||||
|
||||
JUCESplashScreen::~JUCESplashScreen()
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<Drawable> JUCESplashScreen::getSplashScreenLogo()
|
||||
{
|
||||
const char* svgData = R"JUCESPLASHSCREEN(
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ class JUCE_API JUCESplashScreen : public Component,
|
|||
{
|
||||
public:
|
||||
JUCESplashScreen (Component& parentToAddTo);
|
||||
~JUCESplashScreen() override;
|
||||
|
||||
static std::unique_ptr<Drawable> getSplashScreenLogo();
|
||||
|
||||
|
|
@ -58,7 +57,6 @@ private:
|
|||
void mouseUp (const MouseEvent&) override;
|
||||
|
||||
std::unique_ptr<Drawable> content;
|
||||
CriticalSection appUsageReporting;
|
||||
ComponentAnimator fader;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JUCESplashScreen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue