/facebook-java-api/src/main/java/com/google/code/facebookapi/Metric.java

http://facebook-java-api.googlecode.com/ · Java · 195 lines · 59 code · 10 blank · 126 comment · 1 complexity · 11dff3dbea3292797e74b5a5ef031066 MD5 · raw file

  1. package com.google.code.facebookapi;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. /**
  5. * This class enumerates the various metrics that are available through the admin.getMetrics API call. Typically, you will pass a set containing the metrics you are
  6. * interested in to the API call.
  7. *
  8. * See http://wiki.developers.facebook.com/index.php/Admin.getMetrics for details.
  9. */
  10. public enum Metric {
  11. /**
  12. * Daily active users for your app. For use with Admin.getDailyMetrics only.
  13. */
  14. @Deprecated
  15. DAILY_ACTIVE_USERS("daily_active_users"),
  16. /**
  17. * Active users for your app. For use with Admin.getMetrics only.
  18. */
  19. ACTIVE_USERS("active_users"),
  20. /**
  21. * Number of unique users adding your app.
  22. */
  23. UNIQUE_ADDS("unique_adds"),
  24. /**
  25. * Number of unique users removing your app.
  26. */
  27. UNIQUE_REMOVES("unique_removes"),
  28. /**
  29. * Number of unique users blocking your app.
  30. */
  31. UNIQUE_BLOCKS("unique_blocks"),
  32. /**
  33. * Number of unique users unblocking your app.
  34. */
  35. UNIQUE_UNBLOCKS("unique_unblocks"),
  36. /**
  37. * Number of API calls made by your app.
  38. */
  39. API_CALLS("api_calls"),
  40. /**
  41. * Number of users making API calls through your app.
  42. */
  43. UNIQUE_API_CALLS("unique_api_calls"),
  44. /**
  45. * Number of canvas page views.
  46. */
  47. CANVAS_PAGE_VIEWS("canvas_page_views"),
  48. /**
  49. * Number of unique users viewing your canvas page.
  50. */
  51. UNIQUE_CANVAS_PAGE_VIEWS("unique_canvas_page_views"),
  52. /**
  53. * Average time required to load your app's canvas page.
  54. */
  55. REQUEST_TIME_AVG("canvas_http_request_time_avg"),
  56. /**
  57. * Average time required to render your app's FBML.
  58. */
  59. FBML_RENDER_TIME_AVG("canvas_fbml_render_time_avg"),
  60. /**
  61. * Number of requests that timed out.
  62. */
  63. REQUEST_TIMEOUT("canvas_page_views_http_code_0"),
  64. /**
  65. * Number of requests, that returned http code 100.
  66. */
  67. REQUEST_CONTINUE("canvas_page_views_http_code_100"),
  68. /**
  69. * Number of requests that completed successfully.
  70. */
  71. REQUEST_OK("canvas_page_views_http_code_200"),
  72. /**
  73. * Number of requests that returned status 200, but with no data.
  74. */
  75. REQUEST_OK_NO_DATA("canvas_page_views_http_code_200ND"),
  76. /**
  77. * Number of requests that produced a status 301 error.
  78. */
  79. REQUEST_ERROR_301("canvas_page_views_http_code_301"),
  80. /**
  81. * Number of requests that produced a status 302 error.
  82. */
  83. REQUEST_ERROR_302("canvas_page_views_http_code_302"),
  84. /**
  85. * Number of requests that produced a status 303 error.
  86. */
  87. REQUEST_ERROR_303("canvas_page_views_http_code_303"),
  88. /**
  89. * Number of requests that produced a status 400 error.
  90. */
  91. REQUEST_ERROR_400("canvas_page_views_http_code_400"),
  92. /**
  93. * Number of requests that produced a status 401 error.
  94. */
  95. REQUEST_ERROR_401("canvas_page_views_http_code_401"),
  96. /**
  97. * Number of requests that produced a status 403 error.
  98. */
  99. REQUEST_ERROR_403("canvas_page_views_http_code_403"),
  100. /**
  101. * Number of requests that produced a status 404 error.
  102. */
  103. REQUEST_ERROR_404("canvas_page_views_http_code_404"),
  104. /**
  105. * Number of requests that produced a status 405 error.
  106. */
  107. REQUEST_ERROR_405("canvas_page_views_http_code_405"),
  108. /**
  109. * Number of requests that produced a status 413 error.
  110. */
  111. REQUEST_ERROR_413("canvas_page_views_http_code_413"),
  112. /**
  113. * Number of requests that produced a status 422 error.
  114. */
  115. REQUEST_ERROR_422("canvas_page_views_http_code_422"),
  116. /**
  117. * Number of requests that produced a status 500 error.
  118. */
  119. REQUEST_ERROR_500("canvas_page_views_http_code_500"),
  120. /**
  121. * Number of requests that produced a status 502 error.
  122. */
  123. REQUEST_ERROR_502("canvas_page_views_http_code_502"),
  124. /**
  125. * Number of requests that produced a status 503 error.
  126. */
  127. REQUEST_ERROR_503("canvas_page_views_http_code_503"),
  128. /**
  129. * Number of requests that produced a status 505 error.
  130. */
  131. REQUEST_ERROR_505("canvas_page_views_http_code_505");
  132. /**
  133. * Use in Admin.getMetrics calls to specify a daily time-period.
  134. */
  135. public static final Long PERIOD_DAY = 86400l;
  136. /**
  137. * Use in Admin.getMetrics calls to specify a weekly time-period.
  138. */
  139. public static final Long PERIOD_WEEK = 604800l;
  140. /**
  141. * Use in Admin.getMetrics calls to specify a monthly time-period.
  142. */
  143. public static final Long PERIOD_MONTH = 2592000l;
  144. private String name;
  145. private Metric( String name ) {
  146. this.name = name;
  147. }
  148. protected static final Map<String,Metric> METRIC_TABLE;
  149. static {
  150. METRIC_TABLE = new HashMap<String,Metric>();
  151. for ( Metric metric : Metric.values() ) {
  152. METRIC_TABLE.put( metric.getName(), metric );
  153. }
  154. }
  155. /**
  156. * Get the name by which Facebook refers to this metric.
  157. *
  158. * @return the Facebook-supplied name of this metric.
  159. */
  160. public String getName() {
  161. return this.name;
  162. }
  163. /**
  164. * Lookup a metric by name.
  165. *
  166. * @param name
  167. * the Facebook-supplied name of the metric to lookup, such as "daily_active_users".
  168. *
  169. * @return the metric the corresponds to the supplied name, or null if none exists.
  170. */
  171. public static Metric getMetric( String name ) {
  172. return METRIC_TABLE.get( name );
  173. }
  174. /**
  175. * Lookup a metric by HTTP error code.
  176. *
  177. * @param errorCode
  178. * the code to get the metric for, such as 500, 404, 401, 200, etc..
  179. *
  180. * @return the metric the corresponds to the supplied HTTP error-code, or null if none exists.
  181. */
  182. public static Metric getErrorMetric( int errorCode ) {
  183. return METRIC_TABLE.get( "canvas_page_views_http_code_" + Integer.toString( errorCode ) );
  184. }
  185. }