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.

210 lines
12 KiB

6 years ago
  1. //
  2. // Answers.h
  3. // Crashlytics
  4. //
  5. // Copyright (c) 2015 Crashlytics, Inc. All rights reserved.
  6. //
  7. #import <Foundation/Foundation.h>
  8. #import "ANSCompatibility.h"
  9. NS_ASSUME_NONNULL_BEGIN
  10. /**
  11. * This class exposes the Answers Events API, allowing you to track key
  12. * user user actions and metrics in your app.
  13. */
  14. @interface Answers : NSObject
  15. /**
  16. * Log a Sign Up event to see users signing up for your app in real-time, understand how
  17. * many users are signing up with different methods and their success rate signing up.
  18. *
  19. * @param signUpMethodOrNil The method by which a user logged in, e.g. Twitter or Digits.
  20. * @param signUpSucceededOrNil The ultimate success or failure of the login
  21. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  22. */
  23. + (void)logSignUpWithMethod:(nullable NSString *)signUpMethodOrNil
  24. success:(nullable NSNumber *)signUpSucceededOrNil
  25. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  26. /**
  27. * Log an Log In event to see users logging into your app in real-time, understand how many
  28. * users are logging in with different methods and their success rate logging into your app.
  29. *
  30. * @param loginMethodOrNil The method by which a user logged in, e.g. email, Twitter or Digits.
  31. * @param loginSucceededOrNil The ultimate success or failure of the login
  32. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  33. */
  34. + (void)logLoginWithMethod:(nullable NSString *)loginMethodOrNil
  35. success:(nullable NSNumber *)loginSucceededOrNil
  36. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  37. /**
  38. * Log a Share event to see users sharing from your app in real-time, letting you
  39. * understand what content they're sharing from the type or genre down to the specific id.
  40. *
  41. * @param shareMethodOrNil The method by which a user shared, e.g. email, Twitter, SMS.
  42. * @param contentNameOrNil The human readable name for this piece of content.
  43. * @param contentTypeOrNil The type of content shared.
  44. * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item.
  45. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  46. */
  47. + (void)logShareWithMethod:(nullable NSString *)shareMethodOrNil
  48. contentName:(nullable NSString *)contentNameOrNil
  49. contentType:(nullable NSString *)contentTypeOrNil
  50. contentId:(nullable NSString *)contentIdOrNil
  51. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  52. /**
  53. * Log an Invite Event to track how users are inviting other users into
  54. * your application.
  55. *
  56. * @param inviteMethodOrNil The method of invitation, e.g. GameCenter, Twitter, email.
  57. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  58. */
  59. + (void)logInviteWithMethod:(nullable NSString *)inviteMethodOrNil
  60. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  61. /**
  62. * Log a Purchase event to see your revenue in real-time, understand how many users are making purchases, see which
  63. * items are most popular, and track plenty of other important purchase-related metrics.
  64. *
  65. * @param itemPriceOrNil The purchased item's price.
  66. * @param currencyOrNil The ISO4217 currency code. Example: USD
  67. * @param purchaseSucceededOrNil Was the purchase successful or unsuccessful
  68. * @param itemNameOrNil The human-readable form of the item's name. Example:
  69. * @param itemTypeOrNil The type, or genre of the item. Example: Song
  70. * @param itemIdOrNil The machine-readable, unique item identifier Example: SKU
  71. * @param customAttributesOrNil A dictionary of custom attributes to associate with this purchase.
  72. */
  73. + (void)logPurchaseWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil
  74. currency:(nullable NSString *)currencyOrNil
  75. success:(nullable NSNumber *)purchaseSucceededOrNil
  76. itemName:(nullable NSString *)itemNameOrNil
  77. itemType:(nullable NSString *)itemTypeOrNil
  78. itemId:(nullable NSString *)itemIdOrNil
  79. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  80. /**
  81. * Log a Level Start Event to track where users are in your game.
  82. *
  83. * @param levelNameOrNil The level name
  84. * @param customAttributesOrNil A dictionary of custom attributes to associate with this level start event.
  85. */
  86. + (void)logLevelStart:(nullable NSString *)levelNameOrNil
  87. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  88. /**
  89. * Log a Level End event to track how users are completing levels in your game.
  90. *
  91. * @param levelNameOrNil The name of the level completed, E.G. "1" or "Training"
  92. * @param scoreOrNil The score the user completed the level with.
  93. * @param levelCompletedSuccesfullyOrNil A boolean representing whether or not the level was completed successfully.
  94. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  95. */
  96. + (void)logLevelEnd:(nullable NSString *)levelNameOrNil
  97. score:(nullable NSNumber *)scoreOrNil
  98. success:(nullable NSNumber *)levelCompletedSuccesfullyOrNil
  99. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  100. /**
  101. * Log an Add to Cart event to see users adding items to a shopping cart in real-time, understand how
  102. * many users start the purchase flow, see which items are most popular, and track plenty of other important
  103. * purchase-related metrics.
  104. *
  105. * @param itemPriceOrNil The purchased item's price.
  106. * @param currencyOrNil The ISO4217 currency code. Example: USD
  107. * @param itemNameOrNil The human-readable form of the item's name. Example:
  108. * @param itemTypeOrNil The type, or genre of the item. Example: Song
  109. * @param itemIdOrNil The machine-readable, unique item identifier Example: SKU
  110. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  111. */
  112. + (void)logAddToCartWithPrice:(nullable NSDecimalNumber *)itemPriceOrNil
  113. currency:(nullable NSString *)currencyOrNil
  114. itemName:(nullable NSString *)itemNameOrNil
  115. itemType:(nullable NSString *)itemTypeOrNil
  116. itemId:(nullable NSString *)itemIdOrNil
  117. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  118. /**
  119. * Log a Start Checkout event to see users moving through the purchase funnel in real-time, understand how many
  120. * users are doing this and how much they're spending per checkout, and see how it related to other important
  121. * purchase-related metrics.
  122. *
  123. * @param totalPriceOrNil The total price of the cart.
  124. * @param currencyOrNil The ISO4217 currency code. Example: USD
  125. * @param itemCountOrNil The number of items in the cart.
  126. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  127. */
  128. + (void)logStartCheckoutWithPrice:(nullable NSDecimalNumber *)totalPriceOrNil
  129. currency:(nullable NSString *)currencyOrNil
  130. itemCount:(nullable NSNumber *)itemCountOrNil
  131. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  132. /**
  133. * Log a Rating event to see users rating content within your app in real-time and understand what
  134. * content is most engaging, from the type or genre down to the specific id.
  135. *
  136. * @param ratingOrNil The integer rating given by the user.
  137. * @param contentNameOrNil The human readable name for this piece of content.
  138. * @param contentTypeOrNil The type of content shared.
  139. * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item.
  140. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  141. */
  142. + (void)logRating:(nullable NSNumber *)ratingOrNil
  143. contentName:(nullable NSString *)contentNameOrNil
  144. contentType:(nullable NSString *)contentTypeOrNil
  145. contentId:(nullable NSString *)contentIdOrNil
  146. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  147. /**
  148. * Log a Content View event to see users viewing content within your app in real-time and
  149. * understand what content is most engaging, from the type or genre down to the specific id.
  150. *
  151. * @param contentNameOrNil The human readable name for this piece of content.
  152. * @param contentTypeOrNil The type of content shared.
  153. * @param contentIdOrNil The unique identifier for this piece of content. Useful for finding the top shared item.
  154. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  155. */
  156. + (void)logContentViewWithName:(nullable NSString *)contentNameOrNil
  157. contentType:(nullable NSString *)contentTypeOrNil
  158. contentId:(nullable NSString *)contentIdOrNil
  159. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  160. /**
  161. * Log a Search event allows you to see users searching within your app in real-time and understand
  162. * exactly what they're searching for.
  163. *
  164. * @param queryOrNil The user's query.
  165. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event.
  166. */
  167. + (void)logSearchWithQuery:(nullable NSString *)queryOrNil
  168. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  169. /**
  170. * Log a Custom Event to see user actions that are uniquely important for your app in real-time, to see how often
  171. * they're performing these actions with breakdowns by different categories you add. Use a human-readable name for
  172. * the name of the event, since this is how the event will appear in Answers.
  173. *
  174. * @param eventName The human-readable name for the event.
  175. * @param customAttributesOrNil A dictionary of custom attributes to associate with this event. Attribute keys
  176. * must be <code>NSString</code> and values must be <code>NSNumber</code> or <code>NSString</code>.
  177. * @discussion How we treat <code>NSNumbers</code>:
  178. * We will provide information about the distribution of values over time.
  179. *
  180. * How we treat <code>NSStrings</code>:
  181. * NSStrings are used as categorical data, allowing comparison across different category values.
  182. * Strings are limited to a maximum length of 100 characters, attributes over this length will be
  183. * truncated.
  184. *
  185. * When tracking the Tweet views to better understand user engagement, sending the tweet's length
  186. * and the type of media present in the tweet allows you to track how tweet length and the type of media influence
  187. * engagement.
  188. */
  189. + (void)logCustomEventWithName:(NSString *)eventName
  190. customAttributes:(nullable ANS_GENERIC_NSDICTIONARY(NSString *, id) *)customAttributesOrNil;
  191. @end
  192. NS_ASSUME_NONNULL_END