User records in BuzzTrip are created and managed via Clerk webhooks and exposed through Convex queries. When a user signs up through Clerk, theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/jacobsamo/buzztrip/llms.txt
Use this file to discover all available pages before exploring further.
user.created webhook fires and calls an internal Convex mutation that creates the user document, sends a welcome email, and bootstraps a default “Main map”. All subsequent profile changes in Clerk are reflected in Convex via the user.updated event.
Public Queries
currentUser
Returns the Convex user document for the currently authenticated session, or null if no session is active. This query does not require authentication — it simply returns null when no JWT token is present.
getUser
Fetches a user record by their Clerk user ID (subject on the JWT identity).
The Clerk user ID (e.g.
user_2abc...). This is the sub claim on the Clerk JWT and is referred to as subject in Convex auth.userLoginStatus
Checks the full login state of the current visitor, including whether their Clerk identity has been synced to Convex via webhook. This is useful for handling the brief window between a user completing OAuth and the webhook delivering their record.
Return type — one of three possible states:
Describes the current authentication state.
The Convex user document when fully logged in;
null otherwise.message | Meaning |
|---|---|
"No JWT Token" | No active Clerk session — user has not started login |
"No Clerk User" | Clerk session exists, but the webhook hasn’t delivered the user record yet |
"Logged In" | Session is active and user record exists in Convex |
userLoginStatus is the recommended way to gate app content on full readiness. Using currentUser alone can return null momentarily for new sign-ups while the webhook is still processing.searchUsers
Full-text search across all users by name. Requires an authenticated session (authedQuery).
The search string. Must be at least 1 character. Matched against the
name field via Convex’s search_user search index.refinedUserSchema objects. The refined schema omits sensitive fields and includes only: _id, email, username, first_name, last_name, name, and image.
Internal Mutations (Webhook-Driven)
These mutations areinternalMutation functions — they cannot be called from client code. They are invoked exclusively by the Clerk webhook handler in convex/http.ts. See the Webhooks page for setup instructions.
createUser
Called when Clerk fires a user.created event. Extracts user fields from the Clerk UserJSON payload, inserts a new document into the users table, and in parallel:
- Sends a welcome email via
internal.emails.sendWelcomeEmail - Creates a default map titled “Main map” with description “The starting point to the next adventure!”
updateUser
Called when Clerk fires a user.updated event. Re-extracts user fields from the updated UserJSON payload and patches the existing user document. Throws if the user record does not exist.
Fields patched: clerkUserId, name, first_name, last_name, email, username, image, updatedAt.
deleteUser
Called when Clerk fires a user.deleted event. Looks up the user by Clerk ID and deletes the document. Logs a warning (and skips) if no matching record is found.
User Schema
The Clerk user ID. Used as the primary foreign key to link Convex records to Clerk identities. Indexed via
by_clerk_id.Full display name, concatenated from
first_name and last_name.Primary email address sourced from Clerk.
Profile image URL from Clerk (typically the OAuth provider avatar).
First name, if provided.
Last name, if provided.
Clerk username, if configured.
Optional user bio.
ISO 8601 timestamp of when the user record was first created. Optional — not always present on older records.
ISO 8601 timestamp of the last Clerk-triggered update.
Whether the user has been granted beta program access. See note below.
The
isBetaUser flag is used for quick permission checks without joining the beta_users table. It is set when a user is admitted to the BuzzTrip beta program. Features gated behind this flag will return errors for users where isBetaUser is false or undefined.Map Users (Sharing)
Map sharing is managed through themap_users join table, which links a user to a map with a specific permission level. The following functions live in convex/maps/mapUsers.ts.
Permission Levels
| Permission | Description |
|---|---|
owner | Full control — can delete the map, manage all users |
editor | Can add, edit, and remove markers, collections, and routes |
commenter | Can add comments and notes |
viewer | Read-only access |
getMapUsers
Returns all map_users records for a given map. Requires authentication.
The Convex document ID of the map.
mapUserSchema[] — each record contains _id, map_id, user_id, and permission.
getCombinedMapUsers
Returns map user records merged with full user details. Useful for rendering a collaborator list with names and avatars.
The Convex document ID of the map.
combinedMapUser[] — each element is a map_users document extended with a nested user object containing the user’s profile fields.
shareMap
Adds one or more users to a map. Existing map users are automatically skipped — this mutation is safe to call with a full user list without creating duplicates.
The Convex document ID of the map to share.
Array of users to add. Each entry requires a
user_id and a permission level. Users already on the map are filtered out before insertion.editMapUser
Updates the permission level for an existing map user.
An object matching
mapUserEditSchema: requires _id (the map_users document ID) and permission (the new permission level). All other fields are optional.deleteMapUser
Removes a user from a map entirely.
The Convex document ID of the map.
The Convex document ID of the
map_users record to delete.