Skip to content

Commit

Permalink
feat: add metadata reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed May 8, 2022
1 parent eb151b1 commit eb7a791
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
19 changes: 13 additions & 6 deletions src/utils/recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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"
);
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/views/Report/RecognitionReport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) => {
Expand Down

1 comment on commit eb7a791

@vercel
Copy link

@vercel vercel bot commented on eb7a791 May 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

frontend-v2 – ./

frontend-v2-git-dev-penguin-statistics.vercel.app
frontend-v2-penguin-statistics.vercel.app

Please sign in to comment.