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.

112 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. The code included in this file is provided under the terms of the ISC license
  8. http://www.isc.org/downloads/software-support-policy/isc-license. Permission
  9. To use, copy, modify, and/or distribute this software for any purpose with or
  10. without fee is hereby granted provided that the above copyright notice and
  11. this permission notice appear in all copies.
  12. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  13. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  14. DISCLAIMED.
  15. ==============================================================================
  16. */
  17. namespace juce
  18. {
  19. //==============================================================================
  20. /**
  21. A singleton class to manage analytics data.
  22. Use an Analytics object to manage sending analytics data to one or more
  23. AnalyticsDestinations.
  24. @see AnalyticsDestination, ThreadedAnalyticsDestination,
  25. AnalyticsDestination::AnalyticsEvent
  26. */
  27. class JUCE_API Analytics : public DeletedAtShutdown
  28. {
  29. public:
  30. //==============================================================================
  31. /** Adds an AnalyticsDestination to the list of AnalyticsDestinations
  32. managed by this Analytics object.
  33. The Analytics class will take ownership of the AnalyticsDestination
  34. passed to this function.
  35. @param destination the AnalyticsDestination to manage
  36. */
  37. void addDestination (AnalyticsDestination* destination);
  38. /** Returns the array of AnalyticsDestinations managed by this class.
  39. If you have added any subclasses of ThreadedAnalyticsDestination to
  40. this class then you can remove them from this list to force them to
  41. flush any pending events.
  42. */
  43. OwnedArray<AnalyticsDestination>& getDestinations();
  44. /** Sets a user ID that will be added to all AnalyticsEvents sent to
  45. AnalyticsDestinations.
  46. @param newUserId the userId to add to AnalyticsEvents
  47. */
  48. void setUserId (const String& newUserId);
  49. /** Sets some user properties that will be added to all AnalyticsEvents sent
  50. to AnalyticsDestinations.
  51. @param properties the userProperties to add to AnalyticsEvents
  52. */
  53. void setUserProperties (const StringPairArray& properties);
  54. /** Sends an AnalyticsEvent to all AnalyticsDestinations.
  55. The AnalyticsEvent will be timestamped, and will have the userId and
  56. userProperties populated by values previously set by calls to
  57. setUserId and setUserProperties. The name, parameters and type will be
  58. populated by the arguments supplied to this function.
  59. @param eventName the event name
  60. @param parameters the event parameters
  61. @param eventType (optional) an integer to indicate the event
  62. type, which will be set to 0 if not supplied.
  63. */
  64. void logEvent (const String& eventName, const StringPairArray& parameters, int eventType = 0);
  65. /** Suspends analytics submissions to AnalyticsDestinations.
  66. @param shouldBeSuspended if event submission should be suspended
  67. */
  68. void setSuspended (bool shouldBeSuspended);
  69. #ifndef DOXYGEN
  70. JUCE_DECLARE_SINGLETON (Analytics, false)
  71. #endif
  72. private:
  73. //==============================================================================
  74. Analytics() = default;
  75. ~Analytics() { clearSingletonInstance(); }
  76. String userId;
  77. StringPairArray userProperties;
  78. bool isSuspended = false;
  79. OwnedArray<AnalyticsDestination> destinations;
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Analytics)
  81. };
  82. } // namespace juce