Events and User methods

Trigger Events

You can trigger events from client to SuprSend using track method. This can be used to trigger event-based workflows.

const resp = await suprSendClient.track(event: string, properties?: Dictionary)
const resp = await suprSendClient.track("test", {name:'john doe'})

Returns: Promise<ApiResponse>


Update User Profile

Returns: Promise<ApiResponse>

Update User channels

Set user channel related information using following methods. Its recommended to use SuprSend's Backend SDK's to set user channels instead of Client SDK's.

await suprSendClient.user.addEmail(email: string)
await suprSendClient.user.removeEmail(email: string)

// mobile should be as per E.164 standard: https://www.twilio.com/docs/glossary/what-e164
await suprSendClient.user.addSms(mobile: string)
await suprSendClient.user.removeSms(mobile: string)

// mobile should be as per E.164 standard
await suprSendClient.user.addWhatsapp(mobile: string)
await suprSendClient.user.removeWhatsapp(mobile: string)

Update User properties

Note: Keys starting with ss_ or $ will be ignored.

Set Timezone

This method will set users timezone. Timezone value should be in IANA timezone format.

await suprSendClient.user.setTimezone(timezone: string)
await suprSendClient.user.setTimezone("America/Bogota")

Set Language

This method will set users preferred language. Language value should be in ISO 639-1 Alpha-2 format.

await suprSendClient.user.setPreferredLanguage(language: string)
await suprSendClient.user.setPreferredLanguage("en")

Set

Set is used to set the custom user property or properties. If already property is already present value will be replaced.

await suprSendClient.user.set(arg1: string | Dictionary, arg2?: unknown)
await suprSendClient.user.set("name", "John Doe")
await suprSendClient.user.set({"name": "John Doe", "designation": "manager"})

SetOnce

This method is similar to set method but values once set cannot be updated.

await suprSendClient.user.setOnce(arg1: string | Dictionary, arg2?: unknown)
await suprSendClient.user.setOnce("DOB", "1991-10-02")
await suprSendClient.user.setOnce({"first_login" : "2021-11-02", "DOB" : "1991-10-02"});

Increment

Add the given amount to an existing user property. If the user does not already have the associated property, the amount will be added to zero. To reduce a property, provide a negative number as the value.

await suprSendClient.user.increment(arg1: string | Dictionary, arg2?: number)
await suprSendClient.user.increment("login_count", 1);
await suprSendClient.user.increment({"login_count" : 1, "order_count" : 1});

Append

This method will add a value to the list for a given property.

await suprSendClient.user.append(arg1: string | Dictionary, arg2?: unknown)
await suprSendClient.user.append("wishlist", "iphone12")
await suprSendClient.user.append({"wishlist" : "iphone12", "cart" : "Apple airpods"});

Remove

This method will remove a value from the list for a given property.

await suprSendClient.user.remove(arg1: string | Dictionary, arg2?: unknown)
await suprSendClient.user.remove("wishlist", "iphone12")
await suprSendClient.user.remove({"wishlist" : "iphone12", "cart" : "Apple airpods"});

Unset

This method will remove user property. To remove channel pass $email, $sms, $whatsapp.

await suprSend.user.unset(arg: string | string[])
await suprSendClient.user.unset("wishlist")
await suprSendClient.user.unset(["wishlist", "$email"]);