From eb7a791acb38727c8776bb96b912aab646ced12e Mon Sep 17 00:00:00 2001 From: GalvinGao Date: Sun, 8 May 2022 23:43:00 +0800 Subject: [PATCH] feat: add metadata reporting --- src/utils/recognizer.js | 19 +++++++++++++------ src/views/Report/RecognitionReport.vue | 8 ++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/utils/recognizer.js b/src/utils/recognizer.js index c4e4f119..17d900ae 100644 --- a/src/utils/recognizer.js +++ b/src/utils/recognizer.js @@ -14,8 +14,8 @@ import config from '@/config' import * as Sentry from "@sentry/vue"; -const recognizerVersion = 'v4.2.2' -const recognizerAssetVersion = 'v4-shared' +const recognizerFirstAPICompatibleVersionFolder = 'v4.2.2' +const recognizerAssetsVersion = 'v4-shared' // async function image2wasmHeapOffset (blob) { // const Module = window.Module @@ -58,7 +58,7 @@ class Recognizer { Console.info('Recognizer', 'init: recognition backend: both js and wasm are already loaded') } else { const script = document.createElement('script') - script.src = mirror.deliver(`/recognition/${recognizerVersion}/penguin-recognizer.js`) + script.src = mirror.deliver(`/recognition/${recognizerFirstAPICompatibleVersionFolder}/penguin-recognizer.js`) // script.src = "/penguin-recognizer.js" document.body.appendChild(script) await new Promise(resolve => { @@ -135,7 +135,7 @@ class Recognizer { Console.info('Recognizer', 'init: preload icons: preloading') await fetch( - mirror.deliver(`/recognition/${recognizerAssetVersion}/items.zip`) + mirror.deliver(`/recognition/${recognizerAssetsVersion}/items.zip`) ) // await fetch("/items.zip") .then((response) => { @@ -310,12 +310,19 @@ class Recognizer { } getVersion() { + return { + recognizerVersion: this.wasm.version, + recognizerAssetsVersion: recognizerAssetsVersion, + }; + } + + getVersionDescription() { return ( `recognizer::{state::${ this.wasm.envCheck() ? "initialized" : "env_check_not_passed" - } / core::v${this.wasm.version} / opencv::v${ + } / core::${this.wasm.version} / opencv::v${ this.wasm.opencvVersion - } / assets::${recognizerAssetVersion}}` || "unknown" + } / assets::${recognizerAssetsVersion}}` || "unknown" ); } } diff --git a/src/views/Report/RecognitionReport.vue b/src/views/Report/RecognitionReport.vue index 8e1cf43c..c5cc43eb 100644 --- a/src/views/Report/RecognitionReport.vue +++ b/src/views/Report/RecognitionReport.vue @@ -785,7 +785,11 @@ export default { this.submission.total = this.selectedResults.length; try { - await recognitionSubmitter(this, (state, chunk) => { + const version = this.recognizer.getVersion() + await recognitionSubmitter(this, { + recognizerVersion: version.recognizerVersion, + recognizerAssetsVersion: version.recognizerAssetsVersion + }, (state, chunk) => { if (state === "resolve") { this.submission.submitted.push(chunk); this.$ga.event( @@ -831,7 +835,7 @@ export default { .initialize(this.$store.getters["dataSource/server"]) .then(() => { this.recognition.state = "initialized"; - this.recognizerVersion = this.recognizer.getVersion() + this.recognizerVersion = this.recognizer.getVersionDescription() span.setStatus("ok"); }) .catch((err) => {