Tags
Use the setTags() method to change the set of tags.
Tag limitations:
- Maximum 100 tags.
- Maximum tag length is 50 characters.
- Each tag must match the tag format below.
Tag format
Each tag must match the following regular expression:
const regExp = /^[\p{L}_\d][\p{L}_\d\-]{0,49}$/u;
- The first character must be a letter (any language), digit, or
_. - Subsequent characters may be letters, digits,
_, or-. - Total length: from 1 to 50 characters.
Valid tags:
| Tag | Why it is valid |
|---|---|
premium | Starts with a letter; only allowed characters |
user_123 | Letters, digits, and _ |
en-US | Hyphen in the middle is allowed |
_internal | May start with _ |
123tag | May start with a digit |
Invalid tags:
| Tag | Why it is invalid |
|---|---|
-premium | Must not start with - |
user name | Spaces are not allowed |
tag.name | . is not allowed |
tag@email | Special characters are not allowed |
"" | Empty string is not allowed |
Example
<div id="stories_widget"></div>
import { AppearanceManager, InAppStoryManager } from "@inappstory/js-sdk";
const inAppStoryManager = new InAppStoryManager({ apiKey: "{projectToken}" });
const appearanceManager = new AppearanceManager();
const storiesList = new inAppStoryManager.StoriesList(
"#stories_widget",
appearanceManager
);
inAppStoryManager.setTags(["tag1", "tag2", "tagN"]);
// Reload stories after tags changed (Optional)
storiesList.reload();
Exceptions
When calling setTags() or passing tags during InAppStoryManager initialization, the following errors may be thrown:
IasTagsCountError
Thrown when the number of tags exceeds the limit of 100.
IasTagsLengthError
Thrown when a tag exceeds the maximum length of 50 characters.