1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2020 MuseScore BVBA
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 //=============================================================================
19
20 #include "sessionstatusobserver.h"
21 #include "musescore.h"
22 #include "telemetrymanager.h"
23
24 namespace Ms {
25
prevSessionStatus(bool sessionFileFound,const QString & sessionFullVersion,bool clean)26 void SessionStatusObserver::prevSessionStatus(bool sessionFileFound, const QString& sessionFullVersion, bool clean)
27 {
28 #ifndef TELEMETRY_DISABLED
29 //if session status data IS the enabled telemetry data
30 if (Ms::enabledTelemetryDataTypes & Ms::TelemetryDataCollectionType::COLLECT_CRASH_FREE_DATA) {
31 QString status;
32 QString label;
33 if (mscoreFirstStart)
34 status = QStringLiteral("first-start");
35 else if (!sessionFileFound)
36 status = QStringLiteral("session-file-not-found");
37 else {
38 const bool versionChanged = MuseScore::fullVersion() != sessionFullVersion;
39 if (versionChanged) {
40 status = QStringLiteral("version-changed");
41 label = sessionFullVersion;
42 }
43 else if (clean)
44 status = QStringLiteral("clean");
45 else
46 status = QStringLiteral("dirty");
47 }
48 TelemetryManager::telemetryService()->sendEvent("prev-session-status", status, label);
49 }
50 #else
51 Q_UNUSED(sessionFileFound);
52 Q_UNUSED(sessionFullVersion);
53 Q_UNUSED(clean);
54 #endif
55 }
56
57 } // namespace Ms
58