Manual Reference Source Test
import AnalyticsService from 'clinical6/src/services/AnalyticsService.js'
public class | source

AnalyticsService

Extends:

AbstractServiceJsonApiService → AnalyticsService

Service handling Analytics calls with specific endpoints.

Method Summary

Public Methods
public

Gets the current location using the browser navigator.geolocation.getCurrentPosition method

public
public

postInsights(action: String, section: String, value: String, label: String, triggeredAt: String, brandId: String, location: Object): Promise<any>

Posts insights tracking to the Clinical6 platform

Inherited Summary

From class AbstractService
public get
public set
public
private
From class JsonApiService
public

options: *

public

async delete(obj: Object, options: String): Promise

Call a DELETE request on the main obj.type expecting JSON API information.

public

async get(params: Object, options: String): Promise

Call a GET request expecting JSON API information.

public

async getChildren(parent: Object, child: Object, options: String): Promise

Call a GET request expecting JSON API information for children given a parent.

public

async insert(obj: Object, options: String): Promise

Call a POST request on the main obj.type expecting JSON API information.

public

async update(obj: Object, options: String): Promise

Call a PATCH request on the main obj.type expecting JSON API information.

Public Methods

public getCurrent(): Promise<any> source

Gets the current location using the browser navigator.geolocation.getCurrentPosition method

Return:

Promise<any>

Promise object that returns success or failure

public getMetrics(params: Object, cacheMode: String): Promise<AnalyticsMetric> source

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server (such as name)

params.name String
  • optional

name of the analyticsMetric

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<AnalyticsMetric>

Promise object that returns one AnalyticsMetric

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { analyticsService } from 'clinical6';

// You will be able to access these analyticsMetrics using the `getMetrics` method. You must
// provide the name of the analyticMetric
analyticsService.getMetrics({ name: 'accepted_users' }).then(analyticsMetric => console.log(analyticsMetric));

Test:

public postInsights(action: String, section: String, value: String, label: String, triggeredAt: String, brandId: String, location: Object): Promise<any> source

Posts insights tracking to the Clinical6 platform

Params:

NameTypeAttributeDescription
action String
  • nullable: false

The action that triggers the track insights event,

section String
  • nullable: false

The section of the application that triggers the application,

value String
  • optional
  • nullable: true

The specific element Id for the given section to track.

label String
  • optional
  • nullable: true

The name/text the user sees for the value being tracked.

triggeredAt String
  • optional
  • nullable: true

The timestamp for when the event occurred. If this parameter is not found, it defaults to the timestamp of the request,

brandId String
  • optional
  • nullable: true

The brand associated with the section/value,

location Object
  • optional
  • default: {}
  • nullable: true

Object including the following location-based fields

location.latitude Float
  • optional
  • nullable: true

latitude in the location

location.longitude Float
  • optional
  • nullable: true

longitude in the location

Return:

Promise<any>

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { analyticsService } from 'clinical6';

analyticsService.postInsights('save', 'Acronyms');
analyticsService.postInsights('save', 'Acronyms');
analyticsService.postInsights('save', 'Acronyms', 'value23', 'label', 53,
 {latitude: 53.20483, longitude: 78.2840});

Test: