telemetry_session.h 1.8 KB

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