From 0b8f52e8ef2763ecbda6c251d608d7d756b62e5c Mon Sep 17 00:00:00 2001 From: Zxilly Date: Tue, 4 Jun 2024 14:07:32 +0800 Subject: [PATCH] feat: enable telemetry --- .github/workflows/build-explorer.yml | 1 + ui/src/tool/wasm_exec.js | 2 +- ui/vite.config-explorer.ts | 18 +++++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-explorer.yml b/.github/workflows/build-explorer.yml index 2ac95401f8..8a6dd9cbba 100644 --- a/.github/workflows/build-explorer.yml +++ b/.github/workflows/build-explorer.yml @@ -88,6 +88,7 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} PULL_REQUEST_COMMIT_SHA: ${{ github.event.pull_request.head.sha }} + GSA_TELEMETRY: true - name: Upload pages artifact uses: actions/upload-pages-artifact@v3 diff --git a/ui/src/tool/wasm_exec.js b/ui/src/tool/wasm_exec.js index cbe79da6ce..ca6f05d239 100644 --- a/ui/src/tool/wasm_exec.js +++ b/ui/src/tool/wasm_exec.js @@ -89,7 +89,7 @@ throw new Error("globalThis.TextDecoder is not available, polyfill required"); } - const encoder = new TextEncoder("utf-8"); + const encoder = new TextEncoder(); const decoder = new TextDecoder("utf-8"); globalThis.Go = class { diff --git a/ui/vite.config-explorer.ts b/ui/vite.config-explorer.ts index ab9af28c35..11ed1b812d 100644 --- a/ui/vite.config-explorer.ts +++ b/ui/vite.config-explorer.ts @@ -2,17 +2,25 @@ import {defineConfig} from 'vite'; import {build, codecov, commonPlugin, getVersionTag} from "./common"; import {createHtmlPlugin} from "vite-plugin-html"; +const tags = [getVersionTag()]; +if (process.env.GSA_TELEMETRY) { + tags.push({ + tag: "script", + attrs: { + defer: true, + src: "https://trail.learningman.top/script.js", + "data-website-id": "1aab8912-b4b0-4561-a683-81a730bdb944", + } + }) +} + export default defineConfig({ plugins: [ ...commonPlugin(), createHtmlPlugin({ minify: true, entry: './src/explorer_main.tsx', - inject: { - tags: [ - getVersionTag(), - ] - } + inject: {tags} }), codecov("gsa-explorer") ],