The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A singleton class to manage analytics data.
  24. Use an Analytics object to manage sending analytics data to one or more
  25. AnalyticsDestinations.
  26. @see AnalyticsDestination, ThreadedAnalyticsDestination,
  27. AnalyticsDestination::AnalyticsEvent
  28. */
  29. class JUCE_API Analytics : public DeletedAtShutdown
  30. {
  31. public:
  32. //==============================================================================
  33. /** Adds an AnalyticsDestination to the list of AnalyticsDestinations
  34. managed by this Analytics object.
  35. The Analytics class will take ownership of the AnalyticsDestination
  36. passed to this function.
  37. @param destination the AnalyticsDestination to manage
  38. */
  39. void addDestination (AnalyticsDestination* destination);
  40. /** Sets a user ID that will be added to all AnalyticsEvents sent to
  41. AnalyticsDestinations.
  42. @param newUserId the userId to add to AnalyticsEvents
  43. */
  44. void setUserId (const String& newUserId);
  45. /** Sets some user properties that will be added to all AnalyticsEvents sent
  46. to AnalyticsDestinations.
  47. @param properties the userProperties to add to AnalyticsEvents
  48. */
  49. void setUserProperties (const StringPairArray& properties);
  50. /** Sends an AnalyticsEvent to all AnalyticsDestinations.
  51. The AnalyticsEvent will be timestamped, and will have the userId and
  52. userProperties populated by values previously set by calls to
  53. setUserId and setUserProperties. The name and parameters will be
  54. populated by the arguments supplied to this function.
  55. @param eventName the event name
  56. @param parameters the event parameters
  57. */
  58. void logEvent (const String& eventName, const StringPairArray& parameters);
  59. /** Suspends analytics submission to AnalyticsDestinations.
  60. @param shouldBeSuspended if event submission should be suspended
  61. */
  62. void setSuspended (bool shouldBeSuspended);
  63. #ifndef DOXYGEN
  64. juce_DeclareSingleton (Analytics, false)
  65. #endif
  66. private:
  67. //==============================================================================
  68. Analytics() = default;
  69. ~Analytics() { clearSingletonInstance(); }
  70. String userId;
  71. StringPairArray userProperties;
  72. bool isSuspended = false;
  73. OwnedArray<AnalyticsDestination> destinations;
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Analytics)
  75. };
  76. } // namespace juce