@snap/camera-kit 0.15.0 → 0.16.2
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/README.md +3 -3
- package/docs/html/assets/main.js +4 -3
- package/docs/html/assets/navigation.js +1 -0
- package/docs/html/assets/search.js +1 -1
- package/docs/html/assets/style.css +72 -25
- package/docs/html/classes/CameraKit.html +11 -196
- package/docs/html/classes/CameraKitSession.html +43 -366
- package/docs/html/classes/CameraKitSource.html +14 -223
- package/docs/html/classes/LensPerformanceMeasurement.html +9 -184
- package/docs/html/classes/LensPerformanceMetrics.html +7 -148
- package/docs/html/classes/LensRepository.html +17 -234
- package/docs/html/classes/Transform2D.html +7 -176
- package/docs/html/classes/TypedCustomEvent.html +4 -178
- package/docs/html/classes/TypedEventTarget.html +4 -209
- package/docs/html/enums/Lens_CameraFacing.html +5 -0
- package/docs/html/enums/UserData_Zodiac.html +15 -0
- package/docs/html/functions/ConcatInjectable.html +10 -193
- package/docs/html/functions/Injectable.html +9 -192
- package/docs/html/functions/bootstrapCameraKit.html +6 -147
- package/docs/html/functions/createExtension.html +6 -123
- package/docs/html/functions/createImageSource.html +4 -130
- package/docs/html/functions/createMediaStreamSource.html +4 -130
- package/docs/html/functions/createVideoSource.html +4 -130
- package/docs/html/functions/estimateLensPerformance.html +3 -120
- package/docs/html/functions/lensSourcesFactory.html +6 -127
- package/docs/html/functions/remoteApiServicesFactory.html +3 -121
- package/docs/html/hierarchy.html +1 -0
- package/docs/html/index.html +8 -165
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +11 -192
- package/docs/html/interfaces/CameraKitDeviceOptions.html +11 -0
- package/docs/html/interfaces/CameraKitSourceInfo.html +9 -0
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +3 -194
- package/docs/html/interfaces/ComputedFrameMetrics.html +2 -150
- package/docs/html/interfaces/CreateSessionOptions.html +5 -148
- package/docs/html/interfaces/EstimatedLensPerformance.html +3 -146
- package/docs/html/interfaces/FunctionSourceOptions.html +7 -0
- package/docs/html/interfaces/Lens.html +12 -205
- package/docs/html/interfaces/LensCreator.html +3 -0
- package/docs/html/interfaces/LensLaunchData.html +3 -179
- package/docs/html/interfaces/LensSource.html +3 -172
- package/docs/html/interfaces/LoadAssetRequest.html +13 -0
- package/docs/html/interfaces/MediaStreamSourceOptions.html +16 -138
- package/docs/html/interfaces/Preview.html +4 -141
- package/docs/html/interfaces/RemoteApiRequest.html +7 -162
- package/docs/html/interfaces/RemoteApiResponse.html +6 -155
- package/docs/html/interfaces/RemoteApiService.html +9 -171
- package/docs/html/interfaces/Snapcode.html +5 -148
- package/docs/html/interfaces/UriCancelRequest.html +2 -138
- package/docs/html/interfaces/UriRequest.html +2 -154
- package/docs/html/interfaces/UriResponse.html +2 -150
- package/docs/html/interfaces/VideoSourceOptions.html +15 -134
- package/docs/html/modules.html +57 -175
- package/docs/html/types/AssetLoader.html +5 -132
- package/docs/html/types/AssetResponse.html +1 -0
- package/docs/html/types/AssetTiming.html +2 -115
- package/docs/html/types/BenchmarkError.html +1 -112
- package/docs/html/types/BootstrapError.html +2 -115
- package/docs/html/types/CacheKeyNotFoundError.html +1 -112
- package/docs/html/types/CameraKitSessionEventListener.html +2 -115
- package/docs/html/types/CameraKitSessionEvents.html +2 -122
- package/docs/html/types/CameraKitSourceError.html +1 -112
- package/docs/html/types/ConfigurationError.html +2 -115
- package/docs/html/types/FetchHandler.html +1 -0
- package/docs/html/types/Keyboard.html +14 -194
- package/docs/html/types/KeyboardEvents.html +2 -124
- package/docs/html/types/LegalError.html +1 -112
- package/docs/html/types/LensAbortError.html +2 -115
- package/docs/html/types/LensAssetError.html +2 -115
- package/docs/html/types/LensContentValidationError.html +1 -112
- package/docs/html/types/LensError.html +1 -112
- package/docs/html/types/LensExecutionError.html +2 -115
- package/docs/html/types/LensImagePickerError.html +2 -115
- package/docs/html/types/LensLaunchParams.html +2 -0
- package/docs/html/types/LensMetricsEvents.html +2 -115
- package/docs/html/types/LensPerformanceCluster.html +1 -113
- package/docs/html/types/LensView.html +2 -115
- package/docs/html/types/LensWait.html +2 -115
- package/docs/html/types/Matrix.html +3 -0
- package/docs/html/types/PersistentStoreError.html +2 -115
- package/docs/html/types/PlatformNotSupportedError.html +2 -115
- package/docs/html/types/PublicContainer.html +2 -115
- package/docs/html/types/PublicServices.html +2 -0
- package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -0
- package/docs/html/types/RemoteApiRequestHandler.html +2 -139
- package/docs/html/types/RemoteApiServices.html +1 -112
- package/docs/html/types/RemoteApiStatus.html +2 -115
- package/docs/html/types/RenderTarget.html +2 -115
- package/docs/html/types/Uri.html +1 -112
- package/docs/html/types/WebGLError.html +1 -112
- package/docs/html/variables/extensionRequestContext.html +2 -115
- package/docs/md/README.md +3 -3
- package/docs/md/classes/CameraKit.md +15 -15
- package/docs/md/classes/CameraKitSession.md +38 -38
- package/docs/md/classes/CameraKitSource.md +22 -30
- package/docs/md/classes/LensPerformanceMeasurement.md +10 -6
- package/docs/md/classes/LensPerformanceMetrics.md +2 -2
- package/docs/md/classes/LensRepository.md +18 -18
- package/docs/md/classes/Transform2D.md +7 -3
- package/docs/md/classes/TypedCustomEvent.md +10 -6
- package/docs/md/classes/TypedEventTarget.md +12 -8
- package/docs/md/enums/Lens_CameraFacing.md +36 -0
- package/docs/md/enums/UserData_Zodiac.md +106 -0
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +2 -2
- package/docs/md/interfaces/CameraKitDeviceOptions.md +41 -0
- package/docs/md/interfaces/CameraKitSourceInfo.md +43 -0
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +7 -7
- 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/FunctionSourceOptions.md +22 -0
- package/docs/md/interfaces/Lens.md +4 -4
- package/docs/md/interfaces/LensCreator.md +17 -0
- package/docs/md/interfaces/LensLaunchData.md +6 -6
- package/docs/md/interfaces/LensSource.md +5 -5
- package/docs/md/interfaces/LoadAssetRequest.md +49 -0
- package/docs/md/interfaces/MediaStreamSourceOptions.md +46 -1
- package/docs/md/interfaces/Preview.md +1 -1
- package/docs/md/interfaces/RemoteApiRequest.md +2 -2
- package/docs/md/interfaces/RemoteApiResponse.md +2 -2
- package/docs/md/interfaces/RemoteApiService.md +1 -1
- package/docs/md/interfaces/Snapcode.md +1 -1
- package/docs/md/interfaces/UriCancelRequest.md +2 -2
- package/docs/md/interfaces/UriRequest.md +3 -3
- package/docs/md/interfaces/UriResponse.md +2 -2
- package/docs/md/interfaces/VideoSourceOptions.md +44 -1
- package/docs/md/modules.md +183 -201
- package/lib/CameraKit.d.ts +108 -108
- package/lib/CameraKit.js +1 -1
- package/lib/CameraKit.js.map +1 -1
- package/lib/bootstrapCameraKit.d.ts +4 -4
- package/lib/bootstrapCameraKit.js +18 -19
- package/lib/bootstrapCameraKit.js.map +1 -1
- package/lib/clients/createTsProtoClient.d.ts +5 -12
- package/lib/clients/createTsProtoClient.js +1 -2
- package/lib/clients/createTsProtoClient.js.map +1 -1
- package/lib/clients/grpcHandler.d.ts +7 -4
- package/lib/clients/grpcHandler.js +8 -5
- package/lib/clients/grpcHandler.js.map +1 -1
- package/lib/clients/lensesClient.d.ts +3 -3
- package/lib/clients/lensesClient.js +2 -2
- package/lib/clients/lensesClient.js.map +1 -1
- package/lib/clients/metricsClient.d.ts +26 -0
- package/lib/clients/metricsClient.js +120 -0
- package/lib/clients/metricsClient.js.map +1 -0
- package/lib/configuration.js +1 -1
- package/lib/configuration.js.map +1 -1
- package/lib/dependency-injection/Container.d.ts +1 -1
- package/lib/dependency-injection/Container.js +1 -1
- package/lib/dependency-injection/Container.js.map +1 -1
- package/lib/dependency-injection/Injectable.d.ts +6 -6
- package/lib/dependency-injection/Injectable.js.map +1 -1
- package/lib/dependency-injection/RootServices.d.ts +7 -8
- package/lib/dependency-injection/RootServices.js.map +1 -1
- package/lib/environment.d.ts +4 -0
- package/lib/environment.js +2 -0
- package/lib/environment.js.map +1 -0
- package/lib/extensions/RemoteApiServices.d.ts +2 -2
- package/lib/extensions/RemoteApiServices.js +11 -6
- package/lib/extensions/RemoteApiServices.js.map +1 -1
- package/lib/extensions/uriHandlersRegister.d.ts +4 -4
- package/lib/extensions/uriHandlersRegister.js +6 -6
- package/lib/extensions/uriHandlersRegister.js.map +1 -1
- package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +4330 -678
- package/lib/generated-proto/blizzard/cameraKitEvents.js +515 -72
- package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +3 -11
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +6 -156
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +19 -19
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +13 -27
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +0 -6
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +2 -83
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -22
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -263
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +30 -34
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +7 -73
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -6
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -110
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +48 -114
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +0 -225
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +6 -6
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +5 -19
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +1422 -1422
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +12 -12
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +10 -24
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +207 -207
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +530 -530
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +10 -24
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
- package/lib/generated-proto/pb_schema/common/value.d.ts +6 -6
- package/lib/generated-proto/pb_schema/common/value.js +4 -18
- package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/api/http.d.ts +0 -6
- package/lib/generated-proto/pb_schema/google/api/http.js +0 -77
- package/lib/generated-proto/pb_schema/google/api/http.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -2
- package/lib/generated-proto/pb_schema/google/protobuf/any.js +0 -44
- package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +4830 -4896
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +10 -997
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +3 -5
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +6 -35
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +6 -6
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +10 -24
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +9 -9
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +11 -11
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +6 -20
- package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +42 -42
- package/lib/generated-proto/pb_schema/lenses/snappable.js +14 -28
- package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
- package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +8 -8
- package/lib/generated-proto/pb_schema/lenses/user_data.js +8 -22
- package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
- package/lib/handlers/defaultFetchHandler.d.ts +1 -1
- package/lib/handlers/defaultFetchHandler.js.map +1 -1
- package/lib/handlers/requestStateEmittingHandler.d.ts +5 -6
- package/lib/handlers/requestStateEmittingHandler.js +6 -8
- package/lib/handlers/requestStateEmittingHandler.js.map +1 -1
- package/lib/handlers/responseCachingHandler.d.ts +9 -10
- package/lib/handlers/responseCachingHandler.js +9 -3
- package/lib/handlers/responseCachingHandler.js.map +1 -1
- package/lib/handlers/utils.d.ts +12 -0
- package/lib/handlers/utils.js +19 -0
- package/lib/handlers/utils.js.map +1 -0
- package/lib/index.d.ts +21 -15
- package/lib/index.js +17 -12
- package/lib/index.js.map +1 -1
- package/lib/lens/Lens.d.ts +12 -2
- package/lib/lens/Lens.js +5 -0
- package/lib/lens/Lens.js.map +1 -1
- package/lib/lens/LensLaunchData.d.ts +6 -3
- package/lib/lens/LensLaunchData.js +2 -0
- package/lib/lens/LensLaunchData.js.map +1 -1
- package/lib/lens/LensPersistenceStore.d.ts +1 -1
- package/lib/lens/LensPersistenceStore.js +1 -1
- package/lib/lens/LensPersistenceStore.js.map +1 -1
- package/lib/lens/LensRepository.d.ts +5 -1
- package/lib/lens/LensRepository.js +9 -5
- package/lib/lens/LensRepository.js.map +1 -1
- package/lib/lens/LensSource.d.ts +2 -2
- package/lib/lens/LensSource.js +2 -2
- package/lib/lens/LensSource.js.map +1 -1
- package/lib/lens/assets/LensAssetRepository.d.ts +35 -4
- package/lib/lens/assets/LensAssetRepository.js +9 -9
- package/lib/lens/assets/LensAssetRepository.js.map +1 -1
- package/lib/lens/assets/LensAssetsProvider.d.ts +1 -1
- package/lib/lens/assets/LensAssetsProvider.js +9 -4
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
- package/lib/lens/assets/deviceDependentAssetLoader.js +3 -2
- package/lib/lens/assets/deviceDependentAssetLoader.js.map +1 -1
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +4 -3
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -1
- package/lib/lens/assets/staticAssetLoader.js +5 -4
- package/lib/lens/assets/staticAssetLoader.js.map +1 -1
- package/lib/lens/cameraKitLensSource.js.map +1 -1
- package/lib/lens-client-interface/imagePicker.d.ts +2 -1
- package/lib/lens-client-interface/imagePicker.js.map +1 -1
- package/lib/lens-client-interface/lensClientInterface.d.ts +1 -1
- package/lib/lens-client-interface/lensClientInterface.js +1 -1
- package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
- package/lib/lens-core-module/lensCore.d.ts +2 -1
- package/lib/lens-core-module/lensCore.js.map +1 -1
- package/lib/lens-core-module/loader/bootstrapURLs.d.ts +12 -0
- package/lib/lens-core-module/loader/bootstrapURLs.js +48 -0
- package/lib/lens-core-module/loader/bootstrapURLs.js.map +1 -0
- package/lib/lens-core-module/loader/lensCoreFactory.d.ts +0 -12
- package/lib/lens-core-module/loader/lensCoreFactory.js +4 -49
- package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
- package/lib/lensCoreWasmVersions.d.ts +6 -0
- package/lib/lensCoreWasmVersions.js +6 -0
- package/lib/lensCoreWasmVersions.js.map +1 -0
- package/lib/media-sources/CameraKitSource.d.ts +39 -17
- package/lib/media-sources/CameraKitSource.js +8 -2
- package/lib/media-sources/CameraKitSource.js.map +1 -1
- package/lib/media-sources/FunctionSource.d.ts +15 -4
- package/lib/media-sources/FunctionSource.js +1 -2
- package/lib/media-sources/FunctionSource.js.map +1 -1
- package/lib/media-sources/ImageSource.d.ts +3 -5
- package/lib/media-sources/ImageSource.js +1 -3
- package/lib/media-sources/ImageSource.js.map +1 -1
- package/lib/media-sources/MediaStreamSource.d.ts +17 -33
- package/lib/media-sources/MediaStreamSource.js +6 -41
- package/lib/media-sources/MediaStreamSource.js.map +1 -1
- package/lib/media-sources/VideoSource.d.ts +14 -10
- package/lib/media-sources/VideoSource.js +5 -11
- package/lib/media-sources/VideoSource.js.map +1 -1
- package/lib/metrics/businessEventsReporter.d.ts +3 -4
- package/lib/metrics/businessEventsReporter.js +11 -55
- package/lib/metrics/businessEventsReporter.js.map +1 -1
- package/lib/metrics/operational/Count.d.ts +2 -0
- package/lib/metrics/operational/Count.js +6 -1
- package/lib/metrics/operational/Count.js.map +1 -1
- package/lib/metrics/operational/Histogram.d.ts +1 -1
- package/lib/metrics/operational/Histogram.js +7 -3
- package/lib/metrics/operational/Histogram.js.map +1 -1
- package/lib/metrics/operational/Metric.js +2 -0
- package/lib/metrics/operational/Metric.js.map +1 -1
- package/lib/metrics/operational/Timer.d.ts +9 -6
- package/lib/metrics/operational/Timer.js +12 -26
- package/lib/metrics/operational/Timer.js.map +1 -1
- package/lib/metrics/reporters/reportBenchmarks.d.ts +3 -3
- package/lib/metrics/reporters/reportBenchmarks.js +6 -5
- package/lib/metrics/reporters/reportBenchmarks.js.map +1 -1
- package/lib/metrics/reporters/reportGlobalException.d.ts +4 -4
- package/lib/metrics/reporters/reportGlobalException.js +13 -11
- package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
- package/lib/metrics/reporters/reportHttpMetrics.d.ts +3 -3
- package/lib/metrics/reporters/reportHttpMetrics.js +19 -16
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
- package/lib/metrics/reporters/reportLegalState.d.ts +3 -3
- package/lib/metrics/reporters/reportLegalState.js +7 -9
- package/lib/metrics/reporters/reportLegalState.js.map +1 -1
- package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +3 -3
- package/lib/metrics/reporters/reportLensAndAssetDownload.js +12 -12
- package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
- package/lib/metrics/reporters/reportLensView.d.ts +3 -3
- package/lib/metrics/reporters/reportLensView.js +6 -6
- package/lib/metrics/reporters/reportLensView.js.map +1 -1
- package/lib/metrics/reporters/reportLensWait.d.ts +2 -3
- package/lib/metrics/reporters/reportLensWait.js +1 -3
- package/lib/metrics/reporters/reportLensWait.js.map +1 -1
- package/lib/metrics/reporters/reportPlatformCapabilities.d.ts +3 -3
- package/lib/metrics/reporters/reportPlatformCapabilities.js +6 -5
- package/lib/metrics/reporters/reportPlatformCapabilities.js.map +1 -1
- package/lib/metrics/reporters/reportUserSession.js +3 -3
- package/lib/metrics/reporters/reportUserSession.js.map +1 -1
- package/lib/metrics/reporters/reporters.d.ts +2 -2
- package/lib/namedErrors.d.ts +1 -1
- package/lib/namedErrors.js +1 -1
- package/lib/namedErrors.js.map +1 -1
- package/lib/observable-operators/unsubscribed.d.ts +1 -1
- package/lib/observable-operators/unsubscribed.js +1 -1
- package/lib/observable-operators/unsubscribed.js.map +1 -1
- package/lib/platform/platformCapabilities.d.ts +1 -1
- package/lib/platform/platformCapabilities.js +9 -3
- package/lib/platform/platformCapabilities.js.map +1 -1
- package/lib/platform/platformInfo.d.ts +1 -0
- package/lib/platform/platformInfo.js +3 -3
- package/lib/platform/platformInfo.js.map +1 -1
- package/lib/remote-configuration/cofHandler.d.ts +3 -3
- package/lib/remote-configuration/cofHandler.js +6 -4
- package/lib/remote-configuration/cofHandler.js.map +1 -1
- package/lib/remote-configuration/preloadConfiguration.d.ts +1 -1
- package/lib/remote-configuration/preloadConfiguration.js +1 -1
- package/lib/remote-configuration/preloadConfiguration.js.map +1 -1
- package/lib/remote-configuration/remoteConfiguration.d.ts +7 -6
- package/lib/remote-configuration/remoteConfiguration.js +18 -15
- package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
- package/lib/session/CameraKitSession.d.ts +8 -8
- package/lib/session/CameraKitSession.js +11 -9
- package/lib/session/CameraKitSession.js.map +1 -1
- package/lib/session/LensKeyboard.d.ts +2 -3
- package/lib/session/LensKeyboard.js.map +1 -1
- package/lib/session/LensPerformanceMeasurement.d.ts +1 -1
- package/lib/session/LensPerformanceMeasurement.js +3 -3
- package/lib/session/LensPerformanceMeasurement.js.map +1 -1
- package/lib/session/LensPerformanceMetrics.d.ts +1 -1
- package/lib/session/LensPerformanceMetrics.js.map +1 -1
- package/lib/session/lensState.d.ts +4 -4
- package/lib/session/lensState.js +10 -10
- package/lib/session/lensState.js.map +1 -1
- package/lib/transforms/Transform2D.d.ts +8 -3
- package/lib/transforms/Transform2D.js +1 -1
- package/lib/transforms/Transform2D.js.map +1 -1
- package/lib/utils.d.ts +3 -0
- package/lib/utils.js +4 -0
- package/lib/utils.js.map +1 -0
- package/package.json +27 -6
- package/docs/html/functions/createUserMediaSource.html +0 -138
- package/docs/html/functions/getRequiredBootstrapURLs.html +0 -130
- package/docs/html/types/CameraKitDeviceInfo.html +0 -125
- package/docs/html/types/CameraKitDeviceOptions.html +0 -120
- package/docs/html/types/CameraKitSourceInfo.html +0 -112
- package/docs/html/types/CameraKitSourceOptions.html +0 -118
- package/lib/common/index.d.ts +0 -2
- package/lib/common/index.js +0 -3
- package/lib/common/index.js.map +0 -1
- package/lib/environment.json +0 -1
- package/lib/handlers/index.d.ts +0 -2
- package/lib/handlers/index.js +0 -3
- package/lib/handlers/index.js.map +0 -1
- package/lib/lens-core-module/index.d.ts +0 -3
- package/lib/lens-core-module/index.js +0 -4
- package/lib/lens-core-module/index.js.map +0 -1
- package/lib/lens-core-module/loader/index.d.ts +0 -1
- package/lib/lens-core-module/loader/index.js +0 -2
- package/lib/lens-core-module/loader/index.js.map +0 -1
- package/lib/lensCoreWasmVersions.json +0 -5
- package/lib/metrics/metricsHandler.d.ts +0 -10
- package/lib/metrics/metricsHandler.js +0 -13
- package/lib/metrics/metricsHandler.js.map +0 -1
- package/lib/metrics/operational/operationalMetricsReporter.d.ts +0 -64
- package/lib/metrics/operational/operationalMetricsReporter.js +0 -144
- package/lib/metrics/operational/operationalMetricsReporter.js.map +0 -1
- package/lib/session/index.d.ts +0 -1
- package/lib/session/index.js +0 -2
- package/lib/session/index.js.map +0 -1
- package/lib/transforms/index.d.ts +0 -1
- package/lib/transforms/index.js +0 -2
- package/lib/transforms/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../../src/metrics/operational/Timer.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../../src/metrics/operational/Timer.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAmB,MAAM,EAAoB,eAAe,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAajH,gBAAgB;AAChB,MAAM,OAAO,KAA2B,SAAQ,MAAM;IAMlD,YAAqB,IAAU,EAAE,aAA+B,EAAE;QAC9D,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QADP,SAAI,GAAJ,IAAI,CAAM;QAHd,cAAS,GAAG,SAAS,EAAE,CAAC;QACjC,YAAO,GAAG,KAAK,CAAC;QAKpB,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAA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,cAAV,UAAU,GAAI,IAAI,CAAC,UAAU;SAC5C,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,IAAI;QACA,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;;;OAOG;IACG,aAAa,CAAC,MAAqB;;YACrC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;KAAA;IAED;;;;;OAKG;IACH,mBAAmB;QACf,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,yBAAyB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YACvE,SAAS;YACT,MAAM,EAAE;gBACJ,KAAK,EAAE,eAAe;gBACtB,aAAa,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;aAClD;SACJ,CAAC,CAAC,CAAC;IACR,CAAC;CACJ","sourcesContent":["import { MetricsClient } from \"../../clients/metricsClient\";\nimport { getTimeMs } from \"../../common/time\";\nimport { OperationalMetric } from \"../../generated-proto/pb_schema/camera_kit/v3/operational_metrics\";\nimport { JoinMetricNames, Metric, MetricDimensions, joinMetricNames, serializeMetricDimensions } from \"./Metric\";\n\ninterface Measure {\n name: string;\n duration: number;\n dimensions: MetricDimensions;\n}\n\n/** @internal */\nexport type LatencyMetric = OperationalMetric & {\n metric: Extract<OperationalMetric[\"metric\"], { $case: \"latencyMillis\" }>;\n};\n\n/** @internal */\nexport class Timer<Name extends string> extends Metric {\n private readonly marks: Set<Timer<string>>;\n private readonly measures: Set<Measure>;\n private readonly startTime = getTimeMs();\n private stopped = false;\n\n constructor(readonly name: Name, dimensions: MetricDimensions = {}) {\n super(name, dimensions);\n\n this.marks = new Set();\n this.measures = new Set();\n }\n\n /**\n * Return all measures created by this Timer and any child timers.\n */\n getMeasures(): ReadonlyArray<Measure> {\n return Array.from(this.measures.values()).concat(\n ...Array.from(this.marks.values()).map((mark) => mark.getMeasures())\n );\n }\n\n /**\n * Create a child Timer, using this Timer's name as a prefix when naming the new Timer. Any measures made with the\n * child Timer will be included when calling `getMeasures()` on this Timer, or when calling `toOperationalMetric`\n * on this Timer.\n *\n * @example\n * ```ts\n * const parent = new Timer('parent')\n * const child = parent.mark('child') // child metric name is parent_child.\n *\n * child.measure()\n * const measures = parent.getMeasures() // has one element.\n * ```\n *\n * @param name\n * @param dimensions If omitted, the child timer will NOT inherit dimensions from the parent -- if the child timer\n * should re-use the parent's dimensions, this must be done explicitly by passing the parent's dimensions as an\n * argument here.\n * @returns A child Timer.\n */\n mark<MarkName extends string>(\n name: MarkName,\n dimensions: MetricDimensions = {}\n ): Timer<JoinMetricNames<Name, MarkName>> {\n const mark = new Timer(joinMetricNames([this.name, name]) as JoinMetricNames<Name, MarkName>, dimensions);\n if (this.stopped) mark.stop();\n this.marks.add(mark);\n return mark;\n }\n\n /**\n * Measure the time (in milliseconds) since this Timer was created.\n *\n * If a name is provided, the measure's name will be prefixed with the name of this Timer. Otherwise the name of\n * the measure will be the name of this Timer.\n *\n * @example\n * ```ts\n * const timer = new Timer('a')\n * timer.measure('b')\n * const measures = timer.getMeasures()\n * // measure[0].name === 'a_b'\n * ```\n *\n * @param name\n * @returns\n */\n measure(): Measure | undefined;\n measure(dimensions: MetricDimensions): Measure | undefined;\n measure(name: string): Measure | undefined;\n measure(name: string, dimensions: MetricDimensions): Measure | undefined;\n measure(nameOrDimensions?: string | MetricDimensions, maybeDimensions?: MetricDimensions): Measure | undefined {\n if (this.stopped) return undefined;\n const name = typeof nameOrDimensions === \"string\" ? nameOrDimensions : \"\";\n const dimensions = typeof nameOrDimensions === \"string\" ? maybeDimensions : nameOrDimensions;\n\n const fullName = joinMetricNames([this.name, name]);\n const measure: Measure = {\n name: fullName,\n duration: getTimeMs() - this.startTime,\n dimensions: dimensions ?? this.dimensions,\n };\n this.measures.add(measure);\n return measure;\n }\n\n /**\n * Remove all measures from this Timer and any child timers previously created by calls to `mark()`.\n */\n clear(): void {\n this.measures.clear();\n this.marks.forEach((mark) => mark.clear());\n }\n\n /**\n * Prevent any future measures from being created by this Timer or any child timers.\n */\n stop(): void {\n this.stopped = true;\n this.marks.forEach((mark) => mark.stop());\n }\n\n /**\n * Report this metric using {@link MetricsClient}.\n *\n * After reporting, the Timer can longer be used. Its internal state is cleared and cannot be updated. Calling this\n * method a second time will no-op.\n *\n * @param reporter All measurements will be reported using the given reporter.\n */\n async stopAndReport(client: MetricsClient): Promise<void> {\n client.setOperationalMetrics(this);\n this.stop();\n this.clear();\n }\n\n /**\n * Convert all measures from this Timer and from any child timers into an array of {@link OperationalMetric}\n * objects, which can be sent to the backend.\n *\n * @returns\n */\n toOperationalMetric(): LatencyMetric[] {\n const timestamp = new Date();\n return this.getMeasures().map((measure) => ({\n name: `${measure.name}${serializeMetricDimensions(measure.dimensions)}`,\n timestamp,\n metric: {\n $case: \"latencyMillis\",\n latencyMillis: `${Math.ceil(measure.duration)}`,\n },\n }));\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { MetricsClient } from "../../clients/metricsClient";
|
|
1
2
|
import { CameraKitConfiguration } from "../../configuration";
|
|
2
3
|
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
3
4
|
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
4
|
-
import { OperationalMetricsReporter } from "../operational/operationalMetricsReporter";
|
|
5
5
|
export type BenchmarkComplete = MakeTaggedBusinessEvent<"benchmarkComplete">;
|
|
6
6
|
export declare const reportBenchmarks: {
|
|
7
|
-
(args_0: MetricsEventTarget, args_1:
|
|
7
|
+
(args_0: MetricsEventTarget, args_1: MetricsClient, args_2: CameraKitConfiguration): Promise<void>;
|
|
8
8
|
token: "reportBenchmarks";
|
|
9
|
-
dependencies: readonly ["metricsEventTarget", "
|
|
9
|
+
dependencies: readonly ["metricsEventTarget", "metricsClient", "configuration"];
|
|
10
10
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
+
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
2
3
|
import { configurationToken } from "../../configuration";
|
|
3
4
|
import { Injectable } from "../../dependency-injection/Injectable";
|
|
4
5
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
5
6
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
6
|
-
import {
|
|
7
|
+
import { Histogram } from "../operational/Histogram";
|
|
7
8
|
// Allowlist the benchmarks we wish to report.
|
|
8
9
|
const reportableBenchmarks = ["gflops"];
|
|
9
|
-
export const reportBenchmarks = Injectable("reportBenchmarks", [metricsEventTargetFactory.token,
|
|
10
|
+
export const reportBenchmarks = Injectable("reportBenchmarks", [metricsEventTargetFactory.token, metricsClientFactory.token, configurationToken], (metricsEventTarget, metrics, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
11
|
if (config.lensPerformance === undefined)
|
|
11
12
|
return;
|
|
12
13
|
// Safety: config.lensPerformance cannot reject – all Promises contained in CameraKitConfiguration have
|
|
@@ -14,16 +15,16 @@ export const reportBenchmarks = Injectable("reportBenchmarks", [metricsEventTarg
|
|
|
14
15
|
const lensPerformance = yield config.lensPerformance;
|
|
15
16
|
const baseBenchmark = {
|
|
16
17
|
name: "benchmarkComplete",
|
|
17
|
-
performanceCluster: lensPerformance.cluster
|
|
18
|
+
performanceCluster: `${lensPerformance.cluster}`,
|
|
18
19
|
webglRendererInfo: lensPerformance.webglRendererInfo,
|
|
19
20
|
};
|
|
20
|
-
const dimensions =
|
|
21
|
+
const dimensions = { performance_cluster: lensPerformance.cluster.toString() };
|
|
21
22
|
for (const benchmark of lensPerformance.benchmarks) {
|
|
22
23
|
if (!reportableBenchmarks.includes(benchmark.name))
|
|
23
24
|
continue;
|
|
24
25
|
const benchmarkComplete = Object.assign(Object.assign({}, baseBenchmark), { benchmarkName: benchmark.name, benchmarkValue: benchmark.value });
|
|
25
26
|
metricsEventTarget.dispatchEvent(new TypedCustomEvent("benchmarkComplete", benchmarkComplete));
|
|
26
|
-
|
|
27
|
+
metrics.setOperationalMetrics(Histogram.level(`benchmark.${benchmark.name}`, benchmark.value, dimensions));
|
|
27
28
|
}
|
|
28
29
|
}));
|
|
29
30
|
//# sourceMappingURL=reportBenchmarks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportBenchmarks.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":";AAAA,OAAO,EAA0B,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"reportBenchmarks.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportBenchmarks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAiB,oBAAoB,EAAE,MAAM,6BAA6B,CA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AAmB,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC/F,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,aAAa,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;KAC9G;AACL,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { MetricsClient, metricsClientFactory } from \"../../clients/metricsClient\";\nimport { CameraKitConfiguration, configurationToken } from \"../../configuration\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { Histogram } from \"../operational/Histogram\";\n\n// Allowlist the benchmarks we wish to report.\nconst reportableBenchmarks = [\"gflops\"];\n\nexport type BenchmarkComplete = MakeTaggedBusinessEvent<\"benchmarkComplete\">;\n\nexport const reportBenchmarks = Injectable(\n \"reportBenchmarks\",\n [metricsEventTargetFactory.token, metricsClientFactory.token, configurationToken] as const,\n async (metricsEventTarget: MetricsEventTarget, metrics: MetricsClient, config: CameraKitConfiguration) => {\n if (config.lensPerformance === undefined) return;\n // Safety: config.lensPerformance cannot reject – all Promises contained in CameraKitConfiguration have\n // catch blocks which return a default value.\n const lensPerformance = await config.lensPerformance;\n const baseBenchmark: Pick<BenchmarkComplete, \"name\" | \"performanceCluster\" | \"webglRendererInfo\"> = {\n name: \"benchmarkComplete\",\n performanceCluster: `${lensPerformance.cluster}`,\n webglRendererInfo: lensPerformance.webglRendererInfo,\n };\n const dimensions = { performance_cluster: lensPerformance.cluster.toString() };\n for (const benchmark of lensPerformance.benchmarks) {\n if (!reportableBenchmarks.includes(benchmark.name)) continue;\n const benchmarkComplete: BenchmarkComplete = {\n ...baseBenchmark,\n benchmarkName: benchmark.name,\n benchmarkValue: benchmark.value,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"benchmarkComplete\", benchmarkComplete));\n metrics.setOperationalMetrics(Histogram.level(`benchmark.${benchmark.name}`, benchmark.value, dimensions));\n }\n }\n);\n"]}
|
|
@@ -2,14 +2,14 @@ import { Observable } from "rxjs";
|
|
|
2
2
|
import { LogEntry } from "../../logger/logger";
|
|
3
3
|
import { LensState } from "../../session/lensState";
|
|
4
4
|
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
5
|
-
import {
|
|
5
|
+
import { MetricsClient } from "../../clients/metricsClient";
|
|
6
6
|
interface RepeatableLogEntry {
|
|
7
7
|
entry: LogEntry;
|
|
8
8
|
count: number;
|
|
9
9
|
lastTime: Date;
|
|
10
10
|
}
|
|
11
11
|
export declare function getContextString(logEntries: RepeatableLogEntry[]): string;
|
|
12
|
-
export declare function reportExceptionToBlizzard(logEntries: Observable<LogEntry>, metricsEventTarget: MetricsEventTarget,
|
|
12
|
+
export declare function reportExceptionToBlizzard(logEntries: Observable<LogEntry>, metricsEventTarget: MetricsEventTarget, metrics: MetricsClient, lensState?: LensState): void;
|
|
13
13
|
export interface GlobalExceptionReporter {
|
|
14
14
|
attachLensContext: (lensState: LensState) => void;
|
|
15
15
|
}
|
|
@@ -19,8 +19,8 @@ export interface GlobalExceptionReporter {
|
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
export declare const reportGlobalException: {
|
|
22
|
-
(args_0: Observable<LogEntry>, args_1: MetricsEventTarget, args_2:
|
|
22
|
+
(args_0: Observable<LogEntry>, args_1: MetricsEventTarget, args_2: MetricsClient): GlobalExceptionReporter;
|
|
23
23
|
token: "reportGlobalException";
|
|
24
|
-
dependencies: readonly ["logEntries", "metricsEventTarget", "
|
|
24
|
+
dependencies: readonly ["logEntries", "metricsEventTarget", "metricsClient"];
|
|
25
25
|
};
|
|
26
26
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { isState } from "@snap/state-management";
|
|
2
2
|
import { filter, map, scan, Subject, takeUntil } from "rxjs";
|
|
3
3
|
import { entries } from "../../common/entries";
|
|
4
|
-
import { ensureError } from "../../common/errorHelpers";
|
|
4
|
+
import { ensureError, stringifyError } from "../../common/errorHelpers";
|
|
5
5
|
import { Injectable } from "../../dependency-injection/Injectable";
|
|
6
6
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
7
7
|
import { logEntriesFactory } from "../../logger/logEntries";
|
|
8
8
|
import { logLevelMap } from "../../logger/logger";
|
|
9
9
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
10
|
-
import {
|
|
10
|
+
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
11
|
+
import { Count } from "../operational/Count";
|
|
11
12
|
const logMethods = entries(logLevelMap).map(([level]) => level);
|
|
12
13
|
// How many log entries to include as the error context
|
|
13
14
|
const maxBufferedEntries = 15;
|
|
@@ -29,21 +30,22 @@ export function getContextString(logEntries) {
|
|
|
29
30
|
*/
|
|
30
31
|
function prettyPrintMessage(message) {
|
|
31
32
|
if (message instanceof Error)
|
|
32
|
-
return
|
|
33
|
+
return stringifyErrorMessage(message);
|
|
33
34
|
if (message instanceof Date)
|
|
34
35
|
return message.toISOString();
|
|
35
36
|
return message + "";
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
|
-
* Returns an error message for a given error, and also appends the error message of any nested error,
|
|
39
|
+
* Returns an error message for a given error, and also appends the error message of any nested error,
|
|
40
|
+
* if one exists. It DOES NOT append error stack trace.
|
|
39
41
|
* @param error Error to stringify.
|
|
40
42
|
* @returns Error message including nested error messages.
|
|
41
43
|
*/
|
|
42
|
-
function
|
|
43
|
-
const cause = error.cause ? `; Caused by ${
|
|
44
|
+
function stringifyErrorMessage(error) {
|
|
45
|
+
const cause = error.cause ? `; Caused by ${stringifyErrorMessage(ensureError(error.cause))}` : "";
|
|
44
46
|
return `${error.name}: ${error.message}${cause}`;
|
|
45
47
|
}
|
|
46
|
-
export function reportExceptionToBlizzard(logEntries, metricsEventTarget,
|
|
48
|
+
export function reportExceptionToBlizzard(logEntries, metricsEventTarget, metrics, lensState) {
|
|
47
49
|
logEntries
|
|
48
50
|
.pipe(scan(({ entries }, newEntry) => {
|
|
49
51
|
const lastEntry = entries[entries.length - 1];
|
|
@@ -80,7 +82,7 @@ export function reportExceptionToBlizzard(logEntries, metricsEventTarget, report
|
|
|
80
82
|
type: error.name,
|
|
81
83
|
reason: `${stringifyError(error)}${contextSeparator}${getContextString(context)}`,
|
|
82
84
|
}));
|
|
83
|
-
|
|
85
|
+
metrics.setOperationalMetrics(Count.count("handled_exception", 1, { type: error.name }));
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
/**
|
|
@@ -88,16 +90,16 @@ export function reportExceptionToBlizzard(logEntries, metricsEventTarget, report
|
|
|
88
90
|
*
|
|
89
91
|
* @internal
|
|
90
92
|
*/
|
|
91
|
-
export const reportGlobalException = Injectable("reportGlobalException", [logEntriesFactory.token, metricsEventTargetFactory.token,
|
|
93
|
+
export const reportGlobalException = Injectable("reportGlobalException", [logEntriesFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token], (logEntries, metricsEventTarget, metrics) => {
|
|
92
94
|
// Initially we log exceptions without any lens context
|
|
93
95
|
const cancellationSubject = new Subject();
|
|
94
|
-
reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget,
|
|
96
|
+
reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget, metrics);
|
|
95
97
|
// Later session scope reporter triggers cancellation of the global one
|
|
96
98
|
// and initiates exception reporting with a lens context
|
|
97
99
|
return {
|
|
98
100
|
attachLensContext: (lensState) => {
|
|
99
101
|
cancellationSubject.next();
|
|
100
|
-
reportExceptionToBlizzard(logEntries, metricsEventTarget,
|
|
102
|
+
reportExceptionToBlizzard(logEntries, metricsEventTarget, metrics, lensState);
|
|
101
103
|
},
|
|
102
104
|
};
|
|
103
105
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportGlobalException.js","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AC;IAEzG,uEAAuE;IACvE,wDAAwD;IACxD,OAAO;QACH,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE;YACxC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAC3B,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACnF,CAAC;KACJ,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { isState } from \"@snap/state-management\";\nimport { filter, map, Observable, scan, Subject, takeUntil } from \"rxjs\";\nimport { entries } from \"../../common/entries\";\nimport { ensureError } from \"../../common/errorHelpers\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { logEntriesFactory } from \"../../logger/logEntries\";\nimport { LogEntry, logLevelMap } from \"../../logger/logger\";\nimport { LensState } from \"../../session/lensState\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport {\n operationalMetricReporterFactory,\n OperationalMetricsReporter,\n} from \"../operational/operationalMetricsReporter\";\n\nconst logMethods = entries(logLevelMap).map(([level]) => level);\n\n// How many log entries to include as the error context\nconst maxBufferedEntries = 15;\nconst contextSeparator = \"\\n\\n----------------- Context -----------------\\n\\n\";\nconst methodLength = logMethods.reduce((max, method) => Math.max(max, method.length), 0);\n\ninterface RepeatableLogEntry {\n entry: LogEntry;\n count: number;\n lastTime: Date;\n}\n\ninterface EntriesBuffer {\n /**\n * LogEntries grouped by their message.\n */\n entries: RepeatableLogEntry[];\n /**\n * The recent log entry.\n */\n recent: LogEntry;\n}\n\nexport function getContextString(logEntries: RepeatableLogEntry[]) {\n const result = [];\n for (const { entry, count, lastTime } of logEntries) {\n const time = entry.time.toISOString();\n const method = entry.level.padStart(methodLength);\n const messages = entry.messages.map(prettyPrintMessage).join(\" \");\n let dupSuffix =\n count > 1 ? ` (Repeated ${count} times with the last occurrence at ${lastTime.toISOString()})` : \"\";\n\n result.push(`${time} [${entry.module}] ${method}: ${messages}${dupSuffix}`);\n }\n return result.join(\"\\n\");\n}\n\n/**\n * Pretty print a log message.\n */\nfunction prettyPrintMessage(message: unknown): string {\n if (message instanceof Error) return stringifyError(message);\n if (message instanceof Date) return message.toISOString();\n return message + \"\";\n}\n\n/**\n * Returns an error message for a given error, and also appends the error message of any nested error, if one exists.\n * @param error Error to stringify.\n * @returns Error message including nested error messages.\n */\nfunction stringifyError(error: Error): string {\n const cause = error.cause ? `; Caused by ${stringifyError(ensureError(error.cause))}` : \"\";\n return `${error.name}: ${error.message}${cause}`;\n}\n\nexport function reportExceptionToBlizzard(\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n reporter: OperationalMetricsReporter,\n lensState?: LensState\n) {\n logEntries\n .pipe(\n scan<LogEntry, EntriesBuffer>(\n ({ entries }, newEntry) => {\n const lastEntry = entries[entries.length - 1];\n const isNewEntryRepeated =\n lastEntry &&\n lastEntry.entry.messages.join() === newEntry.messages.join() &&\n lastEntry.entry.level === newEntry.level;\n if (isNewEntryRepeated) {\n lastEntry.count += 1;\n lastEntry.lastTime = newEntry.time;\n } else {\n entries.push({\n entry: newEntry,\n count: 1,\n lastTime: newEntry.time,\n });\n }\n return {\n entries: entries.slice(-maxBufferedEntries),\n recent: newEntry,\n };\n },\n // Start with a dummy recent entry -- it gets overridden each time we handle a log entry.\n { entries: [], recent: { time: new Date(), module: \"any\", level: \"debug\", messages: [] } }\n ),\n filter(({ recent }) => recent.level === \"error\"),\n map(({ entries, recent }) => ({\n context: entries,\n error: recent.messages.find((e) => e instanceof Error) as Error,\n })),\n filter(({ error }) => !!error)\n )\n .subscribe(({ error, context }) => {\n const currentLensState = lensState?.getState();\n const lensId =\n currentLensState && !isState(currentLensState, \"noLensApplied\") ? currentLensState.data.id : \"none\";\n metricsEventTarget.dispatchEvent(\n new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId,\n type: error.name,\n reason: `${stringifyError(error)}${contextSeparator}${getContextString(context)}`,\n })\n );\n\n reporter.count(\"handled_exception\", 1, new Map([[\"type\", error.name]]));\n });\n}\n\nexport interface GlobalExceptionReporter {\n attachLensContext: (lensState: LensState) => void;\n}\n\n/**\n * Reports log entries to Blizzard when there is no CameraKit session yet.\n *\n * @internal\n */\nexport const reportGlobalException = Injectable(\n \"reportGlobalException\",\n [logEntriesFactory.token, metricsEventTargetFactory.token, operationalMetricReporterFactory.token] as const,\n (\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n reporter: OperationalMetricsReporter\n ): GlobalExceptionReporter => {\n // Initially we log exceptions without any lens context\n const cancellationSubject = new Subject<void>();\n reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget, reporter);\n\n // Later session scope reporter triggers cancellation of the global one\n // and initiates exception reporting with a lens context\n return {\n attachLensContext: (lensState: LensState) => {\n cancellationSubject.next();\n reportExceptionToBlizzard(logEntries, metricsEventTarget, reporter, lensState);\n },\n };\n }\n);\n"]}
|
|
1
|
+
{"version":3,"file":"reportGlobalException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportGlobalException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAc,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAY,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB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K,CAAC,IAAI;YAChB,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,EAAE;SACpF,CAAC,CACL,CAAC;QAEF,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC,CAAC,CAAC;AACX,CAAC;AAMD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAC3C,uBAAuB,EACvB,CAAC,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAU,EAC/F,CACI,UAAgC,EAChC,kBAAsC,EACtC,OAAsB,EACC,EAAE;IACzB,uDAAuD;IACvD,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAQ,CAAC;IAChD,yBAAyB,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAExG,uEAAuE;IACvE,wDAAwD;IACxD,OAAO;QACH,iBAAiB,EAAE,CAAC,SAAoB,EAAE,EAAE;YACxC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAC3B,yBAAyB,CAAC,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAClF,CAAC;KACJ,CAAC;AACN,CAAC,CACJ,CAAC","sourcesContent":["import { isState } from \"@snap/state-management\";\nimport { filter, map, Observable, scan, Subject, takeUntil } from \"rxjs\";\nimport { entries } from \"../../common/entries\";\nimport { ensureError, stringifyError } from \"../../common/errorHelpers\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { logEntriesFactory } from \"../../logger/logEntries\";\nimport { LogEntry, logLevelMap } from \"../../logger/logger\";\nimport { LensState } from \"../../session/lensState\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { MetricsClient, metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\nconst logMethods = entries(logLevelMap).map(([level]) => level);\n\n// How many log entries to include as the error context\nconst maxBufferedEntries = 15;\nconst contextSeparator = \"\\n\\n----------------- Context -----------------\\n\\n\";\nconst methodLength = logMethods.reduce((max, method) => Math.max(max, method.length), 0);\n\ninterface RepeatableLogEntry {\n entry: LogEntry;\n count: number;\n lastTime: Date;\n}\n\ninterface EntriesBuffer {\n /**\n * LogEntries grouped by their message.\n */\n entries: RepeatableLogEntry[];\n /**\n * The recent log entry.\n */\n recent: LogEntry;\n}\n\nexport function getContextString(logEntries: RepeatableLogEntry[]) {\n const result = [];\n for (const { entry, count, lastTime } of logEntries) {\n const time = entry.time.toISOString();\n const method = entry.level.padStart(methodLength);\n const messages = entry.messages.map(prettyPrintMessage).join(\" \");\n let dupSuffix =\n count > 1 ? ` (Repeated ${count} times with the last occurrence at ${lastTime.toISOString()})` : \"\";\n\n result.push(`${time} [${entry.module}] ${method}: ${messages}${dupSuffix}`);\n }\n return result.join(\"\\n\");\n}\n\n/**\n * Pretty print a log message.\n */\nfunction prettyPrintMessage(message: unknown): string {\n if (message instanceof Error) return stringifyErrorMessage(message);\n if (message instanceof Date) return message.toISOString();\n return message + \"\";\n}\n\n/**\n * Returns an error message for a given error, and also appends the error message of any nested error,\n * if one exists. It DOES NOT append error stack trace.\n * @param error Error to stringify.\n * @returns Error message including nested error messages.\n */\nfunction stringifyErrorMessage(error: Error): string {\n const cause = error.cause ? `; Caused by ${stringifyErrorMessage(ensureError(error.cause))}` : \"\";\n return `${error.name}: ${error.message}${cause}`;\n}\n\nexport function reportExceptionToBlizzard(\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient,\n lensState?: LensState\n) {\n logEntries\n .pipe(\n scan<LogEntry, EntriesBuffer>(\n ({ entries }, newEntry) => {\n const lastEntry = entries[entries.length - 1];\n const isNewEntryRepeated =\n lastEntry &&\n lastEntry.entry.messages.join() === newEntry.messages.join() &&\n lastEntry.entry.level === newEntry.level;\n if (isNewEntryRepeated) {\n lastEntry.count += 1;\n lastEntry.lastTime = newEntry.time;\n } else {\n entries.push({\n entry: newEntry,\n count: 1,\n lastTime: newEntry.time,\n });\n }\n return {\n entries: entries.slice(-maxBufferedEntries),\n recent: newEntry,\n };\n },\n // Start with a dummy recent entry -- it gets overridden each time we handle a log entry.\n { entries: [], recent: { time: new Date(), module: \"any\", level: \"debug\", messages: [] } }\n ),\n filter(({ recent }) => recent.level === \"error\"),\n map(({ entries, recent }) => ({\n context: entries,\n error: recent.messages.find((e) => e instanceof Error) as Error,\n })),\n filter(({ error }) => !!error)\n )\n .subscribe(({ error, context }) => {\n const currentLensState = lensState?.getState();\n const lensId =\n currentLensState && !isState(currentLensState, \"noLensApplied\") ? currentLensState.data.id : \"none\";\n metricsEventTarget.dispatchEvent(\n new TypedCustomEvent(\"exception\", {\n name: \"exception\",\n lensId,\n type: error.name,\n reason: `${stringifyError(error)}${contextSeparator}${getContextString(context)}`,\n })\n );\n\n metrics.setOperationalMetrics(Count.count(\"handled_exception\", 1, { type: error.name }));\n });\n}\n\nexport interface GlobalExceptionReporter {\n attachLensContext: (lensState: LensState) => void;\n}\n\n/**\n * Reports log entries to Blizzard when there is no CameraKit session yet.\n *\n * @internal\n */\nexport const reportGlobalException = Injectable(\n \"reportGlobalException\",\n [logEntriesFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (\n logEntries: Observable<LogEntry>,\n metricsEventTarget: MetricsEventTarget,\n metrics: MetricsClient\n ): GlobalExceptionReporter => {\n // Initially we log exceptions without any lens context\n const cancellationSubject = new Subject<void>();\n reportExceptionToBlizzard(logEntries.pipe(takeUntil(cancellationSubject)), metricsEventTarget, metrics);\n\n // Later session scope reporter triggers cancellation of the global one\n // and initiates exception reporting with a lens context\n return {\n attachLensContext: (lensState: LensState) => {\n cancellationSubject.next();\n reportExceptionToBlizzard(logEntries, metricsEventTarget, metrics, lensState);\n },\n };\n }\n);\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CofDimensions } from "../../remote-configuration/cofHandler";
|
|
2
2
|
import { Dimensions, RequestStateEventTarget } from "../../handlers/requestStateEmittingHandler";
|
|
3
|
-
import {
|
|
3
|
+
import { MetricsClient } from "../../clients/metricsClient";
|
|
4
4
|
import { AssetDownloadDimensions, LensDownloadDimensions } from "./reportLensAndAssetDownload";
|
|
5
5
|
export declare const isRelevantRequest: (value: Dimensions) => value is CofDimensions | AssetDownloadDimensions | LensDownloadDimensions;
|
|
6
6
|
export declare const reportHttpMetrics: {
|
|
7
|
-
(args_0:
|
|
7
|
+
(args_0: MetricsClient, args_1: RequestStateEventTarget): void;
|
|
8
8
|
token: "reportHttpMetrics";
|
|
9
|
-
dependencies: readonly ["
|
|
9
|
+
dependencies: readonly ["metricsClient", "requestStateEventTarget"];
|
|
10
10
|
};
|
|
@@ -3,8 +3,10 @@ import { Injectable } from "../../dependency-injection/Injectable";
|
|
|
3
3
|
import { scan } from "../../events/scan";
|
|
4
4
|
import { COF_REQUEST_TYPE } from "../../remote-configuration/cofHandler";
|
|
5
5
|
import { requestStateEventTargetFactory, } from "../../handlers/requestStateEmittingHandler";
|
|
6
|
-
import { operationalMetricReporterFactory, } from "../operational/operationalMetricsReporter";
|
|
7
6
|
import { getPlatformInfo } from "../../platform/platformInfo";
|
|
7
|
+
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
8
|
+
import { Count } from "../operational/Count";
|
|
9
|
+
import { Histogram } from "../operational/Histogram";
|
|
8
10
|
import { isLensOrAssetRequest } from "./reportLensAndAssetDownload";
|
|
9
11
|
const getAdditionalDimensions = (dimensions) => {
|
|
10
12
|
switch (dimensions.requestType) {
|
|
@@ -57,16 +59,17 @@ const getStatus = (event) => {
|
|
|
57
59
|
export const isRelevantRequest = (value) => {
|
|
58
60
|
return isLensOrAssetRequest(value) || value["requestType"] === COF_REQUEST_TYPE;
|
|
59
61
|
};
|
|
60
|
-
export const reportHttpMetrics = Injectable("reportHttpMetrics", [
|
|
62
|
+
export const reportHttpMetrics = Injectable("reportHttpMetrics", [metricsClientFactory.token, requestStateEventTargetFactory.token], (metrics, requestStateEventTarget) => {
|
|
61
63
|
scan({ name: "inProgress", inProgress: new Map() })(requestStateEventTarget, ["started", "completed", "errored"], (state, event) => {
|
|
62
64
|
var _a;
|
|
63
65
|
const { inProgress } = state;
|
|
64
|
-
const { dimensions, requestId
|
|
66
|
+
const { dimensions, requestId } = event.detail;
|
|
65
67
|
if (!isRelevantRequest(dimensions))
|
|
66
68
|
return state;
|
|
67
69
|
switch (event.type) {
|
|
68
70
|
case "started":
|
|
69
|
-
|
|
71
|
+
const timer = event.detail.timer;
|
|
72
|
+
inProgress.set(requestId, { timer });
|
|
70
73
|
return { name: "inProgress", inProgress };
|
|
71
74
|
case "completed":
|
|
72
75
|
case "errored":
|
|
@@ -74,23 +77,23 @@ export const reportHttpMetrics = Injectable("reportHttpMetrics", [operationalMet
|
|
|
74
77
|
if (!completedRequest)
|
|
75
78
|
return state;
|
|
76
79
|
inProgress.delete(requestId);
|
|
77
|
-
const downloadTimeMs = timeMs - completedRequest.startTimeMs;
|
|
78
80
|
const downloadSizeKb = getSizeKb(event);
|
|
79
81
|
const status = getStatus(event);
|
|
80
|
-
const operationalDimensions =
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const operationalDimensions = {
|
|
83
|
+
content_type: getContentType(dimensions),
|
|
84
|
+
network_type: (_a = getPlatformInfo().connectionType) !== null && _a !== void 0 ? _a : "unknown",
|
|
85
|
+
status,
|
|
86
|
+
};
|
|
85
87
|
for (const [key, value] of getAdditionalDimensions(dimensions)) {
|
|
86
|
-
operationalDimensions
|
|
88
|
+
operationalDimensions[key] = value;
|
|
87
89
|
}
|
|
90
|
+
completedRequest.timer.measure(operationalDimensions);
|
|
88
91
|
return {
|
|
89
92
|
name: "completed",
|
|
90
93
|
inProgress: state.inProgress,
|
|
91
94
|
dimensions: operationalDimensions,
|
|
92
95
|
downloadSizeKb,
|
|
93
|
-
|
|
96
|
+
timer: completedRequest.timer,
|
|
94
97
|
};
|
|
95
98
|
default:
|
|
96
99
|
assertUnreachable(event);
|
|
@@ -98,10 +101,10 @@ export const reportHttpMetrics = Injectable("reportHttpMetrics", [operationalMet
|
|
|
98
101
|
}).addEventListener("state", ({ detail: state }) => {
|
|
99
102
|
if (state.name !== "completed")
|
|
100
103
|
return;
|
|
101
|
-
const { dimensions,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
const { dimensions, timer, downloadSizeKb } = state;
|
|
105
|
+
metrics.setOperationalMetrics(Count.count("download_finished", 1, dimensions));
|
|
106
|
+
metrics.setOperationalMetrics(Histogram.level("download_size_kb", downloadSizeKb, dimensions));
|
|
107
|
+
metrics.setOperationalMetrics(timer);
|
|
105
108
|
});
|
|
106
109
|
});
|
|
107
110
|
//# sourceMappingURL=reportHttpMetrics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportHttpMetrics.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportHttpMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAiB,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAIH,8BAA8B,GACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"reportHttpMetrics.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportHttpMetrics.ts"],"names":[],"mappings":"AAAA,OA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AC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;QAC9C,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,OAAO;QAEvC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QAEpD,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/E,OAAO,CAAC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,kBAAkB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/F,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { assertUnreachable } from \"../../common/assertions\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { scan } from \"../../events/scan\";\nimport { CofDimensions, COF_REQUEST_TYPE } from \"../../remote-configuration/cofHandler\";\nimport {\n Dimensions,\n RequestStateEventTarget,\n RequestStateEvents,\n requestStateEventTargetFactory,\n} from \"../../handlers/requestStateEmittingHandler\";\nimport { getPlatformInfo } from \"../../platform/platformInfo\";\nimport { MetricsClient, metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\nimport { Histogram } from \"../operational/Histogram\";\nimport { Timer } from \"../operational/Timer\";\nimport { AssetDownloadDimensions, isLensOrAssetRequest, LensDownloadDimensions } from \"./reportLensAndAssetDownload\";\n\ntype InProgressMap = Map<number, { timer: Timer<\"download_latency\"> }>;\ninterface InProgress {\n name: \"inProgress\";\n inProgress: InProgressMap;\n}\ninterface Completed {\n name: \"completed\";\n inProgress: InProgressMap;\n dimensions: Record<string, string>;\n timer: Timer<\"download_latency\">;\n downloadSizeKb: number;\n}\ntype RequestState = InProgress | Completed;\n\nconst getAdditionalDimensions = (\n dimensions: LensDownloadDimensions | AssetDownloadDimensions | CofDimensions\n): [string, string][] => {\n switch (dimensions.requestType) {\n case \"lens_content\":\n case \"asset\":\n return [];\n case COF_REQUEST_TYPE:\n return [[\"delta\", dimensions.delta]];\n default:\n assertUnreachable(dimensions);\n }\n};\n\nconst getContentType = (dimensions: LensDownloadDimensions | AssetDownloadDimensions | CofDimensions): string => {\n switch (dimensions.requestType) {\n case \"lens_content\":\n return \"lens_content\";\n case \"asset\":\n return dimensions.assetType;\n case COF_REQUEST_TYPE:\n return COF_REQUEST_TYPE;\n default:\n assertUnreachable(dimensions);\n }\n};\n\nconst getSizeKb = (event: RequestStateEvents): number => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n return 0;\n case \"completed\":\n return event.detail.sizeByte / 1024;\n default:\n assertUnreachable(event);\n }\n};\n\nconst getStatus = (event: RequestStateEvents): string => {\n switch (event.type) {\n case \"started\":\n case \"errored\":\n // We'll use status 0 to indicate that an exception occurred during the request. This is somewhat in keeping\n // with browsers that set the response status to 0 if the request was not able to be made (e.g. CORs\n // preflight failed, or the user canceled the request).\n return \"0\";\n case \"completed\":\n return event.detail.status.toString();\n default:\n assertUnreachable(event);\n }\n};\n\nexport const isRelevantRequest = (\n value: Dimensions\n): value is LensDownloadDimensions | AssetDownloadDimensions | CofDimensions => {\n return isLensOrAssetRequest(value) || value[\"requestType\"] === COF_REQUEST_TYPE;\n};\n\nexport const reportHttpMetrics = Injectable(\n \"reportHttpMetrics\",\n [metricsClientFactory.token, requestStateEventTargetFactory.token] as const,\n (metrics: MetricsClient, requestStateEventTarget: RequestStateEventTarget) => {\n scan<RequestState>({ name: \"inProgress\", inProgress: new Map() })(\n requestStateEventTarget,\n [\"started\", \"completed\", \"errored\"],\n (state, event) => {\n const { inProgress } = state;\n const { dimensions, requestId } = event.detail;\n\n if (!isRelevantRequest(dimensions)) return state;\n\n switch (event.type) {\n case \"started\":\n const timer = event.detail.timer;\n inProgress.set(requestId, { timer });\n return { name: \"inProgress\", inProgress };\n case \"completed\":\n case \"errored\":\n const completedRequest = inProgress.get(requestId);\n if (!completedRequest) return state;\n inProgress.delete(requestId);\n\n const downloadSizeKb = getSizeKb(event);\n const status = getStatus(event);\n const operationalDimensions: Record<string, string> = {\n content_type: getContentType(dimensions),\n network_type: getPlatformInfo().connectionType ?? \"unknown\",\n status,\n };\n\n for (const [key, value] of getAdditionalDimensions(dimensions)) {\n operationalDimensions[key] = value;\n }\n\n completedRequest.timer.measure(operationalDimensions);\n\n return {\n name: \"completed\",\n inProgress: state.inProgress,\n dimensions: operationalDimensions,\n downloadSizeKb,\n timer: completedRequest.timer,\n };\n default:\n assertUnreachable(event);\n }\n }\n ).addEventListener(\"state\", ({ detail: state }) => {\n if (state.name !== \"completed\") return;\n\n const { dimensions, timer, downloadSizeKb } = state;\n\n metrics.setOperationalMetrics(Count.count(\"download_finished\", 1, dimensions));\n metrics.setOperationalMetrics(Histogram.level(\"download_size_kb\", downloadSizeKb, dimensions));\n metrics.setOperationalMetrics(timer);\n });\n }\n);\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
2
2
|
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
3
|
-
import {
|
|
3
|
+
import { MetricsClient } from "../../clients/metricsClient";
|
|
4
4
|
/**
|
|
5
5
|
* The LegalPrompt metric reports each time a BIPA legal prompt is shown.
|
|
6
6
|
*/
|
|
@@ -9,7 +9,7 @@ export type LegalPrompt = MakeTaggedBusinessEvent<"legalPrompt">;
|
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
export declare const reportLegalState: {
|
|
12
|
-
(args_0: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>, args_1: MetricsEventTarget, args_2:
|
|
12
|
+
(args_0: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>, args_1: MetricsEventTarget, args_2: MetricsClient): void;
|
|
13
13
|
token: "reportLegalState";
|
|
14
|
-
dependencies: readonly ["legalState", "metricsEventTarget", "
|
|
14
|
+
dependencies: readonly ["legalState", "metricsEventTarget", "metricsClient"];
|
|
15
15
|
};
|
|
@@ -5,11 +5,12 @@ import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
|
5
5
|
import { CameraKitLegalPromptResult } from "../../generated-proto/blizzard/cameraKitEvents";
|
|
6
6
|
import { legalStateFactory } from "../../legal/legalState";
|
|
7
7
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
8
|
-
import {
|
|
8
|
+
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
9
|
+
import { Count } from "../operational/Count";
|
|
9
10
|
/**
|
|
10
11
|
* @internal
|
|
11
12
|
*/
|
|
12
|
-
export const reportLegalState = Injectable("reportLegalState", [legalStateFactory.token, metricsEventTargetFactory.token,
|
|
13
|
+
export const reportLegalState = Injectable("reportLegalState", [legalStateFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token], (legalState, metricsEventTarget, metrics) => {
|
|
13
14
|
legalState.events
|
|
14
15
|
.pipe(forActions("accept", "reject"), map(([{ data, name }]) => ({
|
|
15
16
|
name: "legalPrompt",
|
|
@@ -21,13 +22,10 @@ export const reportLegalState = Injectable("reportLegalState", [legalStateFactor
|
|
|
21
22
|
.subscribe({
|
|
22
23
|
next: (legalPromptEvent) => {
|
|
23
24
|
metricsEventTarget.dispatchEvent(new TypedCustomEvent("legalPrompt", legalPromptEvent));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED).toString(),
|
|
29
|
-
],
|
|
30
|
-
]));
|
|
25
|
+
metrics.setOperationalMetrics(Count.count("legal_prompt_interaction", 1, {
|
|
26
|
+
accepted: (legalPromptEvent.legalPromptResult ===
|
|
27
|
+
CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED).toString(),
|
|
28
|
+
}));
|
|
31
29
|
},
|
|
32
30
|
});
|
|
33
31
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reportLegalState.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLegalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAc,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,
|
|
1
|
+
{"version":3,"file":"reportLegalState.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLegalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAc,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEvE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAiB,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAO7C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,kBAAkB,EAClB,CAAC,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAU,EAC/F,CAAC,UAAsB,EAAE,kBAAsC,EAAE,OAAsB,EAAE,EAAE;IACvF,UAAU,CAAC,MAAM;SACZ,IAAI,CACD,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACvB,IAAI,EAAE,aAAsB;QAC5B,aAAa,EAAE,IAAI;QACnB,iBAAiB,EACb,IAAI,KAAK,QAAQ;YACb,CAAC,CAAC,0BAA0B,CAAC,gCAAgC;YAC7D,CAAC,CAAC,0BAA0B,CAAC,iCAAiC;KACzE,CAAC,CAAC,CACN;SACA,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,gBAAgB,EAAE,EAAE;YACvB,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;YACxF,OAAO,CAAC,qBAAqB,CACzB,KAAK,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,EAAE;gBACvC,QAAQ,EAAE,CACN,gBAAgB,CAAC,iBAAiB;oBAClC,0BAA0B,CAAC,gCAAgC,CAC9D,CAAC,QAAQ,EAAE;aACf,CAAC,CACL,CAAC;QACN,CAAC;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { forActions } from \"@snap/state-management\";\nimport { map } from \"rxjs\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { CameraKitLegalPromptResult } from \"../../generated-proto/blizzard/cameraKitEvents\";\nimport { LegalState, legalStateFactory } from \"../../legal/legalState\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { MetricsClient, metricsClientFactory } from \"../../clients/metricsClient\";\nimport { Count } from \"../operational/Count\";\n\n/**\n * The LegalPrompt metric reports each time a BIPA legal prompt is shown.\n */\nexport type LegalPrompt = MakeTaggedBusinessEvent<\"legalPrompt\">;\n\n/**\n * @internal\n */\nexport const reportLegalState = Injectable(\n \"reportLegalState\",\n [legalStateFactory.token, metricsEventTargetFactory.token, metricsClientFactory.token] as const,\n (legalState: LegalState, metricsEventTarget: MetricsEventTarget, metrics: MetricsClient) => {\n legalState.events\n .pipe(\n forActions(\"accept\", \"reject\"),\n map(([{ data, name }]) => ({\n name: \"legalPrompt\" as const,\n legalPromptId: data,\n legalPromptResult:\n name === \"accept\"\n ? CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n : CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_DISMISSED,\n }))\n )\n .subscribe({\n next: (legalPromptEvent) => {\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"legalPrompt\", legalPromptEvent));\n metrics.setOperationalMetrics(\n Count.count(\"legal_prompt_interaction\", 1, {\n accepted: (\n legalPromptEvent.legalPromptResult ===\n CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n ).toString(),\n })\n );\n },\n });\n }\n);\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { MetricsClient } from "../../clients/metricsClient";
|
|
1
2
|
import { Dimensions, RequestStateEventTarget } from "../../handlers/requestStateEmittingHandler";
|
|
2
3
|
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
3
4
|
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
4
|
-
import { OperationalMetricsReporter } from "../operational/operationalMetricsReporter";
|
|
5
5
|
export declare const isLensOrAssetRequest: (value: Dimensions) => value is AssetDownloadDimensions | LensDownloadDimensions;
|
|
6
6
|
/**
|
|
7
7
|
* The LensDownload metric is triggered by any download of lens content.
|
|
@@ -32,7 +32,7 @@ export type AssetDownloadDimensions = {
|
|
|
32
32
|
lensId: string;
|
|
33
33
|
};
|
|
34
34
|
export declare const reportLensAndAssetDownload: {
|
|
35
|
-
(args_0: MetricsEventTarget, args_1:
|
|
35
|
+
(args_0: MetricsEventTarget, args_1: MetricsClient, args_2: RequestStateEventTarget): void;
|
|
36
36
|
token: "reportLensAndAssetDownload";
|
|
37
|
-
dependencies: readonly ["metricsEventTarget", "
|
|
37
|
+
dependencies: readonly ["metricsEventTarget", "metricsClient", "requestStateEventTarget"];
|
|
38
38
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { metricsClientFactory } from "../../clients/metricsClient";
|
|
1
2
|
import { assertUnreachable } from "../../common/assertions";
|
|
2
3
|
import { stringifyError } from "../../common/errorHelpers";
|
|
3
4
|
import { Injectable } from "../../dependency-injection/Injectable";
|
|
@@ -5,33 +6,32 @@ import { scan } from "../../events/scan";
|
|
|
5
6
|
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
7
|
import { requestStateEventTargetFactory, } from "../../handlers/requestStateEmittingHandler";
|
|
7
8
|
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
8
|
-
import {
|
|
9
|
+
import { Count } from "../operational/Count";
|
|
9
10
|
const relevantRequestTypes = ["lens_content", "asset"];
|
|
10
11
|
export const isLensOrAssetRequest = (value) => {
|
|
11
12
|
const requestType = value["requestType"];
|
|
12
13
|
// Safety: the cast makes the type less specific so we can check if any string is present in the tuple.
|
|
13
14
|
return typeof requestType === "string" && relevantRequestTypes.includes(requestType);
|
|
14
15
|
};
|
|
15
|
-
export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload", [
|
|
16
|
-
metricsEventTargetFactory.token,
|
|
17
|
-
operationalMetricReporterFactory.token,
|
|
18
|
-
requestStateEventTargetFactory.token,
|
|
19
|
-
], (metricsEventTarget, reporter, requestStateEventTarget) => {
|
|
16
|
+
export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload", [metricsEventTargetFactory.token, metricsClientFactory.token, requestStateEventTargetFactory.token], (metricsEventTarget, metrics, requestStateEventTarget) => {
|
|
20
17
|
scan({ name: "inProgress", inProgress: new Map() })(requestStateEventTarget, ["started", "completed", "errored"], (state, event) => {
|
|
18
|
+
var _a;
|
|
21
19
|
const { inProgress } = state;
|
|
22
|
-
const { dimensions, requestId
|
|
20
|
+
const { dimensions, requestId } = event.detail;
|
|
23
21
|
if (!isLensOrAssetRequest(dimensions))
|
|
24
22
|
return state;
|
|
25
23
|
switch (event.type) {
|
|
26
24
|
case "started":
|
|
27
|
-
|
|
25
|
+
const timer = event.detail.timer;
|
|
26
|
+
inProgress.set(requestId, { timer });
|
|
28
27
|
return { name: "inProgress", inProgress };
|
|
29
28
|
case "completed":
|
|
30
29
|
const completedRequest = inProgress.get(requestId);
|
|
31
30
|
if (!completedRequest)
|
|
32
31
|
return state;
|
|
33
32
|
inProgress.delete(requestId);
|
|
34
|
-
const
|
|
33
|
+
const { duration } = (_a = completedRequest.timer.measure()) !== null && _a !== void 0 ? _a : { duration: 0 };
|
|
34
|
+
const downloadTimeSec = duration / 1000;
|
|
35
35
|
const { sizeByte } = event.detail;
|
|
36
36
|
switch (dimensions.requestType) {
|
|
37
37
|
case "lens_content":
|
|
@@ -42,7 +42,7 @@ export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload
|
|
|
42
42
|
name: "lensDownload",
|
|
43
43
|
lensId: dimensions.lensId,
|
|
44
44
|
automaticDownload: false,
|
|
45
|
-
sizeByte
|
|
45
|
+
sizeByte: `${Math.ceil(sizeByte)}`,
|
|
46
46
|
downloadTimeSec,
|
|
47
47
|
}),
|
|
48
48
|
};
|
|
@@ -54,7 +54,7 @@ export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload
|
|
|
54
54
|
name: "assetDownload",
|
|
55
55
|
assetId: dimensions.assetId,
|
|
56
56
|
automaticDownload: false,
|
|
57
|
-
sizeByte
|
|
57
|
+
sizeByte: `${Math.ceil(sizeByte)}`,
|
|
58
58
|
downloadTimeSec,
|
|
59
59
|
}),
|
|
60
60
|
};
|
|
@@ -85,7 +85,7 @@ export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload
|
|
|
85
85
|
return;
|
|
86
86
|
metricsEventTarget.dispatchEvent(state.event);
|
|
87
87
|
if (state.event.detail.name === "exception") {
|
|
88
|
-
|
|
88
|
+
metrics.setOperationalMetrics(Count.count("handled_exception", 1, { type: state.event.detail.type }));
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
});
|