groups:
  - id: event.session.start
    stability: development
    type: event
    name: session.start
    brief: >
      Indicates that a new session has been started, optionally linking to the prior session.
    note: >
      For instrumentation that tracks user behavior during user sessions, a `session.start` event MUST be emitted
      every time a session is created. When a new session is created as a continuation of a prior session,
      the `session.previous_id` SHOULD be included in the event. The values of `session.id` and `session.previous_id`
      MUST be different.

      When the `session.start` event contains both `session.id` and `session.previous_id` fields, the event indicates
      that the previous session has ended. If the session ID in `session.previous_id` has not yet ended via explicit
      `session.end` event, then the consumer SHOULD treat this continuation event as semantically equivalent to
      `session.end(session.previous_id)` and `session.start(session.id)`.
    attributes:
      - ref: session.id
        requirement_level: required
        brief: The ID of the new session being started.
      - ref: session.previous_id
        requirement_level:
          conditionally_required: >
            If the new session is being created as a continuation of a previous session,
            the `session.previous_id` SHOULD be included in the event. The `session.id` and `session.previous_id`
            attributes MUST have different values.
        brief: The previous `session.id` for this user, when known.
  - id: event.session.end
    stability: development
    type: event
    name: session.end
    brief: >
      Indicates that a session has ended.
    note: >
      For instrumentation that tracks user behavior during user sessions, a `session.end` event SHOULD be emitted
      every time a session ends. When a session ends and continues as a new session, this event SHOULD be
      emitted prior to the `session.start` event.
    attributes:
      - ref: session.id
        requirement_level: required
        brief: The ID of the session being ended.
