@snap/camera-kit 0.23.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (567) hide show
  1. package/LICENSE.md +1122 -537
  2. package/README.md +1 -1
  3. package/dist/CameraKit.d.ts +3 -3
  4. package/dist/CameraKit.d.ts.map +1 -1
  5. package/dist/CameraKit.js +1 -2
  6. package/dist/CameraKit.js.map +1 -1
  7. package/dist/RootServices.d.ts +78 -0
  8. package/dist/RootServices.d.ts.map +1 -0
  9. package/dist/RootServices.js.map +1 -0
  10. package/dist/bootstrapCameraKit.d.ts +3 -4
  11. package/dist/bootstrapCameraKit.d.ts.map +1 -1
  12. package/dist/bootstrapCameraKit.js +8 -8
  13. package/dist/bootstrapCameraKit.js.map +1 -1
  14. package/dist/clients/createTsProtoClient.d.ts +2 -2
  15. package/dist/clients/createTsProtoClient.d.ts.map +1 -1
  16. package/dist/clients/createTsProtoClient.js.map +1 -1
  17. package/dist/clients/grpcHandler.d.ts.map +1 -1
  18. package/dist/clients/grpcHandler.js +1 -1
  19. package/dist/clients/grpcHandler.js.map +1 -1
  20. package/dist/clients/lensesClient.js +1 -1
  21. package/dist/clients/lensesClient.js.map +1 -1
  22. package/dist/clients/metricsClient.d.ts.map +1 -1
  23. package/dist/clients/metricsClient.js +1 -1
  24. package/dist/clients/metricsClient.js.map +1 -1
  25. package/dist/common/pageVisibility.js +1 -1
  26. package/dist/common/pageVisibility.js.map +1 -1
  27. package/dist/configuration.d.ts.map +1 -1
  28. package/dist/configuration.js +1 -1
  29. package/dist/configuration.js.map +1 -1
  30. package/dist/environment.d.ts.map +1 -1
  31. package/dist/environment.js +1 -1
  32. package/dist/environment.js.map +1 -1
  33. package/dist/extensions/RemoteApiServices.js +1 -1
  34. package/dist/extensions/RemoteApiServices.js.map +1 -1
  35. package/dist/extensions/UriHandlers.js +1 -1
  36. package/dist/extensions/UriHandlers.js.map +1 -1
  37. package/dist/extensions/uriHandlersRegister.d.ts.map +1 -1
  38. package/dist/extensions/uriHandlersRegister.js +1 -1
  39. package/dist/extensions/uriHandlersRegister.js.map +1 -1
  40. package/dist/generated-proto/blizzard/cameraKitEvents.d.ts +45 -9270
  41. package/dist/generated-proto/blizzard/cameraKitEvents.d.ts.map +1 -1
  42. package/dist/generated-proto/blizzard/cameraKitEvents.js +300 -123
  43. package/dist/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
  44. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +12 -32
  45. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts.map +1 -1
  46. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js +77 -37
  47. package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  48. package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts +19 -454
  49. package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts.map +1 -1
  50. package/dist/generated-proto/pb_schema/camera_kit/v3/export.js +219 -118
  51. package/dist/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
  52. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts +12 -12
  53. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts.map +1 -1
  54. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js +16 -13
  55. package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js.map +1 -1
  56. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +12 -12
  57. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts.map +1 -1
  58. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +16 -13
  59. package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -1
  60. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +13 -54
  61. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts.map +1 -1
  62. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -34
  63. package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  64. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +19 -299
  65. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts.map +1 -1
  66. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js +294 -133
  67. package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  68. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +14 -148
  69. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts.map +1 -1
  70. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +74 -48
  71. package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
  72. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +12 -18
  73. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts.map +1 -1
  74. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js +34 -19
  75. package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
  76. package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts +19 -516
  77. package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts.map +1 -1
  78. package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js +164 -80
  79. package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js.map +1 -1
  80. package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts +80 -2371
  81. package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts.map +1 -1
  82. package/dist/generated-proto/pb_schema/camera_kit/v3/service.js +847 -174
  83. package/dist/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  84. package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.d.ts.map +1 -1
  85. package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js +0 -6
  86. package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js.map +1 -1
  87. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +18 -59
  88. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts.map +1 -1
  89. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js +88 -52
  90. package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
  91. package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts.map +1 -1
  92. package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -6
  93. package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
  94. package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts +12 -106
  95. package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts.map +1 -1
  96. package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js +328 -140
  97. package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js.map +1 -1
  98. package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts +12 -18
  99. package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts.map +1 -1
  100. package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js +35 -20
  101. package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js.map +1 -1
  102. package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts +12 -34
  103. package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts.map +1 -1
  104. package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js +86 -39
  105. package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js.map +1 -1
  106. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +47 -28591
  107. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts.map +1 -1
  108. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js +644 -348
  109. package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
  110. package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts +12 -12
  111. package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts.map +1 -1
  112. package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js +16 -13
  113. package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js.map +1 -1
  114. package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts +18 -214
  115. package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts.map +1 -1
  116. package/dist/generated-proto/pb_schema/cdp/cof/config_request.js +362 -157
  117. package/dist/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
  118. package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts +20 -3801
  119. package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts.map +1 -1
  120. package/dist/generated-proto/pb_schema/cdp/cof/config_response.js +144 -46
  121. package/dist/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
  122. package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts +49 -10060
  123. package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts.map +1 -1
  124. package/dist/generated-proto/pb_schema/cdp/cof/config_result.js +443 -182
  125. package/dist/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  126. package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.d.ts.map +1 -1
  127. package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js +0 -6
  128. package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js.map +1 -1
  129. package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts +12 -12
  130. package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts.map +1 -1
  131. package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js +16 -13
  132. package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js.map +1 -1
  133. package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts +12 -14
  134. package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts.map +1 -1
  135. package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js +24 -17
  136. package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js.map +1 -1
  137. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +14 -56
  138. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts.map +1 -1
  139. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js +78 -45
  140. package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
  141. package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts +28 -0
  142. package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts.map +1 -0
  143. package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js +89 -0
  144. package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js.map +1 -0
  145. package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts +28 -1103
  146. package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts.map +1 -1
  147. package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js +358 -210
  148. package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js.map +1 -1
  149. package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts +12 -16
  150. package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts.map +1 -1
  151. package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js +31 -23
  152. package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js.map +1 -1
  153. package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts +13 -15
  154. package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts.map +1 -1
  155. package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js +22 -15
  156. package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js.map +1 -1
  157. package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts +12 -14
  158. package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts.map +1 -1
  159. package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js +22 -15
  160. package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js.map +1 -1
  161. package/dist/generated-proto/pb_schema/cdp/cof/namespace.d.ts.map +1 -1
  162. package/dist/generated-proto/pb_schema/cdp/cof/namespace.js +0 -6
  163. package/dist/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
  164. package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts +12 -16
  165. package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts.map +1 -1
  166. package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js +29 -18
  167. package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js.map +1 -1
  168. package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts +12 -12
  169. package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts.map +1 -1
  170. package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js +16 -13
  171. package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js.map +1 -1
  172. package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts +12 -12
  173. package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts.map +1 -1
  174. package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js +16 -13
  175. package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js.map +1 -1
  176. package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts +12 -12
  177. package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts.map +1 -1
  178. package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js +16 -13
  179. package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js.map +1 -1
  180. package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts +12 -12
  181. package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts.map +1 -1
  182. package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js +16 -13
  183. package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js.map +1 -1
  184. package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts +12 -18
  185. package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts.map +1 -1
  186. package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js +35 -20
  187. package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js.map +1 -1
  188. package/dist/generated-proto/pb_schema/cdp/media/snap_source.d.ts.map +1 -1
  189. package/dist/generated-proto/pb_schema/cdp/media/snap_source.js +0 -6
  190. package/dist/generated-proto/pb_schema/cdp/media/snap_source.js.map +1 -1
  191. package/dist/generated-proto/pb_schema/common/ruid.d.ts +12 -16
  192. package/dist/generated-proto/pb_schema/common/ruid.d.ts.map +1 -1
  193. package/dist/generated-proto/pb_schema/common/ruid.js +28 -17
  194. package/dist/generated-proto/pb_schema/common/ruid.js.map +1 -1
  195. package/dist/generated-proto/pb_schema/common/value.d.ts +25 -123
  196. package/dist/generated-proto/pb_schema/common/value.d.ts.map +1 -1
  197. package/dist/generated-proto/pb_schema/common/value.js +136 -71
  198. package/dist/generated-proto/pb_schema/common/value.js.map +1 -1
  199. package/dist/generated-proto/pb_schema/content/asset.d.ts +12 -14
  200. package/dist/generated-proto/pb_schema/content/asset.d.ts.map +1 -1
  201. package/dist/generated-proto/pb_schema/content/asset.js +22 -15
  202. package/dist/generated-proto/pb_schema/content/asset.js.map +1 -1
  203. package/dist/generated-proto/pb_schema/content/media_reference.d.ts +13 -46
  204. package/dist/generated-proto/pb_schema/content/media_reference.d.ts.map +1 -1
  205. package/dist/generated-proto/pb_schema/content/media_reference.js +86 -47
  206. package/dist/generated-proto/pb_schema/content/media_reference.js.map +1 -1
  207. package/dist/generated-proto/pb_schema/content/media_source.d.ts.map +1 -1
  208. package/dist/generated-proto/pb_schema/content/media_source.js +0 -6
  209. package/dist/generated-proto/pb_schema/content/media_source.js.map +1 -1
  210. package/dist/generated-proto/pb_schema/content/media_types.d.ts.map +1 -1
  211. package/dist/generated-proto/pb_schema/content/media_types.js +0 -6
  212. package/dist/generated-proto/pb_schema/content/media_types.js.map +1 -1
  213. package/dist/generated-proto/pb_schema/google/api/annotations.d.ts.map +1 -1
  214. package/dist/generated-proto/pb_schema/google/api/annotations.js +0 -6
  215. package/dist/generated-proto/pb_schema/google/api/annotations.js.map +1 -1
  216. package/dist/generated-proto/pb_schema/google/api/http.d.ts +15 -3336
  217. package/dist/generated-proto/pb_schema/google/api/http.d.ts.map +1 -1
  218. package/dist/generated-proto/pb_schema/google/api/http.js +129 -68
  219. package/dist/generated-proto/pb_schema/google/api/http.js.map +1 -1
  220. package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts +12 -14
  221. package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts.map +1 -1
  222. package/dist/generated-proto/pb_schema/google/protobuf/any.js +24 -17
  223. package/dist/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
  224. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +126 -50157
  225. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts.map +1 -1
  226. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js +1162 -563
  227. package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -1
  228. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +12 -14
  229. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts.map +1 -1
  230. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js +23 -19
  231. package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
  232. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +20 -84
  233. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts.map +1 -1
  234. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js +141 -77
  235. package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
  236. package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts +12 -23
  237. package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts.map +1 -1
  238. package/dist/generated-proto/pb_schema/lenses/geocircle.js +26 -18
  239. package/dist/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
  240. package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts +12 -14
  241. package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts.map +1 -1
  242. package/dist/generated-proto/pb_schema/lenses/geopoint.js +22 -15
  243. package/dist/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
  244. package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts +12 -12
  245. package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts.map +1 -1
  246. package/dist/generated-proto/pb_schema/lenses/launch_params.js +18 -15
  247. package/dist/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
  248. package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts +15 -324
  249. package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts.map +1 -1
  250. package/dist/generated-proto/pb_schema/lenses/launchdata.js +112 -66
  251. package/dist/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
  252. package/dist/generated-proto/pb_schema/lenses/lures.d.ts +12 -91
  253. package/dist/generated-proto/pb_schema/lenses/lures.d.ts.map +1 -1
  254. package/dist/generated-proto/pb_schema/lenses/lures.js +37 -28
  255. package/dist/generated-proto/pb_schema/lenses/lures.js.map +1 -1
  256. package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts +12 -12
  257. package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts.map +1 -1
  258. package/dist/generated-proto/pb_schema/lenses/persistent_store.js +18 -15
  259. package/dist/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
  260. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +30 -396
  261. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts.map +1 -1
  262. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +520 -240
  263. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -1
  264. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts +30 -2429
  265. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts.map +1 -1
  266. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js +991 -440
  267. package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js.map +1 -1
  268. package/dist/generated-proto/pb_schema/lenses/snappable.d.ts +27 -783
  269. package/dist/generated-proto/pb_schema/lenses/snappable.d.ts.map +1 -1
  270. package/dist/generated-proto/pb_schema/lenses/snappable.js +502 -245
  271. package/dist/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
  272. package/dist/generated-proto/pb_schema/lenses/user_data.d.ts +15 -174
  273. package/dist/generated-proto/pb_schema/lenses/user_data.d.ts.map +1 -1
  274. package/dist/generated-proto/pb_schema/lenses/user_data.js +144 -77
  275. package/dist/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
  276. package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts +12 -14
  277. package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts.map +1 -1
  278. package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js +24 -17
  279. package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js.map +1 -1
  280. package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts +14 -18
  281. package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts.map +1 -1
  282. package/dist/generated-proto/pb_schema/snapdoc/extensions.js +29 -18
  283. package/dist/generated-proto/pb_schema/snapdoc/extensions.js.map +1 -1
  284. package/dist/generated-proto/pb_schema/snapdoc/media.d.ts +52 -576
  285. package/dist/generated-proto/pb_schema/snapdoc/media.d.ts.map +1 -1
  286. package/dist/generated-proto/pb_schema/snapdoc/media.js +615 -318
  287. package/dist/generated-proto/pb_schema/snapdoc/media.js.map +1 -1
  288. package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.d.ts.map +1 -1
  289. package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js +0 -6
  290. package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js.map +1 -1
  291. package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.d.ts.map +1 -1
  292. package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js +0 -6
  293. package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js.map +1 -1
  294. package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts +12 -12
  295. package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts.map +1 -1
  296. package/dist/generated-proto/pb_schema/snapdoc/media_id.js +17 -17
  297. package/dist/generated-proto/pb_schema/snapdoc/media_id.js.map +1 -1
  298. package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.d.ts.map +1 -1
  299. package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js +0 -6
  300. package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js.map +1 -1
  301. package/dist/handlers/cameraKitServiceFetchHandlerFactory.d.ts.map +1 -1
  302. package/dist/handlers/cameraKitServiceFetchHandlerFactory.js +1 -1
  303. package/dist/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -1
  304. package/dist/handlers/defaultFetchHandler.js +1 -1
  305. package/dist/handlers/defaultFetchHandler.js.map +1 -1
  306. package/dist/handlers/requestStateEmittingHandler.js +1 -1
  307. package/dist/handlers/requestStateEmittingHandler.js.map +1 -1
  308. package/dist/index.d.ts +3 -4
  309. package/dist/index.d.ts.map +1 -1
  310. package/dist/index.js +2 -3
  311. package/dist/index.js.map +1 -1
  312. package/dist/legal/legalPrompt.js +1 -1
  313. package/dist/legal/legalPrompt.js.map +1 -1
  314. package/dist/legal/legalState.js +1 -1
  315. package/dist/legal/legalState.js.map +1 -1
  316. package/dist/lens/LensPersistenceStore.js +1 -1
  317. package/dist/lens/LensPersistenceStore.js.map +1 -1
  318. package/dist/lens/LensRepository.js +1 -1
  319. package/dist/lens/LensRepository.js.map +1 -1
  320. package/dist/lens/LensSource.js +1 -1
  321. package/dist/lens/LensSource.js.map +1 -1
  322. package/dist/lens/assets/LensAssetRepository.js +1 -1
  323. package/dist/lens/assets/LensAssetRepository.js.map +1 -1
  324. package/dist/lens/assets/LensAssetsProvider.js +1 -1
  325. package/dist/lens/assets/LensAssetsProvider.js.map +1 -1
  326. package/dist/lens/assets/deviceDependentAssetLoader.js +1 -1
  327. package/dist/lens/assets/deviceDependentAssetLoader.js.map +1 -1
  328. package/dist/lens/assets/remoteMediaAssetLoaderFactory.js +1 -1
  329. package/dist/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -1
  330. package/dist/lens/assets/staticAssetLoader.js +1 -1
  331. package/dist/lens/assets/staticAssetLoader.js.map +1 -1
  332. package/dist/lens/cameraKitLensSource.d.ts.map +1 -1
  333. package/dist/lens/cameraKitLensSource.js +6 -6
  334. package/dist/lens/cameraKitLensSource.js.map +1 -1
  335. package/dist/lens/fetchWatermarkLens.d.ts.map +1 -1
  336. package/dist/lens/fetchWatermarkLens.js +1 -1
  337. package/dist/lens/fetchWatermarkLens.js.map +1 -1
  338. package/dist/lens/userDataAccessResolver.d.ts +52 -0
  339. package/dist/lens/userDataAccessResolver.d.ts.map +1 -0
  340. package/dist/lens/userDataAccessResolver.js +3 -0
  341. package/dist/lens/userDataAccessResolver.js.map +1 -0
  342. package/dist/lens-client-interface/filePicker.d.ts.map +1 -1
  343. package/dist/lens-client-interface/filePicker.js +1 -1
  344. package/dist/lens-client-interface/filePicker.js.map +1 -1
  345. package/dist/lens-client-interface/lensClientInterface.js +1 -1
  346. package/dist/lens-client-interface/lensClientInterface.js.map +1 -1
  347. package/dist/lens-core-module/loader/lensCoreFactory.d.ts.map +1 -1
  348. package/dist/lens-core-module/loader/lensCoreFactory.js +1 -1
  349. package/dist/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  350. package/dist/lensCoreWasmVersions.js +3 -3
  351. package/dist/lensCoreWasmVersions.js.map +1 -1
  352. package/dist/logger/logEntries.js +1 -1
  353. package/dist/logger/logEntries.js.map +1 -1
  354. package/dist/logger/registerLogEntriesSubscriber.d.ts.map +1 -1
  355. package/dist/logger/registerLogEntriesSubscriber.js +1 -1
  356. package/dist/logger/registerLogEntriesSubscriber.js.map +1 -1
  357. package/dist/media-sources/CameraKitSource.d.ts +6 -0
  358. package/dist/media-sources/CameraKitSource.d.ts.map +1 -1
  359. package/dist/media-sources/CameraKitSource.js +2 -2
  360. package/dist/media-sources/CameraKitSource.js.map +1 -1
  361. package/dist/metrics/businessEventsReporter.js +1 -1
  362. package/dist/metrics/businessEventsReporter.js.map +1 -1
  363. package/dist/metrics/metricsEventTarget.js +1 -1
  364. package/dist/metrics/metricsEventTarget.js.map +1 -1
  365. package/dist/metrics/reporters/reportBenchmarks.d.ts.map +1 -1
  366. package/dist/metrics/reporters/reportBenchmarks.js +1 -1
  367. package/dist/metrics/reporters/reportBenchmarks.js.map +1 -1
  368. package/dist/metrics/reporters/reportGlobalException.js +1 -1
  369. package/dist/metrics/reporters/reportGlobalException.js.map +1 -1
  370. package/dist/metrics/reporters/reportHttpMetrics.js +1 -1
  371. package/dist/metrics/reporters/reportHttpMetrics.js.map +1 -1
  372. package/dist/metrics/reporters/reportLegalState.js +1 -1
  373. package/dist/metrics/reporters/reportLegalState.js.map +1 -1
  374. package/dist/metrics/reporters/reportLensAndAssetDownload.d.ts.map +1 -1
  375. package/dist/metrics/reporters/reportLensAndAssetDownload.js +1 -1
  376. package/dist/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
  377. package/dist/metrics/reporters/reportLensValidationFailed.js +1 -1
  378. package/dist/metrics/reporters/reportLensValidationFailed.js.map +1 -1
  379. package/dist/metrics/reporters/reportLensView.js +1 -1
  380. package/dist/metrics/reporters/reportLensView.js.map +1 -1
  381. package/dist/metrics/reporters/reportLensWait.js +1 -1
  382. package/dist/metrics/reporters/reportLensWait.js.map +1 -1
  383. package/dist/metrics/reporters/reportPlatformCapabilities.d.ts.map +1 -1
  384. package/dist/metrics/reporters/reportPlatformCapabilities.js +1 -1
  385. package/dist/metrics/reporters/reportPlatformCapabilities.js.map +1 -1
  386. package/dist/metrics/reporters/reportSessionException.js +1 -1
  387. package/dist/metrics/reporters/reportSessionException.js.map +1 -1
  388. package/dist/metrics/reporters/reportUserSession.js +1 -1
  389. package/dist/metrics/reporters/reportUserSession.js.map +1 -1
  390. package/dist/metrics/reporters/reporters.d.ts +1 -1
  391. package/dist/metrics/reporters/reporters.d.ts.map +1 -1
  392. package/dist/metrics/reporters/reporters.js +1 -1
  393. package/dist/metrics/reporters/reporters.js.map +1 -1
  394. package/dist/remote-configuration/cofHandler.d.ts.map +1 -1
  395. package/dist/remote-configuration/cofHandler.js +1 -1
  396. package/dist/remote-configuration/cofHandler.js.map +1 -1
  397. package/dist/remote-configuration/preloadConfiguration.js +1 -1
  398. package/dist/remote-configuration/preloadConfiguration.js.map +1 -1
  399. package/dist/remote-configuration/remoteConfiguration.d.ts.map +1 -1
  400. package/dist/remote-configuration/remoteConfiguration.js +1 -1
  401. package/dist/remote-configuration/remoteConfiguration.js.map +1 -1
  402. package/dist/session/CameraKitSession.d.ts +6 -1
  403. package/dist/session/CameraKitSession.d.ts.map +1 -1
  404. package/dist/session/CameraKitSession.js +1 -1
  405. package/dist/session/CameraKitSession.js.map +1 -1
  406. package/dist/session/LensKeyboard.js +1 -1
  407. package/dist/session/LensKeyboard.js.map +1 -1
  408. package/dist/session/lensState.d.ts +3 -2
  409. package/dist/session/lensState.d.ts.map +1 -1
  410. package/dist/session/lensState.js +9 -3
  411. package/dist/session/lensState.js.map +1 -1
  412. package/dist/session/sessionState.js +1 -1
  413. package/dist/session/sessionState.js.map +1 -1
  414. package/docs/html/assets/navigation.js +1 -1
  415. package/docs/html/assets/search.js +1 -1
  416. package/docs/html/classes/CameraKit.html +2 -2
  417. package/docs/html/classes/CameraKitSession.html +7 -3
  418. package/docs/html/classes/CameraKitSource.html +6 -2
  419. package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
  420. package/docs/html/classes/LensPerformanceMetrics.html +2 -2
  421. package/docs/html/classes/LensRepository.html +2 -2
  422. package/docs/html/classes/Transform2D.html +2 -2
  423. package/docs/html/classes/TypedCustomEvent.html +2 -2
  424. package/docs/html/classes/TypedEventTarget.html +2 -2
  425. package/docs/html/enums/Lens_CameraFacing.html +2 -2
  426. package/docs/html/functions/bootstrapCameraKit.html +2 -2
  427. package/docs/html/functions/createExtension.html +2 -2
  428. package/docs/html/functions/createImageSource.html +2 -2
  429. package/docs/html/functions/createMediaStreamSource.html +2 -2
  430. package/docs/html/functions/createVideoSource.html +2 -2
  431. package/docs/html/functions/estimateLensPerformance.html +2 -2
  432. package/docs/html/functions/filePickerFactory.html +2 -4
  433. package/docs/html/functions/lensSourcesFactory.html +3 -5
  434. package/docs/html/functions/remoteApiServicesFactory.html +1 -3
  435. package/docs/html/hierarchy.html +1 -1
  436. package/docs/html/index.html +3 -3
  437. package/docs/html/interfaces/BitmojiUserInfo.html +2 -2
  438. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
  439. package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
  440. package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
  441. package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
  442. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
  443. package/docs/html/interfaces/CreateSessionOptions.html +2 -2
  444. package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
  445. package/docs/html/interfaces/FriendUserInfo.html +2 -2
  446. package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
  447. package/docs/html/interfaces/Lens.html +2 -2
  448. package/docs/html/interfaces/LensCreator.html +2 -2
  449. package/docs/html/interfaces/LensLaunchData.html +2 -2
  450. package/docs/html/interfaces/LensSource.html +2 -2
  451. package/docs/html/interfaces/LensUserData.html +2 -2
  452. package/docs/html/interfaces/LoadAssetRequest.html +2 -2
  453. package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
  454. package/docs/html/interfaces/Preview.html +2 -2
  455. package/docs/html/interfaces/RemoteApiRequest.html +2 -2
  456. package/docs/html/interfaces/RemoteApiResponse.html +2 -2
  457. package/docs/html/interfaces/RemoteApiService.html +2 -2
  458. package/docs/html/interfaces/Snapcode.html +2 -2
  459. package/docs/html/interfaces/UriCancelRequest.html +2 -2
  460. package/docs/html/interfaces/UriRequest.html +2 -2
  461. package/docs/html/interfaces/UriResponse.html +2 -2
  462. package/docs/html/interfaces/VideoSourceOptions.html +2 -2
  463. package/docs/html/modules.html +2 -4
  464. package/docs/html/types/ArgumentValidationError.html +2 -2
  465. package/docs/html/types/AssetLoader.html +2 -2
  466. package/docs/html/types/AssetResponse.html +1 -1
  467. package/docs/html/types/AssetTiming.html +2 -2
  468. package/docs/html/types/BenchmarkError.html +1 -1
  469. package/docs/html/types/BootstrapError.html +2 -2
  470. package/docs/html/types/CacheKeyNotFoundError.html +1 -1
  471. package/docs/html/types/CameraKitSessionEventListener.html +2 -2
  472. package/docs/html/types/CameraKitSessionEvents.html +2 -2
  473. package/docs/html/types/CameraKitSourceError.html +1 -1
  474. package/docs/html/types/ConfigurationError.html +2 -2
  475. package/docs/html/types/FetchHandler.html +1 -1
  476. package/docs/html/types/FilePicker.html +2 -2
  477. package/docs/html/types/FilePickerOptions.html +2 -2
  478. package/docs/html/types/FilePickerResult.html +2 -2
  479. package/docs/html/types/Keyboard.html +2 -2
  480. package/docs/html/types/KeyboardEvents.html +2 -2
  481. package/docs/html/types/LegalError.html +1 -1
  482. package/docs/html/types/LensAbortError.html +2 -2
  483. package/docs/html/types/LensAssetError.html +2 -2
  484. package/docs/html/types/LensContentValidationError.html +1 -1
  485. package/docs/html/types/LensError.html +1 -1
  486. package/docs/html/types/LensExecutionError.html +2 -2
  487. package/docs/html/types/LensImagePickerError.html +2 -2
  488. package/docs/html/types/LensLaunchParams.html +2 -2
  489. package/docs/html/types/LensMetricsEvents.html +2 -2
  490. package/docs/html/types/LensPerformanceCluster.html +1 -1
  491. package/docs/html/types/LensView.html +2 -2
  492. package/docs/html/types/LensWait.html +2 -2
  493. package/docs/html/types/Matrix.html +2 -2
  494. package/docs/html/types/PersistentStoreError.html +2 -2
  495. package/docs/html/types/PlatformNotSupportedError.html +2 -2
  496. package/docs/html/types/PublicContainer.html +2 -2
  497. package/docs/html/types/PublicServices.html +2 -2
  498. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
  499. package/docs/html/types/RemoteApiRequestHandler.html +2 -2
  500. package/docs/html/types/RemoteApiServices.html +1 -1
  501. package/docs/html/types/RemoteApiStatus.html +2 -2
  502. package/docs/html/types/RenderTarget.html +2 -2
  503. package/docs/html/types/Uri.html +1 -1
  504. package/docs/html/types/WebGLError.html +1 -1
  505. package/docs/html/types/Zodiac.html +1 -1
  506. package/docs/html/variables/extensionRequestContext.html +2 -2
  507. package/docs/md/README.md +1 -1
  508. package/docs/md/classes/CameraKit.md +1 -1
  509. package/docs/md/classes/CameraKitSession.md +7 -2
  510. package/docs/md/classes/CameraKitSource.md +6 -1
  511. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  512. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  513. package/docs/md/classes/LensRepository.md +1 -1
  514. package/docs/md/classes/Transform2D.md +1 -1
  515. package/docs/md/classes/TypedCustomEvent.md +1 -1
  516. package/docs/md/classes/TypedEventTarget.md +1 -1
  517. package/docs/md/enums/Lens_CameraFacing.md +1 -1
  518. package/docs/md/interfaces/BitmojiUserInfo.md +1 -1
  519. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  520. package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
  521. package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
  522. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  523. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  524. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  525. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  526. package/docs/md/interfaces/FriendUserInfo.md +1 -1
  527. package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
  528. package/docs/md/interfaces/Lens.md +1 -1
  529. package/docs/md/interfaces/LensCreator.md +1 -1
  530. package/docs/md/interfaces/LensLaunchData.md +1 -1
  531. package/docs/md/interfaces/LensSource.md +1 -1
  532. package/docs/md/interfaces/LensUserData.md +1 -1
  533. package/docs/md/interfaces/LoadAssetRequest.md +1 -1
  534. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  535. package/docs/md/interfaces/Preview.md +1 -1
  536. package/docs/md/interfaces/RemoteApiRequest.md +1 -1
  537. package/docs/md/interfaces/RemoteApiResponse.md +1 -1
  538. package/docs/md/interfaces/RemoteApiService.md +1 -1
  539. package/docs/md/interfaces/Snapcode.md +1 -1
  540. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  541. package/docs/md/interfaces/UriRequest.md +1 -1
  542. package/docs/md/interfaces/UriResponse.md +1 -1
  543. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  544. package/docs/md/modules.md +5 -166
  545. package/package.json +5 -5
  546. package/dist/dependency-injection/Container.d.ts +0 -177
  547. package/dist/dependency-injection/Container.d.ts.map +0 -1
  548. package/dist/dependency-injection/Container.js +0 -72
  549. package/dist/dependency-injection/Container.js.map +0 -1
  550. package/dist/dependency-injection/Injectable.d.ts +0 -96
  551. package/dist/dependency-injection/Injectable.d.ts.map +0 -1
  552. package/dist/dependency-injection/Injectable.js +0 -37
  553. package/dist/dependency-injection/Injectable.js.map +0 -1
  554. package/dist/dependency-injection/PartialContainer.d.ts +0 -86
  555. package/dist/dependency-injection/PartialContainer.d.ts.map +0 -1
  556. package/dist/dependency-injection/PartialContainer.js +0 -28
  557. package/dist/dependency-injection/PartialContainer.js.map +0 -1
  558. package/dist/dependency-injection/RootServices.d.ts +0 -76
  559. package/dist/dependency-injection/RootServices.d.ts.map +0 -1
  560. package/dist/dependency-injection/RootServices.js.map +0 -1
  561. package/dist/dependency-injection/types.d.ts +0 -57
  562. package/dist/dependency-injection/types.d.ts.map +0 -1
  563. package/dist/dependency-injection/types.js +0 -2
  564. package/dist/dependency-injection/types.js.map +0 -1
  565. package/docs/html/functions/ConcatInjectable.html +0 -19
  566. package/docs/html/functions/Injectable.html +0 -17
  567. /package/dist/{dependency-injection/RootServices.js → RootServices.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  export default {
2
- version: "281",
3
- buildNumber: "404",
4
- baseUrl: "https://cf-st.sc-cdn.net/d/WEdh9uNS2aPmOYgaM1M1r?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92",
2
+ version: "285",
3
+ buildNumber: "435",
4
+ baseUrl: "https://cf-st.sc-cdn.net/d/cLSplk9up0w6P1GYxKklJ?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92",
5
5
  };
6
6
  //# sourceMappingURL=lensCoreWasmVersions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lensCoreWasmVersions.js","sourceRoot":"","sources":["../src/lensCoreWasmVersions.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,oFAAoF;CAChG,CAAC","sourcesContent":["export default {\n version: \"281\",\n buildNumber: \"404\",\n baseUrl: \"https://cf-st.sc-cdn.net/d/WEdh9uNS2aPmOYgaM1M1r?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92\",\n};\n"]}
1
+ {"version":3,"file":"lensCoreWasmVersions.js","sourceRoot":"","sources":["../src/lensCoreWasmVersions.ts"],"names":[],"mappings":"AAAA,eAAe;IACX,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,oFAAoF;CAChG,CAAC","sourcesContent":["export default {\n version: \"285\",\n buildNumber: \"435\",\n baseUrl: \"https://cf-st.sc-cdn.net/d/cLSplk9up0w6P1GYxKklJ?go=IgsKCTIBBEgBUFxgAQ%3D%3D&uc=92\",\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { Injectable } from "../dependency-injection/Injectable";
1
+ import { Injectable } from "@snap/ts-inject";
2
2
  import { resetLogger } from "./logger";
3
3
  export const logEntriesFactory = Injectable("logEntries", () => resetLogger().asObservable());
4
4
  //# sourceMappingURL=logEntries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logEntries.js","sourceRoot":"","sources":["../../src/logger/logEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAYvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC","sourcesContent":["import { Injectable } from \"../dependency-injection/Injectable\";\nimport { resetLogger } from \"./logger\";\n\n/**\n * The factory creates new logEntries subject.\n *\n * NOTE: The factory calls `resetLogger()`, which overrides the global `logEntrySubject`.\n * This is currently necessary to avoid sharing the same subject between multiple `CameraKit` instances.\n * In the future, we may throw an error when bootstrapping more than a single `CameraKit`,\n * that will allow us to have a single log entry subject.\n *\n * @internal\n */\nexport const logEntriesFactory = Injectable(\"logEntries\", () => resetLogger().asObservable());\n"]}
1
+ {"version":3,"file":"logEntries.js","sourceRoot":"","sources":["../../src/logger/logEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAYvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { resetLogger } from \"./logger\";\n\n/**\n * The factory creates new logEntries subject.\n *\n * NOTE: The factory calls `resetLogger()`, which overrides the global `logEntrySubject`.\n * This is currently necessary to avoid sharing the same subject between multiple `CameraKit` instances.\n * In the future, we may throw an error when bootstrapping more than a single `CameraKit`,\n * that will allow us to have a single log entry subject.\n *\n * @internal\n */\nexport const logEntriesFactory = Injectable(\"logEntries\", () => resetLogger().asObservable());\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"registerLogEntriesSubscriber.d.ts","sourceRoot":"","sources":["../../src/logger/registerLogEntriesSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAK/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;;;;CAyBxC,CAAC"}
1
+ {"version":3,"file":"registerLogEntriesSubscriber.d.ts","sourceRoot":"","sources":["../../src/logger/registerLogEntriesSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B;;;;CAyBxC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { filter } from "rxjs";
2
+ import { Injectable } from "@snap/ts-inject";
2
3
  import { stringifyError } from "../common/errorHelpers";
3
4
  import { configurationToken } from "../configuration";
4
- import { Injectable } from "../dependency-injection/Injectable";
5
5
  import { getPlatformInfo } from "../platform/platformInfo";
6
6
  import { logEntriesFactory } from "./logEntries";
7
7
  import { logLevelMap } from "./logger";
@@ -1 +1 @@
1
- {"version":3,"file":"registerLogEntriesSubscriber.js","sourceRoot":"","sources":["../../src/logger/registerLogEntriesSubscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQvC,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAClD,8BAA8B,EAC9B,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,KAAK,CAAU,EACtD,CAAC,aAAqC,EAAE,UAAgC,EAAE,EAAE;IACxE,UAAU;SACL,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;SACxF,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpB,QAAQ,aAAa,CAAC,MAAM,EAAE;YAC1B,KAAK,SAAS;gBAGV,MAAM,QAAQ,GACV,eAAe,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ;oBACxC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;wBAC9B,IAAI,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;4BAAE,OAAO,OAAO,CAAC;wBAChD,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;wBACxC,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACJ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAE5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,cAAc,QAAQ,CAAC,MAAM,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC;gBACvE,MAAM;SACb;IACL,CAAC,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import type { Observable } from \"rxjs\";\nimport { filter } from \"rxjs\";\nimport { stringifyError } from \"../common/errorHelpers\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\nimport { logEntriesFactory } from \"./logEntries\";\nimport type { LogEntry } from \"./logger\";\nimport { logLevelMap } from \"./logger\";\n\n/**\n * The factory subscribes to log entry events and, based on the configured log level,\n * forwards matching log entries to the logger specified in the CameraKit configuration object.\n *\n * @internal\n */\nexport const registerLogEntriesSubscriber = Injectable(\n \"registerLogEntriesSubscriber\",\n [configurationToken, logEntriesFactory.token] as const,\n (configuration: CameraKitConfiguration, logEntries: Observable<LogEntry>) => {\n logEntries\n .pipe(filter((entry) => logLevelMap[entry.level] >= logLevelMap[configuration.logLevel]))\n .subscribe((logEntry) => {\n switch (configuration.logger) {\n case \"console\":\n // Chrome doesn't print the `cause` Error property, so we need to manually construct a complete\n // stack trace using our `stringifyError` helper.\n const messages =\n getPlatformInfo().browser.brand === \"Chrome\"\n ? logEntry.messages.map((message) => {\n if (!(message instanceof Error)) return message;\n message.stack = stringifyError(message);\n return message;\n })\n : logEntry.messages;\n\n console[logEntry.level](`[CameraKit.${logEntry.module}]`, ...messages);\n break;\n }\n });\n }\n);\n"]}
1
+ {"version":3,"file":"registerLogEntriesSubscriber.js","sourceRoot":"","sources":["../../src/logger/registerLogEntriesSubscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAQvC,MAAM,CAAC,MAAM,4BAA4B,GAAG,UAAU,CAClD,8BAA8B,EAC9B,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,KAAK,CAAU,EACtD,CAAC,aAAqC,EAAE,UAAgC,EAAE,EAAE;IACxE,UAAU;SACL,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;SACxF,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE;QACpB,QAAQ,aAAa,CAAC,MAAM,EAAE;YAC1B,KAAK,SAAS;gBAGV,MAAM,QAAQ,GACV,eAAe,EAAE,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ;oBACxC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;wBAC9B,IAAI,CAAC,CAAC,OAAO,YAAY,KAAK,CAAC;4BAAE,OAAO,OAAO,CAAC;wBAChD,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;wBACxC,OAAO,OAAO,CAAC;oBACnB,CAAC,CAAC;oBACJ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBAE5B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,cAAc,QAAQ,CAAC,MAAM,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC;gBACvE,MAAM;SACb;IACL,CAAC,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import type { Observable } from \"rxjs\";\nimport { filter } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { stringifyError } from \"../common/errorHelpers\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\nimport { logEntriesFactory } from \"./logEntries\";\nimport type { LogEntry } from \"./logger\";\nimport { logLevelMap } from \"./logger\";\n\n/**\n * The factory subscribes to log entry events and, based on the configured log level,\n * forwards matching log entries to the logger specified in the CameraKit configuration object.\n *\n * @internal\n */\nexport const registerLogEntriesSubscriber = Injectable(\n \"registerLogEntriesSubscriber\",\n [configurationToken, logEntriesFactory.token] as const,\n (configuration: CameraKitConfiguration, logEntries: Observable<LogEntry>) => {\n logEntries\n .pipe(filter((entry) => logLevelMap[entry.level] >= logLevelMap[configuration.logLevel]))\n .subscribe((logEntry) => {\n switch (configuration.logger) {\n case \"console\":\n // Chrome doesn't print the `cause` Error property, so we need to manually construct a complete\n // stack trace using our `stringifyError` helper.\n const messages =\n getPlatformInfo().browser.brand === \"Chrome\"\n ? logEntry.messages.map((message) => {\n if (!(message instanceof Error)) return message;\n message.stack = stringifyError(message);\n return message;\n })\n : logEntry.messages;\n\n console[logEntry.level](`[CameraKit.${logEntry.module}]`, ...messages);\n break;\n }\n });\n }\n);\n"]}
@@ -61,6 +61,12 @@ export interface CameraKitSourceInfo {
61
61
  * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior
62
62
  * that will occur when the source is attached and detached. This can be used to e.g. update the render size.
63
63
  *
64
+ * **Important:** Once a source has been attached to a {@link CameraKitSession}, it cannot be reattached,
65
+ * even if it has been detached. You must supply a new instance of {@link CameraKitSource} to {@link
66
+ * CameraKitSession.setSource}.
67
+ * If you want to reuse the existing source, you can use its {@link CameraKitSource.copy} method to create a new
68
+ * instance.
69
+ *
64
70
  * @category Rendering
65
71
  */
66
72
  declare class CameraKitSource {
@@ -1 +1 @@
1
- {"version":3,"file":"CameraKitSource.d.ts","sourceRoot":"","sources":["../../src/media-sources/CameraKitSource.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAG7D,eAAO,MAAM,iBAAiB,EAAE,sBAG/B,CAAC;AAKF;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAChB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAClC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAWD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED,wBAAgB,0CAA0C,CACtD,KAAK,EAAE,OAAO,GACf,KAAK,IAAI,OAAO,CAAC,sBAAsB,CAAC,GAAG,SAAS,CAEtD;AAcD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACnC;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,aAAa,CAAC;IAEnC;;;;OAIG;IACH,QA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AAC;KACpC,CAAC;CACL;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,cAAM,eAAe;IAKb,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL/B,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;gBAG/B,UAAU,EAAE,mBAAmB,EAC/B,UAAU,GAAE,yBAA8B,EAC3D,UAAU,GAAE,OAAO,CAAC,sBAAsB,CAAM;IAKpD;;;;;;;OAOG;IACG,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BpF;;;;;OAKG;IACH,IAAI,CAAC,UAAU,GAAE,OAAO,CAAC,sBAAsB,CAAM,GAAG,eAAe;IAIvE;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IAEH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D;;;;OAIG;IAEH,YAAY,CAAC,SAAS,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAKtD;AAGD,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -41,8 +41,8 @@ let CameraKitSource = (() => {
41
41
  attach(lensCore, reportError) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  if (this.lensCore) {
44
- throw new Error("Cannot attach. This CameraKitCustomSource has already been attached to " +
45
- "a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.");
44
+ throw new Error("This CameraKitSource has already been attached to this CameraKitSession " +
45
+ "and cannot be reattached, even after detachment.");
46
46
  }
47
47
  this.lensCore = lensCore;
48
48
  yield lensCore.useMediaElement({
@@ -1 +1 @@
1
- {"version":3,"file":"CameraKitSource.js","sourceRoot":"","sources":["../../src/media-sources/CameraKitSource.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,iBAAiB,GAA2B;IACrD,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM,CAAC,iBAAiB;CACrC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAE,EAAE,CAC/C,IAAI,KAAK,CAAC,GAAG,OAAO,+DAA+D,CAAC,CAAC;AAmBzF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAC9B,MAAM,CAAC,IAAI,CAAC;IACR,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,CAAC;CACe,CAAiB,CACrD,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,OAAO,KAAK,YAAY,eAAe,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,0CAA0C,CACtD,KAAc;IAEd,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,+BAA+B,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,+BAA+B,CAAC,KAAc;IACnD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,uBAAuB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAChC,OAAO,kBAAkB,CAAC,GAAG,CAAC,KAAmB,CAAC,CAAC;AACvD,CA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AC;gBAClD,OAAO,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACvD,CAAC;;;yCAjBA,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;wCAYtC,QAAQ,CAAC,aAAa,CAAC;YAXxB,wLAAA,aAAa,wCAIZ;YAQD,qLAAA,YAAY,wCAIX;;;;AAIL,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n\nimport { copyDefinedProperties } from \"../common/copyDefinedProperties\";\nimport { isRecord, isUndefined, isValidNumber, isValidNumberOrUndefined } from \"../common/typeguards\";\nimport { validate } from \"../common/validate\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { Transform2D } from \"../transforms/Transform2D\";\nimport { isTransform2D } from \"../transforms/Transform2D\";\n\nexport const defaultDeviceInfo: CameraKitDeviceOptions = {\n cameraType: \"user\",\n fpsLimit: Number.POSITIVE_INFINITY,\n};\n\nconst createNotAttachedError = (message: string) =>\n new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);\n\n/**\n * When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will\n * run whenever that source is attached/detached from a CameraKitSession.\n *\n * @category Rendering\n */\nexport interface CameraKitSourceSubscriber {\n readonly onAttach?: (\n source: CameraKitSource,\n lensCore: LensCore,\n reportError: (error: Error) => void\n ) => void | Promise<void>;\n readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;\n}\n\n// Helper set to ensure that changes to cameraType will ensure changes to the guard.\ntype CameraType = CameraKitDeviceOptions[\"cameraType\"];\nconst cameraTypeValueSet = new Set(\n Object.keys({\n user: 0,\n environment: 0,\n } satisfies Record<CameraType, 0>) as CameraType[]\n);\n\nexport function isCameraKitSource(value: unknown): value is CameraKitSource {\n return value instanceof CameraKitSource;\n}\n\nexport function isPartialCameraKitDeviceOptionsOrUndefined(\n value: unknown\n): value is Partial<CameraKitDeviceOptions> | undefined {\n return isUndefined(value) || isPartialCameraKitDeviceOptions(value);\n}\n\nfunction isPartialCameraKitDeviceOptions(value: unknown): value is Partial<CameraKitDeviceOptions> {\n return isRecord(value) && isCameraTypeOrUndefined(value.cameraType) && isValidNumberOrUndefined(value.fpsLimit);\n}\n\nfunction isCameraType(value: unknown): value is CameraType {\n return cameraTypeValueSet.has(value as CameraType);\n}\n\nfunction isCameraTypeOrUndefined(value: unknown): value is CameraType | undefined {\n return isUndefined(value) || isCameraType(value);\n}\n\n/**\n * Device options.\n *\n * @category Rendering\n */\nexport interface CameraKitDeviceOptions {\n /**\n * Specifies the camera type for which certain features are enabled or disabled.\n * For example, surface tracking features are only active when the camera is set to \"environment\" mode.\n * The default value is \"user\", which accommodates the majority of Lenses.\n * \"user\" refers to the front-facing camera, while \"environment\" refers to the rear-facing camera.\n */\n cameraType: \"user\" | \"environment\";\n\n /**\n * Limits the frames per second (FPS) to optimize performance by reducing compute resources\n * when high FPS is not critical. By default, no limit is set, allowing usage of the video's native FPS.\n * Useful for controlling resource usage on varying device capabilities.\n */\n fpsLimit: number;\n}\n\n/** @category Rendering */\nexport interface CameraKitSourceInfo {\n /**\n * HTML element or MediaStream as an input source.\n * If useManualFrameProcessing is true, then this parameter is optional.\n */\n media?: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | MediaStream;\n\n /**\n * Whether to provide frames manually.\n */\n useManualFrameProcessing?: boolean;\n\n /**\n * If specified, the passed-in tracking data buffer will be used as tracking data for the current\n * media element instead of live tracking data.\n */\n replayTrackingData?: {\n buffer: Uint8Array | ArrayBuffer;\n };\n}\n\n/**\n * This general-purpose class represents a source of media for a {@link CameraKitSession}.\n *\n * When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be \"attached\"\n * to the session. Later it may be \"detached\" from the session.\n *\n * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior\n * that will occur when the source is attached and detached. This can be used to e.g. update the render size.\n *\n * @category Rendering\n */\nclass CameraKitSource {\n private lensCore?: LensCore;\n private readonly deviceInfo: CameraKitDeviceOptions;\n\n constructor(\n private readonly sourceInfo: CameraKitSourceInfo,\n private readonly subscriber: CameraKitSourceSubscriber = {},\n deviceInfo: Partial<CameraKitDeviceOptions> = {}\n ) {\n this.deviceInfo = { ...defaultDeviceInfo, ...copyDefinedProperties(deviceInfo) };\n }\n\n /**\n * Called by {@link CameraKitSession} when this source is set as that session's source.\n *\n * @param lensCore\n * @param reportError Calling this function will report an error back to the session.\n * @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.\n * @internal\n */\n async attach(lensCore: LensCore, reportError: (error: Error) => void): Promise<void> {\n if (this.lensCore) {\n throw new Error(\n \"Cannot attach. This CameraKitCustomSource has already been attached to \" +\n \"a CameraKitSession. To re-attach, create a copy of this CameraKitCustomSource.\"\n );\n }\n\n this.lensCore = lensCore;\n\n await lensCore.useMediaElement({\n autoplayNewMedia: false,\n autoplayPreviewCanvas: false,\n media: this.sourceInfo.media,\n pauseExistingMedia: false,\n replayTrackingData: this.sourceInfo.replayTrackingData,\n requestWebcam: false,\n startOnFrontCamera: [\"user\", \"front\"].includes(this.deviceInfo.cameraType),\n useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,\n });\n\n // LensCore uses 0 to remove the limit.\n const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;\n await lensCore.setFPSLimit({ fps });\n await lensCore.setRenderSize({ mode: \"matchInputResolution\" });\n\n if (this.subscriber.onAttach) await this.subscriber.onAttach(this, lensCore, reportError);\n }\n\n /**\n * Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.\n *\n * @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).\n * @returns The new {@link CameraKitSource}\n */\n copy(deviceInfo: Partial<CameraKitDeviceOptions> = {}): CameraKitSource {\n return new CameraKitSource(this.sourceInfo, this.subscriber, { ...this.deviceInfo, ...deviceInfo });\n }\n\n /**\n * Called by {@link CameraKitSession} when it must remove this source.\n *\n * @param reportError Calling this function will report an error back to the session.\n * @returns\n * @internal\n */\n detach(reportError: (error: Error) => void): void | Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot detach\"));\n if (this.subscriber.onDetach) return this.subscriber.onDetach(reportError);\n }\n\n /**\n * Set the resolution used to render this source.\n *\n * If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including\n * loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).\n *\n * By default (i.e. if this method is never called), then the render size will match the size of the input media.\n * Best performance can be achieved by varying the size of the input media and allowing CameraKit to render at a\n * resolution that matches the input media -- this method should only be used if the input media resolution cannot\n * be changed to the desired size.\n *\n * It’s important to distinguish render size from display size. The size at which the output canvases are displayed\n * on a web page is determined by the CSS of the page. It is distinct from the size at which CameraKit renders\n * Lenses. Performance is dominated by render size, while any display scaling (using CSS) can most often be thought\n * of as free.\n *\n * The size of the Live and Capture {@link RenderTarget} is always the same.\n *\n * @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This\n * constraint should be removed, so callers don't have to understand the underlying LensCore state machine.\n *\n * @param width pixels\n * @param height pixels\n * @returns Promise resolves when the render size has been successfully updated.\n */\n @validate(isValidNumber, isValidNumber)\n setRenderSize(width: number, height: number): Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot setRenderSize\"));\n const target = { width, height };\n return this.lensCore.setRenderSize({ mode: \"explicit\", target });\n }\n\n /**\n * Apply a 2D transformation to the source (e.g. translation, rotation, scale).\n *\n * @param transform Specifies the 3x3 matrix describing the transformation.\n */\n @validate(isTransform2D)\n setTransform(transform: Transform2D): Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot setTransform\"));\n const matrix = new Float32Array(transform.matrix);\n return this.lensCore.setInputTransform({ matrix });\n }\n}\n\n// NOTE: jest doesn't like default exports of classes with decorated methods.\nexport { CameraKitSource };\n"]}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,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YACvD,CAAC;;;yCAjBA,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;wCAYtC,QAAQ,CAAC,aAAa,CAAC;YAXxB,wLAAA,aAAa,wCAIZ;YAQD,qLAAA,YAAY,wCAIX;;;;AAIL,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/member-ordering */\n\nimport { copyDefinedProperties } from \"../common/copyDefinedProperties\";\nimport { isRecord, isUndefined, isValidNumber, isValidNumberOrUndefined } from \"../common/typeguards\";\nimport { validate } from \"../common/validate\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { Transform2D } from \"../transforms/Transform2D\";\nimport { isTransform2D } from \"../transforms/Transform2D\";\n\nexport const defaultDeviceInfo: CameraKitDeviceOptions = {\n cameraType: \"user\",\n fpsLimit: Number.POSITIVE_INFINITY,\n};\n\nconst createNotAttachedError = (message: string) =>\n new Error(`${message}. This CameraKitSource is not attached to a CameraKitSession.`);\n\n/**\n * When creating a {@link CameraKitSource}, passing a CameraKitSourceSubscriber allows logic to implemented which will\n * run whenever that source is attached/detached from a CameraKitSession.\n *\n * @category Rendering\n */\nexport interface CameraKitSourceSubscriber {\n readonly onAttach?: (\n source: CameraKitSource,\n lensCore: LensCore,\n reportError: (error: Error) => void\n ) => void | Promise<void>;\n readonly onDetach?: (reportError: (error: Error) => void) => void | Promise<void>;\n}\n\n// Helper set to ensure that changes to cameraType will ensure changes to the guard.\ntype CameraType = CameraKitDeviceOptions[\"cameraType\"];\nconst cameraTypeValueSet = new Set(\n Object.keys({\n user: 0,\n environment: 0,\n } satisfies Record<CameraType, 0>) as CameraType[]\n);\n\nexport function isCameraKitSource(value: unknown): value is CameraKitSource {\n return value instanceof CameraKitSource;\n}\n\nexport function isPartialCameraKitDeviceOptionsOrUndefined(\n value: unknown\n): value is Partial<CameraKitDeviceOptions> | undefined {\n return isUndefined(value) || isPartialCameraKitDeviceOptions(value);\n}\n\nfunction isPartialCameraKitDeviceOptions(value: unknown): value is Partial<CameraKitDeviceOptions> {\n return isRecord(value) && isCameraTypeOrUndefined(value.cameraType) && isValidNumberOrUndefined(value.fpsLimit);\n}\n\nfunction isCameraType(value: unknown): value is CameraType {\n return cameraTypeValueSet.has(value as CameraType);\n}\n\nfunction isCameraTypeOrUndefined(value: unknown): value is CameraType | undefined {\n return isUndefined(value) || isCameraType(value);\n}\n\n/**\n * Device options.\n *\n * @category Rendering\n */\nexport interface CameraKitDeviceOptions {\n /**\n * Specifies the camera type for which certain features are enabled or disabled.\n * For example, surface tracking features are only active when the camera is set to \"environment\" mode.\n * The default value is \"user\", which accommodates the majority of Lenses.\n * \"user\" refers to the front-facing camera, while \"environment\" refers to the rear-facing camera.\n */\n cameraType: \"user\" | \"environment\";\n\n /**\n * Limits the frames per second (FPS) to optimize performance by reducing compute resources\n * when high FPS is not critical. By default, no limit is set, allowing usage of the video's native FPS.\n * Useful for controlling resource usage on varying device capabilities.\n */\n fpsLimit: number;\n}\n\n/** @category Rendering */\nexport interface CameraKitSourceInfo {\n /**\n * HTML element or MediaStream as an input source.\n * If useManualFrameProcessing is true, then this parameter is optional.\n */\n media?: HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | MediaStream;\n\n /**\n * Whether to provide frames manually.\n */\n useManualFrameProcessing?: boolean;\n\n /**\n * If specified, the passed-in tracking data buffer will be used as tracking data for the current\n * media element instead of live tracking data.\n */\n replayTrackingData?: {\n buffer: Uint8Array | ArrayBuffer;\n };\n}\n\n/**\n * This general-purpose class represents a source of media for a {@link CameraKitSession}.\n *\n * When an instance is passed to {@link CameraKitSession.setSource | CameraKitSession.setSource}, it will be \"attached\"\n * to the session. Later it may be \"detached\" from the session.\n *\n * Passing a {@link CameraKitSourceSubscriber} to the constructor allows callers to specify behavior\n * that will occur when the source is attached and detached. This can be used to e.g. update the render size.\n *\n * **Important:** Once a source has been attached to a {@link CameraKitSession}, it cannot be reattached,\n * even if it has been detached. You must supply a new instance of {@link CameraKitSource} to {@link\n * CameraKitSession.setSource}.\n * If you want to reuse the existing source, you can use its {@link CameraKitSource.copy} method to create a new\n * instance.\n *\n * @category Rendering\n */\nclass CameraKitSource {\n private lensCore?: LensCore;\n private readonly deviceInfo: CameraKitDeviceOptions;\n\n constructor(\n private readonly sourceInfo: CameraKitSourceInfo,\n private readonly subscriber: CameraKitSourceSubscriber = {},\n deviceInfo: Partial<CameraKitDeviceOptions> = {}\n ) {\n this.deviceInfo = { ...defaultDeviceInfo, ...copyDefinedProperties(deviceInfo) };\n }\n\n /**\n * Called by {@link CameraKitSession} when this source is set as that session's source.\n *\n * @param lensCore\n * @param reportError Calling this function will report an error back to the session.\n * @returns Rejects if any calls to LensCore or CameraKitSource.subscriber.onAttach fail.\n * @internal\n */\n async attach(lensCore: LensCore, reportError: (error: Error) => void): Promise<void> {\n if (this.lensCore) {\n throw new Error(\n \"This CameraKitSource has already been attached to this CameraKitSession \" +\n \"and cannot be reattached, even after detachment.\"\n );\n }\n\n this.lensCore = lensCore;\n\n await lensCore.useMediaElement({\n autoplayNewMedia: false,\n autoplayPreviewCanvas: false,\n media: this.sourceInfo.media,\n pauseExistingMedia: false,\n replayTrackingData: this.sourceInfo.replayTrackingData,\n requestWebcam: false,\n startOnFrontCamera: [\"user\", \"front\"].includes(this.deviceInfo.cameraType),\n useManualFrameProcessing: this.sourceInfo.useManualFrameProcessing,\n });\n\n // LensCore uses 0 to remove the limit.\n const fps = this.deviceInfo.fpsLimit < Number.POSITIVE_INFINITY ? this.deviceInfo.fpsLimit : 0;\n await lensCore.setFPSLimit({ fps });\n await lensCore.setRenderSize({ mode: \"matchInputResolution\" });\n\n if (this.subscriber.onAttach) await this.subscriber.onAttach(this, lensCore, reportError);\n }\n\n /**\n * Make a copy of the source, sharing the same {@link CameraKitSourceSubscriber}.\n *\n * @param deviceInfo Optionally provide new device info for the copy (e.g. to change the camera type).\n * @returns The new {@link CameraKitSource}\n */\n copy(deviceInfo: Partial<CameraKitDeviceOptions> = {}): CameraKitSource {\n return new CameraKitSource(this.sourceInfo, this.subscriber, { ...this.deviceInfo, ...deviceInfo });\n }\n\n /**\n * Called by {@link CameraKitSession} when it must remove this source.\n *\n * @param reportError Calling this function will report an error back to the session.\n * @returns\n * @internal\n */\n detach(reportError: (error: Error) => void): void | Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot detach\"));\n if (this.subscriber.onDetach) return this.subscriber.onDetach(reportError);\n }\n\n /**\n * Set the resolution used to render this source.\n *\n * If greater performance is required, a smaller render size may boost frame-rate. It does come at a cost, including\n * loss of accuracy in various tracking and computer-vision algorithms (since they'll be operating on fewer pixels).\n *\n * By default (i.e. if this method is never called), then the render size will match the size of the input media.\n * Best performance can be achieved by varying the size of the input media and allowing CameraKit to render at a\n * resolution that matches the input media -- this method should only be used if the input media resolution cannot\n * be changed to the desired size.\n *\n * It’s important to distinguish render size from display size. The size at which the output canvases are displayed\n * on a web page is determined by the CSS of the page. It is distinct from the size at which CameraKit renders\n * Lenses. Performance is dominated by render size, while any display scaling (using CSS) can most often be thought\n * of as free.\n *\n * The size of the Live and Capture {@link RenderTarget} is always the same.\n *\n * @todo Currently it's only valid to call `setRenderSize` after `CameraKitSession.play` has been called. This\n * constraint should be removed, so callers don't have to understand the underlying LensCore state machine.\n *\n * @param width pixels\n * @param height pixels\n * @returns Promise resolves when the render size has been successfully updated.\n */\n @validate(isValidNumber, isValidNumber)\n setRenderSize(width: number, height: number): Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot setRenderSize\"));\n const target = { width, height };\n return this.lensCore.setRenderSize({ mode: \"explicit\", target });\n }\n\n /**\n * Apply a 2D transformation to the source (e.g. translation, rotation, scale).\n *\n * @param transform Specifies the 3x3 matrix describing the transformation.\n */\n @validate(isTransform2D)\n setTransform(transform: Transform2D): Promise<void> {\n if (!this.lensCore) return Promise.reject(createNotAttachedError(\"Cannot setTransform\"));\n const matrix = new Float32Array(transform.matrix);\n return this.lensCore.setInputTransform({ matrix });\n }\n}\n\n// NOTE: jest doesn't like default exports of classes with decorated methods.\nexport { CameraKitSource };\n"]}
@@ -1,8 +1,8 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { v4 } from "uuid";
3
3
  import { catchError, combineLatestWith, from, fromEvent, map, merge, of, switchMap, take } from "rxjs";
4
+ import { Injectable } from "@snap/ts-inject";
4
5
  import { entries } from "../common/entries";
5
- import { Injectable } from "../dependency-injection/Injectable";
6
6
  import * as blizzard from "../generated-proto/blizzard/cameraKitEvents";
7
7
  import { getLogger } from "../logger/logger";
8
8
  import { metricsClientFactory } from "../clients/metricsClient";
@@ -1 +1 @@
1
- {"version":3,"file":"businessEventsReporter.js","sourceRoot":"","sources":["../../src/metrics/businessEventsReporter.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGhE,OAAO,KAAK,QAAQ,MAAM,6CAA6C,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAA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";\nimport type { Observable } from \"rxjs\";\nimport { catchError, combineLatestWith, from, fromEvent, map, merge, of, switchMap, take } from \"rxjs\";\nimport { entries } from \"../common/entries\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport type { EventOfType } from \"../events/TypedCustomEvent\";\nimport type { EventsFromTarget } from \"../events/TypedEventTarget\";\nimport * as blizzard from \"../generated-proto/blizzard/cameraKitEvents\";\nimport { getLogger } from \"../logger/logger\";\nimport type { MetricsClient } from \"../clients/metricsClient\";\nimport { metricsClientFactory } from \"../clients/metricsClient\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { RemoteConfiguration } from \"../remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport { ExpiringPersistence } from \"../persistence/ExpiringPersistence\";\nimport { convertDaysToSeconds } from \"../common/time\";\nimport type { ConnectionType } from \"../platform/platformInfo\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\nimport type { MetricsEventTarget } from \"./metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"./metricsEventTarget\";\n\nconst logger = getLogger(\"BusinessEventsReporter\");\n\ntype Nullables<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];\ntype UndefinedToOptional<T> = Partial<Pick<T, Nullables<T>>> & Omit<T, Nullables<T>>;\n\ntype CameraKitBusinessEvents = EventsFromTarget<MetricsEventTarget>[\"detail\"];\n\ntype MakeBlizzardEvent<E> = Omit<E, \"name\"> & { cameraKitEventBase: blizzard.CameraKitEventBase };\n\ntype CreateEventData<EventType extends EventsFromTarget<MetricsEventTarget>[\"type\"]> = (\n event: MakeBlizzardEvent<EventOfType<EventType, EventsFromTarget<MetricsEventTarget>>[\"detail\"]>\n) => [string, UndefinedToOptional<blizzard.ServerEventData>];\n\ntype EventHandlers = {\n [EventType in EventsFromTarget<MetricsEventTarget>[\"type\"]]: CreateEventData<EventType>;\n};\n\n/**\n * Translate between an external metric name, which is exposed to SDK users, and an internal Blizzard event name,\n * property name, and constructor.\n *\n * It is very important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * For a full list of business events (using their internal names), see:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n */\ntype CameraKitBusinessEventMap = {\n assetDownload: MakeBusinessEvent<blizzard.CameraKitAssetDownload>;\n assetValidationFailed: MakeBusinessEvent<blizzard.CameraKitAssetValidationFailed>;\n benchmarkComplete: MakeBusinessEvent<blizzard.CameraKitWebBenchmarkComplete>;\n exception: MakeBusinessEvent<blizzard.CameraKitException>;\n legalPrompt: MakeBusinessEvent<blizzard.CameraKitLegalPrompt>;\n lensDownload: MakeBusinessEvent<blizzard.CameraKitLensDownload>;\n lensView: MakeBusinessEvent<blizzard.CameraKitWebLensSwipe>;\n lensWait: MakeBusinessEvent<blizzard.CameraKitLensSpin>;\n lensContentValidationFailed: MakeBusinessEvent<blizzard.CameraKitLensContentValidationFailed>;\n session: MakeBusinessEvent<blizzard.CameraKitSession>;\n};\n\ninterface AppVendorAndPartnerUuid {\n appVendorUuid: string | undefined;\n partnerUuid: string | undefined;\n}\n\nconst connectivityTypeMapping: Partial<Record<ConnectionType, blizzard.CameraKitConnectivityType>> = {\n cellular: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_MOBILE,\n bluetooth: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_BLUETOOTH,\n wifi: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_WIFI,\n unknown: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNKNOWN,\n none: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNREACHABLE,\n};\n\nconst vendorUuidKey = \"vendorUuid\";\nconst vendorUuidExpiry = convertDaysToSeconds(60);\n\n/**\n * Retrieves or generates a vendor UUID (Universally Unique Identifier).\n *\n * @param persistence - The persistence storage interface where UUID is stored.\n * @returns {Promise<string | undefined>} - A Promise that resolves to the vendor UUID or undefined,\n * if any failure occurs or opt-in is not enabled.\n */\nconst getOrGenerateVendorUuid = async (persistence: ExpiringPersistence<string>): Promise<string | undefined> => {\n try {\n const storedUuid = await persistence.retrieve(vendorUuidKey);\n if (storedUuid) {\n return storedUuid;\n }\n\n const newUuid = v4();\n await persistence.store(vendorUuidKey, newUuid);\n\n return newUuid;\n } catch (error) {\n throw new Error(\"Failed to generate vendor UUID\");\n }\n};\n\nfunction listenAndReport(\n metricsEventTarget: MetricsEventTarget,\n metricsClient: MetricsClient,\n eventHandlers: EventHandlers,\n appVendorAndPartnerUuid: Observable<AppVendorAndPartnerUuid>\n): void {\n const sessionId = v4();\n logger.log(`Session ID: ${sessionId}`);\n\n // Blizzard convention is to start the sequenceId at 1.\n let sequenceId = 1;\n\n const makeBlizzardEvent = <E extends CameraKitBusinessEvents>(\n event: E,\n appVendorUuid: string | undefined,\n partnerUuid: string | undefined\n ): MakeBlizzardEvent<E> => {\n const { sdkShortVersion, sdkLongVersion, lensCore, locale, origin, deviceModel, connectionType } =\n getPlatformInfo();\n\n const deviceConnectivity =\n connectivityTypeMapping[connectionType!] ??\n blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNKNOWN;\n\n return {\n ...event,\n cameraKitEventBase: blizzard.CameraKitEventBase.fromPartial({\n kitEventBase: blizzard.KitEventBase.fromPartial({\n locale,\n kitVariant: blizzard.KitType.CAMERA_KIT_WEB,\n kitVariantVersion: sdkShortVersion,\n kitClientTimestampMillis: `${Date.now()}`,\n }),\n deviceCluster: \"0\",\n cameraKitVersion: sdkLongVersion,\n lensCoreVersion: lensCore.version,\n deviceModel,\n cameraKitVariant: blizzard.CameraKitVariant.CAMERA_KIT_VARIANT_PARTNER,\n cameraKitFlavor: blizzard.CameraKitFlavor.CAMERA_KIT_FLAVOR_DEBUG,\n // We overload appId, using the origin instead because it's nice and human-readable (our backed adds\n // the true appId as oauth_client_id before forwarding events to Blizzard).\n appId: origin,\n deviceConnectivity,\n sessionId,\n appVendorUuid,\n partnerUuid,\n }),\n };\n };\n\n const sendServerEvent = (\n eventName: string,\n eventData: UndefinedToOptional<blizzard.ServerEventData>\n ): Promise<void> => {\n const { osName: osType, osVersion } = getPlatformInfo();\n return metricsClient.setBusinessEvents(\n blizzard.ServerEvent.fromPartial({\n eventName,\n osType,\n osVersion,\n maxSequenceIdOnInstance: \"0\",\n sequenceId: `${sequenceId++}`,\n eventData,\n })\n );\n };\n\n // Add event listeners for each event type and turn those listeners into Observables\n const metricsEvents = entries(eventHandlers).map(([eventType, createEventData]) =>\n fromEvent(metricsEventTarget, eventType).pipe(map((event) => ({ event, createEventData })))\n );\n\n // Subscribe to all the metrics events and combine them with the app/partner IDs obtained\n // from remote configuration -- this means we'll queue up any metrics events that occur\n // before remote config is downloaded, and send them once that config is available.\n merge(...metricsEvents)\n .pipe(combineLatestWith(appVendorAndPartnerUuid))\n .subscribe(([{ event, createEventData }, { appVendorUuid, partnerUuid }]) => {\n // Safety: When iterating over object keys in a mapped type, we lose the association between the key type\n // and the value type – at each iteration, the key type is a union of all possible keys and the value type\n // is a union of all possible values. When the value is a function with an argument, and that argument\n // depends on the key type (which is a union), the contravariance of the argument type means that the union\n // becomes an intersection. In our case here, this means the compiler expects each argument to contain all\n // properties from all event types. The cast is safe because the mapped `EventHandlers` type ensures that\n // `createEventData` takes an argument of the type corresponding its key's `eventType`'s event detail.\n const [eventName, eventData] = createEventData(\n makeBlizzardEvent(event.detail, appVendorUuid, partnerUuid) as any\n );\n sendServerEvent(eventName, eventData);\n });\n}\n\nexport type MakeBusinessEvent<E> = Omit<\n {\n [K in keyof E]: Exclude<E[K], undefined> extends Record<keyof any, any>\n ? MakeBusinessEvent<Exclude<E[K], undefined>>\n : E[K];\n },\n \"cameraKitEventBase\"\n>;\n\nfunction getAppVendorAndPartnerUuid(\n configuration: CameraKitConfiguration,\n remoteConfiguration: RemoteConfiguration\n): Observable<AppVendorAndPartnerUuid> {\n const vendorAnalyticsPersistence = new ExpiringPersistence<string>(\n () => vendorUuidExpiry,\n new IndexedDBPersistence({ databaseName: \"VendorAnalytics\" })\n );\n\n return remoteConfiguration.getInitializationConfig().pipe(\n take(1),\n\n switchMap(({ appVendorUuidOptIn }) => {\n const partnerUuid = configuration.analyticsId;\n if (appVendorUuidOptIn) {\n return from(getOrGenerateVendorUuid(vendorAnalyticsPersistence)).pipe(\n map((appVendorUuid) => ({ appVendorUuid, partnerUuid }))\n );\n }\n return of({ appVendorUuid: undefined, partnerUuid });\n }),\n\n catchError((error) => {\n logger.warn(`Failed to retrieve or generate vendor UUID.`, error);\n return of({ appVendorUuid: undefined, partnerUuid: configuration.analyticsId });\n })\n );\n}\n\nexport type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {\n name: K;\n} & CameraKitBusinessEventMap[K];\n\nexport const businessEventsReporterFactory = Injectable(\n \"businessEventsReporter\",\n [\n metricsEventTargetFactory.token,\n metricsClientFactory.token,\n configurationToken,\n remoteConfigurationFactory.token,\n ] as const,\n (\n metricsEventTarget: MetricsEventTarget,\n metricsClient: MetricsClient,\n configuration: CameraKitConfiguration,\n remoteConfiguration: RemoteConfiguration\n ) => {\n const appVendorAndPartnerUuid = getAppVendorAndPartnerUuid(configuration, remoteConfiguration);\n\n /**\n * This defines a mapping from a business event's external name (the name we document in public\n * API docs), to its internal representation as a Blizzard ServerEvent.\n *\n * It is important that we do this, since the naming of these internal business events are\n * unintuitive and will not make sense to SDK users.\n *\n * To specify the internal event, we must give the ServerEvent's eventName, the specific property\n * name which contains the event data (this is a \"oneof\" property on ServerEvent), and use the\n * correct event type's `fromPartial` method (this is generated from the ServerEvent protobuf).\n *\n * These events are documented here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n *\n * They are defined in code here:\n * https://github.sc-corp.net/Snapchat/snapchat/tree/master/blizzard/schema/blizzard-schema/\n * codeGen/src/main/java/com/snapchat/analytics/schema/events/cameraKit\n */\n listenAndReport(\n metricsEventTarget,\n metricsClient,\n {\n assetDownload: (event) => [\n \"CAMERA_KIT_ASSET_DOWNLOAD\",\n { cameraKitAssetDownload: blizzard.CameraKitAssetDownload.fromPartial(event) },\n ],\n assetValidationFailed: (event) => [\n \"CAMERA_KIT_ASSET_VALIDATION_FAILED\",\n {\n cameraKitAssetValidationFailed: blizzard.CameraKitAssetValidationFailed.fromPartial(event),\n },\n ],\n benchmarkComplete: (event) => [\n \"CAMERA_KIT_WEB_BENCHMARK_COMPLETE\",\n {\n cameraKitWebBenchmarkComplete: blizzard.CameraKitWebBenchmarkComplete.fromPartial(event),\n },\n ],\n exception: (event) => [\n \"CAMERA_KIT_EXCEPTION\",\n { cameraKitException: blizzard.CameraKitException.fromPartial(event) },\n ],\n legalPrompt: (event) => [\n \"CAMERA_KIT_LEGAL_PROMPT\",\n { cameraKitLegalPrompt: blizzard.CameraKitLegalPrompt.fromPartial(event) },\n ],\n lensDownload: (event) => [\n \"CAMERA_KIT_LENS_DOWNLOAD\",\n { cameraKitLensDownload: blizzard.CameraKitLensDownload.fromPartial(event) },\n ],\n lensView: (event) => [\n \"CAMERA_KIT_WEB_LENS_SWIPE\",\n { cameraKitWebLensSwipe: blizzard.CameraKitWebLensSwipe.fromPartial(event) },\n ],\n lensWait: (event) => [\n \"CAMERA_KIT_LENS_SPIN\",\n { cameraKitLensSpin: blizzard.CameraKitLensSpin.fromPartial(event) },\n ],\n lensContentValidationFailed: (event) => [\n \"CAMERA_KIT_LENS_CONTENT_VALIDATION_FAILED\",\n {\n cameraKitLensContentValidationFailed:\n blizzard.CameraKitLensContentValidationFailed.fromPartial(event),\n },\n ],\n session: (event) => [\n \"CAMERA_KIT_SESSION\",\n { cameraKitSession: blizzard.CameraKitSession.fromPartial(event)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E;SAC7E;QACD,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACrB,0BAA0B;YAC1B,EAAE,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SAC/E;QACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACjB,2BAA2B;YAC3B,EAAE,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SAC/E;QACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACjB,sBAAsB;YACtB,EAAE,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SACvE;QACD,2BAA2B,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACpC,2CAA2C;YAC3C;gBACI,oCAAoC,EAChC,QAAQ,CAAC,oCAAoC,CAAC,WAAW,CAAC,KAAK,CAAC;aACvE;SACJ;QACD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YAChB,oBAAoB;YACpB,EAAE,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE;SACrE;KACJ,EACD,uBAAuB,CAC1B,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { v4 } from \"uuid\";\nimport type { Observable } from \"rxjs\";\nimport { catchError, combineLatestWith, from, fromEvent, map, merge, of, switchMap, take } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { entries } from \"../common/entries\";\nimport type { EventOfType } from \"../events/TypedCustomEvent\";\nimport type { EventsFromTarget } from \"../events/TypedEventTarget\";\nimport * as blizzard from \"../generated-proto/blizzard/cameraKitEvents\";\nimport { getLogger } from \"../logger/logger\";\nimport type { MetricsClient } from \"../clients/metricsClient\";\nimport { metricsClientFactory } from \"../clients/metricsClient\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { RemoteConfiguration } from \"../remote-configuration/remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport { ExpiringPersistence } from \"../persistence/ExpiringPersistence\";\nimport { convertDaysToSeconds } from \"../common/time\";\nimport type { ConnectionType } from \"../platform/platformInfo\";\nimport { getPlatformInfo } from \"../platform/platformInfo\";\nimport type { MetricsEventTarget } from \"./metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"./metricsEventTarget\";\n\nconst logger = getLogger(\"BusinessEventsReporter\");\n\ntype Nullables<T> = { [K in keyof T]-?: undefined extends T[K] ? K : never }[keyof T];\ntype UndefinedToOptional<T> = Partial<Pick<T, Nullables<T>>> & Omit<T, Nullables<T>>;\n\ntype CameraKitBusinessEvents = EventsFromTarget<MetricsEventTarget>[\"detail\"];\n\ntype MakeBlizzardEvent<E> = Omit<E, \"name\"> & { cameraKitEventBase: blizzard.CameraKitEventBase };\n\ntype CreateEventData<EventType extends EventsFromTarget<MetricsEventTarget>[\"type\"]> = (\n event: MakeBlizzardEvent<EventOfType<EventType, EventsFromTarget<MetricsEventTarget>>[\"detail\"]>\n) => [string, UndefinedToOptional<blizzard.ServerEventData>];\n\ntype EventHandlers = {\n [EventType in EventsFromTarget<MetricsEventTarget>[\"type\"]]: CreateEventData<EventType>;\n};\n\n/**\n * Translate between an external metric name, which is exposed to SDK users, and an internal Blizzard event name,\n * property name, and constructor.\n *\n * It is very important that we do this, since the naming of these internal business events are unintuitive and will\n * not make sense to SDK users.\n *\n * For a full list of business events (using their internal names), see:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n */\ntype CameraKitBusinessEventMap = {\n assetDownload: MakeBusinessEvent<blizzard.CameraKitAssetDownload>;\n assetValidationFailed: MakeBusinessEvent<blizzard.CameraKitAssetValidationFailed>;\n benchmarkComplete: MakeBusinessEvent<blizzard.CameraKitWebBenchmarkComplete>;\n exception: MakeBusinessEvent<blizzard.CameraKitException>;\n legalPrompt: MakeBusinessEvent<blizzard.CameraKitLegalPrompt>;\n lensDownload: MakeBusinessEvent<blizzard.CameraKitLensDownload>;\n lensView: MakeBusinessEvent<blizzard.CameraKitWebLensSwipe>;\n lensWait: MakeBusinessEvent<blizzard.CameraKitLensSpin>;\n lensContentValidationFailed: MakeBusinessEvent<blizzard.CameraKitLensContentValidationFailed>;\n session: MakeBusinessEvent<blizzard.CameraKitSession>;\n};\n\ninterface AppVendorAndPartnerUuid {\n appVendorUuid: string | undefined;\n partnerUuid: string | undefined;\n}\n\nconst connectivityTypeMapping: Partial<Record<ConnectionType, blizzard.CameraKitConnectivityType>> = {\n cellular: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_MOBILE,\n bluetooth: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_BLUETOOTH,\n wifi: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_WIFI,\n unknown: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNKNOWN,\n none: blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNREACHABLE,\n};\n\nconst vendorUuidKey = \"vendorUuid\";\nconst vendorUuidExpiry = convertDaysToSeconds(60);\n\n/**\n * Retrieves or generates a vendor UUID (Universally Unique Identifier).\n *\n * @param persistence - The persistence storage interface where UUID is stored.\n * @returns {Promise<string | undefined>} - A Promise that resolves to the vendor UUID or undefined,\n * if any failure occurs or opt-in is not enabled.\n */\nconst getOrGenerateVendorUuid = async (persistence: ExpiringPersistence<string>): Promise<string | undefined> => {\n try {\n const storedUuid = await persistence.retrieve(vendorUuidKey);\n if (storedUuid) {\n return storedUuid;\n }\n\n const newUuid = v4();\n await persistence.store(vendorUuidKey, newUuid);\n\n return newUuid;\n } catch (error) {\n throw new Error(\"Failed to generate vendor UUID\");\n }\n};\n\nfunction listenAndReport(\n metricsEventTarget: MetricsEventTarget,\n metricsClient: MetricsClient,\n eventHandlers: EventHandlers,\n appVendorAndPartnerUuid: Observable<AppVendorAndPartnerUuid>\n): void {\n const sessionId = v4();\n logger.log(`Session ID: ${sessionId}`);\n\n // Blizzard convention is to start the sequenceId at 1.\n let sequenceId = 1;\n\n const makeBlizzardEvent = <E extends CameraKitBusinessEvents>(\n event: E,\n appVendorUuid: string | undefined,\n partnerUuid: string | undefined\n ): MakeBlizzardEvent<E> => {\n const { sdkShortVersion, sdkLongVersion, lensCore, locale, origin, deviceModel, connectionType } =\n getPlatformInfo();\n\n const deviceConnectivity =\n connectivityTypeMapping[connectionType!] ??\n blizzard.CameraKitConnectivityType.CAMERA_KIT_CONNECTIVITY_TYPE_UNKNOWN;\n\n return {\n ...event,\n cameraKitEventBase: blizzard.CameraKitEventBase.fromPartial({\n kitEventBase: blizzard.KitEventBase.fromPartial({\n locale,\n kitVariant: blizzard.KitType.CAMERA_KIT_WEB,\n kitVariantVersion: sdkShortVersion,\n kitClientTimestampMillis: `${Date.now()}`,\n }),\n deviceCluster: \"0\",\n cameraKitVersion: sdkLongVersion,\n lensCoreVersion: lensCore.version,\n deviceModel,\n cameraKitVariant: blizzard.CameraKitVariant.CAMERA_KIT_VARIANT_PARTNER,\n cameraKitFlavor: blizzard.CameraKitFlavor.CAMERA_KIT_FLAVOR_DEBUG,\n // We overload appId, using the origin instead because it's nice and human-readable (our backed adds\n // the true appId as oauth_client_id before forwarding events to Blizzard).\n appId: origin,\n deviceConnectivity,\n sessionId,\n appVendorUuid,\n partnerUuid,\n }),\n };\n };\n\n const sendServerEvent = (\n eventName: string,\n eventData: UndefinedToOptional<blizzard.ServerEventData>\n ): Promise<void> => {\n const { osName: osType, osVersion } = getPlatformInfo();\n return metricsClient.setBusinessEvents(\n blizzard.ServerEvent.fromPartial({\n eventName,\n osType,\n osVersion,\n maxSequenceIdOnInstance: \"0\",\n sequenceId: `${sequenceId++}`,\n eventData,\n })\n );\n };\n\n // Add event listeners for each event type and turn those listeners into Observables\n const metricsEvents = entries(eventHandlers).map(([eventType, createEventData]) =>\n fromEvent(metricsEventTarget, eventType).pipe(map((event) => ({ event, createEventData })))\n );\n\n // Subscribe to all the metrics events and combine them with the app/partner IDs obtained\n // from remote configuration -- this means we'll queue up any metrics events that occur\n // before remote config is downloaded, and send them once that config is available.\n merge(...metricsEvents)\n .pipe(combineLatestWith(appVendorAndPartnerUuid))\n .subscribe(([{ event, createEventData }, { appVendorUuid, partnerUuid }]) => {\n // Safety: When iterating over object keys in a mapped type, we lose the association between the key type\n // and the value type – at each iteration, the key type is a union of all possible keys and the value type\n // is a union of all possible values. When the value is a function with an argument, and that argument\n // depends on the key type (which is a union), the contravariance of the argument type means that the union\n // becomes an intersection. In our case here, this means the compiler expects each argument to contain all\n // properties from all event types. The cast is safe because the mapped `EventHandlers` type ensures that\n // `createEventData` takes an argument of the type corresponding its key's `eventType`'s event detail.\n const [eventName, eventData] = createEventData(\n makeBlizzardEvent(event.detail, appVendorUuid, partnerUuid) as any\n );\n sendServerEvent(eventName, eventData);\n });\n}\n\nexport type MakeBusinessEvent<E> = Omit<\n {\n [K in keyof E]: Exclude<E[K], undefined> extends Record<keyof any, any>\n ? MakeBusinessEvent<Exclude<E[K], undefined>>\n : E[K];\n },\n \"cameraKitEventBase\"\n>;\n\nfunction getAppVendorAndPartnerUuid(\n configuration: CameraKitConfiguration,\n remoteConfiguration: RemoteConfiguration\n): Observable<AppVendorAndPartnerUuid> {\n const vendorAnalyticsPersistence = new ExpiringPersistence<string>(\n () => vendorUuidExpiry,\n new IndexedDBPersistence({ databaseName: \"VendorAnalytics\" })\n );\n\n return remoteConfiguration.getInitializationConfig().pipe(\n take(1),\n\n switchMap(({ appVendorUuidOptIn }) => {\n const partnerUuid = configuration.analyticsId;\n if (appVendorUuidOptIn) {\n return from(getOrGenerateVendorUuid(vendorAnalyticsPersistence)).pipe(\n map((appVendorUuid) => ({ appVendorUuid, partnerUuid }))\n );\n }\n return of({ appVendorUuid: undefined, partnerUuid });\n }),\n\n catchError((error) => {\n logger.warn(`Failed to retrieve or generate vendor UUID.`, error);\n return of({ appVendorUuid: undefined, partnerUuid: configuration.analyticsId });\n })\n );\n}\n\nexport type MakeTaggedBusinessEvent<K extends keyof CameraKitBusinessEventMap> = {\n name: K;\n} & CameraKitBusinessEventMap[K];\n\nexport const businessEventsReporterFactory = Injectable(\n \"businessEventsReporter\",\n [\n metricsEventTargetFactory.token,\n metricsClientFactory.token,\n configurationToken,\n remoteConfigurationFactory.token,\n ] as const,\n (\n metricsEventTarget: MetricsEventTarget,\n metricsClient: MetricsClient,\n configuration: CameraKitConfiguration,\n remoteConfiguration: RemoteConfiguration\n ) => {\n const appVendorAndPartnerUuid = getAppVendorAndPartnerUuid(configuration, remoteConfiguration);\n\n /**\n * This defines a mapping from a business event's external name (the name we document in public\n * API docs), to its internal representation as a Blizzard ServerEvent.\n *\n * It is important that we do this, since the naming of these internal business events are\n * unintuitive and will not make sense to SDK users.\n *\n * To specify the internal event, we must give the ServerEvent's eventName, the specific property\n * name which contains the event data (this is a \"oneof\" property on ServerEvent), and use the\n * correct event type's `fromPartial` method (this is generated from the ServerEvent protobuf).\n *\n * These events are documented here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n *\n * They are defined in code here:\n * https://github.sc-corp.net/Snapchat/snapchat/tree/master/blizzard/schema/blizzard-schema/\n * codeGen/src/main/java/com/snapchat/analytics/schema/events/cameraKit\n */\n listenAndReport(\n metricsEventTarget,\n metricsClient,\n {\n assetDownload: (event) => [\n \"CAMERA_KIT_ASSET_DOWNLOAD\",\n { cameraKitAssetDownload: blizzard.CameraKitAssetDownload.fromPartial(event) },\n ],\n assetValidationFailed: (event) => [\n \"CAMERA_KIT_ASSET_VALIDATION_FAILED\",\n {\n cameraKitAssetValidationFailed: blizzard.CameraKitAssetValidationFailed.fromPartial(event),\n },\n ],\n benchmarkComplete: (event) => [\n \"CAMERA_KIT_WEB_BENCHMARK_COMPLETE\",\n {\n cameraKitWebBenchmarkComplete: blizzard.CameraKitWebBenchmarkComplete.fromPartial(event),\n },\n ],\n exception: (event) => [\n \"CAMERA_KIT_EXCEPTION\",\n { cameraKitException: blizzard.CameraKitException.fromPartial(event) },\n ],\n legalPrompt: (event) => [\n \"CAMERA_KIT_LEGAL_PROMPT\",\n { cameraKitLegalPrompt: blizzard.CameraKitLegalPrompt.fromPartial(event) },\n ],\n lensDownload: (event) => [\n \"CAMERA_KIT_LENS_DOWNLOAD\",\n { cameraKitLensDownload: blizzard.CameraKitLensDownload.fromPartial(event) },\n ],\n lensView: (event) => [\n \"CAMERA_KIT_WEB_LENS_SWIPE\",\n { cameraKitWebLensSwipe: blizzard.CameraKitWebLensSwipe.fromPartial(event) },\n ],\n lensWait: (event) => [\n \"CAMERA_KIT_LENS_SPIN\",\n { cameraKitLensSpin: blizzard.CameraKitLensSpin.fromPartial(event) },\n ],\n lensContentValidationFailed: (event) => [\n \"CAMERA_KIT_LENS_CONTENT_VALIDATION_FAILED\",\n {\n cameraKitLensContentValidationFailed:\n blizzard.CameraKitLensContentValidationFailed.fromPartial(event),\n },\n ],\n session: (event) => [\n \"CAMERA_KIT_SESSION\",\n { cameraKitSession: blizzard.CameraKitSession.fromPartial(event) },\n ],\n },\n appVendorAndPartnerUuid\n );\n }\n);\n"]}
@@ -1,4 +1,4 @@
1
- import { Injectable } from "../dependency-injection/Injectable";
1
+ import { Injectable } from "@snap/ts-inject";
2
2
  import { TypedEventTarget } from "../events/TypedEventTarget";
3
3
  export const metricsEventTargetFactory = Injectable("metricsEventTarget", () => new TypedEventTarget());
4
4
  //# sourceMappingURL=metricsEventTarget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metricsEventTarget.js","sourceRoot":"","sources":["../../src/metrics/metricsEventTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAoD9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAC/C,oBAAoB,EACpB,GAAuB,EAAE,CAAC,IAAI,gBAAgB,EAAE,CACnD,CAAC","sourcesContent":["import { Injectable } from \"../dependency-injection/Injectable\";\nimport type { TypedCustomEvent } from \"../events/TypedCustomEvent\";\nimport { TypedEventTarget } from \"../events/TypedEventTarget\";\nimport type { AssetValidationFailed } from \"../lens/assets/LensAssetsProvider\";\nimport type { AssetDownload, LensDownload } from \"./reporters/reportLensAndAssetDownload\";\nimport type { LensContentValidationFailed } from \"./reporters/reportLensValidationFailed\";\nimport type { LensView } from \"./reporters/reportLensView\";\nimport type { LensWait } from \"./reporters/reportLensWait\";\nimport type { Session } from \"./reporters/reportUserSession\";\nimport type { BenchmarkComplete } from \"./reporters/reportBenchmarks\";\nimport type { LegalPrompt } from \"./reporters/reportLegalState\";\nimport type { MakeTaggedBusinessEvent } from \"./businessEventsReporter\";\n\n/**\n * The Exception metric reports every time we handle an exception.\n */\nexport type Exception = MakeTaggedBusinessEvent<\"exception\">;\n\nexport type CameraKitBootstrapMetricEvents = TypedCustomEvent<BenchmarkComplete[\"name\"], BenchmarkComplete>;\n\nexport type CameraKitSessionMetricEvents =\n | TypedCustomEvent<LegalPrompt[\"name\"], LegalPrompt>\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>\n | TypedCustomEvent<LensDownload[\"name\"], LensDownload>\n | TypedCustomEvent<AssetDownload[\"name\"], AssetDownload>\n | TypedCustomEvent<AssetValidationFailed[\"name\"], AssetValidationFailed>\n | TypedCustomEvent<LensContentValidationFailed[\"name\"], LensContentValidationFailed>\n | TypedCustomEvent<Session[\"name\"], Session>;\n\n/**\n * A union of all event types emitted by the {@link CameraKit.events} event emitter.\n *\n * @internal\n */\nexport type CameraKitMetricEvents =\n | CameraKitSessionMetricEvents\n | CameraKitBootstrapMetricEvents\n | TypedCustomEvent<Exception[\"name\"], Exception>;\n\n/**\n * This event target may be used to listen for any of the metrics events reported by CameraKit.\n *\n * @internal\n */\nexport type MetricsEventTarget = TypedEventTarget<CameraKitMetricEvents>;\n\n/**\n * Any metrics that we wish to emit to applications should be dispatched on this event target.\n *\n * Our business events reporter also listens to this event target, and may report the emitted metrics to our backend.\n *\n * @internal\n */\nexport const metricsEventTargetFactory = Injectable(\n \"metricsEventTarget\",\n (): MetricsEventTarget => new TypedEventTarget()\n);\n"]}
1
+ {"version":3,"file":"metricsEventTarget.js","sourceRoot":"","sources":["../../src/metrics/metricsEventTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAoD9D,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAC/C,oBAAoB,EACpB,GAAuB,EAAE,CAAC,IAAI,gBAAgB,EAAE,CACnD,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { TypedCustomEvent } from \"../events/TypedCustomEvent\";\nimport { TypedEventTarget } from \"../events/TypedEventTarget\";\nimport type { AssetValidationFailed } from \"../lens/assets/LensAssetsProvider\";\nimport type { AssetDownload, LensDownload } from \"./reporters/reportLensAndAssetDownload\";\nimport type { LensContentValidationFailed } from \"./reporters/reportLensValidationFailed\";\nimport type { LensView } from \"./reporters/reportLensView\";\nimport type { LensWait } from \"./reporters/reportLensWait\";\nimport type { Session } from \"./reporters/reportUserSession\";\nimport type { BenchmarkComplete } from \"./reporters/reportBenchmarks\";\nimport type { LegalPrompt } from \"./reporters/reportLegalState\";\nimport type { MakeTaggedBusinessEvent } from \"./businessEventsReporter\";\n\n/**\n * The Exception metric reports every time we handle an exception.\n */\nexport type Exception = MakeTaggedBusinessEvent<\"exception\">;\n\nexport type CameraKitBootstrapMetricEvents = TypedCustomEvent<BenchmarkComplete[\"name\"], BenchmarkComplete>;\n\nexport type CameraKitSessionMetricEvents =\n | TypedCustomEvent<LegalPrompt[\"name\"], LegalPrompt>\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>\n | TypedCustomEvent<LensDownload[\"name\"], LensDownload>\n | TypedCustomEvent<AssetDownload[\"name\"], AssetDownload>\n | TypedCustomEvent<AssetValidationFailed[\"name\"], AssetValidationFailed>\n | TypedCustomEvent<LensContentValidationFailed[\"name\"], LensContentValidationFailed>\n | TypedCustomEvent<Session[\"name\"], Session>;\n\n/**\n * A union of all event types emitted by the {@link CameraKit.events} event emitter.\n *\n * @internal\n */\nexport type CameraKitMetricEvents =\n | CameraKitSessionMetricEvents\n | CameraKitBootstrapMetricEvents\n | TypedCustomEvent<Exception[\"name\"], Exception>;\n\n/**\n * This event target may be used to listen for any of the metrics events reported by CameraKit.\n *\n * @internal\n */\nexport type MetricsEventTarget = TypedEventTarget<CameraKitMetricEvents>;\n\n/**\n * Any metrics that we wish to emit to applications should be dispatched on this event target.\n *\n * Our business events reporter also listens to this event target, and may report the emitted metrics to our backend.\n *\n * @internal\n */\nexport const metricsEventTargetFactory = Injectable(\n \"metricsEventTarget\",\n (): MetricsEventTarget => new TypedEventTarget()\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reportBenchmarks.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAIlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAOhE,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AAE7E,eAAO,MAAM,gBAAgB;;;;CAyB5B,CAAC"}
1
+ {"version":3,"file":"reportBenchmarks.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAOhE,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AAE7E,eAAO,MAAM,gBAAgB;;;;CAyB5B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from "tslib";
2
+ import { Injectable } from "@snap/ts-inject";
2
3
  import { metricsClientFactory } from "../../clients/metricsClient";
3
4
  import { configurationToken } from "../../configuration";
4
- import { Injectable } from "../../dependency-injection/Injectable";
5
5
  import { TypedCustomEvent } from "../../events/TypedCustomEvent";
6
6
  import { metricsEventTargetFactory } from "../metricsEventTarget";
7
7
  import { Histogram } from "../operational/Histogram";
@@ -1 +1 @@
1
- {"version":3,"file":"reportBenchmarks.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,MAAM,oBAAoB,GAAG,CAAC,QAAQ,CAAC,CAAC;AAIxC,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,kBAAkB,EAClB,CAAC,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,CAAU,EAC1F,CAAO,kBAAsC,EAAE,OAAsB,EAAE,MAA8B,EAAE,EAAE;IACrG,IAAI,MAAM,CAAC,eAAe,KAAK,SAAS;QAAE,OAAO;IAGjD,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC;IACrD,MAAM,aAAa,GAAiF;QAChG,IAAI,EAAE,mBAAmB;QACzB,kBAAkB,EAAE,GAAG,eAAe,CAAC,OAAO,EAAE;QAChD,iBAAiB,EAAE,eAAe,CAAC,iBAAiB;KACvD,CAAC;IACF,MAAM,UAAU,GAAG,EAAE,mBAAmB,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC/E,KAAK,MAAM,SAAS,IAAI,eAAe,CAAC,UAAU,EAAE;QAChD,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC;YAAE,SAAS;QAC7D,MAAM,iBAAiB,mCAChB,aAAa,KAChB,aAAa,EAAE,SAAS,CAAC,IAAI,EAC7B,cAAc,EAAE,SAAS,CAAC,KAAK,GAClC,CAAC;QACF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC/F,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;KAC9G;AACL,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport type { CameraKitConfiguration } from \"../../configuration\";\nimport { configurationToken } from \"../../configuration\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { Histogram } from \"../operational/Histogram\";\n\n// Allowlist the benchmarks we wish to report.\nconst reportableBenchmarks = [\"gflops\"];\n\nexport type BenchmarkComplete = MakeTaggedBusinessEvent<\"benchmarkComplete\">;\n\nexport const reportBenchmarks = Injectable(\n \"reportBenchmarks\",\n [metricsEventTargetFactory.token, metricsClientFactory.token, configurationToken] as const,\n async (metricsEventTarget: MetricsEventTarget, metrics: MetricsClient, config: CameraKitConfiguration) => {\n if (config.lensPerformance === undefined) return;\n // Safety: config.lensPerformance cannot reject – all Promises contained in CameraKitConfiguration have\n // catch blocks which return a default value.\n const lensPerformance = await config.lensPerformance;\n const baseBenchmark: Pick<BenchmarkComplete, \"name\" | \"performanceCluster\" | \"webglRendererInfo\"> = {\n name: \"benchmarkComplete\",\n performanceCluster: `${lensPerformance.cluster}`,\n webglRendererInfo: lensPerformance.webglRendererInfo,\n };\n const dimensions = { performance_cluster: lensPerformance.cluster.toString() };\n for (const benchmark of lensPerformance.benchmarks) {\n if (!reportableBenchmarks.includes(benchmark.name)) continue;\n const benchmarkComplete: BenchmarkComplete = {\n ...baseBenchmark,\n benchmarkName: benchmark.name,\n benchmarkValue: benchmark.value,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"benchmarkComplete\", benchmarkComplete));\n metrics.setOperationalMetrics(Histogram.level(`benchmark.${benchmark.name}`, benchmark.value, dimensions));\n }\n }\n);\n"]}
1
+ {"version":3,"file":"reportBenchmarks.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM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,KAAK,CAAC,aAAa,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;KAC9G;AACL,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport type { CameraKitConfiguration } from \"../../configuration\";\nimport { configurationToken } from \"../../configuration\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { Histogram } from \"../operational/Histogram\";\n\n// Allowlist the benchmarks we wish to report.\nconst reportableBenchmarks = [\"gflops\"];\n\nexport type BenchmarkComplete = MakeTaggedBusinessEvent<\"benchmarkComplete\">;\n\nexport const reportBenchmarks = Injectable(\n \"reportBenchmarks\",\n [metricsEventTargetFactory.token, metricsClientFactory.token, configurationToken] as const,\n async (metricsEventTarget: MetricsEventTarget, metrics: MetricsClient, config: CameraKitConfiguration) => {\n if (config.lensPerformance === undefined) return;\n // Safety: config.lensPerformance cannot reject – all Promises contained in CameraKitConfiguration have\n // catch blocks which return a default value.\n const lensPerformance = await config.lensPerformance;\n const baseBenchmark: Pick<BenchmarkComplete, \"name\" | \"performanceCluster\" | \"webglRendererInfo\"> = {\n name: \"benchmarkComplete\",\n performanceCluster: `${lensPerformance.cluster}`,\n webglRendererInfo: lensPerformance.webglRendererInfo,\n };\n const dimensions = { performance_cluster: lensPerformance.cluster.toString() };\n for (const benchmark of lensPerformance.benchmarks) {\n if (!reportableBenchmarks.includes(benchmark.name)) continue;\n const benchmarkComplete: BenchmarkComplete = {\n ...baseBenchmark,\n benchmarkName: benchmark.name,\n benchmarkValue: benchmark.value,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"benchmarkComplete\", benchmarkComplete));\n metrics.setOperationalMetrics(Histogram.level(`benchmark.${benchmark.name}`, benchmark.value, dimensions));\n }\n }\n);\n"]}
@@ -1,8 +1,8 @@
1
1
  import { isState } from "@snap/state-management";
2
2
  import { filter, map, scan, Subject, takeUntil } from "rxjs";
3
+ import { Injectable } from "@snap/ts-inject";
3
4
  import { entries } from "../../common/entries";
4
5
  import { stringifyError, stringifyErrorMessage } from "../../common/errorHelpers";
5
- import { Injectable } from "../../dependency-injection/Injectable";
6
6
  import { TypedCustomEvent } from "../../events/TypedCustomEvent";
7
7
  import { logEntriesFactory } from "../../logger/logEntries";
8
8
  import { logLevelMap } from "../../logger/logger";
@@ -1 +1 @@
1
- {"version":3,"file":"reportGlobalException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportGlobalException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CA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BAAmB,GAAG,IAAI,OAAO,EAAQ,CAAC;IAChD,yBAAyB,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAIxG,OAAO;QACH,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE;YACxC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAC3B,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAClF,CAAC;KACJ,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { isState } from \"@snap/state-management\";\nimport type { Observable } from \"rxjs\";\nimport { filter, map, scan, Subject, takeUntil } from \"rxjs\";\nimport { entries } from \"../../common/entries\";\nimport { stringifyError, stringifyErrorMessage } from \"../../common/errorHelpers\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { logEntriesFactory } from \"../../logger/logEntries\";\nimport type { LogEntry } from \"../../logger/logger\";\nimport { logLevelMap } from \"../../logger/logger\";\nimport type { LensState } from \"../../session/lensState\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\nconst logMethods = entries(logLevelMap).map(([level]) => level);\n\n// How many log entries to include as the error context\nconst maxBufferedEntries = 15;\nconst contextSeparator = \"\\n\\n----------------- Context -----------------\\n\\n\";\nconst methodLength = logMethods.reduce((max, method) => Math.max(max, method.length), 0);\n\ninterface RepeatableLogEntry {\n entry: LogEntry;\n count: number;\n lastTime: Date;\n}\n\ninterface EntriesBuffer {\n /**\n * LogEntries grouped by their message.\n */\n entries: RepeatableLogEntry[];\n /**\n * The recent log entry.\n */\n recent: LogEntry;\n}\n\nexport function getContextString(logEntries: RepeatableLogEntry[]) {\n const result = [];\n for (const { entry, count, lastTime } of logEntries) {\n const time = entry.time.toISOString();\n const method = entry.level.padStart(methodLength);\n const messages = entry.messages.map(prettyPrintMessage).join(\" \");\n let dupSuffix =\n count > 1 ? ` (Repeated ${count} times with the last occurrence at ${lastTime.toISOString()})` : \"\";\n\n result.push(`${time} [${entry.module}] ${method}: ${messages}${dupSuffix}`);\n }\n return result.join(\"\\n\");\n}\n\n/**\n * Pretty print a log message.\n */\nfunction prettyPrintMessage(message: unknown): string {\n if (message instanceof Error) return stringifyErrorMessage(message);\n if (message instanceof Date) return message.toISOString();\n return message + \"\";\n}\n\nexport function reportExceptionToBlizzard(\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n lensState?: LensState\n) {\n logEntries\n .pipe(\n scan<LogEntry, EntriesBuffer>(\n ({ entries }, newEntry) => {\n const lastEntry = entries[entries.length - 1];\n const isNewEntryRepeated =\n lastEntry &&\n lastEntry.entry.messages.join() === newEntry.messages.join() &&\n lastEntry.entry.level === newEntry.level;\n if (isNewEntryRepeated) {\n lastEntry.count += 1;\n lastEntry.lastTime = newEntry.time;\n } else {\n entries.push({\n entry: newEntry,\n count: 1,\n lastTime: newEntry.time,\n });\n }\n return {\n entries: entries.slice(-maxBufferedEntries),\n recent: newEntry,\n };\n },\n // Start with a dummy recent entry -- it gets overridden each time we handle a log entry.\n { entries: [], recent: { time: new Date(), module: \"any\", level: \"debug\", messages: [] } }\n ),\n filter(({ recent }) => recent.level === \"error\"),\n map(({ entries, recent }) => ({\n context: entries,\n error: recent.messages.find((e) => e instanceof Error) as Error,\n })),\n filter(({ error }) => !!error)\n )\n .subscribe(({ error, context }) => {\n const currentLensState = lensState?.getState();\n const lensId =\n currentLensState && !isState(currentLensState, \"noLensApplied\") ? currentLensState.data.id : \"none\";\n metricsEventTarget.dispatchEvent(\n new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId,\n type: error.name,\n reason: `${stringifyError(error)}${contextSeparator}${getContextString(context)}`,\n })\n );\n\n metrics.setOperationalMetrics(Count.count(\"handled_exception\", 1, { type: error.name }));\n });\n}\n\nexport interface GlobalExceptionReporter {\n attachLensContext: (lensState: LensState) => void;\n}\n\n/**\n * Reports log entries to Blizzard when there is no CameraKit session yet.\n *\n * @internal\n */\nexport const reportGlobalException = Injectable(\n \"reportGlobalException\",\n [logEntriesFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient\n ): GlobalExceptionReporter => {\n // Initially we log exceptions without any lens context\n const cancellationSubject = new Subject<void>();\n reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget, metrics);\n\n // Later session scope reporter triggers cancellation of the global one\n // and initiates exception reporting with a lens context\n return {\n attachLensContext: (lensState: LensState) => {\n cancellationSubject.next();\n reportExceptionToBlizzard(logEntries, metricsEventTarget, metrics, lensState);\n },\n };\n }\n);\n"]}
1
+ {"version":3,"file":"reportGlobalException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportGlobalException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,EAAE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AC;AAWD,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAC3C,uBAAuB,EACvB,CAAC,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAU,EAC/F,CACI,UAAgC,EAChC,kBAAsC,EACtC,OAAsB,EACC,EAAE;IAEzB,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAQ,CAAC;IAChD,yBAAyB,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAIxG,OAAO;QACH,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE;YACxC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAC3B,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAClF,CAAC;KACJ,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { isState } from \"@snap/state-management\";\nimport type { Observable } from \"rxjs\";\nimport { filter, map, scan, Subject, takeUntil } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { entries } from \"../../common/entries\";\nimport { stringifyError, stringifyErrorMessage } from \"../../common/errorHelpers\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { logEntriesFactory } from \"../../logger/logEntries\";\nimport type { LogEntry } from \"../../logger/logger\";\nimport { logLevelMap } from \"../../logger/logger\";\nimport type { LensState } from \"../../session/lensState\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\nconst logMethods = entries(logLevelMap).map(([level]) => level);\n\n// How many log entries to include as the error context\nconst maxBufferedEntries = 15;\nconst contextSeparator = \"\\n\\n----------------- Context -----------------\\n\\n\";\nconst methodLength = logMethods.reduce((max, method) => Math.max(max, method.length), 0);\n\ninterface RepeatableLogEntry {\n entry: LogEntry;\n count: number;\n lastTime: Date;\n}\n\ninterface EntriesBuffer {\n /**\n * LogEntries grouped by their message.\n */\n entries: RepeatableLogEntry[];\n /**\n * The recent log entry.\n */\n recent: LogEntry;\n}\n\nexport function getContextString(logEntries: RepeatableLogEntry[]) {\n const result = [];\n for (const { entry, count, lastTime } of logEntries) {\n const time = entry.time.toISOString();\n const method = entry.level.padStart(methodLength);\n const messages = entry.messages.map(prettyPrintMessage).join(\" \");\n let dupSuffix =\n count > 1 ? ` (Repeated ${count} times with the last occurrence at ${lastTime.toISOString()})` : \"\";\n\n result.push(`${time} [${entry.module}] ${method}: ${messages}${dupSuffix}`);\n }\n return result.join(\"\\n\");\n}\n\n/**\n * Pretty print a log message.\n */\nfunction prettyPrintMessage(message: unknown): string {\n if (message instanceof Error) return stringifyErrorMessage(message);\n if (message instanceof Date) return message.toISOString();\n return message + \"\";\n}\n\nexport function reportExceptionToBlizzard(\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n lensState?: LensState\n) {\n logEntries\n .pipe(\n scan<LogEntry, EntriesBuffer>(\n ({ entries }, newEntry) => {\n const lastEntry = entries[entries.length - 1];\n const isNewEntryRepeated =\n lastEntry &&\n lastEntry.entry.messages.join() === newEntry.messages.join() &&\n lastEntry.entry.level === newEntry.level;\n if (isNewEntryRepeated) {\n lastEntry.count += 1;\n lastEntry.lastTime = newEntry.time;\n } else {\n entries.push({\n entry: newEntry,\n count: 1,\n lastTime: newEntry.time,\n });\n }\n return {\n entries: entries.slice(-maxBufferedEntries),\n recent: newEntry,\n };\n },\n // Start with a dummy recent entry -- it gets overridden each time we handle a log entry.\n { entries: [], recent: { time: new Date(), module: \"any\", level: \"debug\", messages: [] } }\n ),\n filter(({ recent }) => recent.level === \"error\"),\n map(({ entries, recent }) => ({\n context: entries,\n error: recent.messages.find((e) => e instanceof Error) as Error,\n })),\n filter(({ error }) => !!error)\n )\n .subscribe(({ error, context }) => {\n const currentLensState = lensState?.getState();\n const lensId =\n currentLensState && !isState(currentLensState, \"noLensApplied\") ? currentLensState.data.id : \"none\";\n metricsEventTarget.dispatchEvent(\n new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId,\n type: error.name,\n reason: `${stringifyError(error)}${contextSeparator}${getContextString(context)}`,\n })\n );\n\n metrics.setOperationalMetrics(Count.count(\"handled_exception\", 1, { type: error.name }));\n });\n}\n\nexport interface GlobalExceptionReporter {\n attachLensContext: (lensState: LensState) => void;\n}\n\n/**\n * Reports log entries to Blizzard when there is no CameraKit session yet.\n *\n * @internal\n */\nexport const reportGlobalException = Injectable(\n \"reportGlobalException\",\n [logEntriesFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient\n ): GlobalExceptionReporter => {\n // Initially we log exceptions without any lens context\n const cancellationSubject = new Subject<void>();\n reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget, metrics);\n\n // Later session scope reporter triggers cancellation of the global one\n // and initiates exception reporting with a lens context\n return {\n attachLensContext: (lensState: LensState) => {\n cancellationSubject.next();\n reportExceptionToBlizzard(logEntries, metricsEventTarget, metrics, lensState);\n },\n };\n }\n);\n"]}
@@ -1,5 +1,5 @@
1
+ import { Injectable } from "@snap/ts-inject";
1
2
  import { assertUnreachable } from "../../common/assertions";
2
- import { Injectable } from "../../dependency-injection/Injectable";
3
3
  import { scan } from "../../events/scan";
4
4
  import { COF_REQUEST_TYPE } from "../../remote-configuration/cofHandler";
5
5
  import { requestStateEventTargetFactory } from "../../handlers/requestStateEmittingHandler";
@@ -1 +1 @@
1
- {"version":3,"file":"reportHttpMetrics.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportHttpMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iB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AU,EAAE,KAAK,CAAC,UAAU;oBAC5B,UAAU,EAAE,qBAAqB;oBACjC,cAAc;oBACd,KAAK,EAAE,gBAAgB,CAAC,KAAK;iBAChC,CAAC;YACN;gBACI,iBAAiB,CAAC,KAAK,CAAC,CAAC;SAChC;IACL,CAAC,CACJ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO;QAEvC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEpD,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,kBAAkB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/F,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { assertUnreachable } from \"../../common/assertions\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { scan } from \"../../events/scan\";\nimport type { CofDimensions } from \"../../remote-configuration/cofHandler\";\nimport { COF_REQUEST_TYPE } from \"../../remote-configuration/cofHandler\";\nimport type {\n Dimensions,\n RequestStateEventTarget,\n RequestStateEvents,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport { requestStateEventTargetFactory } from \"../../handlers/requestStateEmittingHandler\";\nimport { getPlatformInfo } from \"../../platform/platformInfo\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\nimport { Histogram } from \"../operational/Histogram\";\nimport type { Timer } from \"../operational/Timer\";\nimport {\n LENS_CORE_JS_REQUEST_TYPE,\n LENS_CORE_WASM_REQUEST_TYPE,\n type LensCoreDownloadDimensions,\n} from \"../../lens-core-module/loader/lensCoreFactory\";\nimport { GRPC_CALL_REQUEST_TYPE, type GrpcRequestDimensions } from \"../../clients/grpcHandler\";\nimport type { AssetDownloadDimensions, LensDownloadDimensions } from \"./reportLensAndAssetDownload\";\n\ntype InProgressMap = Map<number, { timer: Timer<\"download_latency\"> }>;\ninterface InProgress {\n name: \"inProgress\";\n inProgress: InProgressMap;\n}\ninterface Completed {\n name: \"completed\";\n inProgress: InProgressMap;\n dimensions: Record<string, string>;\n timer: Timer<\"download_latency\">;\n downloadSizeKb: number;\n}\ntype RequestState = InProgress | Completed;\n\ntype ReportableMetricDimensions =\n | LensDownloadDimensions\n | AssetDownloadDimensions\n | CofDimensions\n | LensCoreDownloadDimensions\n | GrpcRequestDimensions;\n\nconst reportableMetricRequestTypes: ReportableMetricDimensions[\"requestType\"][] = [\n \"asset\",\n \"lens_content\",\n LENS_CORE_JS_REQUEST_TYPE,\n LENS_CORE_WASM_REQUEST_TYPE,\n COF_REQUEST_TYPE,\n GRPC_CALL_REQUEST_TYPE,\n];\n\nconst getAdditionalDimensions = (dimensions: ReportableMetricDimensions): [string, string][] => {\n switch (dimensions.requestType) {\n case COF_REQUEST_TYPE:\n return [[\"delta\", dimensions.delta]];\n case GRPC_CALL_REQUEST_TYPE:\n return [[\"method\", dimensions.methodName]];\n case LENS_CORE_JS_REQUEST_TYPE:\n case LENS_CORE_WASM_REQUEST_TYPE:\n return [[\"custom\", dimensions.customBuild]];\n default:\n return [];\n }\n};\n\nconst getContentType = (dimensions: ReportableMetricDimensions): string => {\n if (dimensions.requestType === \"asset\") {\n return dimensions.assetType;\n }\n return dimensions.requestType;\n};\n\nconst getSizeKb = (event: RequestStateEvents): number => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n return 0;\n case \"completed\":\n return event.detail.sizeByte / 1024;\n default:\n assertUnreachable(event);\n }\n};\n\nconst getStatus = (event: RequestStateEvents): string => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n // We'll use status 0 to indicate that an exception occurred during the request. This is somewhat in keeping\n // with browsers that set the response status to 0 if the request was not able to be made (e.g. CORs\n // preflight failed, or the user canceled the request).\n return \"0\";\n case \"completed\":\n return event.detail.status.toString();\n default:\n assertUnreachable(event);\n }\n};\n\nexport const isRelevantRequest = (value: Dimensions): value is ReportableMetricDimensions => {\n const reportableMetricDimensions = value as ReportableMetricDimensions;\n return reportableMetricRequestTypes.includes(reportableMetricDimensions.requestType);\n};\n\nexport const reportHttpMetrics = Injectable(\n \"reportHttpMetrics\",\n [metricsClientFactory.token, requestStateEventTargetFactory.token] as const,\n (metrics: MetricsClient, requestStateEventTarget: RequestStateEventTarget) => {\n scan<RequestState>({ name: \"inProgress\", inProgress: new Map() })(\n requestStateEventTarget,\n [\"started\", \"completed\", \"errored\"],\n (state, event) => {\n const { inProgress } = state;\n const { dimensions, requestId } = event.detail;\n\n if (!isRelevantRequest(dimensions)) return state;\n\n switch (event.type) {\n case \"started\":\n const timer = event.detail.timer;\n inProgress.set(requestId, { timer });\n return { name: \"inProgress\", inProgress };\n case \"completed\":\n case \"errored\":\n const completedRequest = inProgress.get(requestId);\n if (!completedRequest) return state;\n inProgress.delete(requestId);\n\n const downloadSizeKb = getSizeKb(event);\n const status = getStatus(event);\n const operationalDimensions: Record<string, string> = {\n content_type: getContentType(dimensions),\n network_type: getPlatformInfo().connectionType ?? \"unknown\",\n status,\n };\n\n for (const [key, value] of getAdditionalDimensions(dimensions)) {\n operationalDimensions[key] = value;\n }\n\n completedRequest.timer.measure(operationalDimensions);\n\n return {\n name: \"completed\",\n inProgress: state.inProgress,\n dimensions: operationalDimensions,\n downloadSizeKb,\n timer: completedRequest.timer,\n };\n default:\n assertUnreachable(event);\n }\n }\n ).addEventListener(\"state\", ({ detail: state }) => {\n if (state.name !== \"completed\") return;\n\n const { dimensions, timer, downloadSizeKb } = state;\n\n metrics.setOperationalMetrics(Count.count(\"download_finished\", 1, dimensions));\n metrics.setOperationalMetrics(Histogram.level(\"download_size_kb\", downloadSizeKb, dimensions));\n metrics.setOperationalMetrics(timer);\n });\n }\n);\n"]}
1
+ {"version":3,"file":"reportHttpMetrics.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportHttpMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAMzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,EACH,yBAAyB,EACzB,2BAA2B,GAE9B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,2BAA2B,CAAC;AAwB/F,MAAM,4BAA4B,GAAgD;IAC9E,OAAO;IACP,cAAc;IACd,yBAAyB;IACzB,2BAA2B;IAC3B,gBAAgB;IAChB,sBAAsB;CACzB,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,UAAsC,EAAsB,EAAE;IAC3F,QAAQ,UAAU,CAAC,WAAW,EAAE;QAC5B,KAAK,gBAAgB;YACjB,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,KAAK,sBAAsB;YACvB,OAAO,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QAC/C,KAAK,yBAAyB,CAAC;QAC/B,KAAK,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AC,IAAI,uBAAuB,CAAC,UAAU,CAAC,EAAE;oBAC5D,qBAAqB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;iBACtC;gBAED,gBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;gBAEtD,OAAO;oBACH,IAAI,EAAE,WAAW;oBACjB,UAAU,EAAE,KAAK,CAAC,UAAU;oBAC5B,UAAU,EAAE,qBAAqB;oBACjC,cAAc;oBACd,KAAK,EAAE,gBAAgB,CAAC,KAAK;iBAChC,CAAC;YACN;gBACI,iBAAiB,CAAC,KAAK,CAAC,CAAC;SAChC;IACL,CAAC,CACJ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO;QAEvC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEpD,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,kBAAkB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/F,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { assertUnreachable } from \"../../common/assertions\";\nimport { scan } from \"../../events/scan\";\nimport type { CofDimensions } from \"../../remote-configuration/cofHandler\";\nimport { COF_REQUEST_TYPE } from \"../../remote-configuration/cofHandler\";\nimport type {\n Dimensions,\n RequestStateEventTarget,\n RequestStateEvents,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport { requestStateEventTargetFactory } from \"../../handlers/requestStateEmittingHandler\";\nimport { getPlatformInfo } from \"../../platform/platformInfo\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\nimport { Histogram } from \"../operational/Histogram\";\nimport type { Timer } from \"../operational/Timer\";\nimport {\n LENS_CORE_JS_REQUEST_TYPE,\n LENS_CORE_WASM_REQUEST_TYPE,\n type LensCoreDownloadDimensions,\n} from \"../../lens-core-module/loader/lensCoreFactory\";\nimport { GRPC_CALL_REQUEST_TYPE, type GrpcRequestDimensions } from \"../../clients/grpcHandler\";\nimport type { AssetDownloadDimensions, LensDownloadDimensions } from \"./reportLensAndAssetDownload\";\n\ntype InProgressMap = Map<number, { timer: Timer<\"download_latency\"> }>;\ninterface InProgress {\n name: \"inProgress\";\n inProgress: InProgressMap;\n}\ninterface Completed {\n name: \"completed\";\n inProgress: InProgressMap;\n dimensions: Record<string, string>;\n timer: Timer<\"download_latency\">;\n downloadSizeKb: number;\n}\ntype RequestState = InProgress | Completed;\n\ntype ReportableMetricDimensions =\n | LensDownloadDimensions\n | AssetDownloadDimensions\n | CofDimensions\n | LensCoreDownloadDimensions\n | GrpcRequestDimensions;\n\nconst reportableMetricRequestTypes: ReportableMetricDimensions[\"requestType\"][] = [\n \"asset\",\n \"lens_content\",\n LENS_CORE_JS_REQUEST_TYPE,\n LENS_CORE_WASM_REQUEST_TYPE,\n COF_REQUEST_TYPE,\n GRPC_CALL_REQUEST_TYPE,\n];\n\nconst getAdditionalDimensions = (dimensions: ReportableMetricDimensions): [string, string][] => {\n switch (dimensions.requestType) {\n case COF_REQUEST_TYPE:\n return [[\"delta\", dimensions.delta]];\n case GRPC_CALL_REQUEST_TYPE:\n return [[\"method\", dimensions.methodName]];\n case LENS_CORE_JS_REQUEST_TYPE:\n case LENS_CORE_WASM_REQUEST_TYPE:\n return [[\"custom\", dimensions.customBuild]];\n default:\n return [];\n }\n};\n\nconst getContentType = (dimensions: ReportableMetricDimensions): string => {\n if (dimensions.requestType === \"asset\") {\n return dimensions.assetType;\n }\n return dimensions.requestType;\n};\n\nconst getSizeKb = (event: RequestStateEvents): number => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n return 0;\n case \"completed\":\n return event.detail.sizeByte / 1024;\n default:\n assertUnreachable(event);\n }\n};\n\nconst getStatus = (event: RequestStateEvents): string => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n // We'll use status 0 to indicate that an exception occurred during the request. This is somewhat in keeping\n // with browsers that set the response status to 0 if the request was not able to be made (e.g. CORs\n // preflight failed, or the user canceled the request).\n return \"0\";\n case \"completed\":\n return event.detail.status.toString();\n default:\n assertUnreachable(event);\n }\n};\n\nexport const isRelevantRequest = (value: Dimensions): value is ReportableMetricDimensions => {\n const reportableMetricDimensions = value as ReportableMetricDimensions;\n return reportableMetricRequestTypes.includes(reportableMetricDimensions.requestType);\n};\n\nexport const reportHttpMetrics = Injectable(\n \"reportHttpMetrics\",\n [metricsClientFactory.token, requestStateEventTargetFactory.token] as const,\n (metrics: MetricsClient, requestStateEventTarget: RequestStateEventTarget) => {\n scan<RequestState>({ name: \"inProgress\", inProgress: new Map() })(\n requestStateEventTarget,\n [\"started\", \"completed\", \"errored\"],\n (state, event) => {\n const { inProgress } = state;\n const { dimensions, requestId } = event.detail;\n\n if (!isRelevantRequest(dimensions)) return state;\n\n switch (event.type) {\n case \"started\":\n const timer = event.detail.timer;\n inProgress.set(requestId, { timer });\n return { name: \"inProgress\", inProgress };\n case \"completed\":\n case \"errored\":\n const completedRequest = inProgress.get(requestId);\n if (!completedRequest) return state;\n inProgress.delete(requestId);\n\n const downloadSizeKb = getSizeKb(event);\n const status = getStatus(event);\n const operationalDimensions: Record<string, string> = {\n content_type: getContentType(dimensions),\n network_type: getPlatformInfo().connectionType ?? \"unknown\",\n status,\n };\n\n for (const [key, value] of getAdditionalDimensions(dimensions)) {\n operationalDimensions[key] = value;\n }\n\n completedRequest.timer.measure(operationalDimensions);\n\n return {\n name: \"completed\",\n inProgress: state.inProgress,\n dimensions: operationalDimensions,\n downloadSizeKb,\n timer: completedRequest.timer,\n };\n default:\n assertUnreachable(event);\n }\n }\n ).addEventListener(\"state\", ({ detail: state }) => {\n if (state.name !== \"completed\") return;\n\n const { dimensions, timer, downloadSizeKb } = state;\n\n metrics.setOperationalMetrics(Count.count(\"download_finished\", 1, dimensions));\n metrics.setOperationalMetrics(Histogram.level(\"download_size_kb\", downloadSizeKb, dimensions));\n metrics.setOperationalMetrics(timer);\n });\n }\n);\n"]}
@@ -1,6 +1,6 @@
1
1
  import { forActions } from "@snap/state-management";
2
2
  import { map } from "rxjs";
3
- import { Injectable } from "../../dependency-injection/Injectable";
3
+ import { Injectable } from "@snap/ts-inject";
4
4
  import { TypedCustomEvent } from "../../events/TypedCustomEvent";
5
5
  import { CameraKitLegalPromptResult } from "../../generated-proto/blizzard/cameraKitEvents";
6
6
  import { legalStateFactory } from "../../legal/legalState";
@@ -1 +1 @@
1
- {"version":3,"file":"reportLegalState.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLegalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAU7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,kBAAkB,EAClB,CAAC,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAU,EAC/F,CAAC,UAAsB,EAAE,kBAAsC,EAAE,OAAsB,EAAE,EAAE;IACvF,UAAU,CAAC,MAAM;SACZ,IAAI,CACD,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,aAAsB;QAC5B,aAAa,EAAE,IAAI;QACnB,iBAAiB,EACb,IAAI,KAAK,QAAQ;YACb,CAAC,CAAC,0BAA0B,CAAC,gCAAgC;YAC7D,CAAC,CAAC,0BAA0B,CAAC,iCAAiC;KACzE,CAAC,CAAC,CACN;SACA,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,gBAAgB,EAAE,EAAE;YACvB,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;YACxF,OAAO,CAAC,qBAAqB,CACzB,KAAK,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,EAAE;gBACvC,QAAQ,EAAE,CACN,gBAAgB,CAAC,iBAAiB;oBAClC,0BAA0B,CAAC,gCAAgC,CAC9D,CAAC,QAAQ,EAAE;aACf,CAAC,CACL,CAAC;QACN,CAAC;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { forActions } from \"@snap/state-management\";\nimport { map } from \"rxjs\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { CameraKitLegalPromptResult } from \"../../generated-proto/blizzard/cameraKitEvents\";\nimport type { LegalState } from \"../../legal/legalState\";\nimport { legalStateFactory } from \"../../legal/legalState\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\n/**\n * The LegalPrompt metric reports each time a BIPA legal prompt is shown.\n */\nexport type LegalPrompt = MakeTaggedBusinessEvent<\"legalPrompt\">;\n\n/**\n * @internal\n */\nexport const reportLegalState = Injectable(\n \"reportLegalState\",\n [legalStateFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (legalState: LegalState, metricsEventTarget: MetricsEventTarget, metrics: MetricsClient) => {\n legalState.events\n .pipe(\n forActions(\"accept\", \"reject\"),\n map(([{ data, name }]) => ({\n name: \"legalPrompt\" as const,\n legalPromptId: data,\n legalPromptResult:\n name === \"accept\"\n ? CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n : CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_DISMISSED,\n }))\n )\n .subscribe({\n next: (legalPromptEvent) => {\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"legalPrompt\", legalPromptEvent));\n metrics.setOperationalMetrics(\n Count.count(\"legal_prompt_interaction\", 1, {\n accepted: (\n legalPromptEvent.legalPromptResult ===\n CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n ).toString(),\n })\n );\n },\n });\n }\n);\n"]}
1
+ {"version":3,"file":"reportLegalState.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLegalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,M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@snap/ts-inject\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { CameraKitLegalPromptResult } from \"../../generated-proto/blizzard/cameraKitEvents\";\nimport type { LegalState } from \"../../legal/legalState\";\nimport { legalStateFactory } from \"../../legal/legalState\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\n/**\n * The LegalPrompt metric reports each time a BIPA legal prompt is shown.\n */\nexport type LegalPrompt = MakeTaggedBusinessEvent<\"legalPrompt\">;\n\n/**\n * @internal\n */\nexport const reportLegalState = Injectable(\n \"reportLegalState\",\n [legalStateFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (legalState: LegalState, metricsEventTarget: MetricsEventTarget, metrics: MetricsClient) => {\n legalState.events\n .pipe(\n forActions(\"accept\", \"reject\"),\n map(([{ data, name }]) => ({\n name: \"legalPrompt\" as const,\n legalPromptId: data,\n legalPromptResult:\n name === \"accept\"\n ? CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n : CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_DISMISSED,\n }))\n )\n .subscribe({\n next: (legalPromptEvent) => {\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"legalPrompt\", legalPromptEvent));\n metrics.setOperationalMetrics(\n Count.count(\"legal_prompt_interaction\", 1, {\n accepted: (\n legalPromptEvent.legalPromptResult ===\n CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n ).toString(),\n })\n );\n },\n });\n }\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reportLensAndAssetDownload.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensAndAssetDownload.ts"],"names":[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M,YAAY,GAAG,uBAAuB,CAAC,cAAc,CAAC,CAAC;AACnE,MAAM,MAAM,sBAAsB,GAAG;IAAE,WAAW,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,uBAAuB,CAAC,eAAe,CAAC,CAAC;AACrE,MAAM,MAAM,uBAAuB,GAAG;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnH,eAAO,MAAM,0BAA0B;;;;CAsFtC,CAAC"}
@@ -1,7 +1,7 @@
1
+ import { Injectable } from "@snap/ts-inject";
1
2
  import { metricsClientFactory } from "../../clients/metricsClient";
2
3
  import { assertUnreachable } from "../../common/assertions";
3
4
  import { stringifyError } from "../../common/errorHelpers";
4
- import { Injectable } from "../../dependency-injection/Injectable";
5
5
  import { scan } from "../../events/scan";
6
6
  import { TypedCustomEvent } from "../../events/TypedCustomEvent";
7
7
  import { requestStateEventTargetFactory } from "../../handlers/requestStateEmittingHandler";