Tayori.Views (Tayori v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

The places an entry can be read.

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).

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

Functions

by_day(entry_id, since)

@spec by_day(Ecto.UUID.t(), Date.t()) :: [
  {Date.t(), %{required(String.t()) => 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()

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

The places an entry can be read.

totals(entry_ids)

@spec totals([Ecto.UUID.t()]) :: %{
  required(Ecto.UUID.t()) => %{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(reader, entry_id, source)

@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.