@snap/camera-kit 0.7.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 +6247 -0
- package/README.md +166 -0
- package/docs/html/.nojekyll +1 -0
- package/docs/html/assets/highlight.css +106 -0
- package/docs/html/assets/main.js +54 -0
- package/docs/html/assets/search.js +1 -0
- package/docs/html/assets/style.css +1225 -0
- package/docs/html/assets/widgets.png +0 -0
- package/docs/html/assets/widgets@2x.png +0 -0
- package/docs/html/classes/CameraKit.html +121 -0
- package/docs/html/classes/CameraKitSession.html +347 -0
- package/docs/html/classes/CameraKitSource.html +152 -0
- package/docs/html/classes/LensPerformanceMeasurement.html +115 -0
- package/docs/html/classes/LensPerformanceMetrics.html +76 -0
- package/docs/html/classes/LensRepository.html +171 -0
- package/docs/html/classes/LensSources.html +82 -0
- package/docs/html/classes/Transform2D.html +99 -0
- package/docs/html/classes/TypedCustomEvent.html +109 -0
- package/docs/html/classes/TypedEventTarget.html +146 -0
- package/docs/html/functions/Injectable.html +193 -0
- package/docs/html/functions/bootstrapCameraKit.html +158 -0
- package/docs/html/functions/createExtension.html +127 -0
- package/docs/html/functions/createImageSource.html +123 -0
- package/docs/html/functions/createMediaStreamSource.html +123 -0
- package/docs/html/functions/createUserMediaSource.html +127 -0
- package/docs/html/functions/createVideoSource.html +124 -0
- package/docs/html/functions/estimateLensPerformance.html +116 -0
- package/docs/html/functions/getRequiredBootstrapURLs.html +124 -0
- package/docs/html/functions/lensSourcesFactory.html +116 -0
- package/docs/html/functions/uriHandlersFactory.html +118 -0
- package/docs/html/index.html +208 -0
- package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +132 -0
- package/docs/html/interfaces/CameraKitSourceSubscriber.html +121 -0
- package/docs/html/interfaces/ComputedFrameMetrics.html +70 -0
- package/docs/html/interfaces/CreateSessionOptions.html +77 -0
- package/docs/html/interfaces/EstimatedLensPerformance.html +78 -0
- package/docs/html/interfaces/Lens.html +115 -0
- package/docs/html/interfaces/LensSource.html +113 -0
- package/docs/html/interfaces/MediaStreamSourceOptions.html +65 -0
- package/docs/html/interfaces/UriCancelRequest.html +65 -0
- package/docs/html/interfaces/UriHandler.html +128 -0
- package/docs/html/interfaces/UriRequest.html +80 -0
- package/docs/html/interfaces/UriResponse.html +80 -0
- package/docs/html/interfaces/VideoSourceOptions.html +60 -0
- package/docs/html/modules.html +198 -0
- package/docs/html/types/AssetLoader.html +126 -0
- package/docs/html/types/AssetTiming.html +116 -0
- package/docs/html/types/BenchmarkError.html +107 -0
- package/docs/html/types/BootstrapError.html +110 -0
- package/docs/html/types/CacheKeyNotFoundError.html +107 -0
- package/docs/html/types/CameraKitDeviceInfo.html +114 -0
- package/docs/html/types/CameraKitSessionEventListener.html +109 -0
- package/docs/html/types/CameraKitSessionEvents.html +118 -0
- package/docs/html/types/CameraKitSourceError.html +107 -0
- package/docs/html/types/CameraKitSourceInfo.html +107 -0
- package/docs/html/types/CameraKitSourceOptions.html +113 -0
- package/docs/html/types/ConfigurationError.html +109 -0
- package/docs/html/types/Keyboard.html +196 -0
- package/docs/html/types/KeyboardEvents.html +109 -0
- package/docs/html/types/LegalError.html +107 -0
- package/docs/html/types/LensAssetError.html +109 -0
- package/docs/html/types/LensContentValidationError.html +107 -0
- package/docs/html/types/LensError.html +107 -0
- package/docs/html/types/LensExecutionError.html +114 -0
- package/docs/html/types/LensImagePickerError.html +110 -0
- package/docs/html/types/LensLaunchParams.html +109 -0
- package/docs/html/types/LensMetricsEvents.html +110 -0
- package/docs/html/types/LensPerformanceCluster.html +107 -0
- package/docs/html/types/LensView.html +119 -0
- package/docs/html/types/LensWait.html +111 -0
- package/docs/html/types/PersistentStoreError.html +109 -0
- package/docs/html/types/PlatformNotSupportedError.html +110 -0
- package/docs/html/types/PublicContainer.html +110 -0
- package/docs/html/types/RenderTarget.html +111 -0
- package/docs/html/types/Uri.html +107 -0
- package/docs/html/types/UriHandlers.html +109 -0
- package/docs/html/types/WebGLError.html +107 -0
- package/docs/html/variables/extensionRequestContext.html +109 -0
- package/docs/md/.nojekyll +1 -0
- package/docs/md/README.md +168 -0
- package/docs/md/classes/CameraKit.md +94 -0
- package/docs/md/classes/CameraKitSession.md +359 -0
- package/docs/md/classes/CameraKitSource.md +110 -0
- package/docs/md/classes/LensPerformanceMeasurement.md +77 -0
- package/docs/md/classes/LensPerformanceMetrics.md +37 -0
- package/docs/md/classes/LensRepository.md +145 -0
- package/docs/md/classes/LensSources.md +29 -0
- package/docs/md/classes/Transform2D.md +55 -0
- package/docs/md/classes/TypedCustomEvent.md +65 -0
- package/docs/md/classes/TypedEventTarget.md +103 -0
- package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +106 -0
- package/docs/md/interfaces/CameraKitSourceSubscriber.md +55 -0
- package/docs/md/interfaces/ComputedFrameMetrics.md +29 -0
- package/docs/md/interfaces/CreateSessionOptions.md +35 -0
- package/docs/md/interfaces/EstimatedLensPerformance.md +38 -0
- package/docs/md/interfaces/Lens.md +84 -0
- package/docs/md/interfaces/LensSource.md +68 -0
- package/docs/md/interfaces/MediaStreamSourceOptions.md +22 -0
- package/docs/md/interfaces/UriCancelRequest.md +22 -0
- package/docs/md/interfaces/UriHandler.md +63 -0
- package/docs/md/interfaces/UriRequest.md +43 -0
- package/docs/md/interfaces/UriResponse.md +43 -0
- package/docs/md/interfaces/VideoSourceOptions.md +15 -0
- package/docs/md/modules.md +827 -0
- package/lib/CameraKit.d.ts +170 -0
- package/lib/CameraKit.js +145 -0
- package/lib/CameraKit.js.map +1 -0
- package/lib/__tests__/data.d.ts +9 -0
- package/lib/__tests__/data.js +50 -0
- package/lib/__tests__/data.js.map +1 -0
- package/lib/__tests__/deferred.d.ts +16 -0
- package/lib/__tests__/deferred.js +29 -0
- package/lib/__tests__/deferred.js.map +1 -0
- package/lib/__tests__/jest.matchers.d.ts +17 -0
- package/lib/__tests__/jest.matchers.js +67 -0
- package/lib/__tests__/jest.matchers.js.map +1 -0
- package/lib/assertPlatformSupported.d.ts +4 -0
- package/lib/assertPlatformSupported.js +10 -0
- package/lib/assertPlatformSupported.js.map +1 -0
- package/lib/benchmark/benchmarkGflops.d.ts +16 -0
- package/lib/benchmark/benchmarkGflops.js +129 -0
- package/lib/benchmark/benchmarkGflops.js.map +1 -0
- package/lib/benchmark/estimateLensPerformanceCluster.d.ts +33 -0
- package/lib/benchmark/estimateLensPerformanceCluster.js +48 -0
- package/lib/benchmark/estimateLensPerformanceCluster.js.map +1 -0
- package/lib/benchmark/webglUtils.d.ts +7 -0
- package/lib/benchmark/webglUtils.js +87 -0
- package/lib/benchmark/webglUtils.js.map +1 -0
- package/lib/bootstrapCameraKit.d.ts +96 -0
- package/lib/bootstrapCameraKit.js +204 -0
- package/lib/bootstrapCameraKit.js.map +1 -0
- package/lib/common/__mocks__/loadScript.d.ts +1 -0
- package/lib/common/__mocks__/loadScript.js +10 -0
- package/lib/common/__mocks__/loadScript.js.map +1 -0
- package/lib/common/assertions.d.ts +27 -0
- package/lib/common/assertions.js +39 -0
- package/lib/common/assertions.js.map +1 -0
- package/lib/common/cameraKitUserAgent.d.ts +34 -0
- package/lib/common/cameraKitUserAgent.js +216 -0
- package/lib/common/cameraKitUserAgent.js.map +1 -0
- package/lib/common/copyDefinedProperties.d.ts +13 -0
- package/lib/common/copyDefinedProperties.js +16 -0
- package/lib/common/copyDefinedProperties.js.map +1 -0
- package/lib/common/entries.d.ts +3 -0
- package/lib/common/entries.js +3 -0
- package/lib/common/entries.js.map +1 -0
- package/lib/common/errorHelpers.d.ts +10 -0
- package/lib/common/errorHelpers.js +24 -0
- package/lib/common/errorHelpers.js.map +1 -0
- package/lib/common/getFilename.d.ts +1 -0
- package/lib/common/getFilename.js +4 -0
- package/lib/common/getFilename.js.map +1 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +3 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/loadScript.d.ts +1 -0
- package/lib/common/loadScript.js +11 -0
- package/lib/common/loadScript.js.map +1 -0
- package/lib/common/locale.d.ts +2 -0
- package/lib/common/locale.js +11 -0
- package/lib/common/locale.js.map +1 -0
- package/lib/common/localization.d.ts +43 -0
- package/lib/common/localization.js +43 -0
- package/lib/common/localization.js.map +1 -0
- package/lib/common/memoize.d.ts +8 -0
- package/lib/common/memoize.js +15 -0
- package/lib/common/memoize.js.map +1 -0
- package/lib/common/pageVisibility.d.ts +20 -0
- package/lib/common/pageVisibility.js +62 -0
- package/lib/common/pageVisibility.js.map +1 -0
- package/lib/common/time.d.ts +1 -0
- package/lib/common/time.js +2 -0
- package/lib/common/time.js.map +1 -0
- package/lib/common/typeguards.d.ts +53 -0
- package/lib/common/typeguards.js +92 -0
- package/lib/common/typeguards.js.map +1 -0
- package/lib/common/types.d.ts +10 -0
- package/lib/common/types.js +2 -0
- package/lib/common/types.js.map +1 -0
- package/lib/common/validate.d.ts +14 -0
- package/lib/common/validate.js +104 -0
- package/lib/common/validate.js.map +1 -0
- package/lib/configuration.d.ts +92 -0
- package/lib/configuration.js +36 -0
- package/lib/configuration.js.map +1 -0
- package/lib/configurationOverrides.d.ts +12 -0
- package/lib/configurationOverrides.js +41 -0
- package/lib/configurationOverrides.js.map +1 -0
- package/lib/dependency-injection/Container.d.ts +177 -0
- package/lib/dependency-injection/Container.js +160 -0
- package/lib/dependency-injection/Container.js.map +1 -0
- package/lib/dependency-injection/Injectable.d.ts +39 -0
- package/lib/dependency-injection/Injectable.js +18 -0
- package/lib/dependency-injection/Injectable.js.map +1 -0
- package/lib/dependency-injection/PartialContainer.d.ts +81 -0
- package/lib/dependency-injection/PartialContainer.js +85 -0
- package/lib/dependency-injection/PartialContainer.js.map +1 -0
- package/lib/dependency-injection/RootServices.d.ts +62 -0
- package/lib/dependency-injection/RootServices.js +2 -0
- package/lib/dependency-injection/RootServices.js.map +1 -0
- package/lib/dependency-injection/types.d.ts +56 -0
- package/lib/dependency-injection/types.js +2 -0
- package/lib/dependency-injection/types.js.map +1 -0
- package/lib/environment.json +1 -0
- package/lib/events/TypedCustomEvent.d.ts +10 -0
- package/lib/events/TypedCustomEvent.js +11 -0
- package/lib/events/TypedCustomEvent.js.map +1 -0
- package/lib/events/TypedEventTarget.d.ts +25 -0
- package/lib/events/TypedEventTarget.js +57 -0
- package/lib/events/TypedEventTarget.js.map +1 -0
- package/lib/events/scan.d.ts +15 -0
- package/lib/events/scan.js +46 -0
- package/lib/events/scan.js.map +1 -0
- package/lib/extensions/LensSources.d.ts +58 -0
- package/lib/extensions/LensSources.js +50 -0
- package/lib/extensions/LensSources.js.map +1 -0
- package/lib/extensions/UriHandlers.d.ts +54 -0
- package/lib/extensions/UriHandlers.js +93 -0
- package/lib/extensions/UriHandlers.js.map +1 -0
- package/lib/extensions/extensionRequestContext.d.ts +4 -0
- package/lib/extensions/extensionRequestContext.js +14 -0
- package/lib/extensions/extensionRequestContext.js.map +1 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +5603 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js +522 -0
- package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +98 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +260 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +543 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +429 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +100 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +164 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +395 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +644 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +185 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +172 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +86 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +234 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +854 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +629 -0
- package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +86 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +185 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +95 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +104 -0
- package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +10212 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +1300 -0
- package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +401 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +525 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +1287 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +135 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +4208 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +1053 -0
- package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +102 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +165 -0
- package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +8 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +17 -0
- package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -0
- package/lib/generated-proto/pb_schema/common/ruid.d.ts +75 -0
- package/lib/generated-proto/pb_schema/common/ruid.js +96 -0
- package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -0
- package/lib/generated-proto/pb_schema/common/value.d.ts +131 -0
- package/lib/generated-proto/pb_schema/common/value.js +204 -0
- package/lib/generated-proto/pb_schema/common/value.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.d.ts +1 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.js +9 -0
- package/lib/generated-proto/pb_schema/google/api/annotations.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/api/http.d.ts +3636 -0
- package/lib/generated-proto/pb_schema/google/api/http.js +271 -0
- package/lib/generated-proto/pb_schema/google/api/http.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +139 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.js +94 -0
- package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +50968 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +2962 -0
- package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +98 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +82 -0
- package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +173 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +332 -0
- package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.d.ts +42 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.js +52 -0
- package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.d.ts +32 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.js +50 -0
- package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.d.ts +29 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.js +43 -0
- package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +365 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js +216 -0
- package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/lures.d.ts +113 -0
- package/lib/generated-proto/pb_schema/lenses/lures.js +64 -0
- package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.d.ts +29 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js +43 -0
- package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +921 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.js +954 -0
- package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +247 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.js +362 -0
- package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -0
- package/lib/handlers/HandlerChainBuilder.d.ts +95 -0
- package/lib/handlers/HandlerChainBuilder.js +187 -0
- package/lib/handlers/HandlerChainBuilder.js.map +1 -0
- package/lib/handlers/arrayBufferParsingHandler.d.ts +10 -0
- package/lib/handlers/arrayBufferParsingHandler.js +18 -0
- package/lib/handlers/arrayBufferParsingHandler.js.map +1 -0
- package/lib/handlers/batchingHandler.d.ts +25 -0
- package/lib/handlers/batchingHandler.js +79 -0
- package/lib/handlers/batchingHandler.js.map +1 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.d.ts +12 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +19 -0
- package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -0
- package/lib/handlers/debugHandler.d.ts +8 -0
- package/lib/handlers/debugHandler.js +27 -0
- package/lib/handlers/debugHandler.js.map +1 -0
- package/lib/handlers/defaultFetchHandler.d.ts +15 -0
- package/lib/handlers/defaultFetchHandler.js +29 -0
- package/lib/handlers/defaultFetchHandler.js.map +1 -0
- package/lib/handlers/headersModifyingFetchHandler.d.ts +8 -0
- package/lib/handlers/headersModifyingFetchHandler.js +13 -0
- package/lib/handlers/headersModifyingFetchHandler.js.map +1 -0
- package/lib/handlers/index.d.ts +2 -0
- package/lib/handlers/index.js +3 -0
- package/lib/handlers/index.js.map +1 -0
- package/lib/handlers/mappingHandler.d.ts +15 -0
- package/lib/handlers/mappingHandler.js +65 -0
- package/lib/handlers/mappingHandler.js.map +1 -0
- package/lib/handlers/noCorsRetryingFetchHandler.d.ts +48 -0
- package/lib/handlers/noCorsRetryingFetchHandler.js +94 -0
- package/lib/handlers/noCorsRetryingFetchHandler.js.map +1 -0
- package/lib/handlers/persistingHandler.d.ts +14 -0
- package/lib/handlers/persistingHandler.js +71 -0
- package/lib/handlers/persistingHandler.js.map +1 -0
- package/lib/handlers/rateLimitingHandler.d.ts +20 -0
- package/lib/handlers/rateLimitingHandler.js +43 -0
- package/lib/handlers/rateLimitingHandler.js.map +1 -0
- package/lib/handlers/requestStateEmittingHandler.d.ts +29 -0
- package/lib/handlers/requestStateEmittingHandler.js +43 -0
- package/lib/handlers/requestStateEmittingHandler.js.map +1 -0
- package/lib/handlers/responseCachingHandler.d.ts +27 -0
- package/lib/handlers/responseCachingHandler.js +94 -0
- package/lib/handlers/responseCachingHandler.js.map +1 -0
- package/lib/handlers/retryingHandler.d.ts +37 -0
- package/lib/handlers/retryingHandler.js +73 -0
- package/lib/handlers/retryingHandler.js.map +1 -0
- package/lib/handlers/timeoutHandler.d.ts +18 -0
- package/lib/handlers/timeoutHandler.js +30 -0
- package/lib/handlers/timeoutHandler.js.map +1 -0
- package/lib/index.d.ts +33 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/legal/legalPrompt.d.ts +17 -0
- package/lib/legal/legalPrompt.js +144 -0
- package/lib/legal/legalPrompt.js.map +1 -0
- package/lib/legal/legalState.d.ts +50 -0
- package/lib/legal/legalState.js +149 -0
- package/lib/legal/legalState.js.map +1 -0
- package/lib/lens/Lens.d.ts +71 -0
- package/lib/lens/Lens.js +63 -0
- package/lib/lens/Lens.js.map +1 -0
- package/lib/lens/LensLaunchParams.d.ts +19 -0
- package/lib/lens/LensLaunchParams.js +38 -0
- package/lib/lens/LensLaunchParams.js.map +1 -0
- package/lib/lens/LensPersistenceStore.d.ts +7 -0
- package/lib/lens/LensPersistenceStore.js +20 -0
- package/lib/lens/LensPersistenceStore.js.map +1 -0
- package/lib/lens/LensRepository.d.ts +134 -0
- package/lib/lens/LensRepository.js +239 -0
- package/lib/lens/LensRepository.js.map +1 -0
- package/lib/lens/assets/LensAssetRepository.d.ts +66 -0
- package/lib/lens/assets/LensAssetRepository.js +179 -0
- package/lib/lens/assets/LensAssetRepository.js.map +1 -0
- package/lib/lens/assets/LensAssetsProvider.d.ts +21 -0
- package/lib/lens/assets/LensAssetsProvider.js +41 -0
- package/lib/lens/assets/LensAssetsProvider.js.map +1 -0
- package/lib/lens/assets/deviceDependentAssetLoader.d.ts +11 -0
- package/lib/lens/assets/deviceDependentAssetLoader.js +58 -0
- package/lib/lens/assets/deviceDependentAssetLoader.js.map +1 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.d.ts +10 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +26 -0
- package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -0
- package/lib/lens/assets/staticAssetLoader.d.ts +10 -0
- package/lib/lens/assets/staticAssetLoader.js +24 -0
- package/lib/lens/assets/staticAssetLoader.js.map +1 -0
- package/lib/lens/index.d.ts +7 -0
- package/lib/lens/index.js +7 -0
- package/lib/lens/index.js.map +1 -0
- package/lib/lens/lensEnvelopeUtil.d.ts +5 -0
- package/lib/lens/lensEnvelopeUtil.js +19 -0
- package/lib/lens/lensEnvelopeUtil.js.map +1 -0
- package/lib/lens/lensHttpUtil.d.ts +4 -0
- package/lib/lens/lensHttpUtil.js +30 -0
- package/lib/lens/lensHttpUtil.js.map +1 -0
- package/lib/lens-client-interface/exif.d.ts +20 -0
- package/lib/lens-client-interface/exif.js +61 -0
- package/lib/lens-client-interface/exif.js.map +1 -0
- package/lib/lens-client-interface/imagePicker.d.ts +7 -0
- package/lib/lens-client-interface/imagePicker.js +128 -0
- package/lib/lens-client-interface/imagePicker.js.map +1 -0
- package/lib/lens-client-interface/lensClientInterface.d.ts +13 -0
- package/lib/lens-client-interface/lensClientInterface.js +30 -0
- package/lib/lens-client-interface/lensClientInterface.js.map +1 -0
- package/lib/lens-core-module/generated-types.d.ts +426 -0
- package/lib/lens-core-module/generated-types.js +2 -0
- package/lib/lens-core-module/generated-types.js.map +1 -0
- package/lib/lens-core-module/index.d.ts +2 -0
- package/lib/lens-core-module/index.js +3 -0
- package/lib/lens-core-module/index.js.map +1 -0
- package/lib/lens-core-module/loader/index.d.ts +1 -0
- package/lib/lens-core-module/loader/index.js +2 -0
- package/lib/lens-core-module/loader/index.js.map +1 -0
- package/lib/lens-core-module/loader/lensCoreFactory.d.ts +30 -0
- package/lib/lens-core-module/loader/lensCoreFactory.js +121 -0
- package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -0
- package/lib/lensCoreWasmVersions.json +5 -0
- package/lib/logger/errorLoggingDecorator.d.ts +9 -0
- package/lib/logger/errorLoggingDecorator.js +32 -0
- package/lib/logger/errorLoggingDecorator.js.map +1 -0
- package/lib/logger/logEntries.d.ts +15 -0
- package/lib/logger/logEntries.js +14 -0
- package/lib/logger/logEntries.js.map +1 -0
- package/lib/logger/logger.d.ts +35 -0
- package/lib/logger/logger.js +48 -0
- package/lib/logger/logger.js.map +1 -0
- package/lib/logger/registerLogEntriesSubscriber.d.ts +14 -0
- package/lib/logger/registerLogEntriesSubscriber.js +23 -0
- package/lib/logger/registerLogEntriesSubscriber.js.map +1 -0
- package/lib/media-sources/CameraKitSource.d.ts +88 -0
- package/lib/media-sources/CameraKitSource.js +140 -0
- package/lib/media-sources/CameraKitSource.js.map +1 -0
- package/lib/media-sources/FunctionSource.d.ts +30 -0
- package/lib/media-sources/FunctionSource.js +132 -0
- package/lib/media-sources/FunctionSource.js.map +1 -0
- package/lib/media-sources/ImageSource.d.ts +13 -0
- package/lib/media-sources/ImageSource.js +28 -0
- package/lib/media-sources/ImageSource.js.map +1 -0
- package/lib/media-sources/MediaStreamSource.d.ts +41 -0
- package/lib/media-sources/MediaStreamSource.js +146 -0
- package/lib/media-sources/MediaStreamSource.js.map +1 -0
- package/lib/media-sources/VideoSource.d.ts +21 -0
- package/lib/media-sources/VideoSource.js +38 -0
- package/lib/media-sources/VideoSource.js.map +1 -0
- package/lib/metrics/businessEventsReporter.d.ts +37 -0
- package/lib/metrics/businessEventsReporter.js +160 -0
- package/lib/metrics/businessEventsReporter.js.map +1 -0
- package/lib/metrics/metricsEventTarget.d.ts +41 -0
- package/lib/metrics/metricsEventTarget.js +11 -0
- package/lib/metrics/metricsEventTarget.js.map +1 -0
- package/lib/metrics/metricsHandler.d.ts +9 -0
- package/lib/metrics/metricsHandler.js +13 -0
- package/lib/metrics/metricsHandler.js.map +1 -0
- package/lib/metrics/operationalMetricsReporter.d.ts +52 -0
- package/lib/metrics/operationalMetricsReporter.js +108 -0
- package/lib/metrics/operationalMetricsReporter.js.map +1 -0
- package/lib/metrics/reporters/reportBenchmarks.d.ts +10 -0
- package/lib/metrics/reporters/reportBenchmarks.js +29 -0
- package/lib/metrics/reporters/reportBenchmarks.js.map +1 -0
- package/lib/metrics/reporters/reportGlobalException.d.ts +19 -0
- package/lib/metrics/reporters/reportGlobalException.js +68 -0
- package/lib/metrics/reporters/reportGlobalException.js.map +1 -0
- package/lib/metrics/reporters/reportHttpMetrics.d.ts +17 -0
- package/lib/metrics/reporters/reportHttpMetrics.js +92 -0
- package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -0
- package/lib/metrics/reporters/reportLegalState.d.ts +15 -0
- package/lib/metrics/reporters/reportLegalState.js +34 -0
- package/lib/metrics/reporters/reportLegalState.js.map +1 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +38 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.js +88 -0
- package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -0
- package/lib/metrics/reporters/reportLensValidationFailed.d.ts +20 -0
- package/lib/metrics/reporters/reportLensValidationFailed.js +24 -0
- package/lib/metrics/reporters/reportLensValidationFailed.js.map +1 -0
- package/lib/metrics/reporters/reportLensView.d.ts +36 -0
- package/lib/metrics/reporters/reportLensView.js +101 -0
- package/lib/metrics/reporters/reportLensView.js.map +1 -0
- package/lib/metrics/reporters/reportLensWait.d.ts +33 -0
- package/lib/metrics/reporters/reportLensWait.js +56 -0
- package/lib/metrics/reporters/reportLensWait.js.map +1 -0
- package/lib/metrics/reporters/reportSessionException.d.ts +17 -0
- package/lib/metrics/reporters/reportSessionException.js +12 -0
- package/lib/metrics/reporters/reportSessionException.js.map +1 -0
- package/lib/metrics/reporters/reportUserSession.d.ts +14 -0
- package/lib/metrics/reporters/reportUserSession.js +67 -0
- package/lib/metrics/reporters/reportUserSession.js.map +1 -0
- package/lib/metrics/reporters/reporters.d.ts +44 -0
- package/lib/metrics/reporters/reporters.js +33 -0
- package/lib/metrics/reporters/reporters.js.map +1 -0
- package/lib/namedErrors.d.ts +107 -0
- package/lib/namedErrors.js +56 -0
- package/lib/namedErrors.js.map +1 -0
- package/lib/persistence/ExpiringPersistence.d.ts +20 -0
- package/lib/persistence/ExpiringPersistence.js +58 -0
- package/lib/persistence/ExpiringPersistence.js.map +1 -0
- package/lib/persistence/IndexedDBPersistence.d.ts +47 -0
- package/lib/persistence/IndexedDBPersistence.js +180 -0
- package/lib/persistence/IndexedDBPersistence.js.map +1 -0
- package/lib/persistence/Persistence.d.ts +25 -0
- package/lib/persistence/Persistence.js +10 -0
- package/lib/persistence/Persistence.js.map +1 -0
- package/lib/remote-configuration/cofHandler.d.ts +21 -0
- package/lib/remote-configuration/cofHandler.js +75 -0
- package/lib/remote-configuration/cofHandler.js.map +1 -0
- package/lib/remote-configuration/remoteConfiguration.d.ts +13 -0
- package/lib/remote-configuration/remoteConfiguration.js +43 -0
- package/lib/remote-configuration/remoteConfiguration.js.map +1 -0
- package/lib/session/CameraKitSession.d.ts +252 -0
- package/lib/session/CameraKitSession.js +439 -0
- package/lib/session/CameraKitSession.js.map +1 -0
- package/lib/session/CameraKitSessionEvents.d.ts +33 -0
- package/lib/session/CameraKitSessionEvents.js +21 -0
- package/lib/session/CameraKitSessionEvents.js.map +1 -0
- package/lib/session/LensKeyboard.d.ts +89 -0
- package/lib/session/LensKeyboard.js +95 -0
- package/lib/session/LensKeyboard.js.map +1 -0
- package/lib/session/LensPerformanceMeasurement.d.ts +55 -0
- package/lib/session/LensPerformanceMeasurement.js +91 -0
- package/lib/session/LensPerformanceMeasurement.js.map +1 -0
- package/lib/session/LensPerformanceMetrics.d.ts +31 -0
- package/lib/session/LensPerformanceMetrics.js +58 -0
- package/lib/session/LensPerformanceMetrics.js.map +1 -0
- package/lib/session/index.d.ts +1 -0
- package/lib/session/index.js +2 -0
- package/lib/session/index.js.map +1 -0
- package/lib/session/lensState.d.ts +29 -0
- package/lib/session/lensState.js +160 -0
- package/lib/session/lensState.js.map +1 -0
- package/lib/session/sessionState.d.ts +10 -0
- package/lib/session/sessionState.js +12 -0
- package/lib/session/sessionState.js.map +1 -0
- package/lib/transforms/Transform2D.d.ts +17 -0
- package/lib/transforms/Transform2D.js +18 -0
- package/lib/transforms/Transform2D.js.map +1 -0
- package/lib/transforms/index.d.ts +1 -0
- package/lib/transforms/index.js +2 -0
- package/lib/transforms/index.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +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,EAAE,gCAAgC,EAA8B,MAAM,+BAA+B,CAAC;AAO7G;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,kBAAkB,EAClB,CAAC,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,gCAAgC,CAAC,KAAK,CAAU,EAC3G,CACI,UAAsB,EACtB,kBAAsC,EACtC,0BAAsD,EACxD,EAAE;IACA,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,0BAA0B,CAAC,KAAK,CAC5B,0BAA0B,EAC1B,CAAC,EACD,IAAI,GAAG,CAAC;gBACJ;oBACI,UAAU;oBACV,CACI,gBAAgB,CAAC,iBAAiB;wBAClC,0BAA0B,CAAC,gCAAgC,CAC9D,CAAC,QAAQ,EAAE;iBACf;aACJ,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 { operationalMetricReporterFactory, OperationalMetricsReporter } from \"../operationalMetricsReporter\";\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, operationalMetricReporterFactory.token] as const,\n (\n legalState: LegalState,\n metricsEventTarget: MetricsEventTarget,\n operationalMetricsReporter: OperationalMetricsReporter\n ) => {\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 operationalMetricsReporter.count(\n \"legal_prompt_interaction\",\n 1,\n new Map([\n [\n \"accepted\",\n (\n legalPromptEvent.legalPromptResult ===\n CameraKitLegalPromptResult.CAMERA_KIT_LEGAL_PROMPT_ACCEPTED\n ).toString(),\n ],\n ])\n );\n },\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Dimensions } from "../../handlers/requestStateEmittingHandler";
|
|
2
|
+
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
3
|
+
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
4
|
+
import { OperationalMetricsReporter } from "../operationalMetricsReporter";
|
|
5
|
+
export declare const isLensOrAssetRequest: (value: Dimensions) => value is AssetDownloadDimensions | LensDownloadDimensions;
|
|
6
|
+
/**
|
|
7
|
+
* The LensDownload metric is triggered by any download of lens content.
|
|
8
|
+
*
|
|
9
|
+
* It contains download stats, which lens was requested, and whether prefetch was used.
|
|
10
|
+
*
|
|
11
|
+
* It corresponds to the internal CameraKitLensDownload event, described here:
|
|
12
|
+
* https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.stqom49qs91t
|
|
13
|
+
*/
|
|
14
|
+
export declare type LensDownload = MakeTaggedBusinessEvent<"lensDownload">;
|
|
15
|
+
export declare type LensDownloadDimensions = {
|
|
16
|
+
requestType: "lens_content";
|
|
17
|
+
lensId: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The AssetDownload metric is triggered by any type of asset download.
|
|
21
|
+
*
|
|
22
|
+
* It contains download stats, which asset was requested, and whether prefetch was used.
|
|
23
|
+
*
|
|
24
|
+
* It corresponds to the internal CameraKitAssetDownload event, described here:
|
|
25
|
+
* https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.vlormd1724fp
|
|
26
|
+
*/
|
|
27
|
+
export declare type AssetDownload = MakeTaggedBusinessEvent<"assetDownload">;
|
|
28
|
+
export declare type AssetDownloadDimensions = {
|
|
29
|
+
requestType: "asset";
|
|
30
|
+
assetType: string;
|
|
31
|
+
assetId: string;
|
|
32
|
+
lensId: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const reportLensAndAssetDownload: {
|
|
35
|
+
(args_0: MetricsEventTarget, args_1: OperationalMetricsReporter): void;
|
|
36
|
+
token: "reportLensAndAssetDownload";
|
|
37
|
+
dependencies: readonly ["metricsEventTarget", "operationalMetricsReporter"];
|
|
38
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { assertUnreachable } from "../../common/assertions";
|
|
2
|
+
import { stringifyError } from "../../common/errorHelpers";
|
|
3
|
+
import { Injectable } from "../../dependency-injection/Injectable";
|
|
4
|
+
import { scan } from "../../events/scan";
|
|
5
|
+
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
|
+
import { requestStateEventTarget } from "../../handlers/requestStateEmittingHandler";
|
|
7
|
+
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
8
|
+
import { operationalMetricReporterFactory } from "../operationalMetricsReporter";
|
|
9
|
+
const relevantRequestTypes = ["lens_content", "asset"];
|
|
10
|
+
export const isLensOrAssetRequest = (value) => {
|
|
11
|
+
const requestType = value["requestType"];
|
|
12
|
+
// Safety: the cast makes the type less specific so we can check if any string is present in the tuple.
|
|
13
|
+
return typeof requestType === "string" && relevantRequestTypes.includes(requestType);
|
|
14
|
+
};
|
|
15
|
+
export const reportLensAndAssetDownload = Injectable("reportLensAndAssetDownload", [metricsEventTargetFactory.token, operationalMetricReporterFactory.token], (metricsEventTarget, reporter) => {
|
|
16
|
+
scan({ name: "inProgress", inProgress: new Map() })(requestStateEventTarget, ["started", "completed", "errored"], (state, event) => {
|
|
17
|
+
const { inProgress } = state;
|
|
18
|
+
const { dimensions, requestId, timeMs } = event.detail;
|
|
19
|
+
if (!isLensOrAssetRequest(dimensions))
|
|
20
|
+
return state;
|
|
21
|
+
switch (event.type) {
|
|
22
|
+
case "started":
|
|
23
|
+
inProgress.set(requestId, { startTimeMs: timeMs });
|
|
24
|
+
return { name: "inProgress", inProgress };
|
|
25
|
+
case "completed":
|
|
26
|
+
const completedRequest = inProgress.get(requestId);
|
|
27
|
+
if (!completedRequest)
|
|
28
|
+
return state;
|
|
29
|
+
inProgress.delete(requestId);
|
|
30
|
+
const downloadTimeSec = (timeMs - completedRequest.startTimeMs) / 1000;
|
|
31
|
+
const { sizeByte } = event.detail;
|
|
32
|
+
switch (dimensions.requestType) {
|
|
33
|
+
case "lens_content":
|
|
34
|
+
return {
|
|
35
|
+
name: "completed",
|
|
36
|
+
inProgress,
|
|
37
|
+
event: new TypedCustomEvent("lensDownload", {
|
|
38
|
+
name: "lensDownload",
|
|
39
|
+
lensId: dimensions.lensId,
|
|
40
|
+
automaticDownload: false,
|
|
41
|
+
sizeByte,
|
|
42
|
+
downloadTimeSec,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
case "asset":
|
|
46
|
+
return {
|
|
47
|
+
name: "completed",
|
|
48
|
+
inProgress,
|
|
49
|
+
event: new TypedCustomEvent("assetDownload", {
|
|
50
|
+
name: "assetDownload",
|
|
51
|
+
assetId: dimensions.assetId,
|
|
52
|
+
automaticDownload: false,
|
|
53
|
+
sizeByte,
|
|
54
|
+
downloadTimeSec,
|
|
55
|
+
}),
|
|
56
|
+
};
|
|
57
|
+
default:
|
|
58
|
+
assertUnreachable(dimensions);
|
|
59
|
+
}
|
|
60
|
+
case "errored":
|
|
61
|
+
const erroredRequest = inProgress.get(requestId);
|
|
62
|
+
if (!erroredRequest)
|
|
63
|
+
return state;
|
|
64
|
+
inProgress.delete(requestId);
|
|
65
|
+
const error = event.detail.error;
|
|
66
|
+
return {
|
|
67
|
+
name: "completed",
|
|
68
|
+
inProgress,
|
|
69
|
+
event: new TypedCustomEvent("exception", {
|
|
70
|
+
name: "exception",
|
|
71
|
+
lensId: dimensions.lensId,
|
|
72
|
+
type: dimensions.requestType === "lens_content" ? "lens" : "asset",
|
|
73
|
+
reason: stringifyError(error),
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
default:
|
|
77
|
+
assertUnreachable(event);
|
|
78
|
+
}
|
|
79
|
+
}).addEventListener("state", ({ detail: state }) => {
|
|
80
|
+
if (state.name !== "completed")
|
|
81
|
+
return;
|
|
82
|
+
metricsEventTarget.dispatchEvent(state.event);
|
|
83
|
+
if (state.event.detail.name === "exception") {
|
|
84
|
+
reporter.count("handled_exception", 1, new Map([["type", state.event.detail.type]]));
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=reportLensAndAssetDownload.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportLensAndAssetDownload.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensAndAssetDownload.ts"],"names":[],"mappings":"AAAA,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;AACjE,OAAO,EAAc,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAEjG,OAAO,EAA6C,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,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,QAAQ,CAAC,KAAK,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACxF;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC","sourcesContent":["import { 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 { Dimensions, requestStateEventTarget } from \"../../handlers/requestStateEmittingHandler\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { CameraKitMetricEvents, MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { operationalMetricReporterFactory, OperationalMetricsReporter } from \"../operationalMetricsReporter\";\n\ntype InProgressMap = Map<number, { startTimeMs: number }>;\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, operationalMetricReporterFactory.token] as const,\n (metricsEventTarget: MetricsEventTarget, reporter: OperationalMetricsReporter) => {\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, timeMs } = event.detail;\n\n if (!isLensOrAssetRequest(dimensions)) return state;\n\n switch (event.type) {\n case \"started\":\n inProgress.set(requestId, { startTimeMs: timeMs });\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 downloadTimeSec = (timeMs - completedRequest.startTimeMs) / 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,\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,\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 reporter.count(\"handled_exception\", 1, new Map([[\"type\", state.event.detail.type]]));\n }\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
2
|
+
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
3
|
+
/**
|
|
4
|
+
* The LensContentValidationFailed metric reports every time we handle an lens checksum validation failure.
|
|
5
|
+
*/
|
|
6
|
+
export declare type LensContentValidationFailed = MakeTaggedBusinessEvent<"lensContentValidationFailed">;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const reportLensValidationFailed: {
|
|
11
|
+
(args_0: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
12
|
+
lens: import("../..").Lens;
|
|
13
|
+
launchParams?: import("../..").LensLaunchParams | undefined;
|
|
14
|
+
}> | import("@snap/state-management").Action<"downloadComplete", import("../..").Lens> | import("@snap/state-management").Action<"turnedOn", import("../..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
15
|
+
error: import("../../session/lensState").LensErrors;
|
|
16
|
+
lens: import("../..").Lens;
|
|
17
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("../..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("../..").Lens> | import("@snap/state-management").State<"lensApplied", import("../..").Lens>>, args_1: MetricsEventTarget): void;
|
|
18
|
+
token: "reportLensValidationFailed";
|
|
19
|
+
dependencies: readonly ["lensState", "metricsEventTarget"];
|
|
20
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { forActions } from "@snap/state-management";
|
|
2
|
+
import { filter } from "rxjs";
|
|
3
|
+
import { Injectable } from "../../dependency-injection/Injectable";
|
|
4
|
+
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
5
|
+
import { lensStateFactory } from "../../session/lensState";
|
|
6
|
+
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const reportLensValidationFailed = Injectable("reportLensValidationFailed", [lensStateFactory.token, metricsEventTargetFactory.token], (lensState, metricsEventTarget) => {
|
|
11
|
+
lensState.events
|
|
12
|
+
.pipe(forActions("applyLensFailed"), filter(([a]) => a.data.error.name === "LensContentValidationError"))
|
|
13
|
+
.subscribe({
|
|
14
|
+
next: ([{ data }]) => {
|
|
15
|
+
const { lens } = data;
|
|
16
|
+
const lensContentValidationFailed = {
|
|
17
|
+
name: "lensContentValidationFailed",
|
|
18
|
+
lensId: lens.id,
|
|
19
|
+
};
|
|
20
|
+
metricsEventTarget.dispatchEvent(new TypedCustomEvent("lensContentValidationFailed", lensContentValidationFailed));
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=reportLensValidationFailed.js.map
|
|
@@ -0,0 +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,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAa,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAOtF;;GAEG;AACH,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 \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { lensStateFactory, LensState } from \"../../session/lensState\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { MetricsEventTarget, 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"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
2
|
+
import { CameraKitSession } from "../../session/CameraKitSession";
|
|
3
|
+
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
4
|
+
import { OperationalMetricsReporter } from "../operationalMetricsReporter";
|
|
5
|
+
import { CameraKitConfiguration } from "../../configuration";
|
|
6
|
+
/**
|
|
7
|
+
* The LensView metric is emitted after a lens has been viewed (for longer than 100ms), when the lens is turned off.
|
|
8
|
+
*
|
|
9
|
+
* It contains information about rendering performance.
|
|
10
|
+
*
|
|
11
|
+
* Notes:
|
|
12
|
+
* - If the page is hidden (e.g. user switches to a different tab, or application, or closes the tab, or closes the
|
|
13
|
+
* browser, navigates to a new page, refreshes, etc.) this metric will be emitted at that time. This is to ensure
|
|
14
|
+
* we don't lose the metric if the page is closed.
|
|
15
|
+
* - If the page is hidden and then made visible again later (e.g. user switches to a different tab, then back), we
|
|
16
|
+
* will begin measuring a new LensView. That is, we will not capture the time when the page is hidden even if the
|
|
17
|
+
* lens is still rendering in the background.
|
|
18
|
+
*
|
|
19
|
+
* @category Lenses
|
|
20
|
+
* @category Metrics
|
|
21
|
+
*/
|
|
22
|
+
export declare type LensView = MakeTaggedBusinessEvent<"lensView">;
|
|
23
|
+
/**
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare const reportLensView: {
|
|
27
|
+
(args_0: CameraKitSession, args_1: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
28
|
+
lens: import("../..").Lens;
|
|
29
|
+
launchParams?: import("../..").LensLaunchParams | undefined;
|
|
30
|
+
}> | import("@snap/state-management").Action<"downloadComplete", import("../..").Lens> | import("@snap/state-management").Action<"turnedOn", import("../..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
31
|
+
error: import("../../session/lensState").LensErrors;
|
|
32
|
+
lens: import("../..").Lens;
|
|
33
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("../..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("../..").Lens> | import("@snap/state-management").State<"lensApplied", import("../..").Lens>>, args_2: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"suspend", CameraKitSession> | import("@snap/state-management").Action<"resume", CameraKitSession>, import("@snap/state-management").State<"inactive", undefined> | import("@snap/state-management").State<"active", CameraKitSession>>, args_3: MetricsEventTarget, args_4: OperationalMetricsReporter, args_5: CameraKitConfiguration): void;
|
|
34
|
+
token: "reportLensView";
|
|
35
|
+
dependencies: readonly ["CameraKitSession", "lensState", "sessionState", "metricsEventTarget", "operationalMetricsReporter", "configuration"];
|
|
36
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { combineLatestWith, filter, map, merge, mergeMap, of, raceWith, switchMap, take, takeUntil } from "rxjs";
|
|
3
|
+
import { forActions, inStates, isState } from "@snap/state-management";
|
|
4
|
+
import { Injectable } from "../../dependency-injection/Injectable";
|
|
5
|
+
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
|
+
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
7
|
+
import { cameraKitSessionFactory } from "../../session/CameraKitSession";
|
|
8
|
+
import { getTimeMs } from "../../common/time";
|
|
9
|
+
import { operationalMetricReporterFactory } from "../operationalMetricsReporter";
|
|
10
|
+
import { configurationToken } from "../../configuration";
|
|
11
|
+
import { lensStateFactory } from "../../session/lensState";
|
|
12
|
+
import { sessionStateFactory } from "../../session/sessionState";
|
|
13
|
+
// We ignore short-duration lens views.
|
|
14
|
+
//
|
|
15
|
+
// The value is documented here:
|
|
16
|
+
// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.q5liip76r9lt
|
|
17
|
+
const viewTimeThresholdSec = 0.1;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export const reportLensView = Injectable("reportLensView", [
|
|
22
|
+
cameraKitSessionFactory.token,
|
|
23
|
+
lensStateFactory.token,
|
|
24
|
+
sessionStateFactory.token,
|
|
25
|
+
metricsEventTargetFactory.token,
|
|
26
|
+
operationalMetricReporterFactory.token,
|
|
27
|
+
configurationToken,
|
|
28
|
+
], (session, lensState, sessionState, metricsEventTarget, operationalMetricsReporter, configuration) => {
|
|
29
|
+
merge(
|
|
30
|
+
// Begin measuring LensCore apply time once the lens has finished downloading and we actually add the lens
|
|
31
|
+
// to LensCore (LensWait measures the full download + LensCore apply time i.e. perceived UX latency).
|
|
32
|
+
lensState.events.pipe(forActions("downloadComplete"), map(([a]) => a.data)),
|
|
33
|
+
// If the session is resumed (e.g. user returns to this tab while a lens is on), we count this as a new
|
|
34
|
+
// LensView (and applyDelaySec will be 0).
|
|
35
|
+
lensState.events.pipe(inStates("lensApplied"), switchMap(([, s]) => sessionState.events.pipe(forActions("resume"), takeUntil(lensState.events.pipe(forActions("removeLens"))), map(() => s.data)))))
|
|
36
|
+
.pipe(map((lens) => [getTimeMs(), lens.id]), mergeMap(([applyLensStartTime, lensId]) => {
|
|
37
|
+
const alreadyOn = isState(lensState.getState(), "lensApplied");
|
|
38
|
+
const applyDelay = alreadyOn
|
|
39
|
+
? of(0)
|
|
40
|
+
: lensState.events.pipe(forActions("resourcesLoaded"), filter(([a]) => a.data.id === lensId),
|
|
41
|
+
// Applying a new lens may happen before removing the old one, so if we kept taking events
|
|
42
|
+
// we would get the lensResourcesLoaded for the next lens, too.
|
|
43
|
+
take(1), map(() => (getTimeMs() - applyLensStartTime) / 1000));
|
|
44
|
+
const viewMetrics = (alreadyOn
|
|
45
|
+
? of([getTimeMs(), session.metrics.beginMeasurement()])
|
|
46
|
+
: lensState.events.pipe(forActions("turnedOn"), filter(([a]) => a.data.id === lensId), map(() => [getTimeMs(), session.metrics.beginMeasurement()]))).pipe(take(1), mergeMap(([lensTurnedOnTime, metricsMeasurement]) => lensState.events.pipe(forActions("turnedOff"),
|
|
47
|
+
// Applying a new lens may happen before removing the old one, so we'll get a
|
|
48
|
+
// lensTurnedOff for the prior lens (if one was applied), which we must filter out.
|
|
49
|
+
filter(([a]) => a.data.id === lensId),
|
|
50
|
+
// If the session is suspended, we'll count that as the lens turning off.
|
|
51
|
+
raceWith(sessionState.events.pipe(forActions("suspend"))), map(() => {
|
|
52
|
+
metricsMeasurement.end();
|
|
53
|
+
return Object.assign({ viewTimeSec: (getTimeMs() - lensTurnedOnTime) / 1000 }, metricsMeasurement.measure());
|
|
54
|
+
}))));
|
|
55
|
+
return applyDelay.pipe(combineLatestWith(viewMetrics),
|
|
56
|
+
// This lens should always receive the lensTurnedOff action *before* the next lens is turned on.
|
|
57
|
+
// But just in case that assumption is violated, we'll clean up (and not report) if another lens
|
|
58
|
+
// turns on before our lens is turned off.
|
|
59
|
+
takeUntil(lensState.events.pipe(forActions("turnedOn"), filter(([a]) => a.data.id !== lensId))), take(1), map(([applyDelaySec, viewMetrics]) => (Object.assign({ applyDelaySec,
|
|
60
|
+
lensId }, viewMetrics))));
|
|
61
|
+
}))
|
|
62
|
+
.subscribe({
|
|
63
|
+
next: ({ applyDelaySec, lensId, viewTimeSec, avgFps, lensFrameProcessingTimeMsAvg, lensFrameProcessingTimeMsStd, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
var _a;
|
|
65
|
+
if (viewTimeSec < viewTimeThresholdSec)
|
|
66
|
+
return;
|
|
67
|
+
const { cluster: performanceCluster, webglRendererInfo, } = (_a = (yield configuration.lensPerformance)) !== null && _a !== void 0 ? _a : {
|
|
68
|
+
cluster: 0,
|
|
69
|
+
webglRendererInfo: "unknown",
|
|
70
|
+
};
|
|
71
|
+
const lensView = {
|
|
72
|
+
name: "lensView",
|
|
73
|
+
applyDelaySec,
|
|
74
|
+
avgFps,
|
|
75
|
+
lensId,
|
|
76
|
+
lensFrameProcessingTimeMsAvg,
|
|
77
|
+
lensFrameProcessingTimeMsStd,
|
|
78
|
+
// We don't support recording video, but applications may do this without our knowledge.
|
|
79
|
+
recordingTimeSec: 0,
|
|
80
|
+
viewTimeSec,
|
|
81
|
+
// TODO: if we want to support these fields, we'll need some persistence to keep track of the
|
|
82
|
+
// date of last application per lens.
|
|
83
|
+
// https://jira.sc-corp.net/browse/CAMKIT-3050
|
|
84
|
+
isLensFirstWithinDay: false,
|
|
85
|
+
isLensFirstWithinMonth: false,
|
|
86
|
+
performanceCluster,
|
|
87
|
+
webglRendererInfo,
|
|
88
|
+
};
|
|
89
|
+
metricsEventTarget.dispatchEvent(new TypedCustomEvent("lensView", lensView));
|
|
90
|
+
// Reporting operational metrics described here:
|
|
91
|
+
// https://docs.google.com/document/d/1g4PncAmKdyrLEFVp8ODp58oer2UJu9PIetRW035nnTo
|
|
92
|
+
//
|
|
93
|
+
// We ignore if applyDelaySec is 0, which will be the case if the session was suspended and then
|
|
94
|
+
// resumed - we only care about this metric when a new lens has been loaded.
|
|
95
|
+
if (applyDelaySec > 0)
|
|
96
|
+
operationalMetricsReporter.timer("lens.core_loading_latency", applyDelaySec * 1000);
|
|
97
|
+
operationalMetricsReporter.timer("lens.processing_time", lensFrameProcessingTimeMsAvg, new Map([["performance_cluster", performanceCluster.toString()]]));
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=reportLensView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportLensView.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportLensView.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,K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KAAK,CAC5B,sBAAsB,EACtB,4BAA4B,EAC5B,IAAI,GAAG,CAAC,CAAC,CAAC,qBAAqB,EAAE,kBAAkB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CACpE,CAAC;QACN,CAAC,CAAA;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { combineLatestWith, filter, 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 { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"../../session/CameraKitSession\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { getTimeMs } from \"../../common/time\";\nimport { operationalMetricReporterFactory, OperationalMetricsReporter } from \"../operationalMetricsReporter\";\nimport { CameraKitConfiguration, configurationToken } from \"../../configuration\";\nimport { lensStateFactory, LensState } from \"../../session/lensState\";\nimport { SessionState, sessionStateFactory } from \"../../session/sessionState\";\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\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 operationalMetricReporterFactory.token,\n configurationToken,\n ] as const,\n (\n session: CameraKitSession,\n lensState: LensState,\n sessionState: SessionState,\n metricsEventTarget: MetricsEventTarget,\n operationalMetricsReporter: OperationalMetricsReporter,\n configuration: CameraKitConfiguration\n ): void => {\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] => [getTimeMs(), lens.id]),\n mergeMap(([applyLensStartTime, lensId]) => {\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 = (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),\n // This lens should always receive the lensTurnedOff action *before* the next lens is turned on.\n // But just in case that assumption is violated, we'll clean up (and not report) if another lens\n // 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]) => ({\n applyDelaySec,\n lensId,\n ...viewMetrics,\n }))\n );\n })\n )\n .subscribe({\n next: async ({\n applyDelaySec,\n lensId,\n viewTimeSec,\n avgFps,\n lensFrameProcessingTimeMsAvg,\n lensFrameProcessingTimeMsStd,\n }) => {\n if (viewTimeSec < viewTimeThresholdSec) return;\n const {\n cluster: performanceCluster,\n webglRendererInfo,\n } = (await configuration.lensPerformance) ?? {\n cluster: 0,\n webglRendererInfo: \"unknown\",\n };\n const lensView: LensView = {\n name: \"lensView\",\n applyDelaySec,\n avgFps,\n lensId,\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 // TODO: if we want to support these fields, we'll need some persistence to keep track of the\n // date of last application per lens.\n // https://jira.sc-corp.net/browse/CAMKIT-3050\n isLensFirstWithinDay: false,\n isLensFirstWithinMonth: false,\n performanceCluster,\n webglRendererInfo,\n };\n\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"lensView\", lensView));\n\n // Reporting operational metrics described here:\n // https://docs.google.com/document/d/1g4PncAmKdyrLEFVp8ODp58oer2UJu9PIetRW035nnTo\n //\n // We ignore if applyDelaySec is 0, which will be the case if the session was suspended and then\n // resumed - we only care about this metric when a new lens has been loaded.\n if (applyDelaySec > 0)\n operationalMetricsReporter.timer(\"lens.core_loading_latency\", applyDelaySec * 1000);\n operationalMetricsReporter.timer(\n \"lens.processing_time\",\n lensFrameProcessingTimeMsAvg,\n new Map([[\"performance_cluster\", performanceCluster.toString()]])\n );\n },\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
2
|
+
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
3
|
+
import { OperationalMetricsReporter } from "../operationalMetricsReporter";
|
|
4
|
+
/**
|
|
5
|
+
* The LensWait metric measures the time spent downloading the lens content and required assets. It gives an indication
|
|
6
|
+
* of the real UX impact of download latency. If lens content and assets are pre-loaded, the latency measured here
|
|
7
|
+
* should decrease – we measure between the request to apply a lens and when the lens is ready to render.
|
|
8
|
+
*
|
|
9
|
+
* @category Lenses
|
|
10
|
+
* @category Metrics
|
|
11
|
+
*/
|
|
12
|
+
export declare type LensWait = MakeTaggedBusinessEvent<"lensWait">;
|
|
13
|
+
/**
|
|
14
|
+
* Each time a lens is applied, we measure the duration until the lens is fully loaded by LensCore. This
|
|
15
|
+
* includes any time spent downloading the lens content and required assets from the lens manifest.
|
|
16
|
+
*
|
|
17
|
+
* The intention of this event is to measure the experienced UX latency between a user requesting a lens and
|
|
18
|
+
* the lens rendering. Of course, the application may call `applyLens` at any time, and may hide/show the
|
|
19
|
+
* rendered result at any time – but this should give us a good baseline for how much UX latency could be seen.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const reportLensWait: {
|
|
24
|
+
(args_0: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
25
|
+
lens: import("../..").Lens;
|
|
26
|
+
launchParams?: import("../..").LensLaunchParams | undefined;
|
|
27
|
+
}> | import("@snap/state-management").Action<"downloadComplete", import("../..").Lens> | import("@snap/state-management").Action<"turnedOn", import("../..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
28
|
+
error: import("../../session/lensState").LensErrors;
|
|
29
|
+
lens: import("../..").Lens;
|
|
30
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("../..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("../..").Lens> | import("@snap/state-management").State<"lensApplied", import("../..").Lens>>, args_1: MetricsEventTarget, args_2: OperationalMetricsReporter): void;
|
|
31
|
+
token: "reportLensWait";
|
|
32
|
+
dependencies: readonly ["lensState", "metricsEventTarget", "operationalMetricsReporter"];
|
|
33
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { forActions } from "@snap/state-management";
|
|
2
|
+
import { map, mergeMap, take } from "rxjs";
|
|
3
|
+
import { getTimeMs } from "../../common/time";
|
|
4
|
+
import { Injectable } from "../../dependency-injection/Injectable";
|
|
5
|
+
import { TypedCustomEvent } from "../../events/TypedCustomEvent";
|
|
6
|
+
import { lensStateFactory } from "../../session/lensState";
|
|
7
|
+
import { metricsEventTargetFactory } from "../metricsEventTarget";
|
|
8
|
+
import { operationalMetricReporterFactory } from "../operationalMetricsReporter";
|
|
9
|
+
// We ignore short-duration lens waits.
|
|
10
|
+
//
|
|
11
|
+
// The value is documented here:
|
|
12
|
+
// https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/edit#heading=h.q5liip76r9lt
|
|
13
|
+
const viewTimeThresholdSec = 0.1;
|
|
14
|
+
/**
|
|
15
|
+
* Each time a lens is applied, we measure the duration until the lens is fully loaded by LensCore. This
|
|
16
|
+
* includes any time spent downloading the lens content and required assets from the lens manifest.
|
|
17
|
+
*
|
|
18
|
+
* The intention of this event is to measure the experienced UX latency between a user requesting a lens and
|
|
19
|
+
* the lens rendering. Of course, the application may call `applyLens` at any time, and may hide/show the
|
|
20
|
+
* rendered result at any time – but this should give us a good baseline for how much UX latency could be seen.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const reportLensWait = Injectable("reportLensWait", [lensStateFactory.token, metricsEventTargetFactory.token, operationalMetricReporterFactory.token], (lensState, metricsEventTarget, reporter) => {
|
|
25
|
+
lensState.events
|
|
26
|
+
.pipe(forActions("applyLens"), mergeMap(([a]) => {
|
|
27
|
+
const lensId = a.data.lens.id;
|
|
28
|
+
const applyLensStartTime = getTimeMs();
|
|
29
|
+
return lensState.events.pipe(
|
|
30
|
+
// We'll measure the time until either the requested lens was rendered, or a new applyLens
|
|
31
|
+
// request was made (in both cases, we're done waiting for this lens).
|
|
32
|
+
//
|
|
33
|
+
// This does have the side-effect that if a user rapidly switches between lenses, we'll record
|
|
34
|
+
// many low-duration lensWait events that are measuring user behavior instead of system latency.
|
|
35
|
+
// But this is a good trade-off so that we can capture those long-duration lensWaits that are
|
|
36
|
+
// terminated by the user trying a different lens.
|
|
37
|
+
//
|
|
38
|
+
// (This effect can be mitigated by increasing the viewtimeThresholdSec to ignore low-duration
|
|
39
|
+
// waits that are likely caused by user behavior).
|
|
40
|
+
forActions("firstFrameProcessed", "applyLens"), take(1), map(() => [(getTimeMs() - applyLensStartTime) / 1000, lensId]));
|
|
41
|
+
}))
|
|
42
|
+
.subscribe({
|
|
43
|
+
next: ([viewTimeSec, lensId]) => {
|
|
44
|
+
if (viewTimeSec < viewTimeThresholdSec)
|
|
45
|
+
return;
|
|
46
|
+
const lensWait = {
|
|
47
|
+
name: "lensWait",
|
|
48
|
+
lensId,
|
|
49
|
+
viewTimeSec,
|
|
50
|
+
};
|
|
51
|
+
metricsEventTarget.dispatchEvent(new TypedCustomEvent("lensWait", lensWait));
|
|
52
|
+
reporter.timer("lens.apply_lens_latency", viewTimeSec * 1000);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=reportLensWait.js.map
|
|
@@ -0,0 +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,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAa,MAAM,yBAAyB,CAAC;AAEtE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,gCAAgC,EAA8B,MAAM,+BAA+B,CAAC;AAE7G,uCAAuC;AACvC,EAAE;AACF,gCAAgC;AAChC,8GAA8G;AAC9G,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAcjC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CACpC,gBAAgB,EAChB,CAAC,gBAAgB,CAAC,KAAK,EAAE,yBAAyB,CAAC,KAAK,EAAE,gCAAgC,CAAC,KAAK,CAAU,EAC1G,CAAC,SAAoB,EAAE,kBAAsC,EAAE,QAAoC,EAAE,EAAE;IACnG,SAAS,CAAC,MAAM;SACX,IAAI,CACD,UAAU,CAAC,WAAW,CAAC,EACvB,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,kBAAkB,GAAG,SAAS,EAAE,CAAC;QACvC,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI;QACxB,0FAA0F;QAC1F,sEAAsE;QACtE,EAAE;QACF,8FAA8F;QAC9F,gGAAgG;QAChG,6FAA6F;QAC7F,kDAAkD;QAClD,EAAE;QACF,8FAA8F;QAC9F,kDAAkD;QAClD,UAAU,CAAC,qBAAqB,EAAE,WAAW,CAAC,EAC9C,IAAI,CAAC,CAAC,CAAC,EACP,GAAG,CAAC,GAAqB,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,kBAAkB,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CACnF,CAAC;IACN,CAAC,CAAC,CACL;SACA,SAAS,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE;YAC5B,IAAI,WAAW,GAAG,oBAAoB;gBAAE,OAAO;YAE/C,MAAM,QAAQ,GAAa;gBACvB,IAAI,EAAE,UAAU;gBAChB,MAAM;gBACN,WAAW;aACd,CAAC;YACF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC7E,QAAQ,CAAC,KAAK,CAAC,yBAAyB,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC;QAClE,CAAC;KACJ,CAAC,CAAC;AACX,CAAC,CACJ,CAAC","sourcesContent":["import { forActions } from \"@snap/state-management\";\nimport { map, mergeMap, take } from \"rxjs\";\nimport { getTimeMs } from \"../../common/time\";\nimport { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { lensStateFactory, LensState } from \"../../session/lensState\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\nimport { operationalMetricReporterFactory, OperationalMetricsReporter } from \"../operationalMetricsReporter\";\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, operationalMetricReporterFactory.token] as const,\n (lensState: LensState, metricsEventTarget: MetricsEventTarget, reporter: OperationalMetricsReporter) => {\n lensState.events\n .pipe(\n forActions(\"applyLens\"),\n mergeMap(([a]) => {\n const lensId = a.data.lens.id;\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] => [(getTimeMs() - applyLensStartTime) / 1000, lensId])\n );\n })\n )\n .subscribe({\n next: ([viewTimeSec, lensId]) => {\n if (viewTimeSec < viewTimeThresholdSec) return;\n\n const lensWait: LensWait = {\n name: \"lensWait\",\n lensId,\n viewTimeSec,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"lensWait\", lensWait));\n reporter.timer(\"lens.apply_lens_latency\", viewTimeSec * 1000);\n },\n });\n }\n);\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GlobalExceptionReporter } from "./reportGlobalException";
|
|
2
|
+
/**
|
|
3
|
+
* Reports log entries to Blizzard during a CameraKit session.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const reportSessionException: {
|
|
8
|
+
(args_0: GlobalExceptionReporter, args_1: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
|
|
9
|
+
lens: import("../..").Lens;
|
|
10
|
+
launchParams?: import("../..").LensLaunchParams | undefined;
|
|
11
|
+
}> | import("@snap/state-management").Action<"downloadComplete", import("../..").Lens> | import("@snap/state-management").Action<"turnedOn", import("../..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
|
|
12
|
+
error: import("../../session/lensState").LensErrors;
|
|
13
|
+
lens: import("../..").Lens;
|
|
14
|
+
}> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("../..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("../..").Lens> | import("@snap/state-management").State<"lensApplied", import("../..").Lens>>): void;
|
|
15
|
+
token: "reportSessionException";
|
|
16
|
+
dependencies: readonly ["reportGlobalException", "lensState"];
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Injectable } from "../../dependency-injection/Injectable";
|
|
2
|
+
import { lensStateFactory } from "../../session/lensState";
|
|
3
|
+
import { reportGlobalException } from "./reportGlobalException";
|
|
4
|
+
/**
|
|
5
|
+
* Reports log entries to Blizzard during a CameraKit session.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const reportSessionException = Injectable("reportSessionException", [reportGlobalException.token, lensStateFactory.token], (globalExceptionReporter, lensState) => {
|
|
10
|
+
globalExceptionReporter.attachLensContext(lensState);
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=reportSessionException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportSessionException.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportSessionException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAa,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAA2B,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEzF;;;;GAIG;AACH,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 \"../../dependency-injection/Injectable\";\nimport { LensState, lensStateFactory } from \"../../session/lensState\";\nimport { GlobalExceptionReporter, 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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MakeTaggedBusinessEvent } from "../businessEventsReporter";
|
|
2
|
+
import { MetricsEventTarget } from "../metricsEventTarget";
|
|
3
|
+
/**
|
|
4
|
+
* The Session metric reports each user session.
|
|
5
|
+
*/
|
|
6
|
+
export declare type Session = MakeTaggedBusinessEvent<"session">;
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const reportUserSession: {
|
|
11
|
+
(args_0: MetricsEventTarget): Promise<void>;
|
|
12
|
+
token: "reportUserSession";
|
|
13
|
+
dependencies: readonly ["metricsEventTarget"];
|
|
14
|
+
};
|