Classes
Typedefs
- CampaignTarget :
object
- Task :
object
- Campaign :
object
- SenderSubscription :
object
- Logger :
object
- NotificationsOptions :
object
- Tag :
object
- Target :
object
- Subscribtion :
object
- Campaign :
object
- Task :
object
- Subscription :
object
- SubscriptionData :
object
Notifications
Kind: global class
- Notifications
- new Notifications()
- instance
- .limit :
number
- .sendLimit :
number
- .api([acl]) ⇒
object
- .createCampaign(name, action, [data], options) ⇒
Promise.<Campaign>
- .pushTasksToQueue(campaignTargets) ⇒
Promise.<Array.<Task>>
- .subscribe(senderId, pageId, tag)
- .unsubscribe(senderId, pageId, [tag], [req], [res])
- .processMessage(event, pageId) ⇒
Promise.<{status:number}>
- .getSubscribtions(senderId, pageId) ⇒
Promise.<Array.<string>>
- .getSubscriptions(senderId, pageId) ⇒
Promise.<Array.<SenderSubscription>>
- .runCampaign(campaign) ⇒
Promise.<{queued:number}>
- .sendCampaignMessage(campaign, processor, pageId, senderId, [data]) ⇒
Promise.<{status: number}>
- .limit :
- static
new Notifications()
Experimental notifications service
number
notifications.limit : Kind: instance property of Notifications
number
notifications.sendLimit : Kind: instance property of Notifications
object
notifications.api([acl]) ⇒ API Factory
Kind: instance method of Notifications
Returns: object
- - the graphql api object
Param | Type | Default | Description |
---|---|---|---|
[acl] | Array.<string> | function |
| limit api to array of groups or use auth function |
Promise.<Campaign>
notifications.createCampaign(name, action, [data], options) ⇒ Upsert the campaign If the campaing does not exists add new. Otherwise, update it.
Kind: instance method of Notifications
Param | Type | Description |
---|---|---|
name | string | |
action | string | |
[data] | object | |
options | object | use { id: '...' } to make campaign accessible from code |
Promise.<Array.<Task>>
notifications.pushTasksToQueue(campaignTargets) ⇒ Add tasks to process by queue
Kind: instance method of Notifications
Param | Type |
---|---|
campaignTargets | Array.<CampaignTarget> |
notifications.subscribe(senderId, pageId, tag)
Subscribe user under certain tag
Kind: instance method of Notifications
Param | Type |
---|---|
senderId | string |
pageId | string |
tag | string |
notifications.unsubscribe(senderId, pageId, [tag], [req], [res])
Unsubscribe user from certain tag or from all tags
Kind: instance method of Notifications
Param | Type | Default |
---|---|---|
senderId | string | |
pageId | string | |
[tag] | string | null |
[req] | object |
|
[res] | object |
|
Promise.<{status:number}>
notifications.processMessage(event, pageId) ⇒ Preprocess message - for read and delivery
Kind: instance method of Notifications
Param | Type |
---|---|
event | object |
pageId | string |
Promise.<Array.<string>>
notifications.getSubscribtions(senderId, pageId) ⇒ Get user subscribtions
Kind: instance method of Notifications
Param | Type |
---|---|
senderId | string |
pageId | string |
Promise.<Array.<SenderSubscription>>
notifications.getSubscriptions(senderId, pageId) ⇒ Get user subscribtions
Kind: instance method of Notifications
Param | Type |
---|---|
senderId | string |
pageId | string |
Promise.<{queued:number}>
notifications.runCampaign(campaign) ⇒ Run the campaign now (push tasks into the queue)
Kind: instance method of Notifications
Param | Type |
---|---|
campaign | object |
Promise.<{status: number}>
notifications.sendCampaignMessage(campaign, processor, pageId, senderId, [data]) ⇒ Sends the message directly (without queue) and records it's delivery status at campaign stats
Kind: instance method of Notifications
Param | Type | Default | Description |
---|---|---|---|
campaign | object | campaign | |
processor | object | channel processor instance | |
pageId | string | page | |
senderId | string | user | |
[data] | object |
| override the data of campaign |
Example
const campaign = await notifications.createCampaign('Custom campaign', 'camp-action', {}, { id: 'custom-campaign' });await notifications.sendCampaignMessage(campaign, channel, pageId, senderId);
Notifications.Notifications
Kind: static class of Notifications
new Notifications(notificationStorage, options)
Creates a new instance on notification service
Param | Type |
---|---|
notificationStorage | NotificationsStorage |
options | NotificationsOptions |
object
CampaignTarget : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
senderId | string | sender identifier |
pageId | string | page identifier |
campaignId | string | campaign identifier |
[data] | object | custom action data for specific target |
[enqueue] | number | custom enqueue time, now will be used by default |
object
Task : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | string | task identifier |
pageId | string | page identifier |
senderId | string | user identifier |
campaignId | string | campaign identifer |
enqueue | number | when the task will be processed with queue |
[data] | object | custom action data for specific target |
[read] | number | time of read |
[delivery] | number | time of delivery |
[sent] | number | time of send |
[reaction] | boolean | user reacted |
[leaved] | number | time the event was not sent because user left |
object
Campaign : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | string | |
name | string | Tatgeting |
include | Array.<string> | |
exclude | Array.<string> | |
pageId | string | Stats |
sent | number | |
failed | number | |
delivery | number | |
read | number | |
notSent | number | |
leaved | number | |
queued | number | Interaction |
action | string | |
[data] | object | Setup |
sliding | boolean | |
delay | number | |
slide | number | |
active | boolean | |
in24hourWindow | boolean | |
allowRepeat | boolean | |
startAt | number | |
slideRound | number |
object
SenderSubscription : Kind: global typedef
Properties
Name | Type |
---|---|
tag | string |
meta | object |
object
Logger : Kind: global typedef
Properties
Name | Type |
---|---|
log | function |
error | function |
object
NotificationsOptions : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
[log] | Logger | |
[options.default24Clearance] | number | use this clearance to ensure delivery in 24h |
[options.allAudienceTag] | string | tag to mark all users |
object
Tag : Kind: global typedef
Properties
Name | Type |
---|---|
tag | string |
subscribtions | number |
object
Target : Kind: global typedef
Properties
Name | Type |
---|---|
senderId | string |
pageId | string |
[meta] | Object.<string, object> |
object
Subscribtion : Kind: global typedef
Properties
Name | Type |
---|---|
senderId | string |
pageId | string |
subs | Array.<string> |
[meta] | Object.<string, object> |
object
Campaign : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | string | |
name | string | Tatgeting |
include | Array.<string> | |
exclude | Array.<string> | |
pageId | string | Stats |
sent | number | |
failed | number | |
delivery | number | |
read | number | |
notSent | number | |
leaved | number | |
queued | number | Interaction |
action | string | |
[data] | object | Setup |
sliding | boolean | |
delay | number | |
slide | number | |
active | boolean | |
in24hourWindow | boolean | |
allowRepeat | boolean | |
startAt | number | |
slideRound | number |
object
Task : Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
id | string | |
pageId | string | |
senderId | string | |
campaignId | string | |
enqueue | number | |
[read] | number | |
[delivery] | number | |
[sent] | number | |
[insEnqueue] | number | |
[reaction] | boolean | user reacted |
[leaved] | number | time the event was not sent because user left |
object
Subscription : Kind: global typedef
Properties
Name | Type |
---|---|
tag | string |
meta | object |
object
SubscriptionData : Kind: global typedef
Properties
Name | Type |
---|---|
pageId | string |
senderId | string |
tags | Array.<string> |
[remove] | boolean |
[meta] | Object.<string, object> |