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.

118 lines
4.0KB

  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. @tags{Analytics}
  29. */
  30. class JUCE_API Analytics : public DeletedAtShutdown
  31. {
  32. public:
  33. //==============================================================================
  34. /** Adds an AnalyticsDestination to the list of AnalyticsDestinations
  35. managed by this Analytics object.
  36. The Analytics class will take ownership of the AnalyticsDestination
  37. passed to this function.
  38. @param destination the AnalyticsDestination to manage
  39. */
  40. void addDestination (AnalyticsDestination* destination);
  41. /** Returns the array of AnalyticsDestinations managed by this class.
  42. If you have added any subclasses of ThreadedAnalyticsDestination to
  43. this class then you can remove them from this list to force them to
  44. flush any pending events.
  45. */
  46. OwnedArray<AnalyticsDestination>& getDestinations();
  47. /** Sets a user ID that will be added to all AnalyticsEvents sent to
  48. AnalyticsDestinations.
  49. @param newUserId the userId to add to AnalyticsEvents
  50. */
  51. void setUserId (String newUserId);
  52. /** Sets some user properties that will be added to all AnalyticsEvents sent
  53. to AnalyticsDestinations.
  54. @param properties the userProperties to add to AnalyticsEvents
  55. */
  56. void setUserProperties (StringPairArray properties);
  57. /** Sends an AnalyticsEvent to all AnalyticsDestinations.
  58. The AnalyticsEvent will be timestamped, and will have the userId and
  59. userProperties populated by values previously set by calls to
  60. setUserId and setUserProperties. The name, parameters and type will be
  61. populated by the arguments supplied to this function.
  62. @param eventName the event name
  63. @param parameters the event parameters
  64. @param eventType (optional) an integer to indicate the event
  65. type, which will be set to 0 if not supplied.
  66. */
  67. void logEvent (const String& eventName, const StringPairArray& parameters, int eventType = 0);
  68. /** Suspends analytics submissions to AnalyticsDestinations.
  69. @param shouldBeSuspended if event submission should be suspended
  70. */
  71. void setSuspended (bool shouldBeSuspended);
  72. #ifndef DOXYGEN
  73. JUCE_DECLARE_SINGLETON (Analytics, false)
  74. #endif
  75. private:
  76. //==============================================================================
  77. Analytics() = default;
  78. ~Analytics() { clearSingletonInstance(); }
  79. String userId;
  80. StringPairArray userProperties;
  81. bool isSuspended = false;
  82. OwnedArray<AnalyticsDestination> destinations;
  83. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Analytics)
  84. };
  85. } // namespace juce