refactor(stage-*): analytics and telemetry, including consent (#1414)
--------- Co-authored-by-agent: Codex <267193182+codex@users.noreply.github.com> Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: RainbowBird <rbxin2003@outlook.com> Co-authored-by: Neko <neko@ayaka.moe>
This commit is contained in:
co-authored by
autofix-ci[bot]
RainbowBird
Neko
parent
8baaff7778
commit
f85a809d7c
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { OnboardingDialog, ToasterRoot } from '@proj-airi/stage-ui/components'
|
||||
import { useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { OnboardingDialog, OnboardingStepAnalyticsNotice, ToasterRoot } from '@proj-airi/stage-ui/components'
|
||||
import { isPosthogAvailableInBuild, useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { useCharacterOrchestratorStore } from '@proj-airi/stage-ui/stores/character'
|
||||
import { useDisplayModelsStore } from '@proj-airi/stage-ui/stores/display-models'
|
||||
import { useModsServerChannelStore } from '@proj-airi/stage-ui/stores/mods/api/channel-server'
|
||||
@@ -96,6 +96,11 @@ function handleSetupSkipped() {
|
||||
}
|
||||
|
||||
const extraSteps = computed(() => [
|
||||
...(
|
||||
isPosthogAvailableInBuild()
|
||||
? [{ id: 'analytics-notice', component: OnboardingStepAnalyticsNotice }]
|
||||
: []
|
||||
),
|
||||
{
|
||||
id: 'step-permissions',
|
||||
component: OnboardingPermissionsStep,
|
||||
|
||||
@@ -17,7 +17,6 @@ import App from './App.vue'
|
||||
|
||||
import { i18n } from './modules/i18n'
|
||||
|
||||
import './modules/posthog'
|
||||
import '@proj-airi/font-cjkfonts-allseto/index.css'
|
||||
import '@proj-airi/font-xiaolai/index.css'
|
||||
import '@unocss/reset/tailwind.css'
|
||||
|
||||
@@ -2,6 +2,7 @@ import messages from '@proj-airi/i18n/locales'
|
||||
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
// TODO: Align this bootstrap locale normalization with `@proj-airi/i18n`.
|
||||
const languageRemap: Record<string, string> = {
|
||||
'zh-CN': 'zh-Hans',
|
||||
'zh-TW': 'zh-Hant',
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import posthog from 'posthog-js'
|
||||
|
||||
import { DEFAULT_POSTHOG_CONFIG, POSTHOG_PROJECT_KEY_POCKET } from '../../../../posthog.config'
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
posthog.init(POSTHOG_PROJECT_KEY_POCKET, {
|
||||
...DEFAULT_POSTHOG_CONFIG,
|
||||
})
|
||||
}
|
||||
@@ -15,9 +15,6 @@ import App from './App.vue'
|
||||
|
||||
import { i18n } from './modules/i18n'
|
||||
|
||||
import './modules/posthog'
|
||||
|
||||
// eslint-disable-next-line perfectionist/sort-imports
|
||||
import '@unocss/reset/tailwind.css'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import 'vue-sonner/style.css'
|
||||
|
||||
@@ -2,6 +2,7 @@ import messages from '@proj-airi/i18n/locales'
|
||||
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
// TODO: Align this bootstrap locale normalization with `@proj-airi/i18n`.
|
||||
const languageRemap: Record<string, string> = {
|
||||
'zh-CN': 'zh-Hans',
|
||||
'zh-TW': 'zh-Hans', // TODO: remove this when zh-Hant is supported
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import posthog from 'posthog-js'
|
||||
|
||||
import { DEFAULT_POSTHOG_CONFIG, POSTHOG_PROJECT_KEY_DESKTOP } from '../../../../../posthog.config'
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
posthog.init(POSTHOG_PROJECT_KEY_DESKTOP, {
|
||||
...DEFAULT_POSTHOG_CONFIG,
|
||||
})
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useElectronAutoUpdater } from '@proj-airi/electron-vueuse'
|
||||
import { AboutContent, MarkdownRenderer } from '@proj-airi/stage-ui/components'
|
||||
import { useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics/index'
|
||||
import { useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { Button, DoubleCheckButton, Progress } from '@proj-airi/ui'
|
||||
import { useMediaQuery } from '@vueuse/core'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { useElectronEventaInvoke } from '@proj-airi/electron-vueuse'
|
||||
import { OnboardingScreen } from '@proj-airi/stage-ui/components'
|
||||
import { OnboardingScreen, OnboardingStepAnalyticsNotice } from '@proj-airi/stage-ui/components'
|
||||
import { isPosthogAvailableInBuild } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { useOnboardingStore } from '@proj-airi/stage-ui/stores/onboarding'
|
||||
import { useTheme } from '@proj-airi/ui'
|
||||
import { computed } from 'vue'
|
||||
@@ -11,6 +12,11 @@ const onboardingStore = useOnboardingStore()
|
||||
const { isDark } = useTheme()
|
||||
|
||||
const bgClass = computed(() => isDark.value ? 'bg-[#0f0f0f]' : 'bg-white')
|
||||
const extraSteps = computed(() => {
|
||||
return isPosthogAvailableInBuild()
|
||||
? [{ id: 'analytics-notice', component: OnboardingStepAnalyticsNotice }]
|
||||
: []
|
||||
})
|
||||
|
||||
const closeWindow = useElectronEventaInvoke(electronOnboardingClose)
|
||||
|
||||
@@ -30,7 +36,7 @@ async function handleConfigured() {
|
||||
<div :class="bgClass" w="100dvw" min-h="12" w-full flex-shrink-0 select-none data-tauri-drag-region />
|
||||
<div class="onboarding-scroll" w-full flex-1 px-3>
|
||||
<div class="onboarding-content" h-full>
|
||||
<OnboardingScreen @skipped="handleSkipped" @configured="handleConfigured" />
|
||||
<OnboardingScreen :extra-steps="extraSteps" @skipped="handleSkipped" @configured="handleConfigured" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,9 @@ FROM node:24-trixie AS build-stage
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG VITE_ENABLE_POSTHOG=false
|
||||
ENV VITE_ENABLE_POSTHOG=${VITE_ENABLE_POSTHOG}
|
||||
|
||||
RUN apt update && apt install -y ca-certificates curl
|
||||
RUN update-ca-certificates
|
||||
RUN apt update && apt install -y build-essential python3 python3-setuptools curl
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { OnboardingDialog, ToasterRoot } from '@proj-airi/stage-ui/components'
|
||||
import { useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { OnboardingDialog, OnboardingStepAnalyticsNotice, ToasterRoot } from '@proj-airi/stage-ui/components'
|
||||
import { isPosthogAvailableInBuild, useSharedAnalyticsStore } from '@proj-airi/stage-ui/stores/analytics'
|
||||
import { useCharacterOrchestratorStore } from '@proj-airi/stage-ui/stores/character'
|
||||
import { useChatSessionStore } from '@proj-airi/stage-ui/stores/chat/session-store'
|
||||
import { useDisplayModelsStore } from '@proj-airi/stage-ui/stores/display-models'
|
||||
@@ -59,6 +59,12 @@ const colors = computed(() => {
|
||||
return [primaryColor.value, secondaryColor.value, tertiaryColor.value, isDark.value ? '#121212' : '#FFFFFF']
|
||||
})
|
||||
|
||||
const onboardingExtraSteps = computed(() => {
|
||||
return isPosthogAvailableInBuild()
|
||||
? [{ id: 'analytics-notice', component: OnboardingStepAnalyticsNotice }]
|
||||
: []
|
||||
})
|
||||
|
||||
watch(settings.language, () => {
|
||||
i18n.locale.value = settings.language.value
|
||||
})
|
||||
@@ -125,6 +131,7 @@ function handleSetupSkipped() {
|
||||
<!-- First Time Setup Dialog -->
|
||||
<OnboardingDialog
|
||||
v-model="showingSetup"
|
||||
:extra-steps="onboardingExtraSteps"
|
||||
@configured="handleSetupConfigured"
|
||||
@skipped="handleSetupSkipped"
|
||||
/>
|
||||
|
||||
@@ -17,7 +17,6 @@ import App from './App.vue'
|
||||
|
||||
import { i18n } from './modules/i18n'
|
||||
|
||||
import './modules/posthog'
|
||||
import '@proj-airi/font-cjkfonts-allseto/index.css'
|
||||
import '@proj-airi/font-xiaolai/index.css'
|
||||
import '@unocss/reset/tailwind.css'
|
||||
|
||||
@@ -1,28 +1,8 @@
|
||||
import messages from '@proj-airi/i18n/locales'
|
||||
|
||||
import { resolveSupportedLocale } from '@proj-airi/i18n'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
const languageRemap: Record<string, string> = {
|
||||
'zh-CN': 'zh-Hans',
|
||||
'zh-TW': 'zh-Hant',
|
||||
'zh-HK': 'zh-Hans', // TODO: remove this when zh-Hant is supported
|
||||
'zh-Hant': 'zh-Hans', // TODO: remove this when zh-Hant is supported
|
||||
'en-US': 'en',
|
||||
'en-GB': 'en',
|
||||
'en-AU': 'en',
|
||||
'en': 'en',
|
||||
'es-ES': 'es',
|
||||
'es-MX': 'es',
|
||||
'es-AR': 'es',
|
||||
'es': 'es',
|
||||
'vi': 'vi',
|
||||
'vi-VN': 'vi',
|
||||
'ru': 'ru',
|
||||
'ru-RU': 'ru',
|
||||
'fr': 'fr',
|
||||
'fr-FR': 'fr',
|
||||
}
|
||||
|
||||
function getLocale() {
|
||||
let language = localStorage.getItem('settings/language')
|
||||
|
||||
@@ -31,14 +11,7 @@ function getLocale() {
|
||||
language = navigator.language || 'en'
|
||||
}
|
||||
|
||||
const languages = Object.keys(messages!)
|
||||
if (languageRemap[language || 'en'] != null) {
|
||||
language = languageRemap[language || 'en']
|
||||
}
|
||||
if (language && languages.includes(language))
|
||||
return language
|
||||
|
||||
return 'en'
|
||||
return resolveSupportedLocale(language, Object.keys(messages!))
|
||||
}
|
||||
|
||||
export const i18n = createI18n({
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import posthog from 'posthog-js'
|
||||
|
||||
import { DEFAULT_POSTHOG_CONFIG, POSTHOG_PROJECT_KEY_WEB } from '../../../../posthog.config'
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
posthog.init(POSTHOG_PROJECT_KEY_WEB, {
|
||||
...DEFAULT_POSTHOG_CONFIG,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user