Module

services/analytics

This service is used to keep track of the different events of our application in a centralised way. The service will depend on external javascript modules, and providers libraries loaded from the HTML template.

This is mandatory, as the analytics libraries must be loaded even before React or any other library.

Involved files

/src
    /static
        /index.ejs              -> Template. We can place the scripts of the analytics providers here to load them on
    /services
        /analytics
            index.js
            analytics.js
    /provider
      /analytics
        /{provider} -> Each provider __must__ export one function as default. It will be added to the analyticsProvider object to iterate over it
          index.js
          {provider}.js

/webpack
    /local
        /dev-config.js

Description /webpack/webpack.common.js This file contains the HtmlWebpackPlugin from webpack that allow us to pass variables to the template (index.ejs) file. i.e Google Tag Manager identifier /src/static/index.ejs EJS Template used by the HtmlWebpackPlugin. We can modify it to include new libraries. This allow us to initialise the analytics libraries before react is initialised /src/services/analytics/analytics.js Analytics service. Load the module and exposed methods to send analytics. We must modify this file to include or remove providers /src/services/analytics/provider/provider.js Analytics providers. They must export one function with the same name than the file (by convention) that sends the event to the provider

Members

# static constant actionClickItem

Track the item click action

# static constant actionClickMenu

Track the menu item click action

# static constant boot

Send the boot event to all the analytic agents

# static constant devicePaired

Set the user into the analytics service and trigger the event actions fo the device pairing

# static constant exit

Send the exit event to all the analytic agents

# static constant favoritesAdd

Track a favourites add action

# static constant favoritesRemove

Track a favourites remove action

# static constant passwordReset

start request for password reset

# static constant passwordResetError

User request a password reset

# static constant passwordResetSuccess

User request a password reset

# static constant playbackEnded

Track the Playback End event

# static constant playbackError

Track the Playback Error event

# static constant playbackFF

Track the Playback Forward event

# static constant playbackHeartbeat

Track the Playback Hearbeat event

# static constant playbackNext

Track the Playback Next event

# static constant playbackPause

Track the Playback pause event

# static constant playbackPlay

Track the Playback play event

# static constant playbackPrev

Track the Playback Prev event

# static constant playbackRequested

Track the Playback play event

# static constant playbackRW

Track the Playback Rewind/Backward event

# static constant playbackSeekComplete

Track the Playback seek (when it starts) event

# static constant playbackSeekStart

Track the Playback seek (when it starts) event

# static constant playbackSelectSubtitle

Track the Playback Select Subtitle event

# static constant playbackStop

Track the Playback Stop event

# static constant screenView

Track the screen view (When a user enter a page)

# static constant startUsage

Send the boot event to all the analytic agents

# static constant stopUsage

Send the boot event to all the analytic agents

# static constant userLoggedInStart

The user start the login process and tried to login into the application

# static constant userLoggedOut

User started loggs out from the app

# static constant userLoggedOutError

Error on loggs out process from the app

# static constant userLoggedOutSuccess

User successfully loggs out from the app

# static constant userLogInError

The login process fails

# static constant userLogInSuccess

The login process succeed

# static constant userSearch

Track a search in the application

# inner constant analyticsProviders

Analytics providers

# inner constant defaultProps

Default Properties to be used in all the events as defined in https://accedobroadband.jira.com/wiki/spaces/VDK/pages/2329674845/Service+Build+Elevate+Analytics+Service#Default-Properties

Methods

# inner sendEvent(event, opts, filter) → {boolean}

Send Event method. This method is a placeholder to call the different 'native' lib methods to trigger the analytics. It iterates over all the providers on the analyticsProviders object, filters the desired providers (if any) and call the function with the object containing the event and the payload

Parameters:
Name Type Description
event string

Event name. Needed in most of the libraries

opts object

Event options. We can

filter Array.<string>

If present, it only send the events to the desired analytic providers. i.e ['gtm', 'mux']

true if everything is ok, false if not

boolean