telemetry_session.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields
  36. };
  37. /**
  38. * Gets TelemetryId, a unique identifier used for the user's telemetry sessions.
  39. * @returns The current TelemetryId for the session.
  40. */
  41. u64 GetTelemetryId();
  42. /**
  43. * Regenerates TelemetryId, a unique identifier used for the user's telemetry sessions.
  44. * @returns The new TelemetryId that was generated.
  45. */
  46. u64 RegenerateTelemetryId();
  47. /**
  48. * Verifies the username and token.
  49. * @param username yuzu username to use for authentication.
  50. * @param token yuzu token to use for authentication.
  51. * @returns Future with bool indicating whether the verification succeeded
  52. */
  53. bool VerifyLogin(const std::string& username, const std::string& token);
  54. } // namespace Core