telemetry_session.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright 2017 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include "common/telemetry.h"
  7. namespace Loader {
  8. class AppLoader;
  9. }
  10. namespace Core {
  11. /**
  12. * Instruments telemetry for this emulation session. Creates a new set of telemetry fields on each
  13. * session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
  14. * data to the web service. Submits session data on close.
  15. */
  16. class TelemetrySession {
  17. public:
  18. explicit TelemetrySession();
  19. ~TelemetrySession();
  20. TelemetrySession(const TelemetrySession&) = delete;
  21. TelemetrySession& operator=(const TelemetrySession&) = delete;
  22. TelemetrySession(TelemetrySession&&) = delete;
  23. TelemetrySession& operator=(TelemetrySession&&) = delete;
  24. /**
  25. * Adds the initial telemetry info necessary when starting up a title.
  26. *
  27. * This includes information such as:
  28. * - Telemetry ID
  29. * - Initialization time
  30. * - Title ID
  31. * - Title name
  32. * - Title file format
  33. * - Miscellaneous settings values.
  34. *
  35. * @param app_loader The application loader to use to retrieve
  36. * title-specific information.
  37. */
  38. void AddInitialInfo(Loader::AppLoader& app_loader);
  39. /**
  40. * Wrapper around the Telemetry::FieldCollection::AddField method.
  41. * @param type Type of the field to add.
  42. * @param name Name of the field to add.
  43. * @param value Value for the field to add.
  44. */
  45. template <typename T>
  46. void AddField(Common::Telemetry::FieldType type, const char* name, T value) {
  47. field_collection.AddField(type, name, std::move(value));
  48. }
  49. /**
  50. * Submits a Testcase.
  51. * @returns A bool indicating whether the submission succeeded
  52. */
  53. bool SubmitTestcase();
  54. private:
  55. /// Tracks all added fields for the session
  56. Common::Telemetry::FieldCollection field_collection;
  57. };
  58. /**
  59. * Gets TelemetryId, a unique identifier used for the user's telemetry sessions.
  60. * @returns The current TelemetryId for the session.
  61. */
  62. u64 GetTelemetryId();
  63. /**
  64. * Regenerates TelemetryId, a unique identifier used for the user's telemetry sessions.
  65. * @returns The new TelemetryId that was generated.
  66. */
  67. u64 RegenerateTelemetryId();
  68. /**
  69. * Verifies the username and token.
  70. * @param username yuzu username to use for authentication.
  71. * @param token yuzu token to use for authentication.
  72. * @returns Future with bool indicating whether the verification succeeded
  73. */
  74. bool VerifyLogin(const std::string& username, const std::string& token);
  75. } // namespace Core