-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.ts
More file actions
41 lines (33 loc) · 1.27 KB
/
index.ts
File metadata and controls
41 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { CommandQueue } from "@/lib/common/command-queue";
import { Logger } from "@/lib/common/logger";
import * as Actions from "@/lib/survey/action";
import * as Attributes from "@/lib/user/attribute";
import * as User from "@/lib/user/user";
const logger = Logger.getInstance();
logger.debug("Create command queue");
const queue = new CommandQueue();
export const track = async (name: string): Promise<void> => {
queue.add(Actions.track, true, name);
await queue.wait();
};
export const setUserId = async (userId: string): Promise<void> => {
queue.add(User.setUserId, true, userId);
await queue.wait();
};
export const setAttribute = async (key: string, value: string): Promise<void> => {
queue.add(Attributes.setAttributes, true, { [key]: value });
await queue.wait();
};
export const setAttributes = async (attributes: Record<string, string>): Promise<void> => {
queue.add(Attributes.setAttributes, true, attributes);
await queue.wait();
};
export const setLanguage = async (language: string): Promise<void> => {
queue.add(Attributes.setAttributes, true, { language });
await queue.wait();
};
export const logout = async (): Promise<void> => {
queue.add(User.logout, true);
await queue.wait();
};
export { Formbricks as default } from "@/components/formbricks";