Identify User

This section covers how to bind each report to the identity of the user reporting the problem. You have the flexibility to add some extra attributes about the device as well as the user.

User Email and Name

By default, we ask the user to enter their email in any report. You can set the email as a required or optional field as explained here. In both cases, the email text area will be visible as shown below.

However, you can set the email as well as the username yourself and the email field will be prefilled with the one you already provided. Ideally, this API should be called as soon as a user logs into your app.

//Set the user Email
cordova.plugins.instabug.identifyUserWithEmail(
    'john.appleseed@apple.com',
  	'John',
    function () {
        console.log('Success');
    },
    function (error) {
        console.log(error);
    }
);

User Attributes

You can assign custom attributes to your users and they will show up on your Instabug dashboard with each report. Those attributes can later be used to filter the reports on the dashboard.

User Attributes - Dashboard

User Attributes - Dashboard

To add a new user attribute use the following method.

//Android only
cordova.plugins.instabug.setUserAttribute(
    'Logged_out',
  	'true',
    function () {
        console.log('Success');
    },
    function (error) {
        console.log(error);
    }
);

You can also retrieve or remove the current value of a certain user attribute, or retrieve all user attributes.

//Android only
//Remove a user attribute
cordova.plugins.instabug.removeUserAttribute(
    'Logged_out',
    function () {
        console.log('Success');
    },
    function (error) {
        console.log(error);
    }
);
//Android only
//Get the value of a ceratin user attribute
cordova.plugins.instabug.getUserAttribute(
    'Logged_out',
    function (userAttribute) {
        console.log('Logged out: ' + userAttribute);
    },
    function (error) {
        console.log(error);
    }
);

//Get all user attributes
cordova.plugins.instabug.getAllUserAttributes(
    function (userAttributes) {
        console.log('Keys: ' + Object.keys(userAttributes));
      	console.log('Logged out: ' + userAttributes.Logged_out);
    },
    function (error) {
        console.log(error);
    }
);

User Data

You can add additional data about users that would help you better assist them. This API is best used for dumping large amounts of data.

//Set the user data 
cordova.plugins.instabug.setUserData(
    'user_data',
    function () {
        console.log('Success');
    },
    function (error) {
        console.log(error);
    }
);

Each call to this method overrides the user data to be attached. The maximum size of the string is 1,000 characters.

Logout

When a user logs out, the following API should be called.

//Android only
cordova.plugins.instabug.logOut(
    function () {
        console.log('Success');
    },
    function (error) {
        console.log(error);
    }
);

Calling LogOut will reset the value of the email and name previously set. It will also remove any currently set user attributes, user events, user chats, and user data.