diff --git a/.gitignore b/.gitignore index a66e527db059..dac793bdcec3 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,5 @@ temp # VSCode addon .favorites.json + +.env diff --git a/locales/index.d.ts b/locales/index.d.ts index 33af9f43d10b..ea165b077171 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1187,6 +1187,8 @@ export interface Locale { "showOldMuteWords": string; "showMutedInfo": string; "showMutedInfoDescription": string; + "optoutStatistics": string; + "optoutStatisticsDescription": string; "_announcement": { "forExistingUsers": string; "forExistingUsersDescription": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 7b622b731cb3..399fc468bebe 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1184,6 +1184,8 @@ tosAndPrivacyPolicy: "利用規約・プライバシーポリシー" showOldMuteWords: "ソフトワードミュートに設定していた情報を表示する" showMutedInfo: "「○○が何か言いました」を表示する" showMutedInfoDescription: "オンにすると以前のソフトミュートと同様の挙動になります。オフで以前のハードミュートの挙動になります。" +optoutStatistics: "エラー情報の送信をやめる" +optoutStatisticsDescription: "{instance}では、不具合の原因の特定を行えるよう、問題が発生したときにエラーの詳細情報を取得しています。ONにすることで、エラー情報の送信をしないようにします。" _announcement: forExistingUsers: "既存ユーザーのみ" diff --git a/package.json b/package.json index 10b2630542a5..70e743760992 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "2023.10.1-kakurega.1.20.1", + "version": "2023.10.1-kakurega.1.20.2", "codename": "nasubi", "repository": { "type": "git", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 39ac39993408..0324b52e033f 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -117,6 +117,7 @@ "acorn": "8.10.0", "cross-env": "7.0.3", "cypress": "13.3.0", + "dotenv": "^16.3.1", "eslint": "8.51.0", "eslint-plugin-import": "2.28.1", "eslint-plugin-vue": "9.17.0", @@ -133,6 +134,7 @@ "storybook": "7.4.6", "storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme", "summaly": "github:misskey-dev/summaly", + "vite-plugin-sentry": "^1.3.0", "vite-plugin-turbosnap": "1.0.3", "vitest": "0.34.6", "vitest-fetch-mock": "0.2.2", diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index e5fcdf6ffb87..f5aba8625fdb 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -254,10 +254,12 @@ export async function common(createVue: () => App) { const app = createVue(); - if (!_DEV_) { + const uri = new URL(location.href); + if (!_DEV_ && uri.hostname === 'misskey.yukineko.me' && !defaultStore.state.optoutStatistics) { Sentry.init({ app, dsn: 'https://4787e38fa976cc8ffc3b9348fb96a2e1@sentry.yukineko.dev/2', + release: version, }); } diff --git a/packages/frontend/src/pages/settings/other.vue b/packages/frontend/src/pages/settings/other.vue index e2fc0210996d..427b74877caa 100644 --- a/packages/frontend/src/pages/settings/other.vue +++ b/packages/frontend/src/pages/settings/other.vue @@ -11,9 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only --> - + {{ i18n.ts.optoutStatistics }}
@@ -88,11 +86,13 @@ import * as os from '@/os.js'; import { defaultStore } from '@/store.js'; import { signout, $i } from '@/account.js'; import { i18n } from '@/i18n.js'; +import { instance } from '@/instance.js'; +import { host } from '@/config.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { unisonReload } from '@/scripts/unison-reload.js'; import FormSection from '@/components/form/section.vue'; -const reportError = computed(defaultStore.makeGetterSetter('reportError')); +const reportError = computed(defaultStore.makeGetterSetter('optoutStatistics')); const enableCondensedLineForAcct = computed(defaultStore.makeGetterSetter('enableCondensedLineForAcct')); const devMode = computed(defaultStore.makeGetterSetter('devMode')); diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index 7e07e502eb24..c06cd38de7a6 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -396,6 +396,10 @@ export const defaultStore = markRaw(new Storage('base', { where: 'device', default: false, }, + optoutStatistics: { + where: 'account', + default: false, + }, })); // TODO: 他のタブと永続化されたstateを同期 diff --git a/packages/frontend/vite.config.ts b/packages/frontend/vite.config.ts index da976b791717..fac8091a8bad 100644 --- a/packages/frontend/vite.config.ts +++ b/packages/frontend/vite.config.ts @@ -4,12 +4,16 @@ import pluginVue from '@vitejs/plugin-vue'; import { type UserConfig, defineConfig } from 'vite'; // @ts-expect-error https://github.com/sxzz/unplugin-vue-macros/issues/257#issuecomment-1410752890 import ReactivityTransform from '@vue-macros/reactivity-transform/vite'; +import viteSentry from 'vite-plugin-sentry'; +import dotenv from 'dotenv'; import locales from '../../locales'; import meta from '../../package.json'; import pluginUnwindCssModuleClassName from './lib/rollup-plugin-unwind-css-module-class-name'; import pluginJson5 from './vite.json5'; +dotenv.config(); + const extensions = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.json', '.json5', '.svg', '.sass', '.scss', '.css', '.vue']; const hash = (str: string, seed = 0): number => { @@ -58,6 +62,17 @@ export function getConfig(): UserConfig { pluginJson5(), ...process.env.NODE_ENV === 'production' ? [ + process.env.SENTRY_AUTH_TOKEN ? viteSentry({ + url: 'https://sentry.yukineko.dev', + org: 'sentry', + project: 'misskey-kakurega', + authToken: process.env.SENTRY_AUTH_TOKEN, + release: meta.version, + sourceMaps: { + urlPrefix: '~/vite', + include: ['../../built/_vite_'], + }, + }) : null, pluginReplace({ preventAssignment: true, values: { @@ -134,7 +149,7 @@ export function getConfig(): UserConfig { outDir: __dirname + '/../../built/_vite_', assetsDir: '.', emptyOutDir: false, - sourcemap: process.env.NODE_ENV === 'development', + sourcemap: true, reportCompressedSize: false, // https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3eed2b7eb2e5..59bef273d6a1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -938,6 +938,9 @@ importers: cypress: specifier: 13.3.0 version: 13.3.0 + dotenv: + specifier: ^16.3.1 + version: 16.3.1 eslint: specifier: 8.51.0 version: 8.51.0 @@ -986,6 +989,9 @@ importers: summaly: specifier: github:misskey-dev/summaly version: github.com/misskey-dev/summaly/d2d8db49943ccb201c1b1b283e9d0a630519fac7 + vite-plugin-sentry: + specifier: ^1.3.0 + version: 1.3.0(vite@4.4.11) vite-plugin-turbosnap: specifier: 1.0.3 version: 1.0.3 @@ -5386,6 +5392,22 @@ packages: tslib: 2.6.2 dev: false + /@sentry/cli@2.21.2: + resolution: {integrity: sha512-X1nye89zl+QV3FSuQDGItfM51tW9PQ7ce0TtV/12DgGgTVEgnVp5uvO3wX5XauHvulQzRPzwUL3ZK+yS5bAwCw==} + engines: {node: '>= 10'} + hasBin: true + requiresBuild: true + dependencies: + https-proxy-agent: 5.0.1 + node-fetch: 2.7.0 + progress: 2.0.3 + proxy-from-env: 1.1.0 + which: 2.0.2 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /@sentry/core@7.74.0: resolution: {integrity: sha512-83NRuqn7nDZkSVBN5yJQqcpXDG4yMYiB7TkYUKrGTzBpRy6KUOrkCdybuKk0oraTIGiGSe5WEwCFySiNgR9FzA==} engines: {node: '>=8'} @@ -10769,6 +10791,12 @@ packages: /dotenv@16.0.3: resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} engines: {node: '>=12'} + dev: false + + /dotenv@16.3.1: + resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} + engines: {node: '>=12'} + dev: true /duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} @@ -14097,7 +14125,7 @@ packages: engines: {node: '>=14.0.0'} dependencies: app-root-dir: 1.0.2 - dotenv: 16.0.3 + dotenv: 16.3.1 dotenv-expand: 10.0.0 dev: true @@ -16367,6 +16395,10 @@ packages: resolution: {integrity: sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A==} dev: true + /proxy-from-env@1.1.0: + resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + dev: true + /ps-tree@1.2.0: resolution: {integrity: sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==} engines: {node: '>= 0.10'} @@ -19118,6 +19150,19 @@ packages: - terser dev: true + /vite-plugin-sentry@1.3.0(vite@4.4.11): + resolution: {integrity: sha512-cei2ocb0l9hOuij8//DPMFl2Fcl0gVOBWGbqZ7F3aNLHUFkZvGm+B+aTWPX9CDpwW0uLcqqoo8O9rckFF0PGLA==} + engines: {node: '>= 14'} + peerDependencies: + vite: ^2.6.0 || ^3.0.0 || ^4.0.0 + dependencies: + '@sentry/cli': 2.21.2 + vite: 4.4.11(@types/node@20.8.4)(sass@1.69.1)(terser@5.21.0) + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /vite-plugin-turbosnap@1.0.3: resolution: {integrity: sha512-p4D8CFVhZS412SyQX125qxyzOgIFouwOcvjZWk6bQbNPR1wtaEzFT6jZxAjf1dejlGqa6fqHcuCvQea6EWUkUA==} dev: true