Options
All
  • Public
  • Public/Protected
  • All
Menu

Track (gauge) a user's engagement with a web page.

Hierarchy

  • Engauge

Index

Constructors

  • Initialize the activity states with the app configuration.

    Parameters

    • config: Config = {}

      Configuration settings for the brief/long activity categories.

    Returns Engauge

Properties

_connected: Map<Function, Function> = ...

The connected callbacks to report payloads to.

_current_state: undefined | "engaged" | "idle" | "off_page"

The current state the user is in.

_idle_timer_id: undefined | number

The timer ID for the current idle timer (used to clear the timer when the user goes active).

_initialized: boolean = false

Flag indicating if the event listeners have been initialized or not.

_log: ILogger

A configurable logger.

_metrics: Report = ...

The summed times the user has been in each state (categorized).

_monitoring: boolean = false

Flag indicating if monitoring is currently on or off.

_registered_videos: HTMLIFrameElement[] = []

An array of the videos that have had their events registered already. Currently, only Vimeo videos are registered, and the iframe src must start with https://player.vimeo.com.

_report_timer_id: undefined | number

The ID for the currently active report timer.

_timer: Timer = ...

A stopwatch-like timer.

idle_brief_timeout: number

How long (ms) the user must be inactive before being considered idle. Defaults to 2 minutes.

idle_long_timeout: number

How long (ms) the user can be idle before being considered off-page. Defaults to 15 minutes.

off_page_long_timeout: number

How long (ms) the user must be off-page while before being considered away for a long time. Defaults to 15 minutes.

report_timeout: number

The length of time (ms) between reports. Defaults to 10 seconds.

track_full_trace: boolean

Should the full trace be reported along with the summary metrics? Defaults to false.

Accessors

  • Get the summary metrics for the user's activity.

    Returns Report

    All report metrics except the full trace.

  • get state(): undefined | "engaged" | "idle" | "off_page"
  • The current state the user is in, see {@link _states _states}.

    Returns undefined | "engaged" | "idle" | "off_page"

Methods

  • connect(callback: (payload?: Report) => void): void
  • Connect a callback that will be called on every report with the report information.

    Parameters

    • callback: (payload?: Report) => void
        • Parameters

          Returns void

    Returns void

  • disconnect(callback: (payload?: Report) => void): void
  • Disconnect a callback from the reporting cycle.

    Parameters

    • callback: (payload?: Report) => void

      The same callback that was initially connected.

        • Parameters

          Returns void

    Returns void

  • mark_engagement(): void
  • Mark the user as active / engaged and record the current time.

    Returns void

  • mark_off_page(): void
  • Mark the user off page and record the current time.

    Returns void

  • monitor(): void
  • Monitor the user's activity, triggering an active state when they engage with the page and various types of idle states depending on their inactivity. See the Report type for the different metrics being monitored.

    Returns void

  • record_time_to(record: Report): void
  • Record the current timer time to the appropriate key in the given record.

    Parameters

    • record: Report

      The report object to record the time to.

    Returns void

  • register_videos(): void
  • Find and register videos, and hook into their events.

    Returns void

  • report(event?: Event): void
  • Report the user's activity statistics for the session.

    Parameters

    • Optional event: Event

      The event that triggered the report, if any.

    Returns void

  • set_state(state: "engaged" | "idle" | "off_page"): void
  • Parameters

    • state: "engaged" | "idle" | "off_page"

    Returns void

  • Signal with the report payload to the connected callbacks.

    Parameters

    Returns void

  • Log the user's activity in the full trace.

    Parameters

    • state: TraceName

      The state the user is moving to.

    Returns void

  • unmonitor(): void
  • Log the current time, then prevent any additional monitoring or reporting.

    Returns void

Generated using TypeDoc