# context

Python API: `luxonis_ml.telemetry.context`

## Functions

### base_context

```python
def base_context(*, library_name: str, library_version: str | None, session_id: str, source_component: str | None) -> dict[str, Any]:
```

Create base context for all events.

> **Note**
> `$process_person_profile` is False on purpose. It keeps the PostHog captures anonymous, so PostHog creates no person profile. Do not change it to True.

Parameters

 * `library_name` (`str`): Name of the emitting library.
 * `library_version` (`str | None`): Version string for the library.
 * `session_id` (`str`): Random session ID. It stays the same for the lifetime of one
   [luxonis_ml.telemetry.Telemetry](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/telemetry/client.md)
   instance, not for the lifetime of the process. The PostHog backend also uses it as the default `distinct_id`.
 * `source_component` (`str | None`): Optional component name for the emitter. If omitted, the library name is reused.

Returns

 * `dict[str, Any]`: The shared base context attached to events. It holds `$process_person_profile`, `$session_id`,
   `source_product`, `source_component`, and `sdk_version`.

### host_context

```python
def host_context() -> dict[str, Any]:
```

Return coarse host metadata for optional event context.

Returns

 * `dict[str, Any]`: A mapping of `os`, `os_version`, `arch`, and `python_version`.

### host_context_provider

```python
def host_context_provider(_telemetry: object) -> dict[str, Any]:
```

Context provider that exposes coarse host metadata.

### is_ci

```python
def is_ci() -> bool:
```

Best-effort detection of CI environments.

### is_luxonis_cloud

```python
def is_luxonis_cloud() -> bool:
```

Return True when telemetry runs inside the Luxonis cloud.

### normalized_processor

```python
def normalized_processor() -> str:
```

Return a coarse processor family for telemetry.

The raw `platform.processor` string never leaves the machine.
[host_context](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/telemetry/context.md)
still sends the `platform.machine` value as `arch`.

Returns

 * `str`: One of `"arm64"`, `"arm"`, `"x86_64"`, `"x86"`, `"powerpc"`, `"riscv"`, or `"unknown"`.

### system_context

```python
def system_context() -> dict[str, Any]:
```

Return extended runtime metadata for optional event context.

Returns

 * `dict[str, Any]`: The keys of
   [host_context](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/telemetry/context.md),
   plus `ci`, `is_luxonis_cloud`, `processor` (a coarse family from
   [normalized_processor](https://docs.luxonis.com/software-v3/ai-inference/model-source/training/luxonis-ml/luxonis-ml-api-reference/telemetry/context.md)),
   `cpu_count`, and `is_docker`.

### system_context_provider

```python
def system_context_provider(_telemetry: object) -> dict[str, Any]:
```

Context provider that exposes extended runtime metadata.

## Attributes

### RESERVED_METADATA_KEYS
