Authentication

Use UserJot.identify(...) to tell UserJot who the current app user is.

Once a user is identified, feedback activity can stay tied to the right person, and UserJot can provide a more consistent signed-in experience across the SDK surfaces.

Basic identification

The minimum identification call only needs your own stable user ID:

UserJot.identify(userId: "user_123")

Use the user ID from your own system. It should be stable for that user over time, not a session ID and not a temporary token.

Add email and profile fields

In most apps, you should include email as well:

UserJot.identify(
    userId: "user_123",
    email: "john@example.com"
)

If you already have more profile data, you can include it too:

UserJot.identify(
    userId: "user_123",
    email: "john@example.com",
    firstName: "John",
    lastName: "Doe",
    avatar: "https://example.com/avatar.jpg"
)

When to identify

The normal pattern is:

  • call identify(...) after the app restores or creates an authenticated session
  • call it again if important profile fields change
  • clear the identity when the user logs out

For example:

func handleLogin(user: User) {
    UserJot.identify(
        userId: user.id,
        email: user.email,
        firstName: user.firstName,
        lastName: user.lastName
    )
}

Logging out

Clear the current UserJot identity when the user logs out:

UserJot.logout()

Signed authentication

If you want a stricter trust model, generate a server-side signature and pass it with the identification payload. The signature is an HMAC-SHA256 hash of the user ID, keyed with your Project secret. Copy the secret from the Secrets section on SettingsLogin in your UserJot dashboard.

To require signatures for every identification, turn on Automatic login on that same page, then enable Require signed tokens, which appears once automatic login is on.

UserJot.identify(
    userId: "user_123",
    email: "john@example.com",
    signature: signatureFromYourServer
)

The signature should be generated on your server, not in the app.

Server-side signing examples

import crypto from 'node:crypto';
 
export function signUserJotIdentity(userId, secret) {
  return crypto.createHmac('sha256', secret).update(userId).digest('hex');
}

Use the returned value as the signature argument in UserJot.identify(...).

SwiftUI app pattern

In a SwiftUI app, identification usually happens once your auth state is ready:

@main
struct MyApp: App {
    @StateObject private var authManager = AuthManager()
 
    init() {
        UserJot.setup(projectId: "YOUR_PROJECT_ID")
    }
 
    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear {
                    if let user = authManager.currentUser {
                        UserJot.identify(
                            userId: user.id,
                            email: user.email
                        )
                    }
                }
        }
    }
}

Practical guidance

  • identify the user as early as you safely can after authentication
  • use stable IDs from your own system
  • include email when you have it
  • clear the identity on logout
  • keep signing logic on the server