Skip to content

Bind a session to a real end-user identity (userId on session creation) #36

Description

@zoharbabin

Why

Every session token minted by the SDK today is anonymous. That's the root blocker for anything per-user: no real per-user memory, no way to attribute a graded answer or a completed interaction to a specific learner, no user identity in analytics. Confirmed live: the reserved sys__user_id template variable resolves to an empty string on every session tested today, regardless of how the session was created.

What

Add an optional userId parameter to Sessions.createAdminToken() and Sessions.createConversationToken() (src/core/session.js), threaded through into the underlying Kaltura session-mint call the same way partnerId already is.

How

  • Kaltura's own session-start API already supports binding a minted session to a real end-user identity — the SDK's current mint call simply never passes that field. This is a client-side, parameter-passing fix; no backend change is required.
  • Add userId to the options object accepted by both methods and thread it into the existing mint request body.
  • Per SDK_CONSTITUTION.md (no shared mutable state across calls): the value must flow as a per-call/per-instance parameter, never cached in shared module-level state.
  • Document the new parameter with JSDoc on both methods, and add a worked example to GETTING-STARTED.md / API-REFERENCE.md.

Success criteria

  • A session created with userId: 'learner-123' makes sys__user_id resolve to 'learner-123' in a live previewPrompt() / converse() call.
  • Existing anonymous-session callers see zero behavior change (the parameter is optional).
  • JSDoc + a runnable example ship in the same PR.

Where it lives

Core — ./management. Every session-creating integration already calls these two methods; there's no population that would opt out of this.

Priority / Labels

Critical. Unlocks real per-user memory, reliable analytics attribution recipes, and the full resolution of the sys__user_obj.* reserved variables (tracked separately — see the reserved-variables issue and the tracking issue for this roadmap).


Unblocks the full resolution of #37 (sys__user_obj.*). Part of #46.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dxDeveloper experience: docs, ergonomics, discoverabilityenhancementNew feature or requestpriority:criticalBlocks other critical work or is a live bug/security gaproadmapTracked as part of the SDK capability roadmapsecuritySecurity-relevant: identity, credentials, data exposure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions