Segment SDK

ContextEngine

Constructor
new ContextEngine()

Context engine constructor. This class helps to determine a user's current context. For instance home, work, etc...

Summary

Methods
getCurrentContext Gets current context that is recognized by N's Context Recognition System
Current context is null before it is successfully retrieved.
Type definitions
onsuccess The callback method to be invoked when current context is successfully retrieved.
onerror The callback method to be invoked when the retrieval fails.

Methods

getCurrentContext(callbackObject)

Gets current context that is recognized by N's Context Recognition System
Current context is null before it is successfully retrieved.

Parameters
Name Type Description
callbackObject Object Callback object

Properties
Name Type Description
onsuccess da.ContextEngine~onsuccess The callback function to be invoked when current context is successfully retrieved.
onerror da.ContextEngine~onerror The callback function to be invoked when the retrieval fails.

Type definitions

onsuccess(context)

Type
function

The callback method to be invoked when current context is successfully retrieved.

Parameters
Name Type Description
context Object

Properties
Name Type Description
place string The current location of the user
Constant values:
  • home
  • office
  • otherPlace
transportation string The user's movement state.
Constant values:
  • goingToWork
  • leavingWork
  • otherTransportation
  • notMoving
activity string The current user's activity.
Constant values:
  • staying
  • walking
  • running
  • ridingBicycle
  • gettingOnCar

onerror(error)

Type
function

The callback method to be invoked when the retrieval fails.

Parameters
Name Type Description
error Object The error object

Properties
Name Type Description
code number The error code
  • 999: unidentified error
message string The error message