MCPcopy Index your code
hub / github.com/simstudioai/sim / handleNewUser

Function handleNewUser

apps/sim/lib/billing/core/usage.ts:146–163  ·  view source on GitHub ↗
(userId: string)

Source from the content-addressed store, hash-verified

144 * Creates userStats record with default free credits
145 */
146export async function handleNewUser(userId: string): Promise<void> {
147 try {
148 await db.insert(userStats).values({
149 id: generateId(),
150 userId: userId,
151 currentUsageLimit: getFreeTierLimit().toString(),
152 usageLimitUpdatedAt: new Date(),
153 })
154
155 logger.info('User stats record created for new user', { userId })
156 } catch (error) {
157 logger.error('Failed to create user stats record for new user', {
158 userId,
159 error,
160 })
161 throw error
162 }
163}
164
165/**
166 * Ensures a userStats record exists for a user.

Callers 1

auth.tsFile · 0.90

Calls 5

generateIdFunction · 0.90
getFreeTierLimitFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected