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
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
| Param | Type | Default | Description |
|---|---|---|---|
| [acl] | Array.<string> | function | | limit 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
| Param | Type | Description |
|---|---|---|
| name | string | |
| action | string | |
| [data] | object | |
| options | object | use { id: '...' } to make campaign accessible from code |
notifications.pushTasksToQueue(campaignTargets) ⇒ Promise.<Array.<Task>>
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 | |
notifications.processMessage(event, pageId) ⇒ Promise.<{status:number}>
Preprocess message - for read and delivery
Kind: instance method of Notifications
| Param | Type |
|---|---|
| event | object |
| pageId | string |
notifications.getSubscribtions(senderId, pageId) ⇒ Promise.<Array.<string>>
Get user subscribtions
Kind: instance method of Notifications
| Param | Type |
|---|---|
| senderId | string |
| pageId | string |
notifications.getSubscriptions(senderId, pageId) ⇒ Promise.<Array.<SenderSubscription>>
Get user subscribtions
Kind: instance method of Notifications
| Param | Type |
|---|---|
| senderId | string |
| pageId | string |
notifications.runCampaign(campaign) ⇒ Promise.<{queued:number}>
Run the campaign now (push tasks into the queue)
Kind: instance method of Notifications
| Param | Type |
|---|---|
| campaign | object |
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
| 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 |
CampaignTarget : object
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 |
Task : object
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 |
Campaign : object
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 |
SenderSubscription : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| tag | string |
| meta | object |
Logger : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| log | function |
| error | function |
NotificationsOptions : object
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 |
Tag : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| tag | string |
| subscribtions | number |
Target : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| senderId | string |
| pageId | string |
| [meta] | Object.<string, object> |
Subscribtion : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| senderId | string |
| pageId | string |
| subs | Array.<string> |
| [meta] | Object.<string, object> |
Campaign : object
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 |
Task : object
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 |
Subscription : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| tag | string |
| meta | object |
SubscriptionData : object
Kind: global typedef
Properties
| Name | Type |
|---|---|
| pageId | string |
| senderId | string |
| tags | Array.<string> |
| [remove] | boolean |
| [meta] | Object.<string, object> |