Classes
Namespaces
Methods
(static) getSharedInstance() → {Newton}
Get the shared instance
Throws:
-
- Throw if getSharedInstanceWithConfig hasn't been called
- Type
-
Error
Returns:
- Type:
-
Newton
(static) getSharedInstanceWithConfig(secret, environmentCustomData, config) → {Newton}
Get the shared instance. Create one if no sharedInstance found
Parameters:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
secret |
String
|
application secret | |||||||||||||||||||||
environmentCustomData |
Object
|
custom data object | |||||||||||||||||||||
config |
Object
|
contains various configurations
|
Throws:
-
- throws if no secret is given, throws if only one of [whiteLabel, isInternational] is passed (both of them must be passed, or none of them)
- Type
-
Error
Returns:
- Type:
-
Newton
(static) getVersionString() → {String}
Get current Newton version
Returns:
- Type:
-
String
(static) immediateFixHistory(replaceStateDelegate)
Fix history for get parameters immediatly
Parameters:
Name | Type | Description |
---|---|---|
replaceStateDelegate |
function
|
An optional function with the same signature as window.history.replaceState to be used to replace browser history |
(static) invalidateInstance(callback)
Invalidates the public interface and flushes the event subsystem
Parameters:
Name | Type | Description |
---|---|---|
callback |
function
|
If waitForFlushOnInvalidate called after server response otherwise called when last XHR is started |
Throws:
-
- Throw if getSharedInstanceWithConfig hasn't been called or if already invalidated
- Type
-
Error
__temporaryUserDelete(userDeleteCallback)
Delete the current user.
Parameters:
Name | Type | Description |
---|---|---|
userDeleteCallback |
UserDeleteCallback
|
The callback invoked when the request is done. It has an error if the request couldn't be completed |
confirmEmail(confirmToken, callback)
Start the confirm identity flow. Call the callback with the result
Parameters:
Name | Type | Description |
---|---|---|
confirmToken |
The token from the email | |
callback |
The callback invoked at the end with the status (undefined or error) |
finalizeLoginFlow(callback)
Finalize login flow.
Used only for customized waiting page
Parameters:
Name | Type | Description |
---|---|---|
callback |
function
|
invoked at the end of the flow. An error is given to discern the error case |
flowBegin(name, customDataopt)
Begin a flow. Close a previous flow with a fail if need.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The name of the flow | |
customData |
Newton.SimpleObject
|
<optional> |
Some data attached to this event |
flowCancel(name, customDataopt)
End a flow with a cancellation
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The reason of the cancellation | |
customData |
Newton.SimpleObject
|
<optional> |
Some data |
Throws:
Throw if there's not a begun flow
flowFail(name, customDataopt)
End a flow with a failure
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The reason of the failure | |
customData |
Newton.SimpleObject
|
<optional> |
Some data |
Throws:
Throw if there's not a begun flow
flowStep(name, customDataopt)
Make a step for a flow
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The name of the step | |
customData |
Newton.SimpleObject
|
<optional> |
Some data attached to this event |
Throws:
Throw if there's not a begun flow
flowSucceed(nameopt, customDataopt)
End a flow with a success
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
String
|
<optional> |
"ok" | A name that identify the end |
customData |
Newton.SimpleObject
|
<optional> |
Some data |
Throws:
Throw if there's not a begun flow
flushEvents()
Force to flush all events - dummy method in javascript
Parameters:
Type | Description |
---|---|
callback
|
invoked asynchronously |
getEnvironmentString() → {String}
Get the environment string representation
Returns:
- Type:
-
String
getIdentityManager() → {IdentityManager}
Return a login builder instance
Returns:
- Type:
-
IdentityManager
getOAuthProviders() → {Array}
Return a list of available and supported oauth provider
Returns:
- Type:
-
Array
- the list
getPaymentManager()
Returns the payment manager, this method is exposed in public interface
getPushManager()
Returns the push manager, this method is exposed in public interface
getSessionId() → {String}
Return the current session id.
Returns:
- Type:
-
String
- The current session id
getSnowplowUser() → {Object}
Get a Snowplow User Context for the current logged user
Returns:
- Type:
-
Object
- Snowplow user context OR null if user is not logged
getTransientToken(callback)
Return a transient user token.
Parameters:
Name | Type | Description |
---|---|---|
callback |
TransientTokenCallback
|
invoked asynchronously |
getUserMetaInfo(callback)
Retreive the user metainfo
Parameters:
Name | Type | Description |
---|---|---|
callback |
MetaInfoCallback
|
getUserToken() → {String}
Return the user token.
Returns:
- Type:
-
String
- The user token
getUserType() → {String}
Return current user type
Returns:
- Type:
-
String
- anonymous, prospect, identified, unknown
isAnalyticFlowBegun() → {Boolean}
Return true if a flow is begun (analytics)
Returns:
- Type:
-
Boolean
- true if there is a begun flow
isLoginFlowRunning() → {Boolean}
Return true is a login flow is running
Returns:
- Type:
-
Boolean
- true if a login flow is running
isTimedEventRunning(name) → {Boolean}
Return true if there is a running timed event with that name
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The name of the running timed event |
Returns:
- Type:
-
Boolean
- true if there is a running timed event with that name
isUserLogged() → {Boolean}
Return true if Newton User is logged
Returns:
- Type:
-
Boolean
- true if Newton User is logged
rankContent(contentId, scope, multiplieropt)
Rank a content in a scope
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
contentId |
String
|
The contentId (at least 4 chars) | |
scope |
Newton.RankingScope
|
The scope for this rank | |
multiplier |
Number
|
<optional> |
The multiplier for this rank |
Throws:
Throw if the params are not correct
resetPassword(forgotToken, password, callback)
Start the reset password flow. Call the callback with the result
Parameters:
Name | Type | Description |
---|---|---|
forgotToken |
The token from the email | |
password |
The new password | |
callback |
The callback invoked at the end with the status (undefined or error) |
sendEvent(name, customDataopt)
Queue a custom event
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The name of this event | |
customData |
Newton.SimpleObject
|
<optional> |
Some data attached to this event |
Throws:
Will throw error if label is not valid or customData is a wrong type
setUserStateChangeListener(listener)
Notify the changing of the user status.
Parameters:
Name | Type | Description |
---|---|---|
listener |
UserStateChangeListener
|
syncUserState(syncStateCallback)
Refresh the current local user state asking to the server the real user state
Parameters:
Name | Type | Description |
---|---|---|
syncStateCallback |
SyncStateCallback
|
The callback invoked when the state is really refreshed |
timedEventStart(name, customDataopt)
Start a timed event
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The name of the timed event | |
customData |
Newton.SimpleObject
|
<optional> |
Some data attached to this event |
timedEventStop(name, customDataopt)
Stop a timed event
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String
|
The name of this event | |
customData |
Newton.SimpleObject
|
<optional> |
Some data attached to this event |
Throws:
Throw if there's no started event the given name