telemetry_session.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <memory>
  6. #include <string>
  7. #include "common/telemetry.h"
  8. namespace Core {
  9. /**
  10. * Instruments telemetry for this emulation session. Creates a new set of telemetry fields on each
  11. * session, logging any one-time fields. Interfaces with the telemetry backend used for submitting
  12. * data to the web service. Submits session data on close.
  13. */
  14. class TelemetrySession : NonCopyable {
  15. public:
  16. TelemetrySession();
  17. ~TelemetrySession();
  18. /**
  19. * Wrapper around the Telemetry::FieldCollection::AddField method.
  20. * @param type Type of the field to add.
  21. * @param name Name of the field to add.
  22. * @param value Value for the field to add.
  23. */
  24. template <typename T>
  25. void AddField(Telemetry::FieldType type, const char* name, T value) {
  26. field_collection.AddField(type, name, std::move(value));
  27. }
  28. /**
  29. * Submits a Testcase.
  30. * @returns A bool indicating whether the submission succeeded
  31. */
  32. bool SubmitTestcase();
  33. private:
  34. Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session
  35. };
  36. /**
  37. * Gets TelemetryId, a unique identifier used for the user's telemetry sessions.
  38. * @returns The current TelemetryId for the session.
  39. */
  40. u64 GetTelemetryId();
  41. /**
  42. * Regenerates TelemetryId, a unique identifier used for the user's telemetry sessions.
  43. * @returns The new TelemetryId that was generated.
  44. */
  45. u64 RegenerateTelemetryId();
  46. /**
  47. * Verifies the username and token.
  48. * @param username yuzu username to use for authentication.
  49. * @param token yuzu token to use for authentication.
  50. * @returns Future with bool indicating whether the verification succeeded
  51. */
  52. bool VerifyLogin(const std::string& username, const std::string& token);
  53. } // namespace Core