Game Analytics.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /******************************************************************************/
  2. #include "stdafx.h"
  3. #define SUPPORT_GAME_ANALYTICS 1
  4. #undef GameAnalytics
  5. #include "../../../ThirdPartyLibs/begin.h"
  6. #if IOS && SUPPORT_GAME_ANALYTICS
  7. #include "../../../ThirdPartyLibs/GameAnalytics/iOS/GameAnalytics.h"
  8. ASSERT((Int)::GAResourceFlowTypeSource==EE::_GameAnalytics::GAResourceFlowTypeSource && (Int)::GAResourceFlowTypeSink==EE::_GameAnalytics::GAResourceFlowTypeSink
  9. && (Int)::GAProgressionStatusStart==EE::_GameAnalytics::GAProgressionStatusStart && (Int)::GAProgressionStatusComplete==EE::_GameAnalytics::GAProgressionStatusComplete && (Int)::GAProgressionStatusFail==EE::_GameAnalytics::GAProgressionStatusFail
  10. && (Int)::GAErrorSeverityDebug==EE::_GameAnalytics::GAErrorSeverityDebug && (Int)::GAErrorSeverityInfo==EE::_GameAnalytics::GAErrorSeverityInfo && (Int)::GAErrorSeverityWarning==EE::_GameAnalytics::GAErrorSeverityWarning && (Int)::GAErrorSeverityError==EE::_GameAnalytics::GAErrorSeverityError && (Int)::GAErrorSeverityCritical==EE::_GameAnalytics::GAErrorSeverityCritical);
  11. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  12. #include "../../../ThirdPartyLibs/GameAnalytics/Android/GameAnalyticsJNI.h"
  13. #endif
  14. #include "../../../ThirdPartyLibs/end.h"
  15. namespace EE{namespace _GameAnalytics{
  16. /******************************************************************************/
  17. void configureAvailableCustomDimensions01(C MemPtr<Str> &customDimensions)
  18. {
  19. #if IOS && SUPPORT_GAME_ANALYTICS
  20. if(NSMutableArray *array=[NSMutableArray arrayWithCapacity:customDimensions.elms()])
  21. {
  22. FREPA(customDimensions)[array addObject:NSStringAuto(customDimensions[i])];
  23. [GameAnalytics configureAvailableCustomDimensions01:array];
  24. //[array release]; NSMutableArray from 'arrayWithCapacity' can't be released
  25. }
  26. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  27. #endif
  28. }
  29. void configureAvailableCustomDimensions02(C MemPtr<Str> &customDimensions)
  30. {
  31. #if IOS && SUPPORT_GAME_ANALYTICS
  32. if(NSMutableArray *array=[NSMutableArray arrayWithCapacity:customDimensions.elms()])
  33. {
  34. FREPA(customDimensions)[array addObject:NSStringAuto(customDimensions[i])];
  35. [GameAnalytics configureAvailableCustomDimensions02:array];
  36. //[array release]; NSMutableArray from 'arrayWithCapacity' can't be released
  37. }
  38. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  39. #endif
  40. }
  41. void configureAvailableCustomDimensions03(C MemPtr<Str> &customDimensions)
  42. {
  43. #if IOS && SUPPORT_GAME_ANALYTICS
  44. if(NSMutableArray *array=[NSMutableArray arrayWithCapacity:customDimensions.elms()])
  45. {
  46. FREPA(customDimensions)[array addObject:NSStringAuto(customDimensions[i])];
  47. [GameAnalytics configureAvailableCustomDimensions03:array];
  48. //[array release]; NSMutableArray from 'arrayWithCapacity' can't be released
  49. }
  50. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  51. #endif
  52. }
  53. void configureAvailableResourceCurrencies(C MemPtr<Str> &resourceCurrencies)
  54. {
  55. #if IOS && SUPPORT_GAME_ANALYTICS
  56. if(NSMutableArray *array=[NSMutableArray arrayWithCapacity:resourceCurrencies.elms()])
  57. {
  58. FREPA(resourceCurrencies)[array addObject:NSStringAuto(resourceCurrencies[i])];
  59. [GameAnalytics configureAvailableResourceCurrencies:array];
  60. //[array release]; NSMutableArray from 'arrayWithCapacity' can't be released
  61. }
  62. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  63. #endif
  64. }
  65. void configureAvailableResourceItemTypes(C MemPtr<Str> &resourceItemTypes)
  66. {
  67. #if IOS && SUPPORT_GAME_ANALYTICS
  68. if(NSMutableArray *array=[NSMutableArray arrayWithCapacity:resourceItemTypes.elms()])
  69. {
  70. FREPA(resourceItemTypes)[array addObject:NSStringAuto(resourceItemTypes[i])];
  71. [GameAnalytics configureAvailableResourceItemTypes:array];
  72. //[array release]; NSMutableArray from 'arrayWithCapacity' can't be released
  73. }
  74. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  75. #endif
  76. }
  77. void configureBuild(C Str &build)
  78. {
  79. #if IOS && SUPPORT_GAME_ANALYTICS
  80. [GameAnalytics configureBuild:NSStringAuto(build)];
  81. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  82. #endif
  83. }
  84. void configureUserId(C Str &userId)
  85. {
  86. #if IOS && SUPPORT_GAME_ANALYTICS
  87. [GameAnalytics configureUserId:NSStringAuto(userId)];
  88. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  89. #endif
  90. }
  91. void configureEngineVersion(C Str &engineVersion)
  92. {
  93. #if IOS && SUPPORT_GAME_ANALYTICS
  94. [GameAnalytics configureEngineVersion:NSStringAuto(engineVersion)];
  95. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  96. #endif
  97. }
  98. void initialize(C Str &gameKey, C Str &gameSecret)
  99. {
  100. #if IOS && SUPPORT_GAME_ANALYTICS
  101. [GameAnalytics initializeWithGameKey:NSStringAuto(gameKey) gameSecret:NSStringAuto(gameSecret)];
  102. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  103. #endif
  104. }
  105. void addBusinessEventWithCurrency(C Str &currency, Int amount, C Str &itemType, C Str &itemId, C Str &cartType, C Str &receipt)
  106. {
  107. #if IOS && SUPPORT_GAME_ANALYTICS
  108. [GameAnalytics addBusinessEventWithCurrency:NSStringAuto(currency) amount:amount itemType:NSStringAuto(itemType) itemId:NSStringAuto(itemId) cartType:NSStringAuto(cartType) receipt:NSStringAuto(receipt)];
  109. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  110. #endif
  111. }
  112. void addBusinessEventWithCurrency(C Str &currency, Int amount, C Str &itemType, C Str &itemId, C Str &cartType, Bool autoFetchReceipt)
  113. {
  114. #if IOS && SUPPORT_GAME_ANALYTICS
  115. [GameAnalytics addBusinessEventWithCurrency:NSStringAuto(currency) amount:amount itemType:NSStringAuto(itemType) itemId:NSStringAuto(itemId) cartType:NSStringAuto(cartType) autoFetchReceipt:autoFetchReceipt];
  116. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  117. #endif
  118. }
  119. void addResourceEventWithFlowType(GAResourceFlowType flowType, C Str &currency, Dbl amount, C Str &itemType, C Str &itemId)
  120. {
  121. #if IOS && SUPPORT_GAME_ANALYTICS
  122. [GameAnalytics addResourceEventWithFlowType:(::GAResourceFlowType)flowType currency:NSStringAuto(currency) amount:[NSNumber numberWithDouble:amount] itemType:NSStringAuto(itemType) itemId:NSStringAuto(itemId)];
  123. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  124. #endif
  125. }
  126. void addProgressionEventWithProgressionStatus(GAProgressionStatus progressionStatus, C Str &progression01, C Str &progression02, C Str &progression03)
  127. {
  128. #if IOS && SUPPORT_GAME_ANALYTICS
  129. [GameAnalytics addProgressionEventWithProgressionStatus:(::GAProgressionStatus)progressionStatus progression01:NSStringAuto(progression01) progression02:NSStringAuto(progression02) progression03:NSStringAuto(progression03)];
  130. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  131. #endif
  132. }
  133. void addProgressionEventWithProgressionStatus(GAProgressionStatus progressionStatus, C Str &progression01, C Str &progression02, C Str &progression03, Int score)
  134. {
  135. #if IOS && SUPPORT_GAME_ANALYTICS
  136. [GameAnalytics addProgressionEventWithProgressionStatus:(::GAProgressionStatus)progressionStatus progression01:NSStringAuto(progression01) progression02:NSStringAuto(progression02) progression03:NSStringAuto(progression03) score:score];
  137. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  138. #endif
  139. }
  140. void addDesignEventWithEventId(C Str &eventId)
  141. {
  142. #if IOS && SUPPORT_GAME_ANALYTICS
  143. [GameAnalytics addDesignEventWithEventId:NSStringAuto(eventId)];
  144. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  145. #endif
  146. }
  147. void addDesignEventWithEventId(C Str &eventId, Dbl value)
  148. {
  149. #if IOS && SUPPORT_GAME_ANALYTICS
  150. [GameAnalytics addDesignEventWithEventId:NSStringAuto(eventId) value:[NSNumber numberWithDouble:value]];
  151. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  152. #endif
  153. }
  154. void addErrorEventWithSeverity(GAErrorSeverity severity, C Str &message)
  155. {
  156. #if IOS && SUPPORT_GAME_ANALYTICS
  157. [GameAnalytics addErrorEventWithSeverity:(::GAErrorSeverity)severity message:NSStringAuto(message)];
  158. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  159. #endif
  160. }
  161. Str getCommandCenterValueAsString(C Str &key)
  162. {
  163. #if IOS && SUPPORT_GAME_ANALYTICS
  164. return [GameAnalytics getCommandCenterValueAsString:NSStringAuto(key)];
  165. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  166. #endif
  167. return S;
  168. }
  169. Str getCommandCenterValueAsString(C Str &key, C Str &defaultValue)
  170. {
  171. #if IOS && SUPPORT_GAME_ANALYTICS
  172. return [GameAnalytics getCommandCenterValueAsString:NSStringAuto(key) defaultValue:NSStringAuto(defaultValue)];
  173. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  174. #endif
  175. return S;
  176. }
  177. Str getCommandCenterConfigurations()
  178. {
  179. #if IOS && SUPPORT_GAME_ANALYTICS
  180. return [GameAnalytics getCommandCenterConfigurations];
  181. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  182. #endif
  183. return S;
  184. }
  185. /*void setCommandCenterDelegate(id newDelegate)
  186. {
  187. #if IOS && SUPPORT_GAME_ANALYTICS
  188. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  189. #endif
  190. }*/
  191. Bool isCommandCenterReady()
  192. {
  193. #if IOS && SUPPORT_GAME_ANALYTICS
  194. return [GameAnalytics isCommandCenterReady];
  195. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  196. #endif
  197. return false;
  198. }
  199. void setEnabledInfoLog(Bool flag)
  200. {
  201. #if IOS && SUPPORT_GAME_ANALYTICS
  202. [GameAnalytics setEnabledInfoLog:flag];
  203. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  204. #endif
  205. }
  206. void setEnabledVerboseLog(Bool flag)
  207. {
  208. #if IOS && SUPPORT_GAME_ANALYTICS
  209. [GameAnalytics setEnabledVerboseLog:flag];
  210. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  211. #endif
  212. }
  213. void setEnabledManualSessionHandling(Bool flag)
  214. {
  215. #if IOS && SUPPORT_GAME_ANALYTICS
  216. [GameAnalytics setEnabledManualSessionHandling:flag];
  217. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  218. #endif
  219. }
  220. void startSession()
  221. {
  222. #if IOS && SUPPORT_GAME_ANALYTICS
  223. [GameAnalytics startSession];
  224. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  225. #endif
  226. }
  227. void endSession()
  228. {
  229. #if IOS && SUPPORT_GAME_ANALYTICS
  230. [GameAnalytics endSession];
  231. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  232. #endif
  233. }
  234. void setCustomDimension01(C Str &dimension01)
  235. {
  236. #if IOS && SUPPORT_GAME_ANALYTICS
  237. [GameAnalytics setCustomDimension01:NSStringAuto(dimension01)];
  238. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  239. #endif
  240. }
  241. void setCustomDimension02(C Str &dimension02)
  242. {
  243. #if IOS && SUPPORT_GAME_ANALYTICS
  244. [GameAnalytics setCustomDimension02:NSStringAuto(dimension02)];
  245. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  246. #endif
  247. }
  248. void setCustomDimension03(C Str &dimension03)
  249. {
  250. #if IOS && SUPPORT_GAME_ANALYTICS
  251. [GameAnalytics setCustomDimension03:NSStringAuto(dimension03)];
  252. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  253. #endif
  254. }
  255. void setFacebookId(C Str &facebookId)
  256. {
  257. #if IOS && SUPPORT_GAME_ANALYTICS
  258. [GameAnalytics setFacebookId:NSStringAuto(facebookId)];
  259. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  260. #endif
  261. }
  262. void setGender(C Str &gender)
  263. {
  264. #if IOS && SUPPORT_GAME_ANALYTICS
  265. [GameAnalytics setGender:NSStringAuto(gender)];
  266. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  267. #endif
  268. }
  269. void setBirthYear(Int birthYear)
  270. {
  271. #if IOS && SUPPORT_GAME_ANALYTICS
  272. [GameAnalytics setBirthYear:birthYear];
  273. #elif ANDROID && SUPPORT_GAME_ANALYTICS
  274. #endif
  275. }
  276. /******************************************************************************/
  277. }}
  278. /******************************************************************************/