Tags
Tags management in the @espressif/rainmaker-base-sdk allows you to add, remove, and confirm tag assignments for users. Tags can be used for categorization, filtering, or feature access control.
note
The userInstance mentioned below refers to the ESPRMUser instance obtained during User Sign in.
Add Tags
Add tags to the current user using the addTags method.
/*
- tags: An array of strings representing the tags to be added.
*/
try {
const response = await userInstance.addTags(["premium", "beta-tester"]);
console.log("Tags added successfully:", response);
} catch (error) {
console.error("Error adding tags:", error);
}
Remove Tags
Remove tags from the current user using the removeTags method.
/*
- tags: An array of strings representing the tags to be removed.
*/
try {
const response = await userInstance.removeTags(["premium"]);
console.log("Tags removed successfully:", response);
} catch (error) {
console.error("Error removing tags:", error);
}
Confirm Tag Assignment
Confirm the assignment of tags to the user by providing a verification code using the confirmTagAssignment method.
/*
- verificationCode: The verification code for confirming the tag assignment.
*/
try {
const response = await userInstance.confirmTagAssignment(verificationCode);
console.log("Tag assignment confirmed successfully:", response);
} catch (error) {
console.error("Error confirming tag assignment:", error);
}