View Source SauceAnalytics.Store (sauce_analytics v0.1.2)

ETS store for tracking view and event sequence per user session.

options

Options

  • :table_name - The name of the table that the ETS will use. Defaults to :sauce_analytic_session_table
  • :session_max_age - The number of seconds before a session in the Store is considered expired. Defaults to 3600 (1 hour)
  • :clean_interval - The number of seconds that specify the period of time between each clean up of expired sessions. Defaults to 5400 (1.5 hours)

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Returns true if an entry associated with the given session_id in the Store, false otherwise.

Returns the state/configuration of the SauceAnalytics.Store GenServer.

Increments view_sequence or event_sequence on a session in the Store.

Returns an entry in the Store.

If an entry with the given session ID does not exist in the store, a new entry is created.

Creates a new entry in the Store.

Starts the Store GenServer with the given opts.

Link to this section Types

@type entry() ::
  {session_id :: reference(), view_sequence :: integer(),
   event_sequence :: integer(), last_modified :: integer()}
@type opts() ::
  {:table_name, atom()}
  | {:session_max_age, integer()}
  | {:clean_interval, integer()}

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

entry_exists?(session_id)

View Source
@spec entry_exists?(session_id :: reference()) :: boolean()

Returns true if an entry associated with the given session_id in the Store, false otherwise.

@spec get_state() :: SauceAnalytics.Store.State.t()

Returns the state/configuration of the SauceAnalytics.Store GenServer.

Link to this function

inc_sequence(session_id, type)

View Source
@spec inc_sequence(session_id :: reference(), type :: :view | :event) ::
  :ok | {:error, :not_found}

Increments view_sequence or event_sequence on a session in the Store.

type can either be :view or :event

Link to this function

lookup_entry(session_id)

View Source
@spec lookup_entry(session_id :: reference()) ::
  {:ok, SauceAnalytics.Store.Entry.t()} | {:error, :not_found}

Returns an entry in the Store.

Link to this function

maybe_restore_entry(session_id)

View Source
@spec maybe_restore_entry(session_id :: reference()) ::
  SauceAnalytics.Store.Entry.t() | nil

If an entry with the given session ID does not exist in the store, a new entry is created.

@spec new_entry(session_id :: reference()) :: {:ok, SauceAnalytics.Store.Entry.t()}

Creates a new entry in the Store.

@spec start_link([opts()]) :: GenServer.on_start()

Starts the Store GenServer with the given opts.

Use this in your application supervision tree.