mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-24 17:41:27 -04:00
Use logger debug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {APIError, APIHandler} from 'api/helpers/endpoint'
|
||||
import {sendDiscordMessage} from 'common/discord/core'
|
||||
import {debug} from 'common/logger'
|
||||
import {jsonToMarkdown} from 'common/md'
|
||||
import {trimStrings} from 'common/parsing'
|
||||
import {HOUR_MS, MINUTE_MS, sleep} from 'common/util/time'
|
||||
@@ -31,7 +32,7 @@ export const createProfile: APIHandler<'create-profile'> = async (body, auth) =>
|
||||
updateUser(pg, auth.uid, {avatarUrl: body.pinned_url})
|
||||
}
|
||||
|
||||
console.debug('body', body)
|
||||
debug('body', body)
|
||||
|
||||
const {data, error} = await tryCatch(insert(pg, 'profiles', {user_id: auth.uid, ...body}))
|
||||
|
||||
@@ -73,7 +74,7 @@ export const createProfile: APIHandler<'create-profile'> = async (body, auth) =>
|
||||
n % 50 === 0
|
||||
)
|
||||
}
|
||||
console.debug(nProfiles, isMilestone(nProfiles))
|
||||
debug(nProfiles, isMilestone(nProfiles))
|
||||
if (isMilestone(nProfiles)) {
|
||||
await sendDiscordMessage(`We just reached **${nProfiles}** total profiles! 🎉`, 'general')
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import * as admin from 'firebase-admin'
|
||||
import {deleteUserFiles} from 'shared/firebase-utils'
|
||||
import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
@@ -42,7 +43,7 @@ export const deleteMe: APIHandler<'me/delete'> = async ({reasonCategory, reasonD
|
||||
try {
|
||||
const auth = admin.auth()
|
||||
await auth.deleteUser(userId)
|
||||
console.debug(`Deleted user ${userId} from Firebase Auth and Supabase`)
|
||||
debug(`Deleted user ${userId} from Firebase Auth and Supabase`)
|
||||
} catch (e) {
|
||||
console.error('Error deleting user from Firebase Auth:', e)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
|
||||
import {APIHandler} from './helpers/endpoint'
|
||||
@@ -12,7 +13,7 @@ export const getMessagesCount: APIHandler<'get-messages-count'> = async (_, _aut
|
||||
[],
|
||||
)
|
||||
const count = Number(result.count)
|
||||
console.debug('private_user_messages count:', count)
|
||||
debug('private_user_messages count:', count)
|
||||
return {
|
||||
count: count,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type APIHandler} from 'api/helpers/endpoint'
|
||||
import {debug} from 'common/logger'
|
||||
import {OptionTableKey} from 'common/profiles/constants'
|
||||
import {compact} from 'lodash'
|
||||
import {convertRow} from 'shared/profiles/supabase'
|
||||
@@ -69,7 +70,7 @@ export type profileQueryType = {
|
||||
|
||||
export const loadProfiles = async (props: profileQueryType) => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
console.debug('loadProfiles', props)
|
||||
debug('loadProfiles', props)
|
||||
const {
|
||||
limit: limitParam,
|
||||
after,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {type JSONContent} from '@tiptap/core'
|
||||
import {APIError} from 'common/api/utils'
|
||||
import {ChatVisibility} from 'common/chat-message'
|
||||
import {debug} from 'common/logger'
|
||||
import {Json} from 'common/supabase/schema'
|
||||
import {User} from 'common/user'
|
||||
import {parseJsonContentToText} from 'common/util/parse'
|
||||
@@ -174,7 +175,7 @@ const notifyOtherUserInChannelIfInactive = async (
|
||||
// TODO: notification only for active user
|
||||
|
||||
const receiver = await getUser(receiverId)
|
||||
console.debug('receiver:', receiver)
|
||||
debug('receiver:', receiver)
|
||||
if (!receiver) return
|
||||
|
||||
// Push notifs
|
||||
@@ -212,7 +213,7 @@ const notifyOtherUserInChannelIfInactive = async (
|
||||
|
||||
const createNewMessageNotification = async (fromUser: User, toUser: User, channelId: number) => {
|
||||
const privateUser = await getPrivateUser(toUser.id)
|
||||
console.debug('privateUser:', privateUser)
|
||||
debug('privateUser:', privateUser)
|
||||
if (!privateUser) return
|
||||
await sendNewMessageEmail(privateUser, fromUser, toUser, channelId)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {loadProfiles, profileQueryType} from 'api/get-profiles'
|
||||
import {debug} from 'common/logger'
|
||||
import {MatchesByUserType} from 'common/profiles/bookmarked_searches'
|
||||
import {Row} from 'common/supabase/utils'
|
||||
import {sendSearchAlertsEmail} from 'email/functions/helpers'
|
||||
@@ -25,7 +26,7 @@ export const sendSearchNotifications = async () => {
|
||||
[],
|
||||
convertSearchRow,
|
||||
)) as Row<'bookmarked_searches'>[]
|
||||
console.debug(`Running ${searches.length} bookmarked searches`)
|
||||
debug(`Running ${searches.length} bookmarked searches`)
|
||||
|
||||
const _users = (await pg.map(
|
||||
renderSql(select('users.*'), from('users')),
|
||||
@@ -33,7 +34,7 @@ export const sendSearchNotifications = async () => {
|
||||
convertSearchRow,
|
||||
)) as Row<'users'>[]
|
||||
const users = keyBy(_users, 'id')
|
||||
console.debug('users', users)
|
||||
debug('users', users)
|
||||
|
||||
const _privateUsers = (await pg.map(
|
||||
renderSql(select('private_users.*'), from('private_users')),
|
||||
@@ -41,7 +42,7 @@ export const sendSearchNotifications = async () => {
|
||||
convertSearchRow,
|
||||
)) as Row<'private_users'>[]
|
||||
const privateUsers = keyBy(_privateUsers, 'id')
|
||||
console.debug('privateUsers', privateUsers)
|
||||
debug('privateUsers', privateUsers)
|
||||
|
||||
const matches: MatchesByUserType = {}
|
||||
|
||||
@@ -56,7 +57,7 @@ export const sendSearchNotifications = async () => {
|
||||
shortBio: true,
|
||||
}
|
||||
const {profiles} = await loadProfiles(props as profileQueryType)
|
||||
console.debug(profiles.map((item: any) => item.name))
|
||||
debug(profiles.map((item: any) => item.name))
|
||||
if (!profiles.length) continue
|
||||
if (!(row.creator_id in matches)) {
|
||||
if (!privateUsers[row.creator_id]) continue
|
||||
@@ -75,7 +76,7 @@ export const sendSearchNotifications = async () => {
|
||||
})),
|
||||
})
|
||||
}
|
||||
console.debug('matches:', JSON.stringify(matches, null, 2))
|
||||
debug('matches:', JSON.stringify(matches, null, 2))
|
||||
await notifyBookmarkedSearch(matches)
|
||||
|
||||
return {status: 'success'}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {sendTestEmail} from 'email/functions/helpers'
|
||||
|
||||
export const localSendTestEmail = async () => {
|
||||
sendTestEmail('hello@compassmeet.com')
|
||||
.then(() => console.debug('Email sent successfully!'))
|
||||
.then(() => debug('Email sent successfully!'))
|
||||
.catch((error) => console.error('Failed to send email:', error))
|
||||
return {message: 'Email sent successfully!'}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {IS_LOCAL} from 'common/hosting/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {sleep} from 'common/util/time'
|
||||
import {type CreateEmailOptions, CreateEmailRequestOptions, Resend} from 'resend'
|
||||
import {log} from 'shared/utils'
|
||||
@@ -11,7 +12,7 @@ export const sendEmail = async (
|
||||
options?: CreateEmailRequestOptions,
|
||||
) => {
|
||||
const resend = getResend()
|
||||
console.debug(resend, payload, options)
|
||||
debug(resend, payload, options)
|
||||
|
||||
const skip = IS_LOCAL
|
||||
if (skip) {
|
||||
@@ -25,7 +26,7 @@ export const sendEmail = async (
|
||||
{replyTo: 'Compass <hello@compassmeet.com>', ...payload},
|
||||
options,
|
||||
)
|
||||
console.debug('resend.emails.send', data, error)
|
||||
debug('resend.emails.send', data, error)
|
||||
|
||||
if (error) {
|
||||
log.error(`Failed to send email to ${payload.to} with subject ${payload.subject}`)
|
||||
@@ -45,7 +46,7 @@ const getResend = () => {
|
||||
if (resend) return resend
|
||||
|
||||
if (!process.env.RESEND_KEY) {
|
||||
console.debug('No RESEND_KEY, skipping email send')
|
||||
debug('No RESEND_KEY, skipping email send')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
import {sendTestEmail} from './helpers'
|
||||
|
||||
if (require.main === module) {
|
||||
const email = process.argv[2]
|
||||
if (!email) {
|
||||
console.error('Please provide an email address')
|
||||
console.debug('Usage: ts-node send-test-email.ts your@email.com')
|
||||
debug('Usage: ts-node send-test-email.ts your@email.com')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
sendTestEmail(email)
|
||||
.then(() => console.debug('Email sent successfully!'))
|
||||
.then(() => debug('Email sent successfully!'))
|
||||
.catch((error) => console.error('Failed to send email:', error))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {runScript} from './run-script'
|
||||
import {from, renderSql, select, where} from 'shared/supabase/sql-builder'
|
||||
import {SupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
runScript(async ({pg}) => {
|
||||
const tests = [
|
||||
@@ -19,7 +20,7 @@ runScript(async ({pg}) => {
|
||||
})
|
||||
|
||||
const getNodes = async (pg: SupabaseDirectClient, nodeName: string) => {
|
||||
console.debug(`\nSearching comments for ${nodeName}...`)
|
||||
debug(`\nSearching comments for ${nodeName}...`)
|
||||
const commentQuery = renderSql(
|
||||
select('id, user_id, on_user_id, content'),
|
||||
from('profile_comments'),
|
||||
@@ -27,15 +28,15 @@ const getNodes = async (pg: SupabaseDirectClient, nodeName: string) => {
|
||||
)
|
||||
const comments = await pg.manyOrNone(commentQuery)
|
||||
|
||||
console.debug(`Found ${comments.length} comments:`)
|
||||
debug(`Found ${comments.length} comments:`)
|
||||
comments.forEach((comment) => {
|
||||
console.debug('\nComment ID:', comment.id)
|
||||
console.debug('From user:', comment.user_id)
|
||||
console.debug('On user:', comment.on_user_id)
|
||||
console.debug('Content:', JSON.stringify(comment.content))
|
||||
debug('\nComment ID:', comment.id)
|
||||
debug('From user:', comment.user_id)
|
||||
debug('On user:', comment.on_user_id)
|
||||
debug('Content:', JSON.stringify(comment.content))
|
||||
})
|
||||
|
||||
console.debug(`\nSearching private messages for ${nodeName}...`)
|
||||
debug(`\nSearching private messages for ${nodeName}...`)
|
||||
const messageQuery = renderSql(
|
||||
select('id, user_id, channel_id, content'),
|
||||
from('private_user_messages'),
|
||||
@@ -43,15 +44,15 @@ const getNodes = async (pg: SupabaseDirectClient, nodeName: string) => {
|
||||
)
|
||||
const messages = await pg.manyOrNone(messageQuery)
|
||||
|
||||
console.debug(`Found ${messages.length} private messages:`)
|
||||
debug(`Found ${messages.length} private messages:`)
|
||||
messages.forEach((msg) => {
|
||||
console.debug('\nMessage ID:', msg.id)
|
||||
console.debug('From user:', msg.user_id)
|
||||
console.debug('Channel:', msg.channel_id)
|
||||
console.debug('Content:', JSON.stringify(msg.content))
|
||||
debug('\nMessage ID:', msg.id)
|
||||
debug('From user:', msg.user_id)
|
||||
debug('Channel:', msg.channel_id)
|
||||
debug('Content:', JSON.stringify(msg.content))
|
||||
})
|
||||
|
||||
console.debug(`\nSearching profiles for ${nodeName}...`)
|
||||
debug(`\nSearching profiles for ${nodeName}...`)
|
||||
const users = renderSql(
|
||||
select('user_id, bio'),
|
||||
from('profiles'),
|
||||
@@ -59,9 +60,9 @@ const getNodes = async (pg: SupabaseDirectClient, nodeName: string) => {
|
||||
)
|
||||
|
||||
const usersWithMentions = await pg.manyOrNone(users)
|
||||
console.debug(`Found ${usersWithMentions.length} users:`)
|
||||
debug(`Found ${usersWithMentions.length} users:`)
|
||||
usersWithMentions.forEach((user) => {
|
||||
console.debug('\nUser ID:', user.user_id)
|
||||
console.debug('Bio:', JSON.stringify(user.bio))
|
||||
debug('\nUser ID:', user.user_id)
|
||||
debug('Bio:', JSON.stringify(user.bio))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as fs from 'fs/promises'
|
||||
import {execSync} from 'child_process'
|
||||
import {type SupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {runScript} from 'run-script'
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
const outputDir = `../supabase/`
|
||||
|
||||
@@ -176,7 +177,7 @@ async function getTableInfo(pg: SupabaseDirectClient, tableName: string) {
|
||||
}
|
||||
|
||||
async function getFunctions(pg: SupabaseDirectClient) {
|
||||
console.debug('Getting functions')
|
||||
debug('Getting functions')
|
||||
const rows = await pg.manyOrNone<{
|
||||
function_name: string
|
||||
definition: string
|
||||
@@ -194,7 +195,7 @@ async function getFunctions(pg: SupabaseDirectClient) {
|
||||
}
|
||||
|
||||
async function getViews(pg: SupabaseDirectClient) {
|
||||
console.debug('Getting views')
|
||||
debug('Getting views')
|
||||
return pg.manyOrNone<{view_name: string; definition: string}>(
|
||||
`SELECT
|
||||
table_name AS view_name,
|
||||
@@ -212,7 +213,7 @@ async function generateSQLFiles(pg: SupabaseDirectClient) {
|
||||
(row) => row.tablename as string,
|
||||
)
|
||||
|
||||
console.debug(`Getting info for ${tables.length} tables`)
|
||||
debug(`Getting info for ${tables.length} tables`)
|
||||
const tableInfos = await Promise.all(tables.map((table) => getTableInfo(pg, table)))
|
||||
const functions = await getFunctions(pg)
|
||||
const views = await getViews(pg)
|
||||
@@ -324,7 +325,7 @@ async function generateSQLFiles(pg: SupabaseDirectClient) {
|
||||
await fs.writeFile(`${outputDir}/${tableInfo.tableName}.sql`, content)
|
||||
}
|
||||
|
||||
console.debug('Writing remaining functions to functions.sql')
|
||||
debug('Writing remaining functions to functions.sql')
|
||||
let functionsContent = `-- This file is autogenerated from regen-schema.ts\n\n`
|
||||
|
||||
for (const func of functions) {
|
||||
@@ -333,7 +334,7 @@ async function generateSQLFiles(pg: SupabaseDirectClient) {
|
||||
|
||||
await fs.writeFile(`${outputDir}/functions.sql`, functionsContent)
|
||||
|
||||
console.debug('Writing views to views.sql')
|
||||
debug('Writing views to views.sql')
|
||||
let viewsContent = `-- This file is autogenerated from regen-schema.ts\n\n`
|
||||
|
||||
for (const view of views) {
|
||||
@@ -343,6 +344,6 @@ async function generateSQLFiles(pg: SupabaseDirectClient) {
|
||||
|
||||
await fs.writeFile(`${outputDir}/views.sql`, viewsContent)
|
||||
|
||||
console.debug('Prettifying SQL files...')
|
||||
debug('Prettifying SQL files...')
|
||||
execSync(`prettier --write ${outputDir}/*.sql --ignore-path ../supabase/.gitignore`)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {runScript} from './run-script'
|
||||
import {from, renderSql, select, where} from 'shared/supabase/sql-builder'
|
||||
import {type JSONContent} from '@tiptap/core'
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
const removeNodesOfType = (content: JSONContent, typeToRemove: string): JSONContent | null => {
|
||||
if (content.type === typeToRemove) {
|
||||
@@ -22,7 +23,7 @@ const removeNodesOfType = (content: JSONContent, typeToRemove: string): JSONCont
|
||||
runScript(async ({pg}) => {
|
||||
const nodeType = 'linkPreview'
|
||||
|
||||
console.debug('\nSearching comments for linkPreviews...')
|
||||
debug('\nSearching comments for linkPreviews...')
|
||||
const commentQuery = renderSql(
|
||||
select('id, content'),
|
||||
from('profile_comments'),
|
||||
@@ -30,21 +31,21 @@ runScript(async ({pg}) => {
|
||||
)
|
||||
const comments = await pg.manyOrNone(commentQuery)
|
||||
|
||||
console.debug(`Found ${comments.length} comments with linkPreviews`)
|
||||
debug(`Found ${comments.length} comments with linkPreviews`)
|
||||
|
||||
for (const comment of comments) {
|
||||
const newContent = removeNodesOfType(comment.content, nodeType)
|
||||
console.debug('before', comment.content)
|
||||
console.debug('after', newContent)
|
||||
debug('before', comment.content)
|
||||
debug('after', newContent)
|
||||
|
||||
await pg.none('update profile_comments set content = $1 where id = $2', [
|
||||
newContent,
|
||||
comment.id,
|
||||
])
|
||||
console.debug('Updated comment:', comment.id)
|
||||
debug('Updated comment:', comment.id)
|
||||
}
|
||||
|
||||
console.debug('\nSearching private messages for linkPreviews...')
|
||||
debug('\nSearching private messages for linkPreviews...')
|
||||
const messageQuery = renderSql(
|
||||
select('id, content'),
|
||||
from('private_user_messages'),
|
||||
@@ -52,17 +53,17 @@ runScript(async ({pg}) => {
|
||||
)
|
||||
const messages = await pg.manyOrNone(messageQuery)
|
||||
|
||||
console.debug(`Found ${messages.length} messages with linkPreviews`)
|
||||
debug(`Found ${messages.length} messages with linkPreviews`)
|
||||
|
||||
for (const msg of messages) {
|
||||
const newContent = removeNodesOfType(msg.content, nodeType)
|
||||
console.debug('before', JSON.stringify(msg.content, null, 2))
|
||||
console.debug('after', JSON.stringify(newContent, null, 2))
|
||||
debug('before', JSON.stringify(msg.content, null, 2))
|
||||
debug('after', JSON.stringify(newContent, null, 2))
|
||||
|
||||
await pg.none('update private_user_messages set content = $1 where id = $2', [
|
||||
newContent,
|
||||
msg.id,
|
||||
])
|
||||
console.debug('Updated message:', msg.id)
|
||||
debug('Updated message:', msg.id)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {initAdmin} from 'shared/init-admin'
|
||||
import {createSupabaseDirectClient, type SupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {refreshConfig} from 'common/envs/prod'
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
export const runScript = async (
|
||||
main: (services: {pg: SupabaseDirectClient}) => Promise<any> | any,
|
||||
@@ -9,14 +10,14 @@ export const runScript = async (
|
||||
initAdmin()
|
||||
await initEnvVariables()
|
||||
if (logEnv) {
|
||||
console.debug('[runScript] Environment variables:')
|
||||
for (const k of Object.keys(process.env)) console.debug(`${k}=${process.env[k]}`)
|
||||
debug('[runScript] Environment variables:')
|
||||
for (const k of Object.keys(process.env)) debug(`${k}=${process.env[k]}`)
|
||||
}
|
||||
|
||||
console.debug('[runScript] Creating Supabase client...')
|
||||
debug('[runScript] Creating Supabase client...')
|
||||
const pg = createSupabaseDirectClient()
|
||||
|
||||
console.debug('[runScript] Running script...')
|
||||
debug('[runScript] Running script...')
|
||||
await main({pg})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {ENV_CONFIG, getStorageBucketId} from 'common/envs/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {getStorage, Storage} from 'firebase-admin/storage'
|
||||
import {readFileSync} from 'fs'
|
||||
|
||||
@@ -40,10 +41,10 @@ export async function deleteUserFiles(username: string) {
|
||||
const [files] = await bucket.getFiles({prefix: path})
|
||||
|
||||
if (files.length === 0) {
|
||||
console.debug(`No files found in bucket for user ${username}`)
|
||||
debug(`No files found in bucket for user ${username}`)
|
||||
return
|
||||
}
|
||||
|
||||
await Promise.all(files.map((file) => file.delete()))
|
||||
console.debug(`Deleted ${files.length} files for user ${username}`)
|
||||
debug(`Deleted ${files.length} files for user ${username}`)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {DOMAIN} from 'common/envs/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {Bucket} from 'shared/firebase-utils'
|
||||
|
||||
export const generateAvatarUrl = async (userId: string, name: string, bucket: Bucket) => {
|
||||
@@ -21,7 +22,7 @@ export const generateAvatarUrl = async (userId: string, name: string, bucket: Bu
|
||||
const buffer = await res.arrayBuffer()
|
||||
return await upload(userId, Buffer.from(buffer), bucket)
|
||||
} catch (e) {
|
||||
console.debug('error generating avatar', e)
|
||||
debug('error generating avatar', e)
|
||||
return `https://${DOMAIN}/images/default-avatar.png`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {debug} from 'common/logger'
|
||||
|
||||
export const constructPrefixTsQuery = (term: string) => {
|
||||
const sanitized = term
|
||||
.replace(/'/g, "''")
|
||||
.replace(/[!&|():*<>]/g, '')
|
||||
.trim()
|
||||
console.debug(`Term: "${sanitized}"`)
|
||||
debug(`Term: "${sanitized}"`)
|
||||
if (sanitized === '') return ''
|
||||
const tokens = sanitized.split(/\s+/)
|
||||
return tokens.join(' & ') + ':*'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {IS_FIREBASE_EMULATOR} from 'common/envs/constants'
|
||||
import {IS_LOCAL} from 'common/hosting/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import * as admin from 'firebase-admin'
|
||||
import {getServiceAccountCredentials} from 'shared/firebase-utils'
|
||||
|
||||
@@ -17,10 +18,10 @@ export const initAdmin = () => {
|
||||
const serviceAccount = getServiceAccountCredentials()
|
||||
|
||||
if (!serviceAccount.project_id) {
|
||||
console.debug(`GOOGLE_APPLICATION_CREDENTIALS not set, skipping admin firebase init.`)
|
||||
debug(`GOOGLE_APPLICATION_CREDENTIALS not set, skipping admin firebase init.`)
|
||||
return
|
||||
}
|
||||
console.debug(`Initializing connection to ${serviceAccount.project_id} Firebase...`)
|
||||
debug(`Initializing connection to ${serviceAccount.project_id} Firebase...`)
|
||||
return admin.initializeApp({
|
||||
projectId: serviceAccount.project_id,
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
@@ -31,6 +32,6 @@ export const initAdmin = () => {
|
||||
}
|
||||
}
|
||||
|
||||
console.debug(`Initializing connection to default Firebase...`)
|
||||
debug(`Initializing connection to default Firebase...`)
|
||||
return admin.initializeApp()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,11 @@ import {PROD_CONFIG} from './prod'
|
||||
export const MAX_DESCRIPTION_LENGTH = 100000
|
||||
export const MAX_ANSWER_LENGTH = 240
|
||||
|
||||
export const ENV_CONFIG = isProd() ? PROD_CONFIG : DEV_CONFIG
|
||||
export const ENV = isProd() ? 'prod' : 'dev'
|
||||
export const IS_PROD = ENV === 'prod'
|
||||
export const IS_DEV = ENV === 'dev'
|
||||
|
||||
export const ENV_CONFIG = IS_PROD ? PROD_CONFIG : DEV_CONFIG
|
||||
|
||||
export function isAdminId(id: string) {
|
||||
return ENV_CONFIG.adminIds.includes(id)
|
||||
@@ -22,10 +26,6 @@ export function isModId(id: string) {
|
||||
return MOD_USERNAMES.includes(id)
|
||||
}
|
||||
|
||||
export const ENV = isProd() ? 'prod' : 'dev'
|
||||
// export const IS_PROD = ENV === 'prod'
|
||||
export const IS_DEV = ENV === 'dev'
|
||||
|
||||
console.debug(`Running in ${HOSTING_ENV} (${ENV})`)
|
||||
|
||||
// class MissingKeyError implements Error {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {ProfileRow} from 'common/profiles/profile'
|
||||
|
||||
export const geodbHost = 'wft-geo-db.p.rapidapi.com'
|
||||
@@ -24,10 +25,10 @@ export const geodbFetch = async (endpoint: string) => {
|
||||
}
|
||||
|
||||
const data = await res.json()
|
||||
console.debug('geodbFetch', endpoint, data)
|
||||
debug('geodbFetch', endpoint, data)
|
||||
return {status: 'success', data}
|
||||
} catch (error) {
|
||||
console.debug('geodbFetch', endpoint, error)
|
||||
debug('geodbFetch', endpoint, error)
|
||||
return {status: 'failure', data: error}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import {IS_PROD} from 'common/envs/constants'
|
||||
|
||||
type LogLevel = 'debug' | 'info' | 'warn' | 'error'
|
||||
|
||||
interface LogContext {
|
||||
@@ -13,11 +15,6 @@ const LOG_LEVELS: Record<LogLevel, number> = {
|
||||
error: 3,
|
||||
}
|
||||
|
||||
const currentLevel = (): LogLevel => {
|
||||
if (process.env.NODE_ENV === 'production') return 'info'
|
||||
return 'debug'
|
||||
}
|
||||
|
||||
function shouldLog(level: LogLevel): boolean {
|
||||
return LOG_LEVELS[level] >= LOG_LEVELS[currentLevel()]
|
||||
}
|
||||
@@ -59,12 +56,27 @@ export const logger = {
|
||||
|
||||
export function logApiError(endpoint: string, error: Error | unknown, extra?: LogContext): void {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||
logger.error(`API Error in ${endpoint}`, error instanceof Error ? error : new Error(errorMessage), {
|
||||
endpoint,
|
||||
...extra,
|
||||
})
|
||||
logger.error(
|
||||
`API Error in ${endpoint}`,
|
||||
error instanceof Error ? error : new Error(errorMessage),
|
||||
{
|
||||
endpoint,
|
||||
...extra,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export function logPageView(path: string): void {
|
||||
logger.info('Page view', {path})
|
||||
}
|
||||
|
||||
const currentLevel = (): LogLevel => {
|
||||
if (IS_PROD) return 'info'
|
||||
return 'debug'
|
||||
}
|
||||
|
||||
export const debug = (...args: unknown[]) => {
|
||||
if (currentLevel() === 'debug') {
|
||||
console.debug(...args)
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
import {IS_LOCAL} from 'common/hosting/constants'
|
||||
|
||||
class Logger {
|
||||
private readonly isLocal: boolean
|
||||
|
||||
constructor(isLocal = false) {
|
||||
this.isLocal = isLocal
|
||||
}
|
||||
|
||||
trace(...args: any[]) {
|
||||
// Does not seem to really work. Was trying to show the real file where the log was called from.
|
||||
if (!this.isLocal) return
|
||||
|
||||
const caller = this.getCallerFrame(3) // skip Logger frames
|
||||
if (caller) {
|
||||
console.log('Trace:', ...args, '\nCalled from:', caller)
|
||||
} else {
|
||||
console.trace(...args)
|
||||
}
|
||||
}
|
||||
|
||||
log(...args: any[]) {
|
||||
if (this.isLocal) console.log(...args)
|
||||
}
|
||||
|
||||
info(...args: any[]) {
|
||||
if (this.isLocal) console.info(...args)
|
||||
}
|
||||
|
||||
warn(...args: any[]) {
|
||||
if (this.isLocal) console.warn(...args)
|
||||
}
|
||||
|
||||
error(...args: any[]) {
|
||||
if (this.isLocal) console.error(...args)
|
||||
}
|
||||
|
||||
debug(...args: any[]) {
|
||||
if (this.isLocal) console.debug(...args)
|
||||
}
|
||||
|
||||
table(...args: any[]) {
|
||||
if (this.isLocal) console.table(...args)
|
||||
}
|
||||
|
||||
group(...args: any[]) {
|
||||
if (this.isLocal) console.group(...args)
|
||||
}
|
||||
|
||||
private getCallerFrame(skip = 2): string | undefined {
|
||||
// Create an Error to get stack trace
|
||||
const err = new Error()
|
||||
if (!err.stack) return undefined
|
||||
|
||||
const lines = err.stack.split('\n')
|
||||
|
||||
// skip frames (0: Error, 1: Logger method, 2+: caller)
|
||||
return lines[skip]?.trim()
|
||||
}
|
||||
}
|
||||
|
||||
export const logger = new Logger(IS_LOCAL)
|
||||
@@ -1,6 +1,6 @@
|
||||
import {isProd} from 'common/envs/is-prod'
|
||||
import {IS_PROD} from 'common/envs/constants'
|
||||
|
||||
export const compassUserId = isProd()
|
||||
export const compassUserId = IS_PROD
|
||||
? 'tRZZ6ihugZQLXPf6aPRneGpWLmz1'
|
||||
: 'RlXR2xa4EFfAzdCbSe45wkcdarh1'
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {SecretManagerServiceClient} from '@google-cloud/secret-manager'
|
||||
import {refreshConfig} from 'common/envs/prod'
|
||||
import {IS_LOCAL} from 'common/hosting/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {zip} from 'lodash'
|
||||
|
||||
// List of secrets that are available to backend (api, functions, scripts, etc.)
|
||||
@@ -54,7 +55,7 @@ export const getSecrets = async (credentials?: any, ...ids: SecretId[]) => {
|
||||
|
||||
const secretIds = ids.length > 0 ? ids : secrets
|
||||
|
||||
console.debug('secretIds', secretIds)
|
||||
debug('secretIds', secretIds)
|
||||
|
||||
const fullSecretNames = secretIds.map(
|
||||
(secret: string) => `${client.projectPath(projectId)}/secrets/${secret}/versions/latest`,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {max, sumBy} from 'lodash'
|
||||
|
||||
// each row has [column, value] pairs
|
||||
@@ -32,7 +33,7 @@ export function factorizeMatrix(
|
||||
const mFeatures = fillMatrix(m, FEATURES, initCell)
|
||||
const nFeatures = fillMatrix(n, FEATURES, initCell)
|
||||
|
||||
console.debug('rows', m, 'columns', n, 'numPoints', points)
|
||||
debug('rows', m, 'columns', n, 'numPoints', points)
|
||||
|
||||
const updateFeature = (a: number, b: number, error: number) =>
|
||||
a + LEARNING_RATE * (2 * error * b - REGULARIZATION_RATE * a)
|
||||
@@ -75,7 +76,7 @@ export function factorizeMatrix(
|
||||
}
|
||||
}
|
||||
}
|
||||
console.debug(iter, 'error', totalError / points)
|
||||
debug(iter, 'error', totalError / points)
|
||||
|
||||
// Complete factorization process if total error falls below a certain threshold
|
||||
if (totalError / points < THRESHOLD) break
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {isProd} from 'common/envs/is-prod'
|
||||
import {IS_PROD} from 'common/envs/constants'
|
||||
import {removeUndefinedProps} from 'common/util/object'
|
||||
import {buildOgUrl} from 'common/util/og'
|
||||
import Head from 'next/head'
|
||||
@@ -16,7 +16,7 @@ export function SEO<P extends Record<string, string | undefined>>(props: {
|
||||
image ?? (ogProps && buildOgUrl(removeUndefinedProps(ogProps.props) as any, ogProps.endpoint))
|
||||
|
||||
const absUrl = 'https://compassmeet.com' + url
|
||||
const endTitle = isProd() ? 'Compass' : 'Compass dev'
|
||||
const endTitle = IS_PROD ? 'Compass' : 'Compass dev'
|
||||
|
||||
return (
|
||||
<Head>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {PlusIcon, XIcon} from '@heroicons/react/outline'
|
||||
import {MAX_ANSWER_LENGTH} from 'common/envs/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {MAX_COMPATIBILITY_QUESTION_LENGTH} from 'common/profiles/constants'
|
||||
import {Row as rowFor} from 'common/supabase/utils'
|
||||
import {User} from 'common/user'
|
||||
@@ -53,7 +54,7 @@ function AddCompatibilityQuestionModal(props: {
|
||||
const [dbQuestion, setDbQuestion] = useState<rowFor<'compatibility_prompts'> | null>(null)
|
||||
const afterAddQuestion = (newQuestion: rowFor<'compatibility_prompts'>) => {
|
||||
setDbQuestion(newQuestion)
|
||||
console.debug('setDbQuestion', newQuestion)
|
||||
debug('setDbQuestion', newQuestion)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -132,7 +133,7 @@ function CreateCompatibilityModalContent(props: {
|
||||
options: generateJson(),
|
||||
}
|
||||
const newQuestion = await api('create-compatibility-question', data)
|
||||
console.debug('create-compatibility-question', newQuestion, data)
|
||||
debug('create-compatibility-question', newQuestion, data)
|
||||
const q = newQuestion?.question
|
||||
if (q) {
|
||||
afterAddQuestion(q as rowFor<'compatibility_prompts'>)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {LOCALE_TO_LANGUAGE} from 'common/choices'
|
||||
import {MAX_INT, MIN_INT} from 'common/constants'
|
||||
import {FilterFields, initialFilters, OriginLocation} from 'common/filters'
|
||||
import {logger} from 'common/logging'
|
||||
import {debug} from 'common/logger'
|
||||
import {kmToMiles} from 'common/measurement-utils'
|
||||
import {Profile} from 'common/profiles/profile'
|
||||
import {
|
||||
@@ -141,7 +141,7 @@ export const useFilters = (you: Profile | undefined, fromSignup?: boolean) => {
|
||||
has_kids: wantsKidsToHasKidsFilter((you?.wants_kids_strength ?? 2) as wantsKidsDatabase),
|
||||
is_smoker: you?.is_smoker,
|
||||
}
|
||||
logger.debug(you, yourFilters)
|
||||
debug(you, yourFilters)
|
||||
|
||||
const isYourFilters =
|
||||
!!you &&
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
RELIGION_CHOICES,
|
||||
ROMANTIC_CHOICES,
|
||||
} from 'common/choices'
|
||||
import {debug} from 'common/logger'
|
||||
import {MultipleChoiceOptions} from 'common/profiles/multiple-choice'
|
||||
import {getProfileRow, Profile, ProfileWithoutUser} from 'common/profiles/profile'
|
||||
import {PLATFORM_LABELS, type Site, SITE_ORDER} from 'common/socials'
|
||||
@@ -148,7 +149,7 @@ export const OptionalProfileUserForm = (props: {
|
||||
work,
|
||||
...otherProfileProps
|
||||
} = profile
|
||||
console.debug('otherProfileProps', removeUndefinedProps(otherProfileProps))
|
||||
debug('otherProfileProps', removeUndefinedProps(otherProfileProps))
|
||||
const promises: Promise<any>[] = [
|
||||
tryCatch(updateProfile(removeUndefinedProps(otherProfileProps) as any)),
|
||||
]
|
||||
@@ -1050,7 +1051,7 @@ export const OptionalProfileUserForm = (props: {
|
||||
<SignupBio
|
||||
profile={profile}
|
||||
onChange={(e: Editor) => {
|
||||
console.debug('bio changed', e, profile.bio)
|
||||
debug('bio changed', e, profile.bio)
|
||||
setProfile('bio', e.getJSON())
|
||||
setProfile('bio_length', e.getText().length)
|
||||
}}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {DotsHorizontalIcon, EyeIcon, LockClosedIcon, PencilIcon} from '@heroicons/react/outline'
|
||||
import clsx from 'clsx'
|
||||
import {debug} from 'common/logger'
|
||||
import {Profile} from 'common/profiles/profile'
|
||||
import {User, UserActivity} from 'common/user'
|
||||
import {capitalize} from 'lodash'
|
||||
@@ -55,7 +56,7 @@ export default function ProfileHeader(props: {
|
||||
const disabled = profile.disabled
|
||||
const t = useT()
|
||||
|
||||
console.debug('ProfileProfileHeader', {
|
||||
debug('ProfileProfileHeader', {
|
||||
user,
|
||||
profile,
|
||||
userActivity,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {JSONContent} from '@tiptap/core'
|
||||
import {debug} from 'common/logger'
|
||||
import {Profile} from 'common/profiles/profile'
|
||||
import {UserActivity} from 'common/user'
|
||||
import {ProfileAnswers} from 'web/components/answers/profile-answers'
|
||||
@@ -29,7 +30,7 @@ export function ProfileInfo(props: {
|
||||
fromSignup?: boolean
|
||||
}) {
|
||||
const {profile, user, refreshProfile, fromProfilePage, fromSignup} = props
|
||||
console.debug('Rendering Profile for', user.username, user.name, props)
|
||||
debug('Rendering Profile for', user.username, user.name, props)
|
||||
|
||||
const currentUser = useUser()
|
||||
const t = useT()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {Profile} from 'common/profiles/profile'
|
||||
import {removeNullOrUndefinedProps} from 'common/util/object'
|
||||
import {DAY_MS} from 'common/util/time'
|
||||
@@ -96,7 +97,7 @@ export function ProfilesHome() {
|
||||
locale,
|
||||
...filters,
|
||||
})
|
||||
console.debug('Refreshing profiles, filters:', args)
|
||||
debug('Refreshing profiles, filters:', args)
|
||||
api('get-profiles', args as any)
|
||||
.then(({profiles, count}) => {
|
||||
if (current === id.current) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import clsx from 'clsx'
|
||||
import {isProd} from 'common/envs/is-prod'
|
||||
import {IS_PROD} from 'common/envs/constants'
|
||||
import Link from 'next/link'
|
||||
import FavIcon from 'web/components/FavIcon'
|
||||
import {Row} from 'web/components/layout/row'
|
||||
@@ -10,7 +10,7 @@ export default function SiteLogo(props: {noLink?: boolean; className?: string})
|
||||
<>
|
||||
<FavIcon className="dark:invert" />
|
||||
<div className={clsx('my-auto text-xl font-thin logo')}>
|
||||
{isProd() ? 'Compass' : 'Compass dev'}
|
||||
{IS_PROD ? 'Compass' : 'Compass dev'}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {JSONContent} from '@tiptap/core'
|
||||
import {formLink} from 'common/constants'
|
||||
import {MAX_DESCRIPTION_LENGTH} from 'common/envs/constants'
|
||||
import {debug} from 'common/logger'
|
||||
import {ORDER_BY, ORDER_BY_CHOICES, OrderBy} from 'common/votes/constants'
|
||||
import Link from 'next/link'
|
||||
import {useEffect, useState} from 'react'
|
||||
@@ -113,7 +114,7 @@ export function VoteComponent() {
|
||||
setTitle('')
|
||||
editor.commands.clearContent()
|
||||
toast.success(t('vote.toast.created', 'Vote created'))
|
||||
console.debug('Vote created', newVote)
|
||||
debug('Vote created', newVote)
|
||||
refreshVotes()
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {useEffect, useRef} from 'react'
|
||||
import {usePersistentLocalState} from 'web/hooks/use-persistent-local-state'
|
||||
import {api} from 'web/lib/api'
|
||||
@@ -17,7 +18,7 @@ export function useNearbyCities(referenceCityId: string | null | undefined, radi
|
||||
cityId: referenceCityId,
|
||||
radius,
|
||||
}).then((result) => {
|
||||
console.debug('search-near-city', result)
|
||||
debug('search-near-city', result)
|
||||
if (thisSearchCount == searchCount.current) {
|
||||
if (result.status === 'failure') {
|
||||
setNearbyCities(null)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {getProfileRow, Profile, ProfileWithoutUser} from 'common/profiles/profile'
|
||||
import {Row} from 'common/supabase/utils'
|
||||
import {User} from 'common/user'
|
||||
@@ -47,11 +48,11 @@ export const useProfileByUser = (user: User | undefined) => {
|
||||
else setProfile({...profile, user})
|
||||
})
|
||||
.catch((error) => {
|
||||
console.debug('Warning: profile not found', user?.username, error)
|
||||
debug('Warning: profile not found', user?.username, error)
|
||||
setProfile(null)
|
||||
return
|
||||
})
|
||||
console.debug('End Refreshing profile for', user?.username, profile)
|
||||
debug('End Refreshing profile for', user?.username, profile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use client'
|
||||
import {debug} from 'common/logger'
|
||||
import {PrivateUser, User} from 'common/user'
|
||||
import {useContext, useEffect, useState} from 'react'
|
||||
import {AuthContext} from 'web/components/auth-context'
|
||||
@@ -30,7 +31,7 @@ export const useWebsocketUser = (userId: string | undefined) => {
|
||||
useApiSubscription({
|
||||
topics: [`user/${userId ?? '_'}`],
|
||||
onBroadcast: ({data}) => {
|
||||
console.debug('User broadcast', {data})
|
||||
debug('User broadcast', {data})
|
||||
setUser((user) => {
|
||||
if (!user || !data.user) {
|
||||
return user
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {API, APIParams, APIPath} from 'common/api/schema'
|
||||
import {debug} from 'common/logger'
|
||||
import {typedAPICall} from 'common/util/api'
|
||||
import {sleep} from 'common/util/time'
|
||||
|
||||
@@ -16,7 +17,7 @@ export async function api<P extends APIPath>(path: P, params: APIParams<P> = {})
|
||||
break
|
||||
}
|
||||
}
|
||||
console.debug('User loaded after', i, 'iterations')
|
||||
debug('User loaded after', i, 'iterations')
|
||||
}
|
||||
|
||||
return typedAPICall(path, params, auth.currentUser)
|
||||
@@ -32,7 +33,7 @@ export const report = curriedAPI('report')
|
||||
|
||||
export const updateBackendLocale = (newLocale: string) => {
|
||||
if (!auth.currentUser) return
|
||||
console.debug('Updating backend locale to', newLocale)
|
||||
debug('Updating backend locale to', newLocale)
|
||||
api('update-user-locale', {locale: newLocale}).catch((error) => {
|
||||
console.error('Failed to update user locale:', error)
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use client'
|
||||
import {debug} from 'common/logger'
|
||||
import {GoogleAuthProvider, signInWithCredential} from 'firebase/auth'
|
||||
import Script from 'next/script'
|
||||
import {useEffect} from 'react'
|
||||
@@ -11,7 +12,7 @@ async function handleResponse(response: any) {
|
||||
const credential = GoogleAuthProvider.credential(idToken)
|
||||
try {
|
||||
const result = await signInWithCredential(auth, credential)
|
||||
console.debug(result.user)
|
||||
debug(result.user)
|
||||
} catch (error) {
|
||||
console.error('could not log in via onetap', error)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {JSONContent} from '@tiptap/core'
|
||||
import {debug} from 'common/logger'
|
||||
import {getProfileOgImageUrl} from 'common/profiles/og-image'
|
||||
import {getProfileRow, ProfileRow} from 'common/profiles/profile'
|
||||
import {getUserForStaticProps} from 'common/supabase/users'
|
||||
@@ -42,7 +43,7 @@ async function getProfile(userId: string) {
|
||||
break
|
||||
}
|
||||
}
|
||||
console.debug(`Profile loaded after ${i} tries`)
|
||||
debug(`Profile loaded after ${i} tries`)
|
||||
return profile
|
||||
}
|
||||
|
||||
@@ -81,10 +82,10 @@ export const getStaticProps = async (
|
||||
|
||||
const user = await getUser(username)
|
||||
|
||||
console.debug('getStaticProps', {user})
|
||||
debug('getStaticProps', {user})
|
||||
|
||||
if (!user) {
|
||||
console.debug('No user')
|
||||
debug('No user')
|
||||
return {
|
||||
props: {
|
||||
notFoundCustomText:
|
||||
@@ -95,7 +96,7 @@ export const getStaticProps = async (
|
||||
}
|
||||
|
||||
if (user.username !== username) {
|
||||
console.debug('Found a case-insensitive match')
|
||||
debug('Found a case-insensitive match')
|
||||
// Found a case-insensitive match, redirect to correct casing
|
||||
return {
|
||||
redirect: {
|
||||
@@ -106,7 +107,7 @@ export const getStaticProps = async (
|
||||
}
|
||||
|
||||
if (user.userDeleted) {
|
||||
console.debug('User deleted')
|
||||
debug('User deleted')
|
||||
return {
|
||||
props: {
|
||||
username,
|
||||
@@ -118,7 +119,7 @@ export const getStaticProps = async (
|
||||
const profile = await getProfile(user.id)
|
||||
|
||||
if (!profile) {
|
||||
console.debug('No profile', `${user.username} hasn't created a profile yet.`)
|
||||
debug('No profile', `${user.username} hasn't created a profile yet.`)
|
||||
return {
|
||||
props: {
|
||||
notFoundCustomText: `${user.username} hasn't created a profile yet.`,
|
||||
@@ -126,7 +127,7 @@ export const getStaticProps = async (
|
||||
revalidate: 1,
|
||||
}
|
||||
}
|
||||
// console.debug('profile', profile)
|
||||
// debug('profile', profile)
|
||||
return {
|
||||
props: {
|
||||
user,
|
||||
@@ -260,7 +261,7 @@ export default function UserPage(props: UserPageProps) {
|
||||
}
|
||||
|
||||
function UserPageInner(props: ActiveUserPageProps) {
|
||||
// console.debug('Starting UserPageInner in /[username]')
|
||||
// debug('Starting UserPageInner in /[username]')
|
||||
const {user, username} = props
|
||||
const router = useRouter()
|
||||
const {query} = router
|
||||
@@ -276,7 +277,7 @@ function UserPageInner(props: ActiveUserPageProps) {
|
||||
const {profile: clientProfile, refreshProfile} = useProfileByUser(user)
|
||||
// Show the previous profile while loading another one
|
||||
const profile = clientProfile ?? staticProfile
|
||||
// console.debug('profile:', user?.username, profile, clientProfile, staticProfile)
|
||||
// debug('profile:', user?.username, profile, clientProfile, staticProfile)
|
||||
|
||||
if (!isCurrentUser && profile?.disabled) {
|
||||
return (
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {debug} from 'common/logger'
|
||||
import {LoggedOutHome} from 'web/components/home/home'
|
||||
import {Col} from 'web/components/layout/col'
|
||||
import {PageBase} from 'web/components/page-base'
|
||||
@@ -17,7 +18,7 @@ export default function ProfilesPage() {
|
||||
return <PageBase trackPageView={'loading'} />
|
||||
}
|
||||
|
||||
console.debug('user:', user)
|
||||
debug('user:', user)
|
||||
|
||||
return (
|
||||
<PageBase trackPageView={'user profiles'} className={'col-span-10'}>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import {debug} from 'common/logger'
|
||||
import {getProfileRow} from 'common/profiles/profile'
|
||||
import {createUserWithEmailAndPassword} from 'firebase/auth'
|
||||
import Link from 'next/link'
|
||||
@@ -61,7 +62,7 @@ function RegisterComponent() {
|
||||
const handleEmailPasswordSignUp = async (email: string, password: string) => {
|
||||
try {
|
||||
const creds = await createUserWithEmailAndPassword(auth, email, password)
|
||||
console.debug('User signed up:', creds.user)
|
||||
debug('User signed up:', creds.user)
|
||||
} catch (error: any) {
|
||||
console.error('Error signing up:', error)
|
||||
toast.error(t('register.toast.signup_failed', 'Failed to sign up: ') + (error?.message ?? ''))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import {logger} from 'common/logging'
|
||||
import {debug} from 'common/logger'
|
||||
import {getProfileRow} from 'common/profiles/profile'
|
||||
import {signInWithEmailAndPassword} from 'firebase/auth'
|
||||
import Link from 'next/link'
|
||||
@@ -45,7 +45,7 @@ function RegisterComponent() {
|
||||
useEffect(() => {
|
||||
const checkAndRedirect = async () => {
|
||||
if (user) {
|
||||
console.debug('User signed in:', user)
|
||||
debug('User signed in:', user)
|
||||
try {
|
||||
const profile = await getProfileRow(user.id, db)
|
||||
if (profile) {
|
||||
@@ -68,7 +68,7 @@ function RegisterComponent() {
|
||||
setError(null)
|
||||
try {
|
||||
const creds = await firebaseLogin()
|
||||
logger.debug('creds', creds)
|
||||
debug('creds', creds)
|
||||
if (creds) {
|
||||
setIsLoading(true)
|
||||
setIsLoadingGoogle(true)
|
||||
@@ -85,7 +85,7 @@ function RegisterComponent() {
|
||||
const handleEmailPasswordSignIn = async (email: string, password: string) => {
|
||||
try {
|
||||
const creds = await signInWithEmailAndPassword(auth, email, password)
|
||||
logger.debug(creds)
|
||||
debug(creds)
|
||||
} catch (error) {
|
||||
console.error('Error signing in:', error)
|
||||
const message = t(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {LOCALE_TO_LANGUAGE} from 'common/choices'
|
||||
import {debug} from 'common/logger'
|
||||
import {ProfileWithoutUser} from 'common/profiles/profile'
|
||||
import {removeNullOrUndefinedProps} from 'common/util/object'
|
||||
import {useRouter} from 'next/router'
|
||||
@@ -162,7 +163,7 @@ export default function SignupPage() {
|
||||
: undefined
|
||||
|
||||
setIsSubmitting(true)
|
||||
console.debug('profileForm', profileForm)
|
||||
debug('profileForm', profileForm)
|
||||
const profile = await api(
|
||||
'create-profile',
|
||||
removeNullOrUndefinedProps({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {logApiError, logger} from 'web/lib/logger'
|
||||
import {logApiError, logger} from 'common/lib/logger'
|
||||
|
||||
describe('logger', () => {
|
||||
const originalEnv = process.env.NODE_ENV
|
||||
|
||||
Reference in New Issue
Block a user