ProtocolAnalytics.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /****************************************************************************
  2. Copyright (c) 2012-2013 cocos2d-x.org
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __CCX_PROTOCOL_ANALYTICS_H__
  21. #define __CCX_PROTOCOL_ANALYTICS_H__
  22. #include "PluginProtocol.h"
  23. #include <map>
  24. #include <string>
  25. namespace cocos2d { namespace plugin {
  26. typedef std::pair< std::string, std::string > LogEventParamPair;
  27. typedef std::map< std::string, std::string > LogEventParamMap;
  28. class ProtocolAnalytics : public PluginProtocol
  29. {
  30. public:
  31. ProtocolAnalytics();
  32. virtual ~ProtocolAnalytics();
  33. /**
  34. @brief Start a new session.
  35. @param appKey The identity of the application.
  36. */
  37. void startSession(const char* appKey);
  38. /**
  39. @brief Stop a session.
  40. @warning This interface only worked on android
  41. */
  42. void stopSession();
  43. /**
  44. @brief Set the timeout for expiring a session.
  45. @param millis In milliseconds as the unit of time.
  46. @note It must be invoked before calling startSession.
  47. */
  48. void setSessionContinueMillis(long millis);
  49. /**
  50. @brief log an error
  51. @param errorId The identity of error
  52. @param message Extern message for the error
  53. */
  54. void logError(const char* errorId, const char* message);
  55. /**
  56. @brief log an event.
  57. @param eventId The identity of event
  58. @param paramMap Extern parameters of the event, use NULL if not needed.
  59. */
  60. void logEvent(const char* eventId, LogEventParamMap* paramMap = NULL);
  61. /**
  62. @brief Track an event begin.
  63. @param eventId The identity of event
  64. */
  65. void logTimedEventBegin(const char* eventId);
  66. /**
  67. @brief Track an event end.
  68. @param eventId The identity of event
  69. */
  70. void logTimedEventEnd(const char* eventId);
  71. /**
  72. @brief Whether to catch uncaught exceptions to server.
  73. @warning This interface only worked on android.
  74. */
  75. void setCaptureUncaughtException(bool enabled);
  76. };
  77. }} // namespace cocos2d { namespace plugin {
  78. #endif /* __CCX_PROTOCOL_ANALYTICS_H__ */