# `Tayori.Views`
[🔗](https://github.com/hattoriai/tayori/blob/v0.1.0/lib/tayori/views.ex#L1)

The views of the entries, by day and by where they were read: the
`:analytics` feature.

A reader's views are counted under their id; a visitor's under no one,
with the other visitors of the day. Nothing else is kept: no address, no
device, no cookie.

The sources are `"panel"` (the app's news panel), `"page"` (the public
page), `"widget"` (`<tayori-news>`) and `"email"` (a link of an email).
A feed is not counted: a feed reader fetches it whether or not anyone
reads it.

# `by_day`

```elixir
@spec by_day(Ecto.UUID.t(), Date.t()) :: [
  {Date.t(), %{required(String.t()) =&gt; integer()}}
]
```

An entry's views by day and by source, since a day: a list of
`{date, %{source => n}}`, the oldest first, with every day.

# `sources`

```elixir
@spec sources() :: [String.t()]
```

The places an entry can be read.

# `totals`

```elixir
@spec totals([Ecto.UUID.t()]) :: %{
  required(Ecto.UUID.t()) =&gt; %{views: integer(), readers: integer()}
}
```

The views and readers of each entry, `%{entry_id => %{views: n, readers: n}}`:
every view, and the readers who viewed it at least once (visitors not
counted).

# `track`

```elixir
@spec track(Tayori.Reader.t() | nil, Ecto.UUID.t(), String.t()) :: :ok
```

Counts a view of an entry by a reader, from a source. Does nothing when
the `:analytics` feature is off.

---

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