From e0cd0198691b670903d33b0d297debabd9efbb6d Mon Sep 17 00:00:00 2001 From: "Michael H." Date: Thu, 27 Aug 2026 13:39:02 +0200 Subject: [PATCH] chore: get rid of debug logs on prod --- .../src/components/ui/create/ProjectCreateModal.vue | 4 +++- .../withdraw-stages/TremendousDetailsStage.vue | 2 +- .../ui/moderation/checklist/ModerationChecklist.vue | 6 +++--- apps/frontend/src/components/ui/servers/Globe.vue | 5 ++++- apps/frontend/src/pages/hosting/index.vue | 4 +++- .../frontend/src/pages/moderation/reports/index.vue | 4 +++- apps/frontend/src/pages/settings/billing/index.vue | 13 ++++++------- packages/ui/src/components/base/Avatar.vue | 5 +++-- .../ui/src/components/billing/AddPaymentMethod.vue | 5 ++++- .../billing/ModrinthServersPurchaseModal.vue | 4 +++- .../ui/src/components/billing/PurchaseModal.vue | 4 +++- packages/ui/src/components/chart/Chart.vue | 3 +-- packages/ui/src/components/chart/CompactChart.vue | 3 +-- packages/ui/src/components/modal/ShareModal.vue | 7 +++++-- packages/ui/src/components/skin/CapeButton.vue | 2 -- packages/ui/src/composables/debug-logger.ts | 4 ++++ .../skin-rendering/use-skin-preview-animation.ts | 7 +++++-- .../skin-rendering/use-skin-preview-fit.ts | 5 ++++- packages/ui/src/composables/stripe.ts | 11 +++++++---- .../ui/src/layouts/wrapped/hosting/manage/root.vue | 4 ++-- 20 files changed, 65 insertions(+), 37 deletions(-) diff --git a/apps/frontend/src/components/ui/create/ProjectCreateModal.vue b/apps/frontend/src/components/ui/create/ProjectCreateModal.vue index 42878864bb..fafd656cdb 100644 --- a/apps/frontend/src/components/ui/create/ProjectCreateModal.vue +++ b/apps/frontend/src/components/ui/create/ProjectCreateModal.vue @@ -143,6 +143,7 @@ import { Input, NewModal, Textarea, + useDebugLogger, useVIntl, } from '@modrinth/ui' import { computed, defineAsyncComponent, h } from 'vue' @@ -163,6 +164,7 @@ interface ShowOptions { const { addNotification } = injectNotificationManager() const { formatMessage } = useVIntl() const router = useRouter() +const debug = useDebugLogger('ProjectCreateModal') defineExpose({ show, @@ -453,7 +455,7 @@ async function createProject() { }, })) as Labrinth.Projects.v3.Project createdProjectId = result.id - console.log(createdProjectId) + debug(createdProjectId) } modal.value?.hide() diff --git a/apps/frontend/src/components/ui/dashboard/withdraw-stages/TremendousDetailsStage.vue b/apps/frontend/src/components/ui/dashboard/withdraw-stages/TremendousDetailsStage.vue index d5d5c5e1ee..58f906c3b9 100644 --- a/apps/frontend/src/components/ui/dashboard/withdraw-stages/TremendousDetailsStage.vue +++ b/apps/frontend/src/components/ui/dashboard/withdraw-stages/TremendousDetailsStage.vue @@ -516,7 +516,7 @@ const selectedRewardOption = computed(() => { }) const selectedMethodDetails = computed(() => { - console.log(rewardOptions.value, selectedGiftCardId.value) + debug(rewardOptions.value, selectedGiftCardId.value) if (!selectedGiftCardId.value) return null const option = rewardOptions.value.find((opt) => opt.value === selectedGiftCardId.value) debug('Selected method details:', option?.methodDetails) diff --git a/apps/frontend/src/components/ui/moderation/checklist/ModerationChecklist.vue b/apps/frontend/src/components/ui/moderation/checklist/ModerationChecklist.vue index e489941202..85024ddaaa 100644 --- a/apps/frontend/src/components/ui/moderation/checklist/ModerationChecklist.vue +++ b/apps/frontend/src/components/ui/moderation/checklist/ModerationChecklist.vue @@ -1105,7 +1105,7 @@ if (!persistedState) { if (thread.value === undefined) return if (currentStage.value === initialAutoStage) { const firstValid = findFirstValidStage() - console.log('[DEBUG settle]', { + debug('settle', { initialAutoStage, currentStage: currentStage.value, firstValid, @@ -1118,7 +1118,7 @@ if (!persistedState) { markStageVisited(currentStageObj.value.id) } } else { - console.log('[DEBUG settle] currentStage already changed before settle', { + debug('settle: currentStage already changed before settle', { initialAutoStage, currentStage: currentStage.value, }) @@ -1143,7 +1143,7 @@ const projectUrlType = computed(() => let lastSyncedStageTarget: string | null = null function syncStageUrl(stage: StageNode | undefined) { const navigate = stage?._navigate - console.log('[DEBUG syncStageUrl]', { stageId: stage?.id, navigate, lastSyncedStageTarget }) + debug('syncStageUrl', { stageId: stage?.id, navigate, lastSyncedStageTarget }) if (navigate === undefined) return const target = `/${projectUrlType.value}/${projectV2.value.slug}${navigate}` if (target === lastSyncedStageTarget) return diff --git a/apps/frontend/src/components/ui/servers/Globe.vue b/apps/frontend/src/components/ui/servers/Globe.vue index 969cf9e914..1925c1e64b 100644 --- a/apps/frontend/src/components/ui/servers/Globe.vue +++ b/apps/frontend/src/components/ui/servers/Globe.vue @@ -42,10 +42,13 @@ diff --git a/packages/ui/src/composables/debug-logger.ts b/packages/ui/src/composables/debug-logger.ts index 776e879400..944b9d415b 100644 --- a/packages/ui/src/composables/debug-logger.ts +++ b/packages/ui/src/composables/debug-logger.ts @@ -18,7 +18,11 @@ function getCallerLocation(): string { } } +const noop = () => {} + export function useDebugLogger(namespace: string) { + if (process.env.NODE_ENV === 'production') return noop + // eslint-disable-next-line return (...args: any[]) => { const location = getCallerLocation() diff --git a/packages/ui/src/composables/skin-rendering/use-skin-preview-animation.ts b/packages/ui/src/composables/skin-rendering/use-skin-preview-animation.ts index 981f15c747..01d87f3a88 100644 --- a/packages/ui/src/composables/skin-rendering/use-skin-preview-animation.ts +++ b/packages/ui/src/composables/skin-rendering/use-skin-preview-animation.ts @@ -2,8 +2,11 @@ import { useRenderLoop } from '@tresjs/core' import * as THREE from 'three' import { computed, type ComputedRef, type Ref, ref, watch } from 'vue' +import { useDebugLogger } from '../debug-logger' import type { SkinPreviewAnimationConfig } from './types' +const debug = useDebugLogger('SkinPreviewAnimation') + type AnimationFinishedListener = ( event: THREE.AnimationMixerEventMap['finished'] & { readonly type: 'finished' @@ -103,7 +106,7 @@ export function useSkinPreviewAnimation( const action = actions.value[name] if (currentAnimation.value === name && action.isRunning() && name !== baseAnimation.value) { - console.log(`Animation "${name}" is already running, ignoring request`) + debug(`Animation "${name}" is already running, ignoring request`) return false } @@ -196,7 +199,7 @@ export function useSkinPreviewAnimation( const action = actions.value[name] if (currentAnimation.value === name && action.isRunning()) { - console.log(`Animation "${name}" is already running, ignoring request`) + debug(`Animation "${name}" is already running, ignoring request`) return } diff --git a/packages/ui/src/composables/skin-rendering/use-skin-preview-fit.ts b/packages/ui/src/composables/skin-rendering/use-skin-preview-fit.ts index 7eaa9b3150..58a38421bf 100644 --- a/packages/ui/src/composables/skin-rendering/use-skin-preview-fit.ts +++ b/packages/ui/src/composables/skin-rendering/use-skin-preview-fit.ts @@ -10,6 +10,7 @@ import { watch, } from 'vue' +import { useDebugLogger } from '../debug-logger' import type { SkinPreviewBounds, SkinPreviewFitLock, @@ -18,6 +19,8 @@ import type { SkinPreviewTuple, } from './types' +const debug = useDebugLogger('SkinPreviewFit') + const FRAMING_PRESETS = { page: { fov: 35, @@ -456,7 +459,7 @@ export function useSkinPreviewFit({ entries.push(snapshot) if (entries.length > 100) entries.splice(0, entries.length - 100) - console.log('[SkinPreviewDebug]', snapshot) + debug(snapshot) } function queueDebugSnapshot(reason: string) { diff --git a/packages/ui/src/composables/stripe.ts b/packages/ui/src/composables/stripe.ts index 837122c23e..00f56aa3dc 100644 --- a/packages/ui/src/composables/stripe.ts +++ b/packages/ui/src/composables/stripe.ts @@ -6,6 +6,7 @@ import { computed, type Ref, ref } from 'vue' import type { ServerBillingInterval } from '../components/billing/ModrinthServersPurchaseModal.vue' import { getPriceForInterval } from '../utils/product-utils' +import { useDebugLogger } from './debug-logger' // export type CreateElements = ( // paymentMethods: Stripe.PaymentMethod[], @@ -35,6 +36,8 @@ export const useStripe = ( onError: (err: Error) => void, affiliateCode?: Ref, ) => { + const debug = useDebugLogger('Stripe') + const stripe = ref(null) let elements: StripeElements | undefined = undefined @@ -188,7 +191,7 @@ export const useStripe = ( } } catch (err) { loadingFailed.value = String(err) - console.log(err) + console.error(err) } } @@ -241,7 +244,7 @@ export const useStripe = ( total.value = result.total noPaymentRequired.value = false - console.log( + debug( `${paymentIntentId.value ? 'Updated' : 'Created'} payment intent: ${interval.value} for ${result.total}`, ) } @@ -392,8 +395,8 @@ export const useStripe = ( } async function reloadPaymentIntent() { - console.log('selected:', selectedPaymentMethod.value) - console.log('token:', confirmationToken.value) + debug('selected:', selectedPaymentMethod.value) + debug('token:', confirmationToken.value) if (selectedPaymentMethod.value) { await refreshPaymentIntent(selectedPaymentMethod.value.id, false) } else if (confirmationToken.value) { diff --git a/packages/ui/src/layouts/wrapped/hosting/manage/root.vue b/packages/ui/src/layouts/wrapped/hosting/manage/root.vue index 094b8515b1..619eedc7b0 100644 --- a/packages/ui/src/layouts/wrapped/hosting/manage/root.vue +++ b/packages/ui/src/layouts/wrapped/hosting/manage/root.vue @@ -879,10 +879,10 @@ const popupOptions = computed( modpack_id: serverProject.value?.id, modpack_name: serverProject.value?.title, }, - onOpen: () => console.log(`Opened survey notice: ${surveyNotice.value?.id}`), + onOpen: () => debug(`Opened survey notice: ${surveyNotice.value?.id}`), onClose: async () => await dismissSurvey(), onSubmit: (payload: unknown) => { - console.log('Form submitted:', payload) + debug('Form submitted:', payload) }, }) satisfies TallyPopupOptions, )