mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-05 13:44:12 -04:00
Move discord move to create profile
This commit is contained in:
@@ -7,6 +7,7 @@ import { track } from 'shared/analytics'
|
||||
import { updateUser } from 'shared/supabase/users'
|
||||
import { tryCatch } from 'common/util/try-catch'
|
||||
import { insert } from 'shared/supabase/utils'
|
||||
import {sendDiscordMessage} from "common/discord/core";
|
||||
|
||||
export const createProfile: APIHandler<'create-profile'> = async (body, auth) => {
|
||||
const pg = createSupabaseDirectClient()
|
||||
@@ -40,7 +41,48 @@ export const createProfile: APIHandler<'create-profile'> = async (body, auth) =>
|
||||
}
|
||||
|
||||
log('Created user', data)
|
||||
await track(user.id, 'create profile', { username: user.username })
|
||||
|
||||
return data
|
||||
const continuation = async () => {
|
||||
try {
|
||||
await track(auth.uid, 'create profile', {username: user.username})
|
||||
} catch (e) {
|
||||
console.log('Failed to track create profile', e)
|
||||
}
|
||||
try {
|
||||
await sendDiscordMessage(
|
||||
`**${user.name}** just created a profile at https://www.compassmeet.com/${user.username}`,
|
||||
'members',
|
||||
)
|
||||
} catch (e) {
|
||||
console.log('Failed to send discord new profile', e)
|
||||
}
|
||||
try {
|
||||
const nProfiles = await pg.one<number>(
|
||||
`SELECT count(*) FROM users`,
|
||||
[],
|
||||
(r) => Number(r.count)
|
||||
)
|
||||
|
||||
const isMilestone = (n: number) => {
|
||||
return (
|
||||
[15, 20, 30, 40].includes(n) || // early milestones
|
||||
n % 50 === 0
|
||||
)
|
||||
}
|
||||
if (isMilestone(nProfiles)) {
|
||||
await sendDiscordMessage(
|
||||
`We just reached **${nProfiles}** total profiles! 🎉`,
|
||||
'general',
|
||||
)
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log('Failed to send discord user milestone', e)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
result: data,
|
||||
continue: continuation,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {insert} from 'shared/supabase/utils'
|
||||
import {convertPrivateUser, convertUser} from 'common/supabase/users'
|
||||
import {getBucket} from "shared/firebase-utils";
|
||||
import {sendDiscordMessage} from "common/discord/core";
|
||||
|
||||
export const createUser: APIHandler<'create-user'> = async (
|
||||
props,
|
||||
@@ -129,37 +128,6 @@ export const createUser: APIHandler<'create-user'> = async (
|
||||
} catch (e) {
|
||||
console.log('Failed to track create profile', e)
|
||||
}
|
||||
try {
|
||||
await sendDiscordMessage(
|
||||
`**${user.name}** just created a profile at https://www.compassmeet.com/${user.username}`,
|
||||
'members',
|
||||
)
|
||||
} catch (e) {
|
||||
console.log('Failed to send discord new user', e)
|
||||
}
|
||||
try {
|
||||
const nProfiles = await pg.one<number>(
|
||||
`SELECT count(*) FROM users`,
|
||||
[],
|
||||
(r) => Number(r.count)
|
||||
)
|
||||
|
||||
const isMilestone = (n: number) => {
|
||||
return (
|
||||
[15, 20, 30, 40].includes(n) || // early milestones
|
||||
n % 50 === 0
|
||||
)
|
||||
}
|
||||
if (isMilestone(nProfiles)) {
|
||||
await sendDiscordMessage(
|
||||
`We just reached **${nProfiles}** total profiles! 🎉`,
|
||||
'general',
|
||||
)
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.log('Failed to send discord user milestone', e)
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user