_internals

Countly. _internals

Source:

Expose internal methods to end user for usability

Methods

(static) add_cly_events(event)

Source:

Add events to event queue

Parameters:
Name Type Description
event Event

countly event

(static) add_event(element, type, listener)

Source:

Listen to specific browser event

Parameters:
Name Type Description
element HTMLElement

HTML element that should listen to event

type String

event name or action

listener function

callback when event is fired

(static) addNewProperties(orig, transferOb, props) → {Object}

Source:

Add specified properties to an object from another object

Parameters:
Name Type Description
orig Object

original object

transferOb Object

object to copy values from

props Array

array with properties to get from object

Returns:

original object with additional requested properties

Type
Object

(static) clearQueue()

Source:

Clear queued data

(static) createNewObjectFromProperties(orig, props) → {Object}

Source:

Retrieve only specific properties from object

Parameters:
Name Type Description
orig Object

original object

props Array

array with properties to get from object

Returns:

new object with requested properties

Type
Object

(static) currentUserAgentString(uaOverride) → {string}

Source:

Returns raw user agent string

Parameters:
Name Type Description
uaOverride string

a string value to pass instead of ua value

Returns:

currentUserAgentString - raw user agent string

Type
string

(static) generateUUID() → {String}

Source:

Generate random UUID value

Returns:

random UUID value

Type
String

(static) get_event_target(event) → {HTMLElement}

Source:

Get element that fired event

Parameters:
Name Type Description
event Event

event that was filed

Returns:

HTML element that caused event to fire

Type
HTMLElement

(static) get_page_coord(e) → {Event}

Source:

Modify event to set standard coordinate properties if they are not available

Parameters:
Name Type Description
e Event

event object

Returns:

modified event object

Type
Event

(static) getDocHeight() → {Number}

Source:

Get height of whole document

Returns:

height in pixels

Type
Number

(static) getDocWidth() → {Number}

Source:

Get width of whole document

Returns:

width in pixels

Type
Number

(static) getEventQueue() → {Array}

Source:

Get event queue

Returns:

event queue

Type
Array

(static) getInternalDeviceIdType() → {String}

Source:

Fetches the current device Id type

Returns:

token - auth token

Type
String

(static) getLastView() → {String}

Source:

Get last view that user visited

Returns:

view name

Type
String

(static) getMetrics() → {Object}

Source:

Get metrics of the browser or config object

Returns:

Metrics object

Type
Object

(static) getMsTimestamp() → {Number}

Source:

Get unique timestamp in milliseconds

Returns:

milliseconds timestamp

Type
Number

(static) getRequestQueue() → {Array}

Source:

Get request queue

Returns:

request queue

Type
Array

(static) getStoredIdOrGenerateId() → {String}

Source:

Get device ID, stored one, or generate new one

Returns:

device id

Type
String

(static) getTimestamp() → {Number}

Source:

Get unix timestamp

Returns:

unix timestamp

Type
Number

(static) getToken() → {String}

Source:

Get auth token

Returns:

auth token

Type
String

(static) getUA() → {string}

Source:

Get and return user agentAgent

Returns:

returns userAgent string

Type
string

(static) getValueFromStorage(key, useLocalStorage, useRawKey) → {Varies}

Source:

Storage function that acts as getter, can be used for fetching data from local storage or cookies

Parameters:
Name Type Description
key String

storage key

useLocalStorage Boolean

if false, will fallback to cookie storage

useRawKey Boolean

if true, raw key will be used without any prefix

Returns:

values stored for key

Type
Varies

(static) getViewportHeight() → {Number}

Source:

Get height of viewable area

Returns:

height in pixels

Type
Number

(static) heartBeat() → {void}

Source:

Making request making and data processing loop

Returns:

void

Type
void

(static) hideLoader()

Source:

Hide loader UI

(static) isResponseValid(statusCode, str) → {Boolean}

Source:

Check if the http response fits the bill of:

  1. The HTTP response code was successful (which is any 2xx code or code between 200 <= x < 300)
  2. The returned request is a JSON object
