AnalyticsFlurry.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. #import "AnalyticsFlurry.h"
  21. #import "Flurry.h"
  22. #define OUTPUT_LOG(...) if (self.debug) NSLog(__VA_ARGS__);
  23. @implementation AnalyticsFlurry
  24. @synthesize debug = __debug;
  25. - (void) startSession: (NSString*) appKey
  26. {
  27. [Flurry startSession:appKey];
  28. }
  29. - (void) stopSession
  30. {
  31. OUTPUT_LOG(@"Flurry stopSession in flurry not available on iOS");
  32. }
  33. - (void) setSessionContinueMillis: (long) millis
  34. {
  35. OUTPUT_LOG(@"Flurry setSessionContinueMillis invoked(%ld)", millis);
  36. int seconds = (int)(millis / 1000);
  37. [Flurry setSessionContinueSeconds:seconds];
  38. }
  39. - (void) setCaptureUncaughtException: (BOOL) isEnabled
  40. {
  41. OUTPUT_LOG(@"Flurry setCaptureUncaughtException in flurry not available on iOS");
  42. }
  43. - (void) setDebugMode: (BOOL) isDebugMode
  44. {
  45. OUTPUT_LOG(@"Flurry setDebugMode invoked(%d)", isDebugMode);
  46. self.debug = isDebugMode;
  47. [Flurry setDebugLogEnabled:isDebugMode];
  48. }
  49. - (void) logError: (NSString*) errorId withMsg:(NSString*) message
  50. {
  51. OUTPUT_LOG(@"Flurry logError invoked(%@, %@)", errorId, message);
  52. NSString* msg = nil;
  53. if (nil == message) {
  54. msg = @"";
  55. } else {
  56. msg = message;
  57. }
  58. [Flurry logError:errorId message:msg exception:nil];
  59. }
  60. - (void) logEvent: (NSString*) eventId
  61. {
  62. OUTPUT_LOG(@"Flurry logEvent invoked(%@)", eventId);
  63. [Flurry logEvent:eventId];
  64. }
  65. - (void) logEvent: (NSString*) eventId withParam:(NSMutableDictionary*) paramMap
  66. {
  67. OUTPUT_LOG(@"Flurry logEventWithParams invoked (%@, %@)", eventId, [paramMap debugDescription]);
  68. [Flurry logEvent:eventId withParameters:paramMap];
  69. }
  70. - (void) logTimedEventBegin: (NSString*) eventId
  71. {
  72. OUTPUT_LOG(@"Flurry logTimedEventBegin invoked (%@)", eventId);
  73. [Flurry logEvent:eventId timed:YES];
  74. }
  75. - (void) logTimedEventEnd: (NSString*) eventId
  76. {
  77. OUTPUT_LOG(@"Flurry logTimedEventEnd invoked (%@)", eventId);
  78. [Flurry endTimedEvent:eventId withParameters:nil];
  79. }
  80. - (NSString*) getSDKVersion
  81. {
  82. return @"4.2.1";
  83. }
  84. - (NSString*) getPluginVersion
  85. {
  86. return @"0.2.0";
  87. }
  88. - (void) setAge: (NSNumber*) age
  89. {
  90. int nAge = [age intValue];
  91. OUTPUT_LOG(@"Flurry setAge invoked (%d)", nAge);
  92. [Flurry setAge:nAge];
  93. }
  94. - (void) setGender: (NSNumber*) gender
  95. {
  96. OUTPUT_LOG(@"Flurry setGender invoked (%@)", gender);
  97. int nValue = [gender intValue];
  98. NSString* strGender;
  99. if (nValue == 1) {
  100. strGender = @"m";
  101. } else {
  102. strGender = @"f";
  103. }
  104. [Flurry setGender:strGender];
  105. }
  106. - (void) setUserId: (NSString*) userId
  107. {
  108. OUTPUT_LOG(@"Flurry setUserId invoked (%@)", userId);
  109. [Flurry setUserID:userId];
  110. }
  111. - (void) setUseHttps: (NSNumber*) enabled
  112. {
  113. BOOL bEnabled = [enabled boolValue];
  114. OUTPUT_LOG(@"Flurry setUseHttps invoked (%@)", enabled);
  115. [Flurry setSecureTransportEnabled:bEnabled];
  116. }
  117. - (void) logPageView
  118. {
  119. OUTPUT_LOG(@"Flurry logPageView invoked");
  120. [Flurry logPageView];
  121. }
  122. - (void) setVersionName: (NSString*) versionName
  123. {
  124. OUTPUT_LOG(@"Flurry setVersionName invoked (%@)", versionName);
  125. [Flurry setAppVersion:versionName];
  126. }
  127. - (void) logTimedEventBeginWithParams: (NSMutableDictionary*) paramMap
  128. {
  129. OUTPUT_LOG(@"Flurry logTimedEventBeginWithParams invoked (%@)", [paramMap debugDescription]);
  130. NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"];
  131. NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"];
  132. if (params) {
  133. [Flurry logEvent:eventId withParameters:paramMap timed:YES];
  134. } else {
  135. [Flurry logEvent:eventId timed:YES];
  136. }
  137. }
  138. - (void) logTimedEventEndWithParams: (NSMutableDictionary*) paramMap
  139. {
  140. OUTPUT_LOG(@"Flurry logTimedEventEndWithParams invoked (%@)", [paramMap debugDescription]);
  141. NSString* eventId = (NSString*) [paramMap objectForKey:@"Param1"];
  142. NSMutableDictionary* params = (NSMutableDictionary*) [paramMap objectForKey:@"Param2"];
  143. [Flurry endTimedEvent:eventId withParameters:params];
  144. }
  145. @end