NavigationHistory.Tracker (navigation_history v0.4.1)

View Source

A plug to track user navigation history.

Visited paths will be stored in the session by the plug. The paths can then be accessed with NavigationHistory.last_path and NavigationHistory.last_paths.

The session must already be fetched with Plug.Conn.fetch_session/1.

Options

  • :excluded_paths - The list of paths which should not be tracked. For example, /login or similar for a lot of apps. Defaults to []
  • :included_paths - Limits list the paths to be tracked when set. :excluded_paths is ignored if set.
  • :methods - The list methods which should be tracked. Defaults to ["GET"]
  • :history_size - The number of history entries to track in last_paths. Defaults to 10.
  • :key - The key used to track the navigation. It can also be passed to :last_path and :last_paths to retrieve the paths for the relevant key. Defaults to "default".
  • :accept_duplicates - By default, if the same URL is repeated, it is ignored, unless this option is set to true. Defaults to false.

Examples

plug NavigationHistory.Tracker, excluded_paths: ["/login", ~r(/admin.*)], history_size: 5

Summary

Functions

Callback implementation for Plug.call/2.

Callback implementation for Plug.init/1.

Functions

call(conn, opts)

Callback implementation for Plug.call/2.

init(opts)

Callback implementation for Plug.init/1.

track_history(conn, opts \\ [])