Parameters:
Name Type Description
statusCode Number

http incoming statusCode.

str String

response from server, ideally must be: {"result":"Success"} or should contain at least result field

Returns:
  • returns true if response passes the tests
Type
Boolean

(static) isResponseValidBroad(statusCode, str) → {Boolean}

Source:

Check if the http response fits the bill of:

  1. The HTTP response code was successful (which is any 2xx code or code between 200 <= x < 300)
  2. The returned request is a JSON object or JSON Array
Parameters:
Name Type Description
statusCode Number

http incoming statusCode.

str String

response from server, ideally must be: {"result":"Success"} or should contain at least result field

Returns:
  • returns true if response passes the tests
Type
Boolean

(static) isUUID(providedId) → {Boolean}

Source:

Check if value is in UUID format

Parameters:
Name Type Description
providedId string

Id to check

Returns:

true if it is in UUID format

Type
Boolean

(static) loadCSS(css, callback)

Source:

Load external css files

Parameters:
Name Type Description
css String

path to CSS file

callback function

callback when done

(static) loadJS(js, callback)

Source:

Load external js files

Parameters:
Name Type Description
js String

path to JS file

callback function

callback when done

(static) log(level, message)

Source:

Logging stuff, works only when debug mode is true

Parameters:
Name Type Description
level string

log level (error, warning, info, debug, verbose)

message string

any string message

(static) prepareParams(params) → {String}

Source:

Convert JSON object to URL encoded query parameter string

Parameters:
Name Type Description
params Object

object with query parameters

Returns:

URL encode query string

Type
String

(static) processScroll()

Source:

Get max scroll position

(static) processScrollView()

Source:

Process scroll data

(static) removeValueFromStorage(key, useLocalStorage, useRawKey)

Source:

A function that can be used for removing data from local storage or cookies

Parameters:
Name Type Description
key String

storage key

useLocalStorage Boolean

if false, will fallback to removing cookies

useRawKey Boolean

if true, raw key will be used without any prefix

(static) reportViewDuration()

Source:

Report duration of how long user was on this view

(static) sendXmlHttpRequest(functionName, url, params, callback, useBroadResponseValidator)

Source:

Making xml HTTP request

Parameters:
Name Type Description
functionName String

Name of the function making the request for more detailed logging

url String

URL where to make request

params Object

key value object with URL params

callback function

callback when request finished or failed

useBroadResponseValidator Boolean

if true that means the expected response is either a JSON object or a JSON array, if false only JSON

(static) setToken(token)

Source:

Set auth token

Parameters:
Name Type Description
token String

auth token

(static) setValueInStorage(key, value, useLocalStorage, useRawKey)

Source:

Storage function that acts as setter, can be used for setting data into local storage or as cookies

Parameters:
Name Type Description
key String

storage key

value Varies

value to set for key

useLocalStorage Boolean

if false, will fallback to storing as cookies

useRawKey Boolean

if true, raw key will be used without any prefix

(static) showLoader()

Source:

Show loader UI when loading external data

(static) stripTrailingSlash(str) → {String}

Source:

Removing trailing slashes

Parameters:
Name Type Description
str String

string from which to remove trailing slash

Returns:

modified string

Type
String

(static) toRequestQueue(request)

Source:

Add request to request queue

Parameters:
Name Type Description
request Object

object with request parameters

(static) userAgentDeviceDetection(uaOverride) → {string}

Source:

Returns device type information according to user agent string

Parameters:
Name Type Description
uaOverride string

a string value to pass instead of ua value

Returns:

userAgentDeviceDetection - current device type (desktop, tablet, phone)

Type
string

(static) userAgentSearchBotDetection(uaOverride) → {boolean}

Source:

Returns information regarding if the current user is a search bot or not

Parameters:
Name Type Description
uaOverride string

a string value to pass instead of ua value

Returns:

userAgentSearchBotDetection - if a search bot is reaching the site or not

Type
boolean