4.1.0 • Published 2 months ago

@availity/analytics-core v4.1.0

Weekly downloads
16
License
MIT
Repository
github
Last release
2 months ago

Analytics Core

A package providing a base Analytics class to track events and page views

Install

npm install @availity/analytics-core

Configuration

AvAnalytics requires Plugins and a Promise lib.

  new AvAnalytics(plugins, promise);

AvAnalytics also has an optional 3rd parameter, a boolean to determine if pageTracking is enabled. For page tracking to be used, startPageTracking and stopPageTracking functions must be defined to create listeners and call trackPageView. AvAnalytics also has an optional 4th parameter, "autoTrack", a boolean which default to true. When true, "autoTrack" will be enabled which will automatically log

  new AvAnalytics(plugins, promise, pageTracking, autoTrack);

Plugins

Plugins can be one or an array of objects/classes:

A default class with functions defined and enabled logic is provided AvAnalyticsPlugin.

import {AvAnalyticsPlugin} from '@availity/analytics-core';

Plugin Methods

the functions/properties used by AvAnalytics are:

isEnabled

Determines if this plugin will be called at various points. If this is a function, the return value will be used. Otherwise will be checked as boolean.

init

if defined, will be called when AvAnalytics is initialized.

trackEvent

if defined, called when AvAnalytics receives a trackEvent call.

trackPageView

if defined, called when AvAnalytics receives a trackPageView call.

Defined Plugins

AvSplunkAnalytics

AvSplunkAnalytics is a plugin to track events with the AvLogMessages api. It defaults the url and level before sending.

import {AvSplunkAnalytics} from '@availity/analytics-core';

const exmpleSplunkAnalytics = new AvSplunkAnalytics(AvLogMessages, isEnabled);

Methods

init()

Initialize analytics pageTracking and plugins

setPageTracking(value)

use parameter to set turn page tracking on/off. Always checks that pageTracking has been set up or torn down as needed.

trackEvent(properties)

Send properties to each plugins trackEvent function.

trackPageView(url)

Send url or location.href to each plugins trackEvent function.

AutoTrack Logged events

With "autoTrack" enabled (enabled by default) you can add special data-analytics-* to any element which will be rendered to the DOM. For native form elements (input, select, and textarea) with the special attribute, focus and blur events will trigger analytics to be logged. For all other element with the special attribute, click events will trigger analytics to be logged. You can have as many of the data-analytics-* attributes on an element as you which, all of the properties will be logged with the data-analytics- prefix removed and the remaining camelcased as the key and the value of the attribute as the logged value. This works with all libraries such as angular, react, jquery, and pure HTML.

  <a
    href="/some-place-cool"
    data-analytics-variation="b"
    data-analytics-organization-id={orgId}
    data-analytics-page-num={currentPage}>
    Go there now!
  </a>
  import { Input } from 'reactstrap';
  //...
  <Input
    data-analytics-variation="b"
    data-analytics-organization-id={orgId} />

Authors

Kasey Powers

License

MIT

4.1.0

2 months ago

4.0.5

3 months ago

1.0.0

9 months ago

4.0.4

9 months ago

4.0.3

2 years ago

4.0.2

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

3.1.8

2 years ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.1.4

2 years ago

3.1.3

3 years ago

3.1.2

3 years ago

3.1.1

3 years ago

3.1.0

3 years ago

2.8.24-alpha.21

3 years ago

3.0.0

3 years ago

2.8.24-alpha.3

4 years ago

2.8.24-alpha.4

4 years ago

2.8.23

4 years ago

2.8.22

4 years ago

2.8.21

4 years ago

2.8.20

4 years ago

2.8.19

4 years ago

2.8.18

4 years ago

2.8.17

4 years ago

2.8.16

4 years ago

2.8.15

4 years ago

2.8.14

4 years ago

2.8.11

4 years ago

2.8.9

4 years ago

2.8.6

4 years ago

2.8.5

4 years ago

2.8.3

4 years ago

2.8.4

4 years ago

3.0.0-alpha.14

4 years ago

3.0.0-alpha.6

4 years ago

2.8.2

4 years ago

2.8.2-alpha.4

4 years ago

2.8.1

5 years ago

2.8.0

5 years ago

2.7.2

5 years ago

2.7.2-alpha.38

5 years ago

2.7.1

5 years ago

2.7.0

5 years ago

2.6.1

5 years ago

2.6.1-alpha.5

5 years ago

2.6.1-alpha.4

5 years ago

2.6.0

5 years ago

2.5.1

5 years ago

2.4.7-alpha.454

5 years ago

2.4.6

6 years ago

2.4.4

6 years ago

2.4.0

6 years ago