Web SDK User profile

Additionally to basic methods, you can observe and change the user profiles data. User profile is the set or properties describing the user. User properties can be divided into 4 groups:

  1. Crossplatform or custom user identifier. If this identifier is not set by developer, then the identifier which was set during the initialization is used.
  2. Automatically collected properties, including data about user's device, geography, app version, SDK, and some other data which can be received from SDK.
  3. Basic set of user properties, which can be set by developer. The set of this parameters works with separate methods. This set includes the data of user's name, sex, age, e-mail, phone-number and url of user picture. Also this set includes the mark of user as cheater.
  4. Custom set of user properties. In this case developer sets any user data he/she needs to know. The data is set in key-value format and can be numeric, string, array or boolean.

You can segment users by all the properties in My Apps section of an application.

 

Cross-platform user ID

This method is used for user initialization in the applications which are the parts of cross-platform project. You also can use this identifier in non-crossplatform projects, but in your app the own unique user identifier is used.

We recommend you to apply this method before the SDK initialization, otherwise the user identifier from the previous session will be used since the SDK initialization moment till the setCrossplatformUserId method call.

If your cross-platform application supposes to be used without cross-platform authorization, don't use the setCrossplatformUserId method or use the empty string ("") as the user identifier. SDK will assign the unique identifier to user. This identifier will be used until the real cross-platform identifier assigns to the user.

/**
* Initializes the user with the specified cross-platform identifier
* @param {string} сrossplatformUserId - unique cross-platform user ID used
* for user identification on your server.
*/

devtodev.setCrossplatformUserId(сrossplatformUserId);

Attention! If your application allows user to relogin (changing the user during the working session of application), then the setCrossplatformUserId method should be called just after the authorization. You don't need to call the SDK initialization one more time.

​To see which identifier is used at the moment:

/**
* Returns current cross-platform user id
* @return crossPlatformUserId - current cross-platform user id
*/

devtodev.getCrossplatformUserId();

 

Replace Cross-platform user ID

If it is possible to replace the cross-platform user identifier in your application (say, to make changes in the login/user id for particular user), use this method at the moment of replacing the identifier.
Attention! Don't use this method if you're going to perform the user's relogin!

/**
* Replaces current cross-platform user id
* Attention! Don't use this method if you're going to perform the user's relogin.
* @param {string} newCrossPlatformID - new cross-platform user ID
*/

devtodev.replaceCrossplatformUserId(newCrossPlatformID);

 

Current user level

If your app uses the user's level mark, we recommend to use this method after every SDK initialization, as soon as data of user's level is available to the application. 

/**
* Initializes the current user level. Required if level feature used in the app.
* @param {number} currentUserLevel - Сurrent game level of the player.
*/

devtodev.setUserLevel(currentUserLevel);

 

Cheater

In case you have your own methods of determining cheaters in the application, you can have such users marked. Payments made by them will not be taken into account in the statistics.

/**
* Mark user if it's cheater.
* @param {boolean} isCheater - true if user is a cheater
*/

devtodev.user.cheater(isCheater);

 

Age

/**
* Track user's age
* @param {number} age - User’s age.
*/

devtodev.user.age(age);

 

Gender

/**
* Track user's gender
* @param {number} gender - User’s gender. (0 - Unknown, 1 - Male, 2 - Female).
*/

devtodev.user.gender(gender);

 

E-mail

/**
* Track user's e-mail
* @param {string} email - User’s e-mail.
*/
devtodev.user.email(email);

 

Phone number

/**
* Track user's phone number
* @param {string} phone_number - User’s phone number.
*/

devtodev.user.phone(phone_number);

 

Photo

/**
* Track user's photo URL
* @param {string} photo_url - User’s phone number.
*/

devtodev.user.photo(photo_url);

 

Custom user property

/*
 * Set properties on a user data.
 *
 * ### Usage:
 *     devtodev.user.set('Hair color', 'copper red');
 *
 *     // to set multiple properties at once
 *     devtodev.user.set({
 *         'Hair color': 'blonde',
 *			'Last payment': 100,
 *			'Last order': ['Coloring','Hair Straightening'],
 *         'Order date': new Date()
 *     });
 *     // properties can be strings, integers, dates, or lists
 *
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
 * @param {*} [val] A value to set on the given property
 */
devtodev.user.set(prop, val);

 

Incrementation of the numeric custom user property

/*
 * Increments or decrements numeric user's properties.
 * ### Usage:
 *     devtodev.user.increment('Rounds played', 1);
 *     // or if you're just incrementing a counter by 1, you can simply do
 *     devtodev.user.increment('Rounds played');
 *
 *     // to decrement a counter, pass a negative number
 *     devtodev.user.increment('Rounds played', -1);
 *
 *     // you can increment multiple properties at once:
 *     devtodev.user.increment({
 *         'Rounds played': 1,
 *         'Enemies killed': 6
 *     });
 * @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and numeric values.
 * @param {Number} [val] An amount to increment the given property
 */
devtodev.user.increment(prop, val);

 

Removing of the custom property

/*
 * Removes properties from a user data.
 *
 * ### Usage:
 *     devtodev.user.remove('Hair color');
 *
 *     // to set multiple properties at once
 *     devtodev.user.remove(['Hair color', 'blonde', 'Last payment']);
 *
 * @param {Array|String} prop If a string, this is the name of the property. If an array, this is an array of names.
 */
devtodev.user.remove(prop);

 

Clearing of the all custom user properties

/*
 * Removes all user's custom personal data from devtodev data base.
 */

devtodev.user.clearUser();

 

Basic Methods
Secondary Methods