# `Electric.LsnTracker`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/lsn_tracker.ex#L1)

# `stack_ref`

```elixir
@type stack_ref() :: Electric.stack_id() | atom()
```

# `broadcast_last_seen_lsn`

```elixir
@spec broadcast_last_seen_lsn(
  stack_ref(),
  Electric.Postgres.Lsn.t() | non_neg_integer()
) :: :ok
```

# `get_last_broadcast_lsn`

```elixir
@spec get_last_broadcast_lsn(stack_ref()) :: non_neg_integer()
```

Returns the most recently broadcast LSN, or 0 if none has been broadcast yet.

# `get_last_processed_lsn`

```elixir
@spec get_last_processed_lsn(stack_ref()) :: Electric.Postgres.Lsn.t() | nil
```

# `initialize`

```elixir
@spec initialize(stack_ref()) :: :ok
```

# `initialize_last_processed_lsn`

```elixir
@spec initialize_last_processed_lsn(stack_ref(), Electric.Postgres.Lsn.t()) :: :ok
```

# `set_last_processed_lsn`

```elixir
@spec set_last_processed_lsn(
  stack_ref(),
  Electric.Postgres.Lsn.t() | non_neg_integer()
) :: :ok
```

# `stack_ref`

```elixir
@spec stack_ref(Electric.stack_id()) :: atom()
```

Returns the ETS table name used to store LSN info for the given stack ID.

# `subscribe_to_global_lsn_updates`

```elixir
@spec subscribe_to_global_lsn_updates(stack_ref(), term()) ::
  {:ok, pid()} | {:error, term()}
```

# `unsubscribe_from_global_lsn_updates`

```elixir
@spec unsubscribe_from_global_lsn_updates(stack_ref()) :: :ok
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
