@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.
- package/LICENSE.md +1122 -537
- package/README.md +1 -1
- package/dist/CameraKit.d.ts +3 -3
- package/dist/CameraKit.d.ts.map +1 -1
- package/dist/CameraKit.js +1 -2
- package/dist/CameraKit.js.map +1 -1
- package/dist/RootServices.d.ts +78 -0
- package/dist/RootServices.d.ts.map +1 -0
- package/dist/RootServices.js.map +1 -0
- package/dist/bootstrapCameraKit.d.ts +3 -4
- package/dist/bootstrapCameraKit.d.ts.map +1 -1
- package/dist/bootstrapCameraKit.js +8 -8
- package/dist/bootstrapCameraKit.js.map +1 -1
- package/dist/clients/createTsProtoClient.d.ts +2 -2
- package/dist/clients/createTsProtoClient.d.ts.map +1 -1
- package/dist/clients/createTsProtoClient.js.map +1 -1
- package/dist/clients/grpcHandler.d.ts.map +1 -1
- package/dist/clients/grpcHandler.js +1 -1
- package/dist/clients/grpcHandler.js.map +1 -1
- package/dist/clients/lensesClient.js +1 -1
- package/dist/clients/lensesClient.js.map +1 -1
- package/dist/clients/metricsClient.d.ts.map +1 -1
- package/dist/clients/metricsClient.js +1 -1
- package/dist/clients/metricsClient.js.map +1 -1
- package/dist/common/pageVisibility.js +1 -1
- package/dist/common/pageVisibility.js.map +1 -1
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js +1 -1
- package/dist/environment.js.map +1 -1
- package/dist/extensions/RemoteApiServices.js +1 -1
- package/dist/extensions/RemoteApiServices.js.map +1 -1
- package/dist/extensions/UriHandlers.js +1 -1
- package/dist/extensions/UriHandlers.js.map +1 -1
- package/dist/extensions/uriHandlersRegister.d.ts.map +1 -1
- package/dist/extensions/uriHandlersRegister.js +1 -1
- package/dist/extensions/uriHandlersRegister.js.map +1 -1
- package/dist/generated-proto/blizzard/cameraKitEvents.d.ts +45 -9270
- package/dist/generated-proto/blizzard/cameraKitEvents.d.ts.map +1 -1
- package/dist/generated-proto/blizzard/cameraKitEvents.js +300 -123
- package/dist/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +12 -32
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js +77 -37
- package/dist/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts +19 -454
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.js +219 -118
- package/dist/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts +12 -12
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js +16 -13
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/ranking_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +12 -12
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +16 -13
- package/dist/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +13 -54
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -34
- package/dist/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +19 -299
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js +294 -133
- package/dist/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +14 -148
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +74 -48
- package/dist/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +12 -18
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js +34 -19
- package/dist/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts +19 -516
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js +164 -80
- package/dist/generated-proto/pb_schema/camera_kit/v3/remote_api_spec.js.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts +80 -2371
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.js +847 -174
- package/dist/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/app_launch_type.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +18 -59
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js +88 -52
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts +12 -106
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js +328 -140
- package/dist/generated-proto/pb_schema/cdp/cof/billboard_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts +12 -18
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js +35 -20
- package/dist/generated-proto/pb_schema/cdp/cof/bolt_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts +12 -34
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js +86 -39
- package/dist/generated-proto/pb_schema/cdp/cof/camera_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +47 -28591
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js +644 -348
- package/dist/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/cognac_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts +18 -214
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.js +362 -157
- package/dist/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts +20 -3801
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.js +144 -46
- package/dist/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts +49 -10060
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.js +443 -182
- package/dist/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/contact_authorization_status.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/content_manager_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts +12 -14
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js +24 -17
- package/dist/generated-proto/pb_schema/cdp/cof/creative_tools_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +14 -56
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js +78 -45
- package/dist/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts +28 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.d.ts.map +1 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js +89 -0
- package/dist/generated-proto/pb_schema/cdp/cof/discover_feed_provided_signals.js.map +1 -0
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts +28 -1103
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js +358 -210
- package/dist/generated-proto/pb_schema/cdp/cof/feature_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts +12 -16
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js +31 -23
- package/dist/generated-proto/pb_schema/cdp/cof/lenses_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts +13 -15
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js +22 -15
- package/dist/generated-proto/pb_schema/cdp/cof/mdp_media_attribution.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts +12 -14
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js +22 -15
- package/dist/generated-proto/pb_schema/cdp/cof/media_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts +12 -16
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js +29 -18
- package/dist/generated-proto/pb_schema/cdp/cof/opera_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/perception_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/recipients_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/routing_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts +12 -12
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js +16 -13
- package/dist/generated-proto/pb_schema/cdp/cof/snap_kit_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts +12 -18
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js +35 -20
- package/dist/generated-proto/pb_schema/cdp/cof/upload_provided_signals.js.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.js +0 -6
- package/dist/generated-proto/pb_schema/cdp/media/snap_source.js.map +1 -1
- package/dist/generated-proto/pb_schema/common/ruid.d.ts +12 -16
- package/dist/generated-proto/pb_schema/common/ruid.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/common/ruid.js +28 -17
- package/dist/generated-proto/pb_schema/common/ruid.js.map +1 -1
- package/dist/generated-proto/pb_schema/common/value.d.ts +25 -123
- package/dist/generated-proto/pb_schema/common/value.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/common/value.js +136 -71
- package/dist/generated-proto/pb_schema/common/value.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/asset.d.ts +12 -14
- package/dist/generated-proto/pb_schema/content/asset.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/asset.js +22 -15
- package/dist/generated-proto/pb_schema/content/asset.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_reference.d.ts +13 -46
- package/dist/generated-proto/pb_schema/content/media_reference.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_reference.js +86 -47
- package/dist/generated-proto/pb_schema/content/media_reference.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_source.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_source.js +0 -6
- package/dist/generated-proto/pb_schema/content/media_source.js.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_types.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/content/media_types.js +0 -6
- package/dist/generated-proto/pb_schema/content/media_types.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/annotations.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/annotations.js +0 -6
- package/dist/generated-proto/pb_schema/google/api/annotations.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/http.d.ts +15 -3336
- package/dist/generated-proto/pb_schema/google/api/http.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/api/http.js +129 -68
- package/dist/generated-proto/pb_schema/google/api/http.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts +12 -14
- package/dist/generated-proto/pb_schema/google/protobuf/any.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/any.js +24 -17
- package/dist/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +126 -50157
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js +1162 -563
- package/dist/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +12 -14
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js +23 -19
- package/dist/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +20 -84
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js +141 -77
- package/dist/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts +12 -23
- package/dist/generated-proto/pb_schema/lenses/geocircle.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geocircle.js +26 -18
- package/dist/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts +12 -14
- package/dist/generated-proto/pb_schema/lenses/geopoint.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/geopoint.js +22 -15
- package/dist/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts +12 -12
- package/dist/generated-proto/pb_schema/lenses/launch_params.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launch_params.js +18 -15
- package/dist/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts +15 -324
- package/dist/generated-proto/pb_schema/lenses/launchdata.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/launchdata.js +112 -66
- package/dist/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/lures.d.ts +12 -91
- package/dist/generated-proto/pb_schema/lenses/lures.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/lures.js +37 -28
- package/dist/generated-proto/pb_schema/lenses/lures.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts +12 -12
- package/dist/generated-proto/pb_schema/lenses/persistent_store.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/persistent_store.js +18 -15
- package/dist/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +30 -396
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +520 -240
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts +30 -2429
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js +991 -440
- package/dist/generated-proto/pb_schema/lenses/remote_api/remote_api_spec.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/snappable.d.ts +27 -783
- package/dist/generated-proto/pb_schema/lenses/snappable.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/snappable.js +502 -245
- package/dist/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/user_data.d.ts +15 -174
- package/dist/generated-proto/pb_schema/lenses/user_data.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/lenses/user_data.js +144 -77
- package/dist/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts +12 -14
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js +24 -17
- package/dist/generated-proto/pb_schema/snapdoc/capture_characteristics.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts +14 -18
- package/dist/generated-proto/pb_schema/snapdoc/extensions.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/extensions.js +29 -18
- package/dist/generated-proto/pb_schema/snapdoc/extensions.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media.d.ts +52 -576
- package/dist/generated-proto/pb_schema/snapdoc/media.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media.js +615 -318
- package/dist/generated-proto/pb_schema/snapdoc/media.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/media_codec_formats.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/media_file_formats.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts +12 -12
- package/dist/generated-proto/pb_schema/snapdoc/media_id.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/media_id.js +17 -17
- package/dist/generated-proto/pb_schema/snapdoc/media_id.js.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.d.ts.map +1 -1
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js +0 -6
- package/dist/generated-proto/pb_schema/snapdoc/snap_component_type.js.map +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.d.ts.map +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.js +1 -1
- package/dist/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -1
- package/dist/handlers/defaultFetchHandler.js +1 -1
- package/dist/handlers/defaultFetchHandler.js.map +1 -1
- package/dist/handlers/requestStateEmittingHandler.js +1 -1
- package/dist/handlers/requestStateEmittingHandler.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/legal/legalPrompt.js +1 -1
- package/dist/legal/legalPrompt.js.map +1 -1
- package/dist/legal/legalState.js +1 -1
- package/dist/legal/legalState.js.map +1 -1
- package/dist/lens/LensPersistenceStore.js +1 -1
- package/dist/lens/LensPersistenceStore.js.map +1 -1
- package/dist/lens/LensRepository.js +1 -1
- package/dist/lens/LensRepository.js.map +1 -1
- package/dist/lens/LensSource.js +1 -1
- package/dist/lens/LensSource.js.map +1 -1
- package/dist/lens/assets/LensAssetRepository.js +1 -1
- package/dist/lens/assets/LensAssetRepository.js.map +1 -1
- package/dist/lens/assets/LensAssetsProvider.js +1 -1
- package/dist/lens/assets/LensAssetsProvider.js.map +1 -1
- package/dist/lens/assets/deviceDependentAssetLoader.js +1 -1
- package/dist/lens/assets/deviceDependentAssetLoader.js.map +1 -1
- package/dist/lens/assets/remoteMediaAssetLoaderFactory.js +1 -1
- package/dist/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -1
- package/dist/lens/assets/staticAssetLoader.js +1 -1
- package/dist/lens/assets/staticAssetLoader.js.map +1 -1
- package/dist/lens/cameraKitLensSource.d.ts.map +1 -1
- package/dist/lens/cameraKitLensSource.js +6 -6
- package/dist/lens/cameraKitLensSource.js.map +1 -1
- package/dist/lens/fetchWatermarkLens.d.ts.map +1 -1
- package/dist/lens/fetchWatermarkLens.js +1 -1
- package/dist/lens/fetchWatermarkLens.js.map +1 -1
- package/dist/lens/userDataAccessResolver.d.ts +52 -0
- package/dist/lens/userDataAccessResolver.d.ts.map +1 -0
- package/dist/lens/userDataAccessResolver.js +3 -0
- package/dist/lens/userDataAccessResolver.js.map +1 -0
- package/dist/lens-client-interface/filePicker.d.ts.map +1 -1
- package/dist/lens-client-interface/filePicker.js +1 -1
- package/dist/lens-client-interface/filePicker.js.map +1 -1
- package/dist/lens-client-interface/lensClientInterface.js +1 -1
- package/dist/lens-client-interface/lensClientInterface.js.map +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.d.ts.map +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.js +1 -1
- package/dist/lens-core-module/loader/lensCoreFactory.js.map +1 -1
- package/dist/lensCoreWasmVersions.js +3 -3
- package/dist/lensCoreWasmVersions.js.map +1 -1
- package/dist/logger/logEntries.js +1 -1
- package/dist/logger/logEntries.js.map +1 -1
- package/dist/logger/registerLogEntriesSubscriber.d.ts.map +1 -1
- package/dist/logger/registerLogEntriesSubscriber.js +1 -1
- package/dist/logger/registerLogEntriesSubscriber.js.map +1 -1
- package/dist/media-sources/CameraKitSource.d.ts +6 -0
- package/dist/media-sources/CameraKitSource.d.ts.map +1 -1
- package/dist/media-sources/CameraKitSource.js +2 -2
- package/dist/media-sources/CameraKitSource.js.map +1 -1
- package/dist/metrics/businessEventsReporter.js +1 -1
- package/dist/metrics/businessEventsReporter.js.map +1 -1
- package/dist/metrics/metricsEventTarget.js +1 -1
- package/dist/metrics/metricsEventTarget.js.map +1 -1
- package/dist/metrics/reporters/reportBenchmarks.d.ts.map +1 -1
- package/dist/metrics/reporters/reportBenchmarks.js +1 -1
- package/dist/metrics/reporters/reportBenchmarks.js.map +1 -1
- package/dist/metrics/reporters/reportGlobalException.js +1 -1
- package/dist/metrics/reporters/reportGlobalException.js.map +1 -1
- package/dist/metrics/reporters/reportHttpMetrics.js +1 -1
- package/dist/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/dist/metrics/reporters/reportLegalState.js +1 -1
- package/dist/metrics/reporters/reportLegalState.js.map +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.d.ts.map +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.js +1 -1
- package/dist/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
- package/dist/metrics/reporters/reportLensValidationFailed.js +1 -1
- package/dist/metrics/reporters/reportLensValidationFailed.js.map +1 -1
- package/dist/metrics/reporters/reportLensView.js +1 -1
- package/dist/metrics/reporters/reportLensView.js.map +1 -1
- package/dist/metrics/reporters/reportLensWait.js +1 -1
- package/dist/metrics/reporters/reportLensWait.js.map +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.d.ts.map +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.js +1 -1
- package/dist/metrics/reporters/reportPlatformCapabilities.js.map +1 -1
- package/dist/metrics/reporters/reportSessionException.js +1 -1
- package/dist/metrics/reporters/reportSessionException.js.map +1 -1
- package/dist/metrics/reporters/reportUserSession.js +1 -1
- package/dist/metrics/reporters/reportUserSession.js.map +1 -1
- package/dist/metrics/reporters/reporters.d.ts +1 -1
- package/dist/metrics/reporters/reporters.d.ts.map +1 -1
- package/dist/metrics/reporters/reporters.js +1 -1
- package/dist/metrics/reporters/reporters.js.map +1 -1
- package/dist/remote-configuration/cofHandler.d.ts.map +1 -1
- package/dist/remote-configuration/cofHandler.js +1 -1
- package/dist/remote-configuration/cofHandler.js.map +1 -1
- package/dist/remote-configuration/preloadConfiguration.js +1 -1
- package/dist/remote-configuration/preloadConfiguration.js.map +1 -1
- package/dist/remote-configuration/remoteConfiguration.d.ts.map +1 -1
- package/dist/remote-configuration/remoteConfiguration.js +1 -1
- package/dist/remote-configuration/remoteConfiguration.js.map +1 -1
- package/dist/session/CameraKitSession.d.ts +6 -1
- package/dist/session/CameraKitSession.d.ts.map +1 -1
- package/dist/session/CameraKitSession.js +1 -1
- package/dist/session/CameraKitSession.js.map +1 -1
- package/dist/session/LensKeyboard.js +1 -1
- package/dist/session/LensKeyboard.js.map +1 -1
- package/dist/session/lensState.d.ts +3 -2
- package/dist/session/lensState.d.ts.map +1 -1
- package/dist/session/lensState.js +9 -3
- package/dist/session/lensState.js.map +1 -1
- package/dist/session/sessionState.js +1 -1
- package/dist/session/sessionState.js.map +1 -1
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/CameraKit.html +2 -2
- package/docs/html/classes/CameraKitSession.html +7 -3
- package/docs/html/classes/CameraKitSource.html +6 -2
- package/docs/html/classes/LensPerformanceMeasurement.html +2 -2
- package/docs/html/classes/LensPerformanceMetrics.html +2 -2
- package/docs/html/classes/LensRepository.html +2 -2
- package/docs/html/classes/Transform2D.html +2 -2
- package/docs/html/classes/TypedCustomEvent.html +2 -2
- package/docs/html/classes/TypedEventTarget.html +2 -2
- package/docs/html/enums/Lens_CameraFacing.html +2 -2
- package/docs/html/functions/bootstrapCameraKit.html +2 -2
- package/docs/html/functions/createExtension.html +2 -2
- package/docs/html/functions/createImageSource.html +2 -2
- package/docs/html/functions/createMediaStreamSource.html +2 -2
- package/docs/html/functions/createVideoSource.html +2 -2
- package/docs/html/functions/estimateLensPerformance.html +2 -2
- package/docs/html/functions/filePickerFactory.html +2 -4
- package/docs/html/functions/lensSourcesFactory.html +3 -5
- package/docs/html/functions/remoteApiServicesFactory.html +1 -3
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +3 -3
- package/docs/html/interfaces/BitmojiUserInfo.html +2 -2
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +2 -2
- package/docs/html/interfaces/CameraKitDeviceOptions.html +2 -2
- package/docs/html/interfaces/CameraKitSourceInfo.html +2 -2
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +2 -2
- package/docs/html/interfaces/ComputedFrameMetrics.html +2 -2
- package/docs/html/interfaces/CreateSessionOptions.html +2 -2
- package/docs/html/interfaces/EstimatedLensPerformance.html +2 -2
- package/docs/html/interfaces/FriendUserInfo.html +2 -2
- package/docs/html/interfaces/FunctionSourceOptions.html +2 -2
- package/docs/html/interfaces/Lens.html +2 -2
- package/docs/html/interfaces/LensCreator.html +2 -2
- package/docs/html/interfaces/LensLaunchData.html +2 -2
- package/docs/html/interfaces/LensSource.html +2 -2
- package/docs/html/interfaces/LensUserData.html +2 -2
- package/docs/html/interfaces/LoadAssetRequest.html +2 -2
- package/docs/html/interfaces/MediaStreamSourceOptions.html +2 -2
- package/docs/html/interfaces/Preview.html +2 -2
- package/docs/html/interfaces/RemoteApiRequest.html +2 -2
- package/docs/html/interfaces/RemoteApiResponse.html +2 -2
- package/docs/html/interfaces/RemoteApiService.html +2 -2
- package/docs/html/interfaces/Snapcode.html +2 -2
- package/docs/html/interfaces/UriCancelRequest.html +2 -2
- package/docs/html/interfaces/UriRequest.html +2 -2
- package/docs/html/interfaces/UriResponse.html +2 -2
- package/docs/html/interfaces/VideoSourceOptions.html +2 -2
- package/docs/html/modules.html +2 -4
- package/docs/html/types/ArgumentValidationError.html +2 -2
- package/docs/html/types/AssetLoader.html +2 -2
- package/docs/html/types/AssetResponse.html +1 -1
- package/docs/html/types/AssetTiming.html +2 -2
- package/docs/html/types/BenchmarkError.html +1 -1
- package/docs/html/types/BootstrapError.html +2 -2
- package/docs/html/types/CacheKeyNotFoundError.html +1 -1
- package/docs/html/types/CameraKitSessionEventListener.html +2 -2
- package/docs/html/types/CameraKitSessionEvents.html +2 -2
- package/docs/html/types/CameraKitSourceError.html +1 -1
- package/docs/html/types/ConfigurationError.html +2 -2
- package/docs/html/types/FetchHandler.html +1 -1
- package/docs/html/types/FilePicker.html +2 -2
- package/docs/html/types/FilePickerOptions.html +2 -2
- package/docs/html/types/FilePickerResult.html +2 -2
- package/docs/html/types/Keyboard.html +2 -2
- package/docs/html/types/KeyboardEvents.html +2 -2
- package/docs/html/types/LegalError.html +1 -1
- package/docs/html/types/LensAbortError.html +2 -2
- package/docs/html/types/LensAssetError.html +2 -2
- package/docs/html/types/LensContentValidationError.html +1 -1
- package/docs/html/types/LensError.html +1 -1
- package/docs/html/types/LensExecutionError.html +2 -2
- package/docs/html/types/LensImagePickerError.html +2 -2
- package/docs/html/types/LensLaunchParams.html +2 -2
- package/docs/html/types/LensMetricsEvents.html +2 -2
- package/docs/html/types/LensPerformanceCluster.html +1 -1
- package/docs/html/types/LensView.html +2 -2
- package/docs/html/types/LensWait.html +2 -2
- package/docs/html/types/Matrix.html +2 -2
- package/docs/html/types/PersistentStoreError.html +2 -2
- package/docs/html/types/PlatformNotSupportedError.html +2 -2
- package/docs/html/types/PublicContainer.html +2 -2
- package/docs/html/types/PublicServices.html +2 -2
- package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -2
- package/docs/html/types/RemoteApiRequestHandler.html +2 -2
- package/docs/html/types/RemoteApiServices.html +1 -1
- package/docs/html/types/RemoteApiStatus.html +2 -2
- package/docs/html/types/RenderTarget.html +2 -2
- package/docs/html/types/Uri.html +1 -1
- package/docs/html/types/WebGLError.html +1 -1
- package/docs/html/types/Zodiac.html +1 -1
- package/docs/html/variables/extensionRequestContext.html +2 -2
- package/docs/md/README.md +1 -1
- package/docs/md/classes/CameraKit.md +1 -1
- package/docs/md/classes/CameraKitSession.md +7 -2
- package/docs/md/classes/CameraKitSource.md +6 -1
- package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
- package/docs/md/classes/LensPerformanceMetrics.md +1 -1
- package/docs/md/classes/LensRepository.md +1 -1
- package/docs/md/classes/Transform2D.md +1 -1
- package/docs/md/classes/TypedCustomEvent.md +1 -1
- package/docs/md/classes/TypedEventTarget.md +1 -1
- package/docs/md/enums/Lens_CameraFacing.md +1 -1
- package/docs/md/interfaces/BitmojiUserInfo.md +1 -1
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
- package/docs/md/interfaces/CameraKitDeviceOptions.md +1 -1
- package/docs/md/interfaces/CameraKitSourceInfo.md +1 -1
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
- package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
- package/docs/md/interfaces/CreateSessionOptions.md +1 -1
- package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
- package/docs/md/interfaces/FriendUserInfo.md +1 -1
- package/docs/md/interfaces/FunctionSourceOptions.md +1 -1
- package/docs/md/interfaces/Lens.md +1 -1
- package/docs/md/interfaces/LensCreator.md +1 -1
- package/docs/md/interfaces/LensLaunchData.md +1 -1
- package/docs/md/interfaces/LensSource.md +1 -1
- package/docs/md/interfaces/LensUserData.md +1 -1
- package/docs/md/interfaces/LoadAssetRequest.md +1 -1
- package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
- package/docs/md/interfaces/Preview.md +1 -1
- package/docs/md/interfaces/RemoteApiRequest.md +1 -1
- package/docs/md/interfaces/RemoteApiResponse.md +1 -1
- package/docs/md/interfaces/RemoteApiService.md +1 -1
- package/docs/md/interfaces/Snapcode.md +1 -1
- package/docs/md/interfaces/UriCancelRequest.md +1 -1
- package/docs/md/interfaces/UriRequest.md +1 -1
- package/docs/md/interfaces/UriResponse.md +1 -1
- package/docs/md/interfaces/VideoSourceOptions.md +1 -1
- package/docs/md/modules.md +5 -166
- package/package.json +5 -5
- package/dist/dependency-injection/Container.d.ts +0 -177
- package/dist/dependency-injection/Container.d.ts.map +0 -1
- package/dist/dependency-injection/Container.js +0 -72
- package/dist/dependency-injection/Container.js.map +0 -1
- package/dist/dependency-injection/Injectable.d.ts +0 -96
- package/dist/dependency-injection/Injectable.d.ts.map +0 -1
- package/dist/dependency-injection/Injectable.js +0 -37
- package/dist/dependency-injection/Injectable.js.map +0 -1
- package/dist/dependency-injection/PartialContainer.d.ts +0 -86
- package/dist/dependency-injection/PartialContainer.d.ts.map +0 -1
- package/dist/dependency-injection/PartialContainer.js +0 -28
- package/dist/dependency-injection/PartialContainer.js.map +0 -1
- package/dist/dependency-injection/RootServices.d.ts +0 -76
- package/dist/dependency-injection/RootServices.d.ts.map +0 -1
- package/dist/dependency-injection/RootServices.js.map +0 -1
- package/dist/dependency-injection/types.d.ts +0 -57
- package/dist/dependency-injection/types.d.ts.map +0 -1
- package/dist/dependency-injection/types.js +0 -2
- package/dist/dependency-injection/types.js.map +0 -1
- package/docs/html/functions/ConcatInjectable.html +0 -19
- package/docs/html/functions/Injectable.html +0 -17
- /package/dist/{dependency-injection/RootServices.js → RootServices.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportLensAndAssetDownload.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensAndAssetDownload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAG5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAe7C,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,OAAO,CAAU,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAiB,EAA6D,EAAE;IACjH,MAAM,WAAW,GAAG,KAAK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AI,gBAAgB,CAAC,WAAW,EAAE;wBACrC,IAAI,EAAE,WAAW;wBACjB,MAAM,EAAE,UAAU,CAAC,MAAM;wBACzB,IAAI,EAAE,UAAU,CAAC,WAAW,KAAK,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;wBAClE,MAAM,EAAE,cAAc,CAAC,KAAK,CAAC;qBAChC,CAAC;iBACL,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;QACvC,kBAAkB,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE;YACzC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SACzG;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { assertUnreachable } from \"../../common/assertions\";\nimport { stringifyError } from \"../../common/errorHelpers\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { scan } from \"../../events/scan\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { Dimensions, RequestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport { requestStateEventTargetFactory } from \"../../handlers/requestStateEmittingHandler\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { CameraKitMetricEvents, MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { Count } from \"../operational/Count\";\nimport type { Timer } from \"../operational/Timer\";\n\ntype InProgressMap = Map<number, { timer: Timer<string> }>;\ninterface InProgress {\n name: \"inProgress\";\n inProgress: InProgressMap;\n}\ninterface Completed {\n name: \"completed\";\n inProgress: InProgressMap;\n event: CameraKitMetricEvents;\n}\ntype RequestState = InProgress | Completed;\n\nconst relevantRequestTypes = [\"lens_content\", \"asset\"] as const;\nexport const isLensOrAssetRequest = (value: Dimensions): value is LensDownloadDimensions | AssetDownloadDimensions => {\n const requestType = value[\"requestType\"];\n // Safety: the cast makes the type less specific so we can check if any string is present in the tuple.\n return typeof requestType === \"string\" && (relevantRequestTypes as readonly string[]).includes(requestType);\n};\n\n/**\n * The LensDownload metric is triggered by any download of lens content.\n *\n * It contains download stats, which lens was requested, and whether prefetch was used.\n *\n * It corresponds to the internal CameraKitLensDownload event, described here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.stqom49qs91t\n */\nexport type LensDownload = MakeTaggedBusinessEvent<\"lensDownload\">;\nexport type LensDownloadDimensions = { requestType: \"lens_content\"; lensId: string };\n\n/**\n * The AssetDownload metric is triggered by any type of asset download.\n *\n * It contains download stats, which asset was requested, and whether prefetch was used.\n *\n * It corresponds to the internal CameraKitAssetDownload event, described here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.vlormd1724fp\n */\nexport type AssetDownload = MakeTaggedBusinessEvent<\"assetDownload\">;\nexport type AssetDownloadDimensions = { requestType: \"asset\"; assetType: string; assetId: string; lensId: string };\n\nexport const reportLensAndAssetDownload = Injectable(\n \"reportLensAndAssetDownload\",\n [metricsEventTargetFactory.token, metricsClientFactory.token, requestStateEventTargetFactory.token] as const,\n (\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n requestStateEventTarget: RequestStateEventTarget\n ) => {\n scan<RequestState>({ name: \"inProgress\", inProgress: new Map() })(\n requestStateEventTarget,\n [\"started\", \"completed\", \"errored\"],\n (state, event): RequestState => {\n const { inProgress } = state;\n const { dimensions, requestId } = event.detail;\n\n if (!isLensOrAssetRequest(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 const completedRequest = inProgress.get(requestId);\n if (!completedRequest) return state;\n inProgress.delete(requestId);\n\n const { duration } = completedRequest.timer.measure() ?? { duration: 0 };\n const downloadTimeSec = duration / 1000;\n const { sizeByte } = event.detail;\n\n switch (dimensions.requestType) {\n case \"lens_content\":\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"lensDownload\", {\n name: \"lensDownload\",\n lensId: dimensions.lensId,\n automaticDownload: false,\n sizeByte: `${Math.ceil(sizeByte)}`,\n downloadTimeSec,\n }),\n };\n case \"asset\":\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"assetDownload\", {\n name: \"assetDownload\",\n assetId: dimensions.assetId,\n automaticDownload: false,\n sizeByte: `${Math.ceil(sizeByte)}`,\n downloadTimeSec,\n }),\n };\n default:\n assertUnreachable(dimensions);\n }\n case \"errored\":\n const erroredRequest = inProgress.get(requestId);\n if (!erroredRequest) return state;\n inProgress.delete(requestId);\n const error = event.detail.error;\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId: dimensions.lensId,\n type: dimensions.requestType === \"lens_content\" ? \"lens\" : \"asset\",\n reason: stringifyError(error),\n }),\n };\n default:\n assertUnreachable(event);\n }\n }\n ).addEventListener(\"state\", ({ detail: state }) => {\n if (state.name !== \"completed\") return;\n metricsEventTarget.dispatchEvent(state.event);\n if (state.event.detail.name === \"exception\") {\n metrics.setOperationalMetrics(Count.count(\"handled_exception\", 1, { type: state.event.detail.type }));\n }\n });\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"reportLensAndAssetDownload.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensAndAssetDownload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAG5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAe7C,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,OAAO,CAAU,CAAC;AAChE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAiB,EAA6D,EAAE;IACjH,MAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC;IAEzC,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAK,oBAA0C,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAChH,CAAC,CAAC;AAwBF,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,4BAA4B,EAC5B,CAAC,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,EAAE,8BAA8B,CAAC,KAAK,CAAU,EAC5G,CACI,kBAAsC,EACtC,OAAsB,EACtB,uBAAgD,EAClD,EAAE;IACA,IAAI,CAAe,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC,CAC7D,uBAAuB,EACvB,CAAC,SAAS,EAA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B,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE;YACzC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SACzG;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { assertUnreachable } from \"../../common/assertions\";\nimport { stringifyError } from \"../../common/errorHelpers\";\nimport { scan } from \"../../events/scan\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { Dimensions, RequestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport { requestStateEventTargetFactory } from \"../../handlers/requestStateEmittingHandler\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { CameraKitMetricEvents, MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { Count } from \"../operational/Count\";\nimport type { Timer } from \"../operational/Timer\";\n\ntype InProgressMap = Map<number, { timer: Timer<string> }>;\ninterface InProgress {\n name: \"inProgress\";\n inProgress: InProgressMap;\n}\ninterface Completed {\n name: \"completed\";\n inProgress: InProgressMap;\n event: CameraKitMetricEvents;\n}\ntype RequestState = InProgress | Completed;\n\nconst relevantRequestTypes = [\"lens_content\", \"asset\"] as const;\nexport const isLensOrAssetRequest = (value: Dimensions): value is LensDownloadDimensions | AssetDownloadDimensions => {\n const requestType = value[\"requestType\"];\n // Safety: the cast makes the type less specific so we can check if any string is present in the tuple.\n return typeof requestType === \"string\" && (relevantRequestTypes as readonly string[]).includes(requestType);\n};\n\n/**\n * The LensDownload metric is triggered by any download of lens content.\n *\n * It contains download stats, which lens was requested, and whether prefetch was used.\n *\n * It corresponds to the internal CameraKitLensDownload event, described here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.stqom49qs91t\n */\nexport type LensDownload = MakeTaggedBusinessEvent<\"lensDownload\">;\nexport type LensDownloadDimensions = { requestType: \"lens_content\"; lensId: string };\n\n/**\n * The AssetDownload metric is triggered by any type of asset download.\n *\n * It contains download stats, which asset was requested, and whether prefetch was used.\n *\n * It corresponds to the internal CameraKitAssetDownload event, described here:\n * https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.vlormd1724fp\n */\nexport type AssetDownload = MakeTaggedBusinessEvent<\"assetDownload\">;\nexport type AssetDownloadDimensions = { requestType: \"asset\"; assetType: string; assetId: string; lensId: string };\n\nexport const reportLensAndAssetDownload = Injectable(\n \"reportLensAndAssetDownload\",\n [metricsEventTargetFactory.token, metricsClientFactory.token, requestStateEventTargetFactory.token] as const,\n (\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n requestStateEventTarget: RequestStateEventTarget\n ) => {\n scan<RequestState>({ name: \"inProgress\", inProgress: new Map() })(\n requestStateEventTarget,\n [\"started\", \"completed\", \"errored\"],\n (state, event): RequestState => {\n const { inProgress } = state;\n const { dimensions, requestId } = event.detail;\n\n if (!isLensOrAssetRequest(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 const completedRequest = inProgress.get(requestId);\n if (!completedRequest) return state;\n inProgress.delete(requestId);\n\n const { duration } = completedRequest.timer.measure() ?? { duration: 0 };\n const downloadTimeSec = duration / 1000;\n const { sizeByte } = event.detail;\n\n switch (dimensions.requestType) {\n case \"lens_content\":\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"lensDownload\", {\n name: \"lensDownload\",\n lensId: dimensions.lensId,\n automaticDownload: false,\n sizeByte: `${Math.ceil(sizeByte)}`,\n downloadTimeSec,\n }),\n };\n case \"asset\":\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"assetDownload\", {\n name: \"assetDownload\",\n assetId: dimensions.assetId,\n automaticDownload: false,\n sizeByte: `${Math.ceil(sizeByte)}`,\n downloadTimeSec,\n }),\n };\n default:\n assertUnreachable(dimensions);\n }\n case \"errored\":\n const erroredRequest = inProgress.get(requestId);\n if (!erroredRequest) return state;\n inProgress.delete(requestId);\n const error = event.detail.error;\n return {\n name: \"completed\",\n inProgress,\n event: new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId: dimensions.lensId,\n type: dimensions.requestType === \"lens_content\" ? \"lens\" : \"asset\",\n reason: stringifyError(error),\n }),\n };\n default:\n assertUnreachable(event);\n }\n }\n ).addEventListener(\"state\", ({ detail: state }) => {\n if (state.name !== \"completed\") return;\n metricsEventTarget.dispatchEvent(state.event);\n if (state.event.detail.name === \"exception\") {\n metrics.setOperationalMetrics(Count.count(\"handled_exception\", 1, { type: state.event.detail.type }));\n }\n });\n }\n);\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forActions } from "@snap/state-management";
|
|
2
2
|
import { filter } from "rxjs";
|
|
3
|
-
import { Injectable } from "
|
|
3
|
+
import { Injectable } from "@snap/ts-inject";
|
|
4
4
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
5
5
|
import { lensStateFactory } from "../../session/lensState";
|
|
6
6
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportLensValidationFailed.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensValidationFailed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reportLensValidationFailed.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensValidationFailed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAUlE,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,4BAA4B,EAC5B,CAAC,gBAAgB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,CAAU,EAClE,CAAC,SAAoB,EAAE,kBAAsC,EAAE,EAAE;IAC7D,SAAS,CAAC,MAAM;SACX,IAAI,CACD,UAAU,CAAC,iBAAiB,CAAC,EAC7B,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,4BAA4B,CAAC,CACtE;SACA,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;YACjB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;YACtB,MAAM,2BAA2B,GAAgC;gBAC7D,IAAI,EAAE,6BAA6B;gBACnC,MAAM,EAAE,IAAI,CAAC,EAAE;aAClB,CAAC;YACF,kBAAkB,CAAC,aAAa,CAC5B,IAAI,gBAAgB,CAAC,6BAA6B,EAAE,2BAA2B,CAAC,CACnF,CAAC;QACN,CAAC;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { forActions } from \"@snap/state-management\";\nimport { filter } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\n\n/**\n * The LensContentValidationFailed metric reports every time we handle an lens checksum validation failure.\n */\nexport type LensContentValidationFailed = MakeTaggedBusinessEvent<\"lensContentValidationFailed\">;\n\n/**\n * @internal\n */\nexport const reportLensValidationFailed = Injectable(\n \"reportLensValidationFailed\",\n [lensStateFactory.token, metricsEventTargetFactory.token] as const,\n (lensState: LensState, metricsEventTarget: MetricsEventTarget) => {\n lensState.events\n .pipe(\n forActions(\"applyLensFailed\"),\n filter(([a]) => a.data.error.name === \"LensContentValidationError\")\n )\n .subscribe({\n next: ([{ data }]) => {\n const { lens } = data;\n const lensContentValidationFailed: LensContentValidationFailed = {\n name: \"lensContentValidationFailed\",\n lensId: lens.id,\n };\n metricsEventTarget.dispatchEvent(\n new TypedCustomEvent(\"lensContentValidationFailed\", lensContentValidationFailed)\n );\n },\n });\n }\n);\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { combineLatestWith, filter, from, map, merge, mergeMap, of, raceWith, switchMap, take, takeUntil } from "rxjs";
|
|
3
3
|
import { forActions, inStates, isState } from "@snap/state-management";
|
|
4
|
-
import { Injectable } from "
|
|
4
|
+
import { Injectable } from "@snap/ts-inject";
|
|
5
5
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
6
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
7
7
|
import { cameraKitSessionFactory } from "../../session/CameraKitSession";
|
|
@@ -1 +1 @@
|
|
|
1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AAK,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;YAKhF,IAAI,oBAAoB,IAAI,EAAE,EAAE;gBAC5B,OAAO,CAAC,qBAAqB,CACzB,SAAS,CAAC,KAAK,CAAC,iCAAiC,EAAE,+BAA+B,EAAE;oBAChF,mBAAmB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;iBACrD,CAAC,CACL,CAAC;aACL;QACL,CAAC,CAAA;KACJ,CAAC,CAAC;AACX,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { combineLatestWith, filter, from, map, merge, mergeMap, of, raceWith, switchMap, take, takeUntil } from \"rxjs\";\nimport { forActions, inStates, isState } from \"@snap/state-management\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { CameraKitSession } from \"../../session/CameraKitSession\";\nimport { cameraKitSessionFactory } from \"../../session/CameraKitSession\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { getTimeMs } from \"../../common/time\";\nimport type { CameraKitConfiguration } from \"../../configuration\";\nimport { configurationToken } from \"../../configuration\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport type { SessionState } from \"../../session/sessionState\";\nimport { sessionStateFactory } from \"../../session/sessionState\";\nimport { Histogram } from \"../operational/Histogram\";\nimport { IndexedDBPersistence } from \"../../persistence/IndexedDBPersistence\";\nimport { ExpiringPersistence } from \"../../persistence/ExpiringPersistence\";\nimport { dayFormatter, monthFormatter } from \"../../common/date\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\n\n// We ignore short-duration lens views.\n//\n// The value is documented here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.q5liip76r9lt\nconst viewTimeThresholdSec = 0.1;\n\nasync function isFirstTimeWithinPeriods(lensId: string, persistence: ExpiringPersistence<Date>) {\n let isLensFirstWithinDay = false;\n let isLensFirstWithinMonth = false;\n\n try {\n const lensLastViewDate = await persistence.retrieve(lensId);\n const currentDate = new Date();\n\n if (!lensLastViewDate) {\n isLensFirstWithinDay = true;\n isLensFirstWithinMonth = true;\n } else {\n isLensFirstWithinDay = dayFormatter.format(lensLastViewDate) !== dayFormatter.format(currentDate);\n isLensFirstWithinMonth = monthFormatter.format(lensLastViewDate) !== monthFormatter.format(currentDate);\n }\n\n await persistence.store(lensId, currentDate);\n } catch (error) {\n console.error(`Error handling persistence for lensId ${lensId}: ${error}`);\n isLensFirstWithinDay = false;\n isLensFirstWithinMonth = false;\n }\n\n return { isLensFirstWithinDay, isLensFirstWithinMonth };\n}\n\n/**\n * The LensView metric is emitted after a lens has been viewed (for longer than 100ms), when the lens is turned off.\n *\n * It contains information about rendering performance.\n *\n * Notes:\n * - If the page is hidden (e.g. user switches to a different tab, or application, or closes the tab, or closes the\n * browser, navigates to a new page, refreshes, etc.) this metric will be emitted at that time. This is to ensure\n * we don't lose the metric if the page is closed.\n * - If the page is hidden and then made visible again later (e.g. user switches to a different tab, then back), we\n * will begin measuring a new LensView. That is, we will not capture the time when the page is hidden even if the\n * lens is still rendering in the background.\n *\n * @category Lenses\n * @category Metrics\n */\n// This type corresponds to the internal CameraKitLensSwipe event, described here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY#heading=h.q5liip76r9lt\nexport type LensView = MakeTaggedBusinessEvent<\"lensView\">;\n\n/**\n * @internal\n */\nexport const reportLensView = Injectable(\n \"reportLensView\",\n [\n cameraKitSessionFactory.token,\n lensStateFactory.token,\n sessionStateFactory.token,\n metricsEventTargetFactory.token,\n metricsClientFactory.token,\n configurationToken,\n ] as const,\n async (\n session: CameraKitSession,\n lensState: LensState,\n sessionState: SessionState,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n configuration: CameraKitConfiguration\n ): Promise<void> => {\n // We need to do this await up front so that it won't interrupt reporting the metric when the session is\n // suspended -- suspension could happen because the tab is closing, in which case we cannot perform await a\n // Promise, because in the case of a tab close the browser will not schedule any work for future turns of the\n // event loop.\n const { cluster: performanceCluster, webglRendererInfo } = (await configuration.lensPerformance) ?? {\n cluster: 0,\n webglRendererInfo: \"unknown\",\n };\n\n const lensViewPersistence = new ExpiringPersistence<Date>(\n // 60 days expiration\n () => 60 * 24 * 60 * 60,\n new IndexedDBPersistence({ databaseName: \"recentLensViews\" })\n );\n\n merge(\n // Begin measuring LensCore apply time once the lens has finished downloading and we actually add the lens\n // to LensCore (LensWait measures the full download + LensCore apply time i.e. perceived UX latency).\n lensState.events.pipe(\n forActions(\"downloadComplete\"),\n map(([a]) => a.data)\n ),\n\n // If the session is resumed (e.g. user returns to this tab while a lens is on), we count this as a new\n // LensView (and applyDelaySec will be 0).\n lensState.events.pipe(\n inStates(\"lensApplied\"),\n switchMap(([, s]) =>\n sessionState.events.pipe(\n forActions(\"resume\"),\n takeUntil(lensState.events.pipe(forActions(\"removeLens\"))),\n map(() => s.data)\n )\n )\n )\n )\n .pipe(\n map((lens): [number, string, string] => [getTimeMs(), lens.id, lens.groupId]),\n mergeMap(([applyLensStartTime, lensId, lensGroupId]) => {\n const alreadyOn = isState(lensState.getState(), \"lensApplied\");\n\n const applyDelay = alreadyOn\n ? of(0)\n : lensState.events.pipe(\n forActions(\"resourcesLoaded\"),\n filter(([a]) => a.data.id === lensId),\n // Applying a new lens may happen before removing the old one, so if we kept taking events\n // we would get the lensResourcesLoaded for the next lens, too.\n take(1),\n map(() => (getTimeMs() - applyLensStartTime) / 1000)\n );\n\n const viewMetrics = (\n alreadyOn\n ? of([getTimeMs(), session.metrics.beginMeasurement()] as const)\n : lensState.events.pipe(\n forActions(\"turnedOn\"),\n filter(([a]) => a.data.id === lensId),\n map(() => [getTimeMs(), session.metrics.beginMeasurement()] as const)\n )\n ).pipe(\n take(1),\n mergeMap(([lensTurnedOnTime, metricsMeasurement]) =>\n lensState.events.pipe(\n forActions(\"turnedOff\"),\n // Applying a new lens may happen before removing the old one, so we'll get a\n // lensTurnedOff for the prior lens (if one was applied), which we must filter out.\n filter(([a]) => a.data.id === lensId),\n // If the session is suspended, we'll count that as the lens turning off.\n raceWith(sessionState.events.pipe(forActions(\"suspend\"))),\n map(() => {\n metricsMeasurement.end();\n return {\n viewTimeSec: (getTimeMs() - lensTurnedOnTime) / 1000,\n ...metricsMeasurement.measure(),\n };\n })\n )\n )\n );\n\n return applyDelay.pipe(\n combineLatestWith(viewMetrics, from(isFirstTimeWithinPeriods(lensId, lensViewPersistence))),\n // This lens should always receive the lensTurnedOff action *before* the next lens is\n // turned on. But just in case that assumption is violated, we'll clean up\n // (and not report) if another lens turns on before our lens is turned off.\n takeUntil(\n lensState.events.pipe(\n forActions(\"turnedOn\"),\n filter(([a]) => a.data.id !== lensId)\n )\n ),\n take(1),\n map(([applyDelaySec, viewMetrics, isFirstTimeResults]) => ({\n applyDelaySec,\n lensId,\n lensGroupId,\n ...viewMetrics,\n ...isFirstTimeResults,\n }))\n );\n })\n )\n .subscribe({\n next: async ({\n applyDelaySec,\n lensId,\n lensGroupId,\n viewTimeSec,\n avgFps,\n lensFrameProcessingTimeMsAvg,\n lensFrameProcessingTimeMsStd,\n lensFrameProcessingTimeMsMedian,\n lensFrameProcessingN,\n isLensFirstWithinDay,\n isLensFirstWithinMonth,\n }) => {\n if (viewTimeSec < viewTimeThresholdSec) return;\n\n const lensView: LensView = {\n name: \"lensView\",\n applyDelaySec,\n avgFps,\n lensId,\n lensGroupId,\n lensFrameProcessingTimeMsAvg,\n lensFrameProcessingTimeMsStd,\n // We don't support recording video, but applications may do this without our knowledge.\n recordingTimeSec: 0,\n viewTimeSec,\n isLensFirstWithinDay,\n isLensFirstWithinMonth,\n performanceCluster: `${performanceCluster}`,\n webglRendererInfo,\n };\n\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"lensView\", lensView));\n metrics.setOperationalMetrics(Histogram.level(\"lens_view\", viewTimeSec * 1000));\n\n // The first few frames will typically take much longer to process (as they might involve requesting\n // remote assets to be downloaded, or other high-latency initialization steps) -- so we'll skip\n // reporting views with a very small number of frames.\n if (lensFrameProcessingN >= 30) {\n metrics.setOperationalMetrics(\n Histogram.level(\"lens_view_frame-processing-time\", lensFrameProcessingTimeMsMedian, {\n performance_cluster: performanceCluster.toString(),\n })\n );\n }\n },\n });\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"reportLensView.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensView.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,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U;gBAChB,aAAa;gBACb,MAAM;gBACN,MAAM;gBACN,WAAW;gBACX,4BAA4B;gBAC5B,4BAA4B;gBAE5B,gBAAgB,EAAE,CAAC;gBACnB,WAAW;gBACX,oBAAoB;gBACpB,sBAAsB;gBACtB,kBAAkB,EAAE,GAAG,kBAAkB,EAAE;gBAC3C,iBAAiB;aACpB,CAAC;YAEF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC7E,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC;YAKhF,IAAI,oBAAoB,IAAI,EAAE,EAAE;gBAC5B,OAAO,CAAC,qBAAqB,CACzB,SAAS,CAAC,KAAK,CAAC,iCAAiC,EAAE,+BAA+B,EAAE;oBAChF,mBAAmB,EAAE,kBAAkB,CAAC,QAAQ,EAAE;iBACrD,CAAC,CACL,CAAC;aACL;QACL,CAAC,CAAA;KACJ,CAAC,CAAC;AACX,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { combineLatestWith, filter, from, map, merge, mergeMap, of, raceWith, switchMap, take, takeUntil } from \"rxjs\";\nimport { forActions, inStates, isState } from \"@snap/state-management\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport type { CameraKitSession } from \"../../session/CameraKitSession\";\nimport { cameraKitSessionFactory } from \"../../session/CameraKitSession\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { getTimeMs } from \"../../common/time\";\nimport type { CameraKitConfiguration } from \"../../configuration\";\nimport { configurationToken } from \"../../configuration\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport type { SessionState } from \"../../session/sessionState\";\nimport { sessionStateFactory } from \"../../session/sessionState\";\nimport { Histogram } from \"../operational/Histogram\";\nimport { IndexedDBPersistence } from \"../../persistence/IndexedDBPersistence\";\nimport { ExpiringPersistence } from \"../../persistence/ExpiringPersistence\";\nimport { dayFormatter, monthFormatter } from \"../../common/date\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\n\n// We ignore short-duration lens views.\n//\n// The value is documented here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.q5liip76r9lt\nconst viewTimeThresholdSec = 0.1;\n\nasync function isFirstTimeWithinPeriods(lensId: string, persistence: ExpiringPersistence<Date>) {\n let isLensFirstWithinDay = false;\n let isLensFirstWithinMonth = false;\n\n try {\n const lensLastViewDate = await persistence.retrieve(lensId);\n const currentDate = new Date();\n\n if (!lensLastViewDate) {\n isLensFirstWithinDay = true;\n isLensFirstWithinMonth = true;\n } else {\n isLensFirstWithinDay = dayFormatter.format(lensLastViewDate) !== dayFormatter.format(currentDate);\n isLensFirstWithinMonth = monthFormatter.format(lensLastViewDate) !== monthFormatter.format(currentDate);\n }\n\n await persistence.store(lensId, currentDate);\n } catch (error) {\n console.error(`Error handling persistence for lensId ${lensId}: ${error}`);\n isLensFirstWithinDay = false;\n isLensFirstWithinMonth = false;\n }\n\n return { isLensFirstWithinDay, isLensFirstWithinMonth };\n}\n\n/**\n * The LensView metric is emitted after a lens has been viewed (for longer than 100ms), when the lens is turned off.\n *\n * It contains information about rendering performance.\n *\n * Notes:\n * - If the page is hidden (e.g. user switches to a different tab, or application, or closes the tab, or closes the\n * browser, navigates to a new page, refreshes, etc.) this metric will be emitted at that time. This is to ensure\n * we don't lose the metric if the page is closed.\n * - If the page is hidden and then made visible again later (e.g. user switches to a different tab, then back), we\n * will begin measuring a new LensView. That is, we will not capture the time when the page is hidden even if the\n * lens is still rendering in the background.\n *\n * @category Lenses\n * @category Metrics\n */\n// This type corresponds to the internal CameraKitLensSwipe event, described here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY#heading=h.q5liip76r9lt\nexport type LensView = MakeTaggedBusinessEvent<\"lensView\">;\n\n/**\n * @internal\n */\nexport const reportLensView = Injectable(\n \"reportLensView\",\n [\n cameraKitSessionFactory.token,\n lensStateFactory.token,\n sessionStateFactory.token,\n metricsEventTargetFactory.token,\n metricsClientFactory.token,\n configurationToken,\n ] as const,\n async (\n session: CameraKitSession,\n lensState: LensState,\n sessionState: SessionState,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n configuration: CameraKitConfiguration\n ): Promise<void> => {\n // We need to do this await up front so that it won't interrupt reporting the metric when the session is\n // suspended -- suspension could happen because the tab is closing, in which case we cannot perform await a\n // Promise, because in the case of a tab close the browser will not schedule any work for future turns of the\n // event loop.\n const { cluster: performanceCluster, webglRendererInfo } = (await configuration.lensPerformance) ?? {\n cluster: 0,\n webglRendererInfo: \"unknown\",\n };\n\n const lensViewPersistence = new ExpiringPersistence<Date>(\n // 60 days expiration\n () => 60 * 24 * 60 * 60,\n new IndexedDBPersistence({ databaseName: \"recentLensViews\" })\n );\n\n merge(\n // Begin measuring LensCore apply time once the lens has finished downloading and we actually add the lens\n // to LensCore (LensWait measures the full download + LensCore apply time i.e. perceived UX latency).\n lensState.events.pipe(\n forActions(\"downloadComplete\"),\n map(([a]) => a.data)\n ),\n\n // If the session is resumed (e.g. user returns to this tab while a lens is on), we count this as a new\n // LensView (and applyDelaySec will be 0).\n lensState.events.pipe(\n inStates(\"lensApplied\"),\n switchMap(([, s]) =>\n sessionState.events.pipe(\n forActions(\"resume\"),\n takeUntil(lensState.events.pipe(forActions(\"removeLens\"))),\n map(() => s.data)\n )\n )\n )\n )\n .pipe(\n map((lens): [number, string, string] => [getTimeMs(), lens.id, lens.groupId]),\n mergeMap(([applyLensStartTime, lensId, lensGroupId]) => {\n const alreadyOn = isState(lensState.getState(), \"lensApplied\");\n\n const applyDelay = alreadyOn\n ? of(0)\n : lensState.events.pipe(\n forActions(\"resourcesLoaded\"),\n filter(([a]) => a.data.id === lensId),\n // Applying a new lens may happen before removing the old one, so if we kept taking events\n // we would get the lensResourcesLoaded for the next lens, too.\n take(1),\n map(() => (getTimeMs() - applyLensStartTime) / 1000)\n );\n\n const viewMetrics = (\n alreadyOn\n ? of([getTimeMs(), session.metrics.beginMeasurement()] as const)\n : lensState.events.pipe(\n forActions(\"turnedOn\"),\n filter(([a]) => a.data.id === lensId),\n map(() => [getTimeMs(), session.metrics.beginMeasurement()] as const)\n )\n ).pipe(\n take(1),\n mergeMap(([lensTurnedOnTime, metricsMeasurement]) =>\n lensState.events.pipe(\n forActions(\"turnedOff\"),\n // Applying a new lens may happen before removing the old one, so we'll get a\n // lensTurnedOff for the prior lens (if one was applied), which we must filter out.\n filter(([a]) => a.data.id === lensId),\n // If the session is suspended, we'll count that as the lens turning off.\n raceWith(sessionState.events.pipe(forActions(\"suspend\"))),\n map(() => {\n metricsMeasurement.end();\n return {\n viewTimeSec: (getTimeMs() - lensTurnedOnTime) / 1000,\n ...metricsMeasurement.measure(),\n };\n })\n )\n )\n );\n\n return applyDelay.pipe(\n combineLatestWith(viewMetrics, from(isFirstTimeWithinPeriods(lensId, lensViewPersistence))),\n // This lens should always receive the lensTurnedOff action *before* the next lens is\n // turned on. But just in case that assumption is violated, we'll clean up\n // (and not report) if another lens turns on before our lens is turned off.\n takeUntil(\n lensState.events.pipe(\n forActions(\"turnedOn\"),\n filter(([a]) => a.data.id !== lensId)\n )\n ),\n take(1),\n map(([applyDelaySec, viewMetrics, isFirstTimeResults]) => ({\n applyDelaySec,\n lensId,\n lensGroupId,\n ...viewMetrics,\n ...isFirstTimeResults,\n }))\n );\n })\n )\n .subscribe({\n next: async ({\n applyDelaySec,\n lensId,\n lensGroupId,\n viewTimeSec,\n avgFps,\n lensFrameProcessingTimeMsAvg,\n lensFrameProcessingTimeMsStd,\n lensFrameProcessingTimeMsMedian,\n lensFrameProcessingN,\n isLensFirstWithinDay,\n isLensFirstWithinMonth,\n }) => {\n if (viewTimeSec < viewTimeThresholdSec) return;\n\n const lensView: LensView = {\n name: \"lensView\",\n applyDelaySec,\n avgFps,\n lensId,\n lensGroupId,\n lensFrameProcessingTimeMsAvg,\n lensFrameProcessingTimeMsStd,\n // We don't support recording video, but applications may do this without our knowledge.\n recordingTimeSec: 0,\n viewTimeSec,\n isLensFirstWithinDay,\n isLensFirstWithinMonth,\n performanceCluster: `${performanceCluster}`,\n webglRendererInfo,\n };\n\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"lensView\", lensView));\n metrics.setOperationalMetrics(Histogram.level(\"lens_view\", viewTimeSec * 1000));\n\n // The first few frames will typically take much longer to process (as they might involve requesting\n // remote assets to be downloaded, or other high-latency initialization steps) -- so we'll skip\n // reporting views with a very small number of frames.\n if (lensFrameProcessingN >= 30) {\n metrics.setOperationalMetrics(\n Histogram.level(\"lens_view_frame-processing-time\", lensFrameProcessingTimeMsMedian, {\n performance_cluster: performanceCluster.toString(),\n })\n );\n }\n },\n });\n }\n);\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { forActions } from "@snap/state-management";
|
|
2
2
|
import { map, mergeMap, take } from "rxjs";
|
|
3
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
4
|
import { getTimeMs } from "../../common/time";
|
|
4
|
-
import { Injectable } from "../../dependency-injection/Injectable";
|
|
5
5
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
6
|
import { lensStateFactory } from "../../session/lensState";
|
|
7
7
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportLensWait.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensWait.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,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YAChC,CAAC,SAAS,EAAE,GAAG,kBAAkB,CAAC,GAAG,IAAI;YACzC,MAAM;YACN,WAAW;SACd,CAAC,CACL,CAAC;IACN,CAAC,CAAC,CACL;SACA,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,EAAE;YACzC,IAAI,WAAW,GAAG,oBAAoB;gBAAE,OAAO;YAE/C,MAAM,QAAQ,GAAa;gBACvB,IAAI,EAAE,UAAU;gBAChB,MAAM;gBACN,WAAW;gBACX,WAAW;aACd,CAAC;YACF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;QACjF,CAAC;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { forActions } from \"@snap/state-management\";\nimport { map, mergeMap, take } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { getTimeMs } from \"../../common/time\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\n\n// We ignore short-duration lens waits.\n//\n// The value is documented here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.q5liip76r9lt\nconst viewTimeThresholdSec = 0.1;\n\n/**\n * The LensWait metric measures the time spent downloading the lens content and required assets. It gives an indication\n * of the real UX impact of download latency. If lens content and assets are pre-loaded, the latency measured here\n * should decrease – we measure between the request to apply a lens and when the lens is ready to render.\n *\n * @category Lenses\n * @category Metrics\n */\n// This type corresponds to the internal CameraKitLensSpin event, described here:\n// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY#heading=h.q5liip76r9lt\nexport type LensWait = MakeTaggedBusinessEvent<\"lensWait\">;\n\n/**\n * Each time a lens is applied, we measure the duration until the lens is fully loaded by LensCore. This\n * includes any time spent downloading the lens content and required assets from the lens manifest.\n *\n * The intention of this event is to measure the experienced UX latency between a user requesting a lens and\n * the lens rendering. Of course, the application may call `applyLens` at any time, and may hide/show the\n * rendered result at any time – but this should give us a good baseline for how much UX latency could be seen.\n *\n * @internal\n */\nexport const reportLensWait = Injectable(\n \"reportLensWait\",\n [lensStateFactory.token, metricsEventTargetFactory.token] as const,\n (lensState: LensState, metricsEventTarget: MetricsEventTarget) => {\n lensState.events\n .pipe(\n forActions(\"applyLens\"),\n mergeMap(([a]) => {\n const lensId = a.data.lens.id;\n const lensGroupId = a.data.lens.groupId;\n const applyLensStartTime = getTimeMs();\n return lensState.events.pipe(\n // We'll measure the time until either the requested lens was rendered, or a new applyLens\n // request was made (in both cases, we're done waiting for this lens).\n //\n // This does have the side-effect that if a user rapidly switches between lenses, we'll record\n // many low-duration lensWait events that are measuring user behavior instead of system latency.\n // But this is a good trade-off so that we can capture those long-duration lensWaits that are\n // terminated by the user trying a different lens.\n //\n // (This effect can be mitigated by increasing the viewtimeThresholdSec to ignore low-duration\n // waits that are likely caused by user behavior).\n forActions(\"firstFrameProcessed\", \"applyLens\"),\n take(1),\n map((): [number, string, string] => [\n (getTimeMs() - applyLensStartTime) / 1000,\n lensId,\n lensGroupId,\n ])\n );\n })\n )\n .subscribe({\n next: ([viewTimeSec, lensId, lensGroupId]) => {\n if (viewTimeSec < viewTimeThresholdSec) return;\n\n const lensWait: LensWait = {\n name: \"lensWait\",\n lensId,\n viewTimeSec,\n lensGroupId,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"lensWait\", lensWait));\n },\n });\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportPlatformCapabilities.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reportPlatformCapabilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reportPlatformCapabilities.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reportPlatformCapabilities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAMjE;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;;CAStC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
3
|
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
3
|
-
import { Injectable } from "../../dependency-injection/Injectable";
|
|
4
4
|
import { getPlatformCapabilities } from "../../platform/platformCapabilities";
|
|
5
5
|
import { Count } from "../operational/Count";
|
|
6
6
|
import { joinMetricNames } from "../operational/Metric";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportPlatformCapabilities.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportPlatformCapabilities.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"reportPlatformCapabilities.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportPlatformCapabilities.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,4BAA4B,EAC5B,CAAC,oBAAoB,CAAC,KAAK,CAAU,EACrC,CAAO,OAAsB,EAAE,EAAE;IAC7B,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,uBAAuB,EAAE,CAAC;IAC/D,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5G,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1G,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChH,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { MetricsClient } from \"../../clients/metricsClient\";\nimport { metricsClientFactory } from \"../../clients/metricsClient\";\nimport { getPlatformCapabilities } from \"../../platform/platformCapabilities\";\nimport { Count } from \"../operational/Count\";\nimport { joinMetricNames } from \"../operational/Metric\";\n\n/**\n * Report the number of total page loads that have support for various capabilities. By dividing by the total number of\n * data points recorded, we can calculate the percent of page loads with support.\n *\n * @internal\n */\nexport const reportPlatformCapabilities = Injectable(\n \"reportPlatformCapabilities\",\n [metricsClientFactory.token] as const,\n async (metrics: MetricsClient) => {\n const { webgl, wasm, webxr } = await getPlatformCapabilities();\n metrics.setOperationalMetrics(Count.count(joinMetricNames([\"platform\", \"webgl\"]), webgl.supported ? 1 : 0));\n metrics.setOperationalMetrics(Count.count(joinMetricNames([\"platform\", \"wasm\"]), wasm.supported ? 1 : 0));\n metrics.setOperationalMetrics(Count.count(joinMetricNames([\"platform\", \"webxr\"]), webxr.supported ? 1 : 0));\n }\n);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable } from "
|
|
1
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
2
|
import { lensStateFactory } from "../../session/lensState";
|
|
3
3
|
import { reportGlobalException } from "./reportGlobalException";
|
|
4
4
|
export const reportSessionException = Injectable("reportSessionException", [reportGlobalException.token, lensStateFactory.token], (globalExceptionReporter, lensState) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportSessionException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportSessionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reportSessionException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportSessionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAC5C,wBAAwB,EACxB,CAAC,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAU,EAC9D,CAAC,uBAAgD,EAAE,SAAoB,EAAE,EAAE;IACvE,uBAAuB,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;AACzD,CAAC,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport type { LensState } from \"../../session/lensState\";\nimport { lensStateFactory } from \"../../session/lensState\";\nimport type { GlobalExceptionReporter } from \"./reportGlobalException\";\nimport { reportGlobalException } from \"./reportGlobalException\";\n\n/**\n * Reports log entries to Blizzard during a CameraKit session.\n *\n * @internal\n */\nexport const reportSessionException = Injectable(\n \"reportSessionException\",\n [reportGlobalException.token, lensStateFactory.token] as const,\n (globalExceptionReporter: GlobalExceptionReporter, lensState: LensState) => {\n globalExceptionReporter.attachLensContext(lensState);\n }\n);\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
3
|
import { dayFormatter, monthFormatter } from "../../common/date";
|
|
3
|
-
import { Injectable } from "../../dependency-injection/Injectable";
|
|
4
4
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
5
5
|
import { DailySessionBucket } from "../../generated-proto/blizzard/cameraKitEvents";
|
|
6
6
|
import { IndexedDBPersistence } from "../../persistence/IndexedDBPersistence";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportUserSession.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportUserSession.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"reportUserSession.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportUserSession.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAG9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAelE,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CACvC,mBAAmB,EACnB,CAAC,yBAAyB,CAAC,KAAK,CAAU,EAC1C,CAAO,kBAAsC,EAAiB,EAAE;;IAC5D,MAAM,cAAc,GAAG,iBAAiB,CAAC;IACzC,MAAM,EAAE,GAAG,IAAI,oBAAoB,CAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CAAC;IA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,IAAI,kBAAkB,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,kBAAkB,mCAAI,kBAAkB,CAAC,iBAAiB,CAAC;IACrG,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IAAI,mCAAmC,KAAK,aAAa,EAAE;QACvD,kBAAkB;YACd,MAAA,qBAAqB,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,CAAC,mCAAI,kBAAkB,CAAC,mBAAmB,CAAC;QAChG,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,0BAA0B,EAAE,IAAI;YAChC,kBAAkB;SACrB,CAAC,CAAC;KACN;SAAM;QACH,kBAAkB;YACd,CAAC,0BAA0B;gBAC3B,cAAc,CAAC,MAAM,CAAC,0BAA0B,CAAC,KAAK,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtF,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,0BAA0B,EAAE,IAAI;YAChC,kBAAkB,EAAE,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,CAAC;SAC5E,CAAC,CAAC;KACN;IACD,MAAM,OAAO,GAAY;QACrB,IAAI,EAAE,SAAS;QACf,kBAAkB;QAClB,kBAAkB;QAClB,KAAK,EAAE,GAAG,KAAK,EAAE;QACjB,GAAG,EAAE,GAAG,GAAG,EAAE;QACb,IAAI,EAAE,GAAG,IAAI,EAAE;KAClB,CAAC;IACF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { Injectable } from \"@snap/ts-inject\";\nimport { dayFormatter, monthFormatter } from \"../../common/date\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { DailySessionBucket } from \"../../generated-proto/blizzard/cameraKitEvents\";\nimport { IndexedDBPersistence } from \"../../persistence/IndexedDBPersistence\";\nimport type { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport type { MetricsEventTarget } from \"../metricsEventTarget\";\nimport { metricsEventTargetFactory } from \"../metricsEventTarget\";\n\ninterface UserSessionInfo {\n mostRecentSessionStartDate: Date;\n dailySessionBucket: DailySessionBucket;\n}\n\n/**\n * The Session metric reports each user session.\n */\nexport type Session = MakeTaggedBusinessEvent<\"session\">;\n\n/**\n * @internal\n */\nexport const reportUserSession = Injectable(\n \"reportUserSession\",\n [metricsEventTargetFactory.token] as const,\n async (metricsEventTarget: MetricsEventTarget): Promise<void> => {\n const userSessionKey = \"userSessionInfo\";\n const db = new IndexedDBPersistence<UserSessionInfo>({ databaseName: \"SessionHistory\" });\n // We standardize all user dates to PST as per our documentation:\n // https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n const date = new Date();\n const formattedDate = dayFormatter.format(date);\n const formattedDateParts = dayFormatter.formatToParts(date);\n const { day, month, year } = formattedDateParts.reduce(\n (acc: Record<string, number>, { type, value }) => ({\n ...acc,\n [type]: parseInt(value),\n }),\n {}\n );\n\n const userSessionInfo = await db.retrieve(userSessionKey);\n const mostRecentSessionStartDate = userSessionInfo?.mostRecentSessionStartDate;\n const formattedMostRecentSessionStartDate = mostRecentSessionStartDate\n ? dayFormatter.format(mostRecentSessionStartDate)\n : null;\n\n const dailySessionBucketMap = new Map<number, DailySessionBucket>([\n [1, DailySessionBucket.ONE_SESSION],\n [2, DailySessionBucket.TWO_SESSION],\n [3, DailySessionBucket.THREE_SESSION],\n [4, DailySessionBucket.FOUR_SESSION],\n [5, DailySessionBucket.FIVE_SESSION],\n [6, DailySessionBucket.SIX_SESSION],\n [7, DailySessionBucket.SEVEN_SESSION],\n [8, DailySessionBucket.EIGHT_SESSION],\n [9, DailySessionBucket.NINE_SESSION],\n ]);\n let dailySessionBucket = userSessionInfo?.dailySessionBucket ?? DailySessionBucket.NO_SESSION_BUCKET;\n let isFirstWithinMonth = false;\n if (formattedMostRecentSessionStartDate === formattedDate) {\n dailySessionBucket =\n dailySessionBucketMap.get(dailySessionBucket + 1) ?? DailySessionBucket.TEN_OR_MORE_SESSION;\n await db.store(userSessionKey, {\n mostRecentSessionStartDate: date,\n dailySessionBucket,\n });\n } else {\n isFirstWithinMonth =\n !mostRecentSessionStartDate ||\n monthFormatter.format(mostRecentSessionStartDate) !== monthFormatter.format(date);\n await db.store(userSessionKey, {\n mostRecentSessionStartDate: date,\n dailySessionBucket: (dailySessionBucket = DailySessionBucket.ONE_SESSION),\n });\n }\n const session: Session = {\n name: \"session\",\n dailySessionBucket,\n isFirstWithinMonth,\n month: `${month}`,\n day: `${day}`,\n year: `${year}`,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"session\", session));\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporters.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reporters.d.ts","sourceRoot":"","sources":["../../../src/metrics/reporters/reporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYnD;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;EAKC,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;EAKE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PartialContainer } from "
|
|
1
|
+
import { PartialContainer } from "@snap/ts-inject";
|
|
2
2
|
import { reportSessionException } from "./reportSessionException";
|
|
3
3
|
import { reportBenchmarks } from "./reportBenchmarks";
|
|
4
4
|
import { reportHttpMetrics } from "./reportHttpMetrics";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporters.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"reporters.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAS1E,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC;KAC9D,QAAQ,CAAC,iBAAiB,CAAC;KAC3B,QAAQ,CAAC,gBAAgB,CAAC;KAC1B,QAAQ,CAAC,0BAA0B,CAAC;KACpC,QAAQ,CAAC,gBAAgB,CAAC;KAC1B,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AAM1C,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC;KAC7D,QAAQ,CAAC,iBAAiB,CAAC;KAC3B,QAAQ,CAAC,cAAc,CAAC;KACxB,QAAQ,CAAC,cAAc,CAAC;KACxB,QAAQ,CAAC,sBAAsB,CAAC;KAChC,QAAQ,CAAC,0BAA0B,CAAC,CAAC","sourcesContent":["import { PartialContainer } from \"@snap/ts-inject\";\nimport { reportSessionException } from \"./reportSessionException\";\nimport { reportBenchmarks } from \"./reportBenchmarks\";\nimport { reportHttpMetrics } from \"./reportHttpMetrics\";\nimport { reportLegalState } from \"./reportLegalState\";\nimport { reportLensAndAssetDownload } from \"./reportLensAndAssetDownload\";\nimport { reportLensValidationFailed } from \"./reportLensValidationFailed\";\nimport { reportLensView } from \"./reportLensView\";\nimport { reportLensWait } from \"./reportLensWait\";\nimport { reportUserSession } from \"./reportUserSession\";\nimport { reportPlatformCapabilities } from \"./reportPlatformCapabilities\";\n\n/**\n * These metrics reporters must be run once in the top-level DI container. They only depend on globally-available\n * services.\n *\n * The businessEventsReporter is special, it doesn't create any of its own metrics, it simply listens to the global\n * metricsEventTarget and reports metrics emitted there to our backend.\n */\nexport const reportGloballyScopedMetrics = new PartialContainer({})\n .provides(reportHttpMetrics)\n .provides(reportBenchmarks)\n .provides(reportLensAndAssetDownload)\n .provides(reportLegalState)\n .provides(reportPlatformCapabilities);\n\n/**\n * These metrics reporters must be run once for each CameraKitSession DI container created. They may depend on services\n * which are only available at the session scope (e.g. the CameraKitSession itself).\n */\nexport const reportSessionScopedMetrics = new PartialContainer({})\n .provides(reportUserSession)\n .provides(reportLensView)\n .provides(reportLensWait)\n .provides(reportSessionException)\n .provides(reportLensValidationFailed);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cofHandler.d.ts","sourceRoot":"","sources":["../../src/remote-configuration/cofHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cofHandler.d.ts","sourceRoot":"","sources":["../../src/remote-configuration/cofHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAGpG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAWvF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAK/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAI9D,MAAM,WAAW,QAAQ;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IAAE,WAAW,EAAE,OAAO,gBAAgB,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAIpF;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CA+H7B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
import { BrowserHeaders } from "browser-headers";
|
|
3
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
4
|
import { getCameraKitUserAgent } from "../platform/cameraKitUserAgent";
|
|
4
5
|
import { ensureError } from "../common/errorHelpers";
|
|
5
6
|
import { unionBy } from "../common/unionBy";
|
|
@@ -11,7 +12,6 @@ import { createRetryingHandler } from "../handlers/retryingHandler";
|
|
|
11
12
|
import { createTimeoutHandler } from "../handlers/timeoutHandler";
|
|
12
13
|
import { IndexedDBPersistence } from "../persistence/IndexedDBPersistence";
|
|
13
14
|
import { configurationToken } from "../configuration";
|
|
14
|
-
import { Injectable } from "../dependency-injection/Injectable";
|
|
15
15
|
import { getLogger } from "../logger/logger";
|
|
16
16
|
import { ExpiringPersistence } from "../persistence/ExpiringPersistence";
|
|
17
17
|
import { convertDaysToSeconds } from "../common/time";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cofHandler.js","sourceRoot":"","sources":["../../src/remote-configuration/cofHandler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EA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K,CAAC;iBAC5B,CAAC,CAAC;gBACH,MAAM,CAAC,KAAK,CAAC,CAAC;aACjB;QACL,CAAC,CAAA,CAAC,CAAC;IACP,CAAC,CAAA,CACJ;SAII,GAAG,CAAC,qBAAqB,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC;SAEzE,GAAG,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;SACjD,GAAG,CACA,4BAA4B,CACxB,QAAQ,EACR,WAAW,EAGX,4BAA4B,CAAC;QACzB,MAAM,EAAE,GAAG,EAAE;YACT,OAAO,CAAC,qBAAqB,CACzB,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CACnE,CAAC;QACN,CAAC;KACJ,CAAC,CACL,CACJ,CAAC,OAAO,CAChB,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { BrowserHeaders } from \"browser-headers\";\nimport { getCameraKitUserAgent } from \"../platform/cameraKitUserAgent\";\nimport { ensureError } from \"../common/errorHelpers\";\nimport { unionBy } from \"../common/unionBy\";\nimport { CircumstancesServiceClientImpl, GrpcWebImpl } from \"../generated-proto/pb_schema/cdp/cof/circumstance_service\";\nimport type { ConfigTargetingRequest } from \"../generated-proto/pb_schema/cdp/cof/config_request\";\nimport type { ConfigTargetingResponse } from \"../generated-proto/pb_schema/cdp/cof/config_response\";\nimport type { RequestMetadata } from \"../handlers/HandlerChainBuilder\";\nimport { HandlerChainBuilder } from \"../handlers/HandlerChainBuilder\";\nimport type { RequestStateEventTarget } from \"../handlers/requestStateEmittingHandler\";\nimport {\n dispatchRequestCompleted,\n dispatchRequestErrored,\n dispatchRequestStarted,\n requestStateEventTargetFactory,\n} from \"../handlers/requestStateEmittingHandler\";\nimport { createResponseCachingHandler, staleWhileRevalidateStrategy } from \"../handlers/responseCachingHandler\";\nimport { createRetryingHandler } from \"../handlers/retryingHandler\";\nimport { createTimeoutHandler } from \"../handlers/timeoutHandler\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { getLogger } from \"../logger/logger\";\nimport { ExpiringPersistence } from \"../persistence/ExpiringPersistence\";\nimport { convertDaysToSeconds } from \"../common/time\";\nimport type { MetricsClient } from \"../clients/metricsClient\";\nimport { metricsClientFactory } from \"../clients/metricsClient\";\nimport { Count } from \"../metrics/operational/Count\";\n\nexport interface Metadata {\n [key: string]: string;\n}\n\nexport const COF_REQUEST_TYPE = \"cof\";\n\nexport type CofDimensions = { requestType: typeof COF_REQUEST_TYPE; delta: string };\n\nconst logger = getLogger(\"cofHandler\");\n\n/**\n * Handler chain used to make COF requests. Uses the COF client to perform the\n * requests, with retries, timeout, and caching.\n *\n * The handler will first attempt to retrieve the COF response from cache. If it is found, the result is returned\n * immediately and the cache is updated in the background. If no response is found, a COF request is made. This request\n * will retry (with exponential backoff + jitter) for 5 seconds before returning an error to the caller.\n */\nexport const cofHandlerFactory = Injectable(\n \"cofHandler\",\n [configurationToken, requestStateEventTargetFactory.token, metricsClientFactory.token] as const,\n (config: CameraKitConfiguration, requestStateEventTarget: RequestStateEventTarget, metrics: MetricsClient) => {\n const cofCache = new ExpiringPersistence<ConfigTargetingResponse>(\n () => convertDaysToSeconds(365),\n new IndexedDBPersistence({ databaseName: \"COFCache\" })\n );\n const getCacheKey = (r: Partial<ConfigTargetingRequest>) => JSON.stringify(r);\n // We need to wrap `targetingQuery` to create a usable Handler – the main issue is that HandlerChainBuilder\n // always adds a `signal` property to the metadata argument (second argument of the Handler), but\n // `targetingQuery` expects the second argument to only contain headers.\n return (\n new HandlerChainBuilder(\n async (\n request: Partial<ConfigTargetingRequest>,\n { signal, isSideEffect: _, ...metadata }: Metadata & RequestMetadata\n ) => {\n const rpc = new GrpcWebImpl(`https://${config.apiHostname}`, {});\n const client = new CircumstancesServiceClientImpl(rpc);\n return new Promise<ConfigTargetingResponse>(async (resolve, reject) => {\n if (signal) {\n signal.addEventListener(\"abort\", () =>\n reject(new Error(\"COF request aborted by handler chain.\"))\n );\n }\n\n const cachedResponse = await cofCache.retrieve(getCacheKey(request)).catch((e) => {\n logger.warn(\"Unable to get COF response from cache.\", e);\n return {\n configResultsEtag: undefined,\n configResults: [],\n };\n });\n const dimensions: CofDimensions = {\n requestType: COF_REQUEST_TYPE,\n delta: `${!!cachedResponse?.configResultsEtag}`,\n };\n const { requestId } = dispatchRequestStarted(requestStateEventTarget, { dimensions });\n\n try {\n const response = await client.targetingQuery(\n {\n ...request,\n configResultsEtag: cachedResponse?.configResultsEtag,\n deltaSync: !!cachedResponse?.configResultsEtag,\n },\n new BrowserHeaders({\n authorization: `Bearer ${config.apiToken}`,\n \"x-snap-client-user-agent\": getCameraKitUserAgent(),\n ...metadata,\n })\n );\n\n // NOTE: in order for cache persistance to work, we need to make the\n // object cloneable i.e. with no methods (it appears targetingQuery()\n // attaches toObject() to response object). Safety: We have to cast response\n // object to a type that has toObject defined, because that is indeed\n // what generated code has:\n // eslint-disable-next-line max-len\n // https://github.sc-corp.net/Snapchat/camera-kit-web-sdk/blob/8d6b4e8bfa3717b376ab197a49972a1e410851f7/packages/web-sdk/src/generated-proto/pb_schema/cdp/cof/circumstance_service.ts#L1459\n delete (response as any).toObject;\n\n // Merge the cached configs into the just-returned configs,\n // making sure to remove any configs that are marked as deleted -- this will then get cached\n // by the responseCachingHandler as we return up the handler chain.\n const configResults = unionBy(\n \"configId\",\n cachedResponse?.configResults ?? [],\n response.configResults\n ).filter((config) => !config.delete);\n\n // TODO: We hardcode status code and sizeByte values because we do not have access to\n // underlying transport of configs-web.\n // When this ticket is done https://jira.sc-corp.net/browse/CAMKIT-2840,\n // we will remove this handler and benefit from existing ones.\n const status = 200;\n let sizeByte = 0;\n try {\n sizeByte = new TextEncoder().encode(JSON.stringify(response)).byteLength;\n } finally {\n dispatchRequestCompleted(requestStateEventTarget, {\n requestId,\n dimensions,\n status,\n sizeByte,\n });\n }\n\n resolve({\n ...response,\n configResults,\n });\n } catch (error) {\n dispatchRequestErrored(requestStateEventTarget, {\n requestId,\n dimensions,\n error: ensureError(error),\n });\n reject(error);\n }\n });\n }\n )\n // targetingQuery() always converts failed responses into errors (unlike fetch()), so we need a custom\n // retryPredicate that retries all errors. We'll keep retrying (with backoff) for 20 seconds total\n // elapsed time before we return an error back up the chain.\n .map(createRetryingHandler({ retryPredicate: (r) => r instanceof Error }))\n // API gateway has 15 seconds timeout, so we rely on that first\n .map(createTimeoutHandler({ timeout: 20 * 1000 }))\n .map(\n createResponseCachingHandler(\n cofCache,\n getCacheKey,\n // If we have a matching response already in cache,\n // we'll return it immediately and then update the cache in the background.\n staleWhileRevalidateStrategy({\n onMiss: () => {\n metrics.setOperationalMetrics(\n Count.count(\"cache_miss\", 1, { request_type: COF_REQUEST_TYPE })\n );\n },\n })\n )\n ).handler\n );\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"cofHandler.js","sourceRoot":"","sources":["../../src/remote-configuration/cofHandler.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,8BAA8B,EAAE,WAAW,EAAE,MAAM,2DAA2D,CAAC;AAIxH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EACH,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B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SACjD,GAAG,CACA,4BAA4B,CACxB,QAAQ,EACR,WAAW,EAGX,4BAA4B,CAAC;QACzB,MAAM,EAAE,GAAG,EAAE;YACT,OAAO,CAAC,qBAAqB,CACzB,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CACnE,CAAC;QACN,CAAC;KACJ,CAAC,CACL,CACJ,CAAC,OAAO,CAChB,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { BrowserHeaders } from \"browser-headers\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { getCameraKitUserAgent } from \"../platform/cameraKitUserAgent\";\nimport { ensureError } from \"../common/errorHelpers\";\nimport { unionBy } from \"../common/unionBy\";\nimport { CircumstancesServiceClientImpl, GrpcWebImpl } from \"../generated-proto/pb_schema/cdp/cof/circumstance_service\";\nimport type { ConfigTargetingRequest } from \"../generated-proto/pb_schema/cdp/cof/config_request\";\nimport type { ConfigTargetingResponse } from \"../generated-proto/pb_schema/cdp/cof/config_response\";\nimport type { RequestMetadata } from \"../handlers/HandlerChainBuilder\";\nimport { HandlerChainBuilder } from \"../handlers/HandlerChainBuilder\";\nimport type { RequestStateEventTarget } from \"../handlers/requestStateEmittingHandler\";\nimport {\n dispatchRequestCompleted,\n dispatchRequestErrored,\n dispatchRequestStarted,\n requestStateEventTargetFactory,\n} from \"../handlers/requestStateEmittingHandler\";\nimport { createResponseCachingHandler, staleWhileRevalidateStrategy } from \"../handlers/responseCachingHandler\";\nimport { createRetryingHandler } from \"../handlers/retryingHandler\";\nimport { createTimeoutHandler } from \"../handlers/timeoutHandler\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport { getLogger } from \"../logger/logger\";\nimport { ExpiringPersistence } from \"../persistence/ExpiringPersistence\";\nimport { convertDaysToSeconds } from \"../common/time\";\nimport type { MetricsClient } from \"../clients/metricsClient\";\nimport { metricsClientFactory } from \"../clients/metricsClient\";\nimport { Count } from \"../metrics/operational/Count\";\n\nexport interface Metadata {\n [key: string]: string;\n}\n\nexport const COF_REQUEST_TYPE = \"cof\";\n\nexport type CofDimensions = { requestType: typeof COF_REQUEST_TYPE; delta: string };\n\nconst logger = getLogger(\"cofHandler\");\n\n/**\n * Handler chain used to make COF requests. Uses the COF client to perform the\n * requests, with retries, timeout, and caching.\n *\n * The handler will first attempt to retrieve the COF response from cache. If it is found, the result is returned\n * immediately and the cache is updated in the background. If no response is found, a COF request is made. This request\n * will retry (with exponential backoff + jitter) for 5 seconds before returning an error to the caller.\n */\nexport const cofHandlerFactory = Injectable(\n \"cofHandler\",\n [configurationToken, requestStateEventTargetFactory.token, metricsClientFactory.token] as const,\n (config: CameraKitConfiguration, requestStateEventTarget: RequestStateEventTarget, metrics: MetricsClient) => {\n const cofCache = new ExpiringPersistence<ConfigTargetingResponse>(\n () => convertDaysToSeconds(365),\n new IndexedDBPersistence({ databaseName: \"COFCache\" })\n );\n const getCacheKey = (r: Partial<ConfigTargetingRequest>) => JSON.stringify(r);\n // We need to wrap `targetingQuery` to create a usable Handler – the main issue is that HandlerChainBuilder\n // always adds a `signal` property to the metadata argument (second argument of the Handler), but\n // `targetingQuery` expects the second argument to only contain headers.\n return (\n new HandlerChainBuilder(\n async (\n request: Partial<ConfigTargetingRequest>,\n { signal, isSideEffect: _, ...metadata }: Metadata & RequestMetadata\n ) => {\n const rpc = new GrpcWebImpl(`https://${config.apiHostname}`, {});\n const client = new CircumstancesServiceClientImpl(rpc);\n return new Promise<ConfigTargetingResponse>(async (resolve, reject) => {\n if (signal) {\n signal.addEventListener(\"abort\", () =>\n reject(new Error(\"COF request aborted by handler chain.\"))\n );\n }\n\n const cachedResponse = await cofCache.retrieve(getCacheKey(request)).catch((e) => {\n logger.warn(\"Unable to get COF response from cache.\", e);\n return {\n configResultsEtag: undefined,\n configResults: [],\n };\n });\n const dimensions: CofDimensions = {\n requestType: COF_REQUEST_TYPE,\n delta: `${!!cachedResponse?.configResultsEtag}`,\n };\n const { requestId } = dispatchRequestStarted(requestStateEventTarget, { dimensions });\n\n try {\n const response = await client.targetingQuery(\n {\n ...request,\n configResultsEtag: cachedResponse?.configResultsEtag,\n deltaSync: !!cachedResponse?.configResultsEtag,\n },\n new BrowserHeaders({\n authorization: `Bearer ${config.apiToken}`,\n \"x-snap-client-user-agent\": getCameraKitUserAgent(),\n ...metadata,\n })\n );\n\n // NOTE: in order for cache persistance to work, we need to make the\n // object cloneable i.e. with no methods (it appears targetingQuery()\n // attaches toObject() to response object). Safety: We have to cast response\n // object to a type that has toObject defined, because that is indeed\n // what generated code has:\n // eslint-disable-next-line max-len\n // https://github.sc-corp.net/Snapchat/camera-kit-web-sdk/blob/8d6b4e8bfa3717b376ab197a49972a1e410851f7/packages/web-sdk/src/generated-proto/pb_schema/cdp/cof/circumstance_service.ts#L1459\n delete (response as any).toObject;\n\n // Merge the cached configs into the just-returned configs,\n // making sure to remove any configs that are marked as deleted -- this will then get cached\n // by the responseCachingHandler as we return up the handler chain.\n const configResults = unionBy(\n \"configId\",\n cachedResponse?.configResults ?? [],\n response.configResults\n ).filter((config) => !config.delete);\n\n // TODO: We hardcode status code and sizeByte values because we do not have access to\n // underlying transport of configs-web.\n // When this ticket is done https://jira.sc-corp.net/browse/CAMKIT-2840,\n // we will remove this handler and benefit from existing ones.\n const status = 200;\n let sizeByte = 0;\n try {\n sizeByte = new TextEncoder().encode(JSON.stringify(response)).byteLength;\n } finally {\n dispatchRequestCompleted(requestStateEventTarget, {\n requestId,\n dimensions,\n status,\n sizeByte,\n });\n }\n\n resolve({\n ...response,\n configResults,\n });\n } catch (error) {\n dispatchRequestErrored(requestStateEventTarget, {\n requestId,\n dimensions,\n error: ensureError(error),\n });\n reject(error);\n }\n });\n }\n )\n // targetingQuery() always converts failed responses into errors (unlike fetch()), so we need a custom\n // retryPredicate that retries all errors. We'll keep retrying (with backoff) for 20 seconds total\n // elapsed time before we return an error back up the chain.\n .map(createRetryingHandler({ retryPredicate: (r) => r instanceof Error }))\n // API gateway has 15 seconds timeout, so we rely on that first\n .map(createTimeoutHandler({ timeout: 20 * 1000 }))\n .map(\n createResponseCachingHandler(\n cofCache,\n getCacheKey,\n // If we have a matching response already in cache,\n // we'll return it immediately and then update the cache in the background.\n staleWhileRevalidateStrategy({\n onMiss: () => {\n metrics.setOperationalMetrics(\n Count.count(\"cache_miss\", 1, { request_type: COF_REQUEST_TYPE })\n );\n },\n })\n )\n ).handler\n );\n }\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { take } from "rxjs";
|
|
2
|
-
import { Injectable } from "
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
3
3
|
import { Namespace } from "../generated-proto/pb_schema/cdp/cof/namespace";
|
|
4
4
|
import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
|
|
5
5
|
import { getLogger } from "../logger/logger";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preloadConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/preloadConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"preloadConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/preloadConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,MAAM,GAAG,SAAS,CAAC,2BAA2B,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAC/C,2BAA2B,EAC3B,CAAC,eAAe,CAAC,KAAK,EAAE,0BAA0B,CAAC,KAAK,CAAU,EAClE,CAAC,QAAkB,EAAE,mBAAwC,EAAE,EAAE;IAC7D,mBAAmB;SACd,YAAY,CAAC,SAAS,CAAC,gBAAgB,CAAC;SACxC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YACd,MAAM,MAAM,GAAmC,OAAO,CAAC,GAAG,CACtD,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAqB,CAAA,CACnE,CAAC;YAEF,QAAQ,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;QACD,KAAK,EAAE,MAAM,CAAC,KAAK;KACtB,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { take } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport { Namespace } from \"../generated-proto/pb_schema/cdp/cof/namespace\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport type { LensCore } from \"../lens-core-module/lensCore\";\nimport type { LensCoreConfig, SetPreloadedConfigurationInput } from \"../lens-core-module/generated-types\";\nimport { getLogger } from \"../logger/logger\";\nimport type { RemoteConfiguration } from \"./remoteConfiguration\";\nimport { remoteConfigurationFactory } from \"./remoteConfiguration\";\n\nconst logger = getLogger(\"setPreloadedConfiguration\");\n\nexport const setPreloadedConfiguration = Injectable(\n \"setPreloadedConfiguration\",\n [lensCoreFactory.token, remoteConfigurationFactory.token] as const,\n (lensCore: LensCore, remoteConfiguration: RemoteConfiguration) => {\n remoteConfiguration\n .getNamespace(Namespace.LENS_CORE_CONFIG)\n .pipe(take(1))\n .subscribe({\n next: (configs) => {\n const inputs: SetPreloadedConfigurationInput = configs.map(\n ({ configId, value }) => ({ configId, value } as LensCoreConfig)\n );\n\n lensCore.setPreloadedConfiguration(inputs);\n },\n error: logger.error,\n });\n }\n);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteConfiguration.d.ts","sourceRoot":"","sources":["../../src/remote-configuration/remoteConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"remoteConfiguration.d.ts","sourceRoot":"","sources":["../../src/remote-configuration/remoteConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMjD,KAAK,mBAAmB,GAAG,SAAS,CAAC,SAAS,GAAG,SAAS,CAAC,eAAe,GAAG,SAAS,CAAC,gBAAgB,CAAC;AAExG,MAAM,MAAM,oBAAoB,GAAG,+BAA+B,CAAC;AAEnE,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAmC;gBAGpE,eAAe,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,EAC1D,UAAU,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,EAChD,UAAU,EAAE,oBAAoB,CAAC,OAAO,iBAAiB,CAAC;IAmD9D;;OAEG;IACH,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;IAIjD;;OAEG;IACH,uBAAuB,IAAI,UAAU,CAAC,oBAAoB,CAAC;IAI3D,YAAY,CAAC,SAAS,EAAE,mBAAmB,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC;CAW3E;AAED,eAAO,MAAM,0BAA0B;;;;;;;CAoBtC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { from, map, mergeMap, shareReplay, take } from "rxjs";
|
|
2
|
+
import { Injectable } from "@snap/ts-inject";
|
|
2
3
|
import { configurationToken } from "../configuration";
|
|
3
|
-
import { Injectable } from "../dependency-injection/Injectable";
|
|
4
4
|
import { Namespace } from "../generated-proto/pb_schema/cdp/cof/namespace";
|
|
5
5
|
import { MetricsDefinition } from "../generated-proto/pb_schema/camera_kit/v3/service";
|
|
6
6
|
import { grpcHandlerFactory } from "../clients/grpcHandler";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/remoteConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"remoteConfiguration.js","sourceRoot":"","sources":["../../src/remote-configuration/remoteConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC9D,OAAO,E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CAAC,CAAC,OAAO,EAAE,EAAE;YACZ,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;iBAChD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;iBACjE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;YAEnC,OAAO,gBAAgB,CAAC;QAC5B,CAAC,CAAC,CACL,CAAC;IACN,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAChD,qBAAqB,EACrB,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,CAAC,KAAK,CAAU,EAChF,CACI,MAA8B,EAC9B,UAAgD,EAChD,WAAwB,EACL,EAAE;IACrB,MAAM,YAAY,GAAG,IAAI,mBAAmB,CACxC,MAAM,CAAC,eAAe,EACtB,UAAU,EACV,mBAAmB,CAAC,iBAAiB,EAAE,WAAW,CAAC,CACtD,CAAC;IAIF,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAE/C,OAAO,YAAY,CAAC;AACxB,CAAC,CACJ,CAAC","sourcesContent":["import type { Observable } from \"rxjs\";\nimport { from, map, mergeMap, shareReplay, take } from \"rxjs\";\nimport { Injectable } from \"@snap/ts-inject\";\nimport type { CameraKitConfiguration } from \"../configuration\";\nimport { configurationToken } from \"../configuration\";\nimport type { ConfigTargetingRequest } from \"../generated-proto/pb_schema/cdp/cof/config_request\";\nimport type { ConfigResult } from \"../generated-proto/pb_schema/cdp/cof/config_result\";\nimport { Namespace } from \"../generated-proto/pb_schema/cdp/cof/namespace\";\nimport type { GetInitializationConfigResponse } from \"../generated-proto/pb_schema/camera_kit/v3/service\";\nimport { MetricsDefinition } from \"../generated-proto/pb_schema/camera_kit/v3/service\";\nimport type { GrpcHandler } from \"../clients/grpcHandler\";\nimport { grpcHandlerFactory } from \"../clients/grpcHandler\";\nimport type { TsProtoServiceClient } from \"../clients/createTsProtoClient\";\nimport { createTsProtoClient } from \"../clients/createTsProtoClient\";\nimport { cofHandlerFactory } from \"./cofHandler\";\n\nconst defaultTargetingRequest: Partial<ConfigTargetingRequest> = {\n namespaces: [Namespace.LENS_CORE, Namespace.CAMERA_KIT_CORE, Namespace.LENS_CORE_CONFIG],\n};\n\ntype SupportedNamespaces = Namespace.LENS_CORE | Namespace.CAMERA_KIT_CORE | Namespace.LENS_CORE_CONFIG;\n\nexport type InitializationConfig = GetInitializationConfigResponse;\n\nexport class RemoteConfiguration {\n private readonly configById: Observable<Map<string, ConfigResult[]>>;\n private readonly initializationConfig: Observable<InitializationConfig>;\n\n constructor(\n lensPerformance: CameraKitConfiguration[\"lensPerformance\"],\n cofHandler: ReturnType<typeof cofHandlerFactory>,\n grpcClient: TsProtoServiceClient<typeof MetricsDefinition>\n ) {\n const lensCluster = Promise.resolve(lensPerformance).then((lensPerformance) => {\n // `0` means no cluster could be determined. For COF, we'll omit a value in that case.\n return lensPerformance?.cluster === 0 ? undefined : lensPerformance?.cluster;\n });\n\n this.configById = from(lensCluster).pipe(\n // Note: we don't catch errors here, purposefully letting them propagate to subscribers outside this class.\n // Subscribers, having more context about the config use-case, will know better how to handle an error than\n // we do here (e.g. their logging / reporting will have more context, and they can use the error they get\n // from this Observable as a cause).\n mergeMap((lensClusterOrig4) =>\n from(\n cofHandler({\n ...defaultTargetingRequest,\n lensClusterOrig4,\n })\n )\n ),\n map((result) => {\n const configById = new Map<string, ConfigResult[]>();\n result.configResults.forEach((config) => {\n const configsWithId = configById.get(config.configId) ?? [];\n configsWithId.push(config);\n configById.set(config.configId, configsWithId);\n });\n return configById;\n }),\n shareReplay(1)\n );\n\n this.initializationConfig = from(grpcClient.getInitializationConfig({})).pipe(\n map((result) => {\n if (result.ok) {\n const response = result.unwrap();\n if (response.message) return response.message;\n else\n throw new Error(\n \"Failed to load initialization config. gRPC response successful, but \" +\n `message was null. gRPC status: ${response.statusMessage}`\n );\n }\n throw new Error(\n `Failed to load initialization config. gRPC status message: ${result.unwrapErr().statusMessage}`\n );\n }),\n shareReplay(1)\n );\n }\n\n /**\n * COF configuration.\n */\n get(configId: string): Observable<ConfigResult[]> {\n return this.configById.pipe(map((config) => config.get(configId) ?? []));\n }\n\n /**\n * Configuration that is provided by Camera Kit backend.\n */\n getInitializationConfig(): Observable<InitializationConfig> {\n return this.initializationConfig;\n }\n\n getNamespace(namespace: SupportedNamespaces): Observable<ConfigResult[]> {\n return this.configById.pipe(\n map((configs) => {\n const namespaceConfigs = Array.from(configs.values())\n .filter((values) => values.some((c) => c.namespace === namespace))\n .flatMap((results) => results);\n\n return namespaceConfigs;\n })\n );\n }\n}\n\nexport const remoteConfigurationFactory = Injectable(\n \"remoteConfiguration\",\n [configurationToken, cofHandlerFactory.token, grpcHandlerFactory.token] as const,\n (\n config: CameraKitConfiguration,\n cofHandler: ReturnType<typeof cofHandlerFactory>,\n grpcHandler: GrpcHandler\n ): RemoteConfiguration => {\n const remoteConfig = new RemoteConfiguration(\n config.lensPerformance,\n cofHandler,\n createTsProtoClient(MetricsDefinition, grpcHandler)\n );\n\n // We'll kick off remote configuration loading by subscribing (and then unsubscribing) to a dummy config value.\n // Subsequent requests for config will use the shared Observable, benefitting from this eager loading.\n remoteConfig.get(\"\").pipe(take(1)).subscribe();\n\n return remoteConfig;\n }\n);\n"]}
|
|
@@ -207,10 +207,15 @@ declare class CameraKitSession {
|
|
|
207
207
|
* - {@link createVideoSource}
|
|
208
208
|
* - {@link createImageSource}
|
|
209
209
|
*
|
|
210
|
+
* **Important:** Once a source has been set for a session, it cannot be set again, even if it has been replaced
|
|
211
|
+
* by another one. You must provide a new instance of {@link CameraKitSource} to {@link CameraKitSession.setSource}.
|
|
212
|
+
* If you want to reuse the existing source, you can use its {@link CameraKitSource.copy} method to create a new
|
|
213
|
+
* instance.
|
|
214
|
+
*
|
|
210
215
|
* @param source A CameraKitSource object representing input media (e.g. a webcam stream, video, or some other
|
|
211
216
|
* source of image data), which CameraKit will supply to Lenses in order for them to render effects on top of that
|
|
212
217
|
* source.
|
|
213
|
-
* @returns Promise is resolved when the source has successfully
|
|
218
|
+
* @returns Promise is resolved when the source has successfully been set. If the session was already in the playing
|
|
214
219
|
* state, the Promise resolves when the first frame from the new source has been rendered. The resolved value is
|
|
215
220
|
* the {@link CameraKitSource} object attached to the session.
|
|
216
221
|
*/
|