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

# Eventos do Tracer

> Consulte todos os fatos de evento JSON públicos emitidos pelo componente Tracer no Midaz, incluindo headers do CloudEvents, tópicos da aplicação, comportamento de entrega e contratos completos de dados.

O Tracer emite seus fatos de negócio JSON públicos como **CloudEvents 1.0** no modo de conteúdo binário pelo Kafka. O Tracer é o componente do Midaz com deploy separado e o único produtor do contrato `studio.lerian.tracer.*` desta página.

## Envelope do CloudEvents

Todo fato JSON público usa o envelope compartilhado abaixo. Os headers carregam informações de roteamento e schema. O valor do Kafka carrega o objeto JSON `data`.

| Header | Presença e valor |
| - | - |
| `ce-specversion` | Sempre `1.0`. |
| `ce-id` | Sempre; identificador de evento opaco definido pelo produtor. |
| `ce-source` | Sempre `tracer`. |
| `ce-type` | Sempre `studio.lerian.tracer.<resource>.<event>`. |
| `ce-time` | Sempre; timestamp de emissão em RFC 3339. |
| `ce-resourcetype` | Sempre; o token de recurso da chave de definição. |
| `ce-eventtype` | Sempre; o token de evento da chave de definição. |
| `ce-subject` | Sempre `p.ID` para esses 12 contratos. |
| `ce-tenantid` | **Sempre presente.** O seu ID de tenant, ou o literal `default` quando o evento não tem tenant. |
| `ce-schemaversion` | `1.2.0` para `limit.created` e `limit.updated`. `1.1.0` para `rule.created` e `rule.updated`. `1.0.0` para os outros 8 fatos JSON públicos. |
| `ce-datacontenttype` | `application/json`. |

## Tópicos, manifesto e roteamento

O tópico da aplicação identifica o Midaz Tracer, não um evento individual. Roteie um registro por `ce-resourcetype` e `ce-eventtype`, e valide `ce-schemaversion` antes de decodificar seu valor `data`.

* **Fatos:** `lerian.streaming.tracer`
* **Rota DLQ:** `lerian.streaming.tracer.dlq`
* **Manifesto:** `GET /v1/streaming/manifest` expõe o catálogo JSON público e o mapeamento de tópicos, inclusive enquanto a publicação está desligada.

## Semântica de entrega e falha

A publicação fica desabilitada até que `STREAMING_ENABLED=true` e a configuração do broker seja bem-sucedida. Quando habilitado, o Tracer emite depois da mudança de estado de negócio. Ele não usa um outbox transacional.

* **Política:** toda definição JSON pública é um `fact` com entrega direta, tratamento de DLQ por `on_routable_failure` e `fallback_on_circuit_open`.
* **Limite real do Tracer:** como o Tracer não tem outbox, o fallback de circuito aberto não consegue persistir um evento. Os caminhos de emissão registram em log e engolem os erros de publicação em vez de retorná-los ao comando de negócio.
* **Requisito do consumidor:** a entrega do broker é pelo menos uma vez para os registros publicados. Torne os handlers idempotentes e faça deduplicação com `(ce-source, ce-id)`.

## Contratos `data` completos

Essas declarações no estilo TypeScript espelham as tags JSON `data` do CloudEvent no Midaz. Cada nome de campo é o seu nome JSON. `?` significa que o campo tem `omitempty`. `| null` significa que o campo é anulável e nunca está ausente. Um comentário de tipo de origem preserva o tipo do inventário exatamente. Todos os campos nesses 12 payloads do Tracer estão presentes (`omitempty: false`), exceto `scheme` em um objeto de escopo, que o Tracer omite quando o escopo não indica esquema. Campos anuláveis ainda carregam `null` quando ausentes.

