Atlas: sign-up identity and the Atlas webhook receiver
Use the Atlas user id as the cross-product person id, identify sign-ups from your server, and keep Lucida people in step with Atlas through a signed webhook.
Atlas is a shared sign-in service. If your app signs users in with Atlas, use the Atlas user id as the one person id everywhere.
Five-line setup
Identify signed-in users with their Atlas user id as the distinct id.
Put the same id in the reserved person property
atlas_user_id.In the Atlas callback route handler, send
$identifyfrom your server (recipe below).Create a webhook source with preset
atlasand give Atlas its URL and secret.Check a new sign-up shows
atlas_user_idon its person.
The recommended person id
Use the Atlas user id as distinctId, and keep it in the person property atlas_user_id. The same value then names one person in Lucida, in the other products and in your own database. atlas_user_id is a convention Lucida reserves for this: the Atlas webhook below sets it, and you can build cohorts, filters and exports on it like any property.
Recipe: server-side sign-up in Next.js
The visitor browsed anonymously before signing up. The browser SDK keeps their anonymous id in the first-party cookie lc_distinct_id, but only when consent allows it (the cookie is absent for visitors who declined or have not answered). Read it in the Atlas callback route handler and tie it to the new user:
// app/auth/callback/route.ts
import { cookies } from "next/headers";
import { Lucida } from "@lucida-analytics/node";
const lucida = new Lucida() // reads LUCIDA_SECRET_KEY;
export async function GET(req: Request) {
const user = await completeAtlasSignIn(req); // your Atlas code: returns { id, email, name }
const anon = (await cookies()).get("lc_distinct_id")?.value; // undefined without consent
lucida.capture({
distinctId: user.id,
event: "$identify",
properties: anon && anon !== user.id ? { $anon_distinct_id: anon } : {},
$set: { atlas_user_id: user.id, email: user.email, name: user.name },
});
await lucida.flush();
return Response.redirect(new URL("/app", req.url));
}$anon_distinct_id merges the earlier anonymous activity into the person; leave it out when the cookie is absent and the person starts at sign-up. The Node SDK's identify() helper takes only properties, so use capture with the $identify event when you need to pass the anonymous id. Do not log the secret key; this code runs only on your server.
In the browser, atlasIdentity() from @lucida-analytics/browser/atlas (browser 0.1.15, Atlas JS 0.29 or later) identifies on sign-in and resets on sign-out for you: Identify visitors with Atlas. From a route handler, captureImmediate sends the sign-up event in one call.
Atlas webhook receiver
Lucida can receive Atlas user webhooks, so people stay in step without your code in the loop.
Atlas generates the signing secret when you add the endpoint, so create the source first, without a secret: it refuses every delivery until it has one.
Create the webhook source (needs
connector:write):curl -X POST https://<your-lucida>/v1/projects/<project-id>/webhook-sources \ -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \ -d '{"name":"Atlas","mapping":{"preset":"atlas"},"auth":{"mode":"atlas"}}'The answer carries
idandpath. Registerhttps://<capture-host><path>as the webhook URL in Atlas, which shows the endpoint's signing secret.Give the source that secret:
curl -X PATCH https://<your-lucida>/v1/projects/<project-id>/webhook-sources/<source-id> \ -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \ -d '{"auth":{"mode":"atlas","secret":"<the signing secret from Atlas>"}}'The secret is stored envelope-encrypted and never shown again. A later
PATCHwithoutsecretkeeps it.
The preset covers the users of an Atlas instance. Platform-level accounts (your own dashboard users, not users of an Atlas instance) are not covered by it: send their $identify and sign-up events, and their deletions, from your server yourself.
What each delivery does:
Atlas event | Lucida |
|---|---|
|
|
| queues a deletion request for that person (the same path as |
anything else | acknowledged and ignored |
Capture a named sign-up event. The $identify carries no event name you can build a funnel on. Add events to the mapping to also capture one:
curl -X POST https://<your-lucida>/v1/projects/<project-id>/webhook-sources \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{"name":"Atlas","mapping":{"preset":"atlas","events":{"user.created":"signed_up"}},"auth":{"mode":"atlas"}}'The keys are Atlas event types: only
user.created,user.updatedanduser.deletedare allowed. The value is the event name. It must not be empty and must not start with$.eventsworks with theatlaspreset only; any other preset is refused.A delivery of a mapped type sends the
$identifyand also one event with that name. It has the same person and the same$set(atlas_user_id,email,name) and no extra properties.The named event has its own uuid, made from the source, the Atlas event id, the user and the name. A redelivery gets the same uuid, so it deduplicates. It never collides with the
$identify.A type that is not in
eventsadds nothing.user.deletedstill only queues the deletion, even if you map it.
Deliveries are verified by signature (atlas-id, atlas-timestamp in milliseconds, atlas-signature: v1,<base64 HMAC-SHA256 of "{id}.{timestamp}.{body}">, five minutes of clock skew). A bad signature is a 401 problem response; a payload without a user id is a 422. Redeliveries are safe: events keep the same uuid and a deletion already open is not queued twice.
Payload shape. This follows the Atlas webhook docs: the envelope is {id, type, timestamp, instance_id, data} and data is the user object. Lucida reads data.id (the Atlas user id), data.primary_email (null until the address is verified; data.email_addresses[0].email_address is the fallback), data.first_name and data.last_name (joined as name), and the anonymous id from data.unsafe_metadata.lc_distinct_id (or public_metadata). Set that metadata key at sign-up from the lc_distinct_id cookie to stitch the visitor to the new user.