> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Session

> Session functionality for Components integration.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/logger/components/session.py)

## [SessionConfig](/sdk/python/references/logger/components/session)

```python theme={null}
@deprecated(
    "This class will be removed in a future version. Use {} which is TypedDict."
)

@dataclass
class SessionConfig()
```

[Session](/sdk/python/references/logger/components/session) config.

This class represents a session config.

## [SessionConfigDict](/sdk/python/references/logger/components/session)

```python theme={null}
class SessionConfigDict(TypedDict)
```

[Session](/sdk/python/references/logger/components/session) config dict.

This class represents a session config dictionary.

#### get\_session\_config\_dict

```python theme={null}
def get_session_config_dict(
        config: Union[SessionConfig, SessionConfigDict]) -> dict[str, Any]
```

Convert a session config to a session config dict else return the config.

**Arguments**:

| Name     | Description            |
| -------- | ---------------------- |
| `config` | The config to convert. |

**Returns**:

dict\[str, Any]: The session config dict.

## [Session](/sdk/python/references/logger/components/session)

```python theme={null}
class Session(EventEmittingBaseContainer)
```

A session is a collection of traces.

A session is created when a new session is started.

A session is ended when the session is stopped.

#### \_\_init\_\_

```python theme={null}
def __init__(config: Union[SessionConfig, SessionConfigDict],
             writer: LogWriter)
```

Create a new session.

**Arguments**:

| Name     | Description                        |
| -------- | ---------------------------------- |
| `config` | The configuration for the session. |

#### trace

```python theme={null}
def trace(config: Union[TraceConfig, TraceConfigDict]) -> Trace
```

Create a new trace for this session.

**Arguments**:

| Name     | Description                      |
| -------- | -------------------------------- |
| `config` | The configuration for the trace. |

**Returns**:

A new [Trace](/sdk/python/references/logger/components/trace) instance.

#### trace\_

```python theme={null}
@staticmethod
def trace_(writer: LogWriter, session_id: str,
           config: Union[TraceConfig, TraceConfigDict]) -> Trace
```

Create a new trace for this session.

**Arguments**:

| Name         | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `writer`     | The [LogWriter](/sdk/python/references/logger/writer) instance to use. |
| `session_id` | The ID of the session to create the trace for.                         |
| `config`     | The configuration for the trace.                                       |

**Returns**:

A new [Trace](/sdk/python/references/logger/components/trace) instance.

#### feedback

```python theme={null}
def feedback(feedback: Union[Feedback, FeedbackDict])
```

Add feedback to this session.

**Arguments**:

| Name       | Description          |
| ---------- | -------------------- |
| `feedback` | The feedback to add. |

#### add\_attachment

```python theme={null}
def add_attachment(attachment: Union[FileAttachment, FileDataAttachment,
                                     UrlAttachment])
```

Add an attachment to this session.

**Arguments**:

| Name         | Description            |
| ------------ | ---------------------- |
| `attachment` | The attachment to add. |

#### add\_attachment\_

```python theme={null}
@staticmethod
def add_attachment_(writer: LogWriter, session_id: str,
                    attachment: Union[FileAttachment, FileDataAttachment,
                                      UrlAttachment])
```

Add an attachment to this session.

**Arguments**:

| Name         | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `writer`     | The [LogWriter](/sdk/python/references/logger/writer) instance to use. |
| `session_id` | The ID of the session to add the attachment to.                        |
| `attachment` | The attachment to add.                                                 |

#### add\_tag\_

```python theme={null}
@staticmethod
def add_tag_(writer: LogWriter, session_id: str, key: str, value: str)
```

Add a tag to this session.

**Arguments**:

| Name         | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `writer`     | The [LogWriter](/sdk/python/references/logger/writer) instance to use. |
| `session_id` | The ID of the session to add the tag to.                               |
| `key`        | The tag key.                                                           |
| `value`      | The tag value.                                                         |

#### end\_

```python theme={null}
@staticmethod
def end_(writer: LogWriter,
         session_id: str,
         data: Optional[Dict[str, Any]] = None)
```

End this session.

**Arguments**:

| Name         | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `writer`     | The [LogWriter](/sdk/python/references/logger/writer) instance to use. |
| `session_id` | The ID of the session to end.                                          |
| `data`       | Optional data to add to the session.                                   |

#### event\_

```python theme={null}
@staticmethod
def event_(writer: LogWriter, session_id: str, id: str, event: str,
           data: Dict[str, str])
```

Add an event to this session.

**Arguments**:

| Name         | Description                                                            |
| ------------ | ---------------------------------------------------------------------- |
| `writer`     | The [LogWriter](/sdk/python/references/logger/writer) instance to use. |
| `session_id` | The ID of the session to add the event to.                             |
| `id`         | The ID of the event.                                                   |
| `event`      | The event.                                                             |
| `data`       | Optional data to add to the event.                                     |