> [accordion] limit.activated
>
> **Chave de definição:** `limit.activated` (`LimitActivatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.activated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `ActivateLimitCommand` ativa um limite com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // limit.activated
> type LimitActivatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] limit.created
>
> **Chave de definição:** `limit.created` (`LimitCreatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.created`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.2.0` (`application/json`)
>
> **Disparado quando:** `CreateLimitCommand` cria um limite com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> type RuleScopePayload = { // Go: RuleScopePayload
>   segmentId: string | null // *string; wire null: true; omitempty: false
>   portfolioId: string | null // *string; wire null: true; omitempty: false
>   accountId: string | null // *string; wire null: true; omitempty: false
>   merchantId: string | null // *string; wire null: true; omitempty: false
>   transactionType: string | null // *string; wire null: true; omitempty: false
>   scheme?: string // *string; wire null: false; omitempty: true
>   subType: string | null // *string; wire null: true; omitempty: false
> }
>
> // limit.created
> type LimitCreatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   limitType: string // string; wire null: false; omitempty: false
>   asset: string // string; wire null: false; omitempty: false
>   scopes: RuleScopePayload[] // []RuleScopePayload; wire null: false; omitempty: false
>   activeTimeStart: string | null // *string; wire null: true; omitempty: false
>   activeTimeEnd: string | null // *string; wire null: true; omitempty: false
>   customStartDate: string | null // *string; wire null: true; omitempty: false
>   customEndDate: string | null // *string; wire null: true; omitempty: false
>   resetTime: string | null // *string; wire null: true; omitempty: false
>   resetAt: string | null // *string; wire null: true; omitempty: false
>   createdAt: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] limit.deactivated
>
> **Chave de definição:** `limit.deactivated` (`LimitDeactivatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.deactivated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DeactivateLimitCommand` desativa um limite com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // limit.deactivated
> type LimitDeactivatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] limit.deleted
>
> **Chave de definição:** `limit.deleted` (`LimitDeletedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.deleted`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DeleteLimitCommand` exclui um limite com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // limit.deleted
> type LimitDeletedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   deletedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] limit.drafted
>
> **Chave de definição:** `limit.drafted` (`LimitDraftedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.drafted`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DraftLimitCommand` move um limite para DRAFT com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // limit.drafted
> type LimitDraftedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] limit.updated
>
> **Chave de definição:** `limit.updated` (`LimitUpdatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.limit.updated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.2.0` (`application/json`)
>
> **Disparado quando:** `UpdateLimitCommand` atualiza um limite com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> type RuleScopePayload = { // Go: RuleScopePayload
>   segmentId: string | null // *string; wire null: true; omitempty: false
>   portfolioId: string | null // *string; wire null: true; omitempty: false
>   accountId: string | null // *string; wire null: true; omitempty: false
>   merchantId: string | null // *string; wire null: true; omitempty: false
>   transactionType: string | null // *string; wire null: true; omitempty: false
>   scheme?: string // *string; wire null: false; omitempty: true
>   subType: string | null // *string; wire null: true; omitempty: false
> }
>
> // limit.updated
> type LimitUpdatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   limitType: string // string; wire null: false; omitempty: false
>   asset: string // string; wire null: false; omitempty: false
>   scopes: RuleScopePayload[] // []RuleScopePayload; wire null: false; omitempty: false
>   activeTimeStart: string | null // *string; wire null: true; omitempty: false
>   activeTimeEnd: string | null // *string; wire null: true; omitempty: false
>   customStartDate: string | null // *string; wire null: true; omitempty: false
>   customEndDate: string | null // *string; wire null: true; omitempty: false
>   resetTime: string | null // *string; wire null: true; omitempty: false
>   resetAt: string | null // *string; wire null: true; omitempty: false
>   createdAt: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.activated
>
> **Chave de definição:** `rule.activated` (`RuleActivatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.activated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `ActivateRuleService` ativa uma regra com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // rule.activated
> type RuleActivatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   activatedAt: string | null // *string; wire null: true; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.created
>
> **Chave de definição:** `rule.created` (`RuleCreatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.created`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.1.0` (`application/json`)
>
> **Disparado quando:** `CreateRuleCommand` cria uma regra com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> type RuleScopePayload = { // Go: RuleScopePayload
>   segmentId: string | null // *string; wire null: true; omitempty: false
>   portfolioId: string | null // *string; wire null: true; omitempty: false
>   accountId: string | null // *string; wire null: true; omitempty: false
>   merchantId: string | null // *string; wire null: true; omitempty: false
>   transactionType: string | null // *string; wire null: true; omitempty: false
>   scheme?: string // *string; wire null: false; omitempty: true
>   subType: string | null // *string; wire null: true; omitempty: false
> }
>
> // rule.created
> type RuleCreatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   action: string // string; wire null: false; omitempty: false
>   scopes: RuleScopePayload[] // []RuleScopePayload; wire null: false; omitempty: false
>   createdAt: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.deactivated
>
> **Chave de definição:** `rule.deactivated` (`RuleDeactivatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.deactivated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DeactivateRuleService` desativa uma regra com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // rule.deactivated
> type RuleDeactivatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   deactivatedAt: string | null // *string; wire null: true; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.deleted
>
> **Chave de definição:** `rule.deleted` (`RuleDeletedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.deleted`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DeleteRuleService` exclui uma regra com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // rule.deleted
> type RuleDeletedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   deletedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.drafted
>
> **Chave de definição:** `rule.drafted` (`RuleDraftedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.drafted`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.0.0` (`application/json`)
>
> **Disparado quando:** `DraftRuleService` move uma regra para DRAFT com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> // rule.drafted
> type RuleDraftedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

> [accordion] rule.updated
>
> **Chave de definição:** `rule.updated` (`RuleUpdatedDefinition`)
>
> **Evento:** `studio.lerian.tracer.rule.updated`
>
> **Tópico:** `lerian.streaming.tracer`
>
> **Rota DLQ:** `lerian.streaming.tracer.dlq`
>
> **Schema:** `1.1.0` (`application/json`)
>
> **Disparado quando:** `UpdateRuleCommand` atualiza uma regra com sucesso.
>
> **Subject:** `p.ID`
>
> ```typescript theme={null}
> type RuleScopePayload = { // Go: RuleScopePayload
>   segmentId: string | null // *string; wire null: true; omitempty: false
>   portfolioId: string | null // *string; wire null: true; omitempty: false
>   accountId: string | null // *string; wire null: true; omitempty: false
>   merchantId: string | null // *string; wire null: true; omitempty: false
>   transactionType: string | null // *string; wire null: true; omitempty: false
>   scheme?: string // *string; wire null: false; omitempty: true
>   subType: string | null // *string; wire null: true; omitempty: false
> }
>
> // rule.updated
> type RuleUpdatedDataV1 = {
>   id: string // string; wire null: false; omitempty: false
>   status: string // string; wire null: false; omitempty: false
>   action: string // string; wire null: false; omitempty: false
>   scopes: RuleScopePayload[] // []RuleScopePayload; wire null: false; omitempty: false
>   createdAt: string // string; wire null: false; omitempty: false
>   updatedAt: string // string; wire null: false; omitempty: false
> }
> ```

## Índice de eventos emitidos

| Chave de definição | `ce-type` | Schema | Subject | Disparado quando |
| - | - | - | - | - |
| `limit.activated` | `studio.lerian.tracer.limit.activated` | `1.0.0` | `p.ID` | `ActivateLimitCommand` ativa um limite com sucesso. |
| `limit.created` | `studio.lerian.tracer.limit.created` | `1.2.0` | `p.ID` | `CreateLimitCommand` cria um limite com sucesso. |
| `limit.deactivated` | `studio.lerian.tracer.limit.deactivated` | `1.0.0` | `p.ID` | `DeactivateLimitCommand` desativa um limite com sucesso. |
| `limit.deleted` | `studio.lerian.tracer.limit.deleted` | `1.0.0` | `p.ID` | `DeleteLimitCommand` exclui um limite com sucesso. |
| `limit.drafted` | `studio.lerian.tracer.limit.drafted` | `1.0.0` | `p.ID` | `DraftLimitCommand` move um limite para DRAFT com sucesso. |
| `limit.updated` | `studio.lerian.tracer.limit.updated` | `1.2.0` | `p.ID` | `UpdateLimitCommand` atualiza um limite com sucesso. |
| `rule.activated` | `studio.lerian.tracer.rule.activated` | `1.0.0` | `p.ID` | `ActivateRuleService` ativa uma regra com sucesso. |
| `rule.created` | `studio.lerian.tracer.rule.created` | `1.1.0` | `p.ID` | `CreateRuleCommand` cria uma regra com sucesso. |
| `rule.deactivated` | `studio.lerian.tracer.rule.deactivated` | `1.0.0` | `p.ID` | `DeactivateRuleService` desativa uma regra com sucesso. |
| `rule.deleted` | `studio.lerian.tracer.rule.deleted` | `1.0.0` | `p.ID` | `DeleteRuleService` exclui uma regra com sucesso. |
| `rule.drafted` | `studio.lerian.tracer.rule.drafted` | `1.0.0` | `p.ID` | `DraftRuleService` move uma regra para DRAFT com sucesso. |
| `rule.updated` | `studio.lerian.tracer.rule.updated` | `1.1.0` | `p.ID` | `UpdateRuleCommand` atualiza uma regra com sucesso. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.