Method Reference

Synerise SDK Lifecycle


Initialization


Initializes Synerise SDK.

Declared In

lib/main/Synerise.js

Builder Parameters

Parameter Type Mandatory Default Description
baseUrl string no - Synerise API custom environment base URL
clientApiKey string no - Synerise Client API Key
debugModeEnabled boolean no - Specifies if console logs are enabled/disabled
crashHandlingEnabled boolean no - Specifies if crash handling is enabled/disabled

Return Value

There is no return value.

Example

Synerise.Initializer()
    .withBaseUrl("YOUR_BASE_URL")
    .withClientApiKey('YOUR_CLIENT_API_KEY')
    .withDebugModeEnabled(true)
    .withCrashHandlingEnabled(true)
    .init();

Client Authentication


Register Client account


Register a new Client with email, password, and optional data.

This method requires the ClientAccountRegisterContext object with a Client’s email, password, and optional data. Omitted fields are not modified.

Depending on backend configuration, the account may require activation. For details, see user registration.

Do NOT allow to sign in again (or sign up) when a user is already signed in. Sign the user out first.

Do not create multiple instances nor call this method multiple times before execution. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientAccountRegisterContext.js

Method

Synerise.Client.registerAccount(context, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
context ClientAccountRegisterContext yes - Object with the Client’s email, password, and other optional data
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email = "EMAIL";
let password = "PASSWORD";

let context = new ClientAccountRegisterContext(email, password);
context.phone = '123456789';
context.customId = '000111';

context.firstName = 'John';
context.lastName = 'Rise';
context.sex = ClientSex.Male;

context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = 'PL';

context.agreements = new ClientAgreements({
    email: true,
    sms: false,
    push: true,
    bluetooth: false,
    rfid: true,
    wifi: false
});

context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
context.tags = ['TAG_1', 'TAG_2']

Synerise.Client.registerAccount(context, function() {
    // success
}, function(error) {
    // failure
});

Confirm Client account


Confirm a Client account with the confirmation token.

The Method returns the HTTP 400 status code if the account is already confirmed or 404 if the account does not exist. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.confirmAccount(token, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
token string yes - Client’s token provided by email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.confirmAccount("TOKEN", function() {
    // success
}, function(error) {
    // failure
});

Activate Client account


Activate a Client with email. This method requires the Client’s email. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.activateAccount(email, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Client’s email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.activateAccount("EMAIL", function() {
    // success
}, function(error) {
    // failure
});

Sign in a Client


Sign in a client in order to obtain the JWT token, which can be used in subsequent requests.

The token is valid for 1 hour (unless configured otherwise in Synerise) and the SDK will refresh the token before each call if it is expiring soon (but still valid).

The method requires valid and non-null email and password. Device ID is optional.

Do NOT allow to sign in again (or sign up) when a user is already signed in. Sign the user out first.

Do not create multiple instances nor call this method multiple times before execution. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.signIn(email, password, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Client’s email
password string yes - Client’s password
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let email = "EMAIL";
let password = "PASSWORD";

Synerise.Client.signIn(email, password, function() {
  // success
}, function(error) {
  // failure
});

Check if a Client is signed in


Check if a Client is signed in (their token is authorized).

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.isSignedIn()

Return Value

true if the user is signed in, otherwise return false.

Example

let isSignedIn = Synerise.Client.isSignedIn();

Sign out a Client


Signing a Client out clears the Client’s JWT token.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.signOut()

Return Value

There is no return value.

Example

Synerise.Client.signOut();

Client Account Management


Get Client account information


Use this method to get a Client’s account information.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientAccountInformation.js

Method

Synerise.Client.getAccount(onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.getAccount(function(clientAccountInformation) {
    //success
  //alert(clientAccountInformation.email);
}, function(error) {
    //failure
});

Update Client account information


Use this method to update a Client’s account information.

This method requires the ClientAccountUpdateContext object with the Client’s account information. Omitted fields are not modified.

Declared In

lib/main/modules/ClientModule.js

lib/classes/models/Client/ClientAccountUpdateContext.js

Method

Synerise.Client.updateAccount(context, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
context ClientAccountUpdateContext yes - Object with the Client’s update data
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let context = new ClientAccountUpdateContext();
context.phone = '123456789';
context.customId = '000111';

context.firstName = 'John';
context.lastName = 'Rise';
context.displayName = 'John Rise';
context.sex = ClientSex.Male;
context.birthDate = '1989-08-03';

context.company = 'Synerise';
context.address = 'Marszałkowska';
context.city = 'Warszawa';
context.province = 'Mazowieckie';
context.zipCode = '00-000';
context.countryCode = '+48';

context.agreements = new ClientAgreements({
    email: true,
    sms: true,
    push: true,
    bluetooth: true,
    rfid: true,
    wifi: true
});

context.attributes = { ATTRIBUTE_1: 'ATTRIBUTE_1' }
context.tags = ['TAG_1', 'TAG_2']

Synerise.Client.updateAccount(context, function() {
    // success
}, function(error) {
    // failure
})

Change Client’s account password


Use this method to change a Client’s password.

Returns the HTTP 403 status code if the provided old password is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.changePassword(newPassword, oldPassword, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
newPassword string yes - Client’s new password
oldPassword string yes - Client’s old password
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let newPassword = "NEW_PASSWORD";
let oldPassword = "OLD_PASSWORD";

Synerise.Client.changePassword(newPassword, oldPassword, function() {
    // success
}, function(error) {
    // failure
});

Request password reset for Client account


Request a Client’s password reset with email. The Client will receive a token at the provided email address. That token is then used for Synerise.Client.confirmResetPassword.

This method requires the Client’s email. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Client.requestPasswordReset(email, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Client’s email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.requestPasswordReset("EMAIL", function() {
  // success
}, function(error) {
  // failure
});

Confirm password reset for Client account


Confirm a Client’s password reset with the new password and token provided by Synerise.Client.requestPasswordReset.

This method requires the Client’s new password and the confirmation token received by e-mail.

This method is a global operation and does not require authorization.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.confirmPasswordReset(password, token, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
password string yes - Client’s new password
token string yes - Client’s token provided by email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.confirmPasswordReset("PASSWORD", "TOKEN", function() {
  // success
}, function(error) {
  // failure
});

Request email change for Client account


Use this method to request a Client’s email change.

Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.requestEmailChange(email, password, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
email string yes - Client’s new email
password string yes - Client’s password
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.requestEmailChange("EMAIL", "PASSWORD", function() {
  // success
}, function(error) {
  // failure
});

Confirm email change for Client account


Use this method to confirm an email change.

Returns the HTTP 403 status code if the provided token is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.confirmEmailChange(token, newsletterAgreement, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
token string yes - Client’s token provided by email
newsletterAgreement boolean yes - Agreement for newsletters to the provided email
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.confirmEmailChange("TOKEN", true, function() {
  // success
}, function(error) {
  // failure
});

Request phone update on Client account


Use this method to request a phone number update. This action requires additional validation by PIN code.

Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.requestPhoneUpdate(phone, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
phone string yes - Client’s new phone number
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.requestPhoneUpdate("PHONE", function() {
  // success
}, function(error) {
  // failure
});

Confirm phone update on Client account


Use this method to confirm a phone number update. This action requires the new phone number and confirmation code as parameters.

Returns the HTTP 403 status code if the provided UUID does not exist or the password is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.confirmPhoneUpdate(phone, confirmationCode, smsAgreement, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
phone string yes - New phone number
confirmationCode string yes - Client’s confirmation code received by phone
smsAgreement boolean yes - Agreement for SMS marketing to the provided number
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.confirmPhoneUpdate("PHONE", "CONFIRMATION_CODE", true, function() {
  // success
}, function(error) {
  // failure
});

Delete Client account


Use this method to delete a Client’s account.

HTTP 403 status code is returned if the provided password is invalid.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.deleteAccount(password, onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
password string yes - Client’s password
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

let password = "PASSWORD";

Synerise.Client.deleteAccount(password, function(token) {
  // success
}, function(error) {
  // failure
});

Recognize anonymous user


Method to recognize anonymous users and save personal information in their CRM entries.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.recognizeAnonymous(email, customIdentify, parameters)

Parameters

Parameter Type Mandatory Default Description
email string no - Client’s email
customIdentify string no - Client’s custom identifier
parameters object no - Client’s custom parameters

Return Value

There is no return value.

Example

Synerise.Client.recognizeAnonymous("EMAIL", "CUSTOM_IDENTIFY", {
    "PARAM_1": "PARAM_1"
});

Client Session


Retrieve Client token


Retrieves the Client’s current, active token.

An error is returned when the Client is not logged in or the token has expired and cannot be refreshed.

Declared In

lib/main/modules/ClientModule.js

lib/classes/Token/Token.js

Method

Synerise.Client.retrieveToken(onSuccess, onError)

Parameters

Parameter Type Mandatory Default Description
onSuccess function no - Callback function to be executed when the operation finishes successfully
onError function no - Callback function to be executed when the operation finishes unsuccessfully

Return Value

There is no return value.

Example

Synerise.Client.retrieveToken(function(token) {
  // success
  // alert(token.tokenString);
}, function(error) {
  // failure
});

Get current Client UUID


Retrieve the Client’s current UUID.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.getUUID()

Return Value

Method returns the Client’s UUID as string.

Example

let uuid = Synerise.Client.getUUID();

Regenerate Client UUID


Regenerate the UUID and clear the authentication token, login session, custom email, and custom identifier.

This operation works only if the Client is anonymous.

Declared In

lib/main/modules/ClientModule.js

Method

Synerise.Client.regenerateUUID()

Return Value

true if the Current Client is anonymous and the operation succeed, false otherwise.

Example

Synerise.Client.regenerateUUID();

Tracking


Set Custom Identifier for events


You can pass a custom identifier to match your users in our CRM. The custom identifier is sent in the parameters of every event.

Declared In

lib/main/modules/TrackerModule.js

Method

Synerise.Tracker.setCustomIdentifier(identifier)

Parameters

Parameter Type Mandatory Default Description
identifier string yes - Client’s custom identifier

Return Value

There is no return value.

Example

Synerise.Tracker.setCustomIdentifier("CUSTOM_IDENTIFIER");

Set Custom Email for events


You can pass a custom email to match your users in our CRM. The custom email is sent in the parameters of every event.

Declared In

lib/main/modules/TrackerModule.js

Method

Synerise.Tracker.setCustomEmail(customEmail)

Parameters

Parameter Type Mandatory Default Description
email string yes - Client’s custom email

Return Value

There is no return value.

Example

Synerise.Tracker.setCustomEmail("CUSTOM_EMAIL");

Send event


Use this method to send an event.

The tracker caches and enqueues all your events locally, so they all will be sent eventually.

Declared In

lib/main/modules/TrackerModule.js

lib/classes/events/Event.js lib/classes/events/CustomEvent.js

Method

Synerise.Tracker.send(event)

Parameters

Parameter Type Mandatory Default Description
event Event yes - Event object

Return Value

There is no return value.

Example

let parameters = {
  "name": "John",
  "surname": "Rise",
  "company": "Synerise",
  "age": 25,
  "lastOrder": 380.50
};

let event = new CustomEvent("My label that will be visible on Activity Stream", "my.action", parameters);
Synerise.Tracker.send(event);

Flush events from Tracker


Forces sending the events from the queue to the server. This method is a global operation and does not require authorization.

Declared In

lib/main/modules/TrackerModule.js

Method

Synerise.Tracker.flushEvents(onSuccess)

Parameters

Parameter Type Mandatory Default Description
onSuccess function no - Callback function to be executed when the operation finishes successfully

Return Value

There is no return value.

Example

Synerise.Tracker.flush(function() {
    // success
});

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.