Newton

Newton

Newton

Constructor

(private) new Newton()

Newton
Source:

Classes

SimpleObject

Namespaces

RankingScope

Methods

(static) getSharedInstance() → {Newton}

Get the shared instance
Source:
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
Source:
Parameters:
Name Type Description
secret String application secret
environmentCustomData Object custom data object
config Object contains various configurations
Name Type Description
whiteLabel String
context Object the analytic context that every event will be inflated with. Can be "application" or "acquisition" (different values will default to "application")
isInternational Boolean
ravenInstance Object note: Raven must be initialized by the application
waitForFlushOnInvalidate Boolean Alter behaviour of invalidateInstance (default false)
replaceStateDelegate function An optional function with the same signature as window.history.replaceState to be used to replace browser history
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
Source:
Returns:
Type:
String

(static) immediateFixHistory(replaceStateDelegate)

Fix history for get parameters immediatly
Source:
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
Source:
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.
Source:
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

clearTimersAndFlush()

Stops the events and heartbeat timers
Source:

confirmEmail(confirmToken, callback)

Start the confirm identity flow. Call the callback with the result
Source:
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
Source:
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.
Source:
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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
Parameters:
Type Description
callback invoked asynchronously

getEnvironmentString() → {String}

Get the environment string representation
Source:
Returns:
Type:
String

getIdentityManager() → {IdentityManager}

Return a login builder instance
Source:
Returns:
Type:
IdentityManager

getLoginBuilder() → {LoginBuilder}

Return a login builder instance
Source:
Returns:
Type:
LoginBuilder

getOAuthProviders() → {Array}

Return a list of available and supported oauth provider
Source:
Returns:
Type:
Array
- the list

getPaymentManager()

Returns the payment manager, this method is exposed in public interface
Source:

getPushManager()

Returns the push manager, this method is exposed in public interface
Source:

getSessionId() → {String}

Return the current session id.
Source:
Returns:
Type:
String
- The current session id

getTransientToken(callback)

Return a transient user token.
Source:
Parameters:
Name Type Description
callback TransientTokenCallback invoked asynchronously

getUserMetaInfo(callback)

Retreive the user metainfo
Source:
Parameters:
Name Type Description
callback MetaInfoCallback

getUserToken() → {String}

Return the user token.
Source:
Returns:
Type:
String
- The user token

isAnalyticFlowBegun() → {Boolean}

Return true if a flow is begun (analytics)
Source:
Returns:
Type:
Boolean
- true if there is a begun flow

isLoginFlowRunning() → {Boolean}

Return true is a login flow is running
Source:
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
Source:
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
Source:
Returns:
Type:
Boolean
- true if Newton User is logged

rankContent(contentId, scope, multiplieropt)

Rank a content in a scope
Source:
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
Source:
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
Source:
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.
Source:
Parameters:
Name Type Description
listener UserStateChangeListener

syncUserState(syncStateCallback)

Refresh the current local user state asking to the server the real user state
Source:
Parameters:
Name Type Description
syncStateCallback SyncStateCallback The callback invoked when the state is really refreshed

timedEventStart(name, customDataopt)

Start a timed event
Source:
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
Source:
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

userLogout()

Log the user out
Source:

userLogoutAsync(callback)

Invoke a logout that force token invalidation
Source:
Parameters:
Name Type Description
callback function called at the end of async process (AFTER loginStateChange) with null OR error as first argument