Classes

Notifications

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

 

new Notifications()

Experimental notifications service

 

notifications.limit : number

Kind: instance property of Notifications

 

notifications.sendLimit : number

Kind: instance property of Notifications

 

notifications.api([acl]) ⇒ object

API Factory

Kind: instance method of Notifications
Returns: object - - the graphql api object

ParamTypeDefaultDescription
[acl]Array.<string> | functionlimit api to array of groups or use auth function
 

notifications.createCampaign(name, action, [data], options) ⇒ Promise.<Campaign>

Upsert the campaign If the campaing does not exists add new. Otherwise, update it.

Kind: instance method of Notifications

ParamTypeDescription
namestring
actionstring
[data]object
optionsobjectuse { id: '...' } to make campaign accessible from code
 

notifications.pushTasksToQueue(campaignTargets) ⇒ Promise.<Array.<Task>>

Add tasks to process by queue

Kind: instance method of Notifications

ParamType
campaignTargetsArray.<CampaignTarget>
 

notifications.subscribe(senderId, pageId, tag)

Subscribe user under certain tag

Kind: instance method of Notifications

ParamType
senderIdstring
pageIdstring
tagstring
 

notifications.unsubscribe(senderId, pageId, [tag], [req], [res])

Unsubscribe user from certain tag or from all tags

Kind: instance method of Notifications

ParamTypeDefault
senderIdstring
pageIdstring
[tag]stringnull
[req]object
[res]object
 

notifications.processMessage(event, pageId) ⇒ Promise.<{status:number}>

Preprocess message - for read and delivery

Kind: instance method of Notifications

ParamType
eventobject
pageIdstring
 

notifications.getSubscribtions(senderId, pageId) ⇒ Promise.<Array.<string>>

Get user subscribtions

Kind: instance method of Notifications

ParamType
senderIdstring
pageIdstring
 

notifications.getSubscriptions(senderId, pageId) ⇒ Promise.<Array.<SenderSubscription>>

Get user subscribtions

Kind: instance method of Notifications

ParamType
senderIdstring
pageIdstring
 

notifications.runCampaign(campaign) ⇒ Promise.<{queued:number}>

Run the campaign now (push tasks into the queue)

Kind: instance method of Notifications

ParamType
campaignobject
 

notifications.sendCampaignMessage(campaign, processor, pageId, senderId, [data]) ⇒ Promise.<{status: number}>

Sends the message directly (without queue) and records it's delivery status at campaign stats

Kind: instance method of Notifications

ParamTypeDefaultDescription
campaignobjectcampaign
processorobjectchannel processor instance
pageIdstringpage
senderIdstringuser
[data]objectoverride 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

ParamType
notificationStorageNotificationsStorage
optionsNotificationsOptions
 

CampaignTarget : object

Kind: global typedef
Properties

NameTypeDescription
senderIdstringsender identifier
pageIdstringpage identifier
campaignIdstringcampaign identifier
[data]objectcustom action data for specific target
[enqueue]numbercustom enqueue time, now will be used by default
 

Task : object

Kind: global typedef
Properties

NameTypeDescription
idstringtask identifier
pageIdstringpage identifier
senderIdstringuser identifier
campaignIdstringcampaign identifer
enqueuenumberwhen the task will be processed with queue
[data]objectcustom action data for specific target
[read]numbertime of read
[delivery]numbertime of delivery
[sent]numbertime of send
[reaction]booleanuser reacted
[leaved]numbertime the event was not sent because user left
 

Campaign : object

Kind: global typedef
Properties

NameTypeDescription
idstring
namestringTatgeting
includeArray.<string>
excludeArray.<string>
pageIdstringStats
sentnumber
failednumber
deliverynumber
readnumber
notSentnumber
leavednumber
queuednumberInteraction
actionstring
[data]objectSetup
slidingboolean
delaynumber
slidenumber
activeboolean
in24hourWindowboolean
allowRepeatboolean
startAtnumber
slideRoundnumber
 

SenderSubscription : object

Kind: global typedef
Properties

NameType
tagstring
metaobject
 

Logger : object

Kind: global typedef
Properties

NameType
logfunction
errorfunction
 

NotificationsOptions : object

Kind: global typedef
Properties

NameTypeDescription
[log]Logger
[options.default24Clearance]numberuse this clearance to ensure delivery in 24h
[options.allAudienceTag]stringtag to mark all users
 

Tag : object

Kind: global typedef
Properties

NameType
tagstring
subscribtionsnumber
 

Target : object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
[meta]Object.<string, object>
 

Subscribtion : object

Kind: global typedef
Properties

NameType
senderIdstring
pageIdstring
subsArray.<string>
[meta]Object.<string, object>
 

Campaign : object

Kind: global typedef
Properties

NameTypeDescription
idstring
namestringTatgeting
includeArray.<string>
excludeArray.<string>
pageIdstringStats
sentnumber
failednumber
deliverynumber
readnumber
notSentnumber
leavednumber
queuednumberInteraction
actionstring
[data]objectSetup
slidingboolean
delaynumber
slidenumber
activeboolean
in24hourWindowboolean
allowRepeatboolean
startAtnumber
slideRoundnumber
 

Task : object

Kind: global typedef
Properties

NameTypeDescription
idstring
pageIdstring
senderIdstring
campaignIdstring
enqueuenumber
[read]number
[delivery]number
[sent]number
[insEnqueue]number
[reaction]booleanuser reacted
[leaved]numbertime the event was not sent because user left
 

Subscription : object

Kind: global typedef
Properties

NameType
tagstring
metaobject
 

SubscriptionData : object

Kind: global typedef
Properties

NameType
pageIdstring
senderIdstring
tagsArray.<string>
[remove]boolean
[meta]Object.<string, object>