Service - Notification Manager: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
Line 38: Line 38:
; uniqueId
; uniqueId
: (sort key)
: (sort key)
: given by the receiver service, expected to be unique per notification group
: given by the receiver service, expected to be unique partition key. Partition key is set by receiver so up to receiver to make sure this is unique
: eg a UUID generated by [[Service - User Contact Manager]] or generated here
: eg for emails [[Service - User Contact Manager]] creates this as: {userContactId}_{uuid}, userContactId is ContactMethodEmail_{uuid created by Email service}, this allows filtering for a specific email record using beginsWith
: eg for emails [[Service - User Contact Manager]] could create this id as {userContactId}_{uuid}, this would allow filtering to only return notifications for a specific email_emailUniqueId (methodTag_emailUniqueId)
; notificationGroupName
; notificationGroupName
: string name set by reciever service, optional
: string name set by reciever service, optional

Revision as of 11:13, 16 February 2021

Overview

Consolidates and sends notifications to any number of receiver services. Will be used for user notifications but can have other types of receiver services added. Activities are received from Activity Switchboard service.

Notification groups set whether activities are considated (eg per day/per month/per x number of activities), if considated activities are stored here until sending is triggered, according to the considation rules. If not consolidated they are sent on immediately.

Repository

https://bitbucket.org/stb_working/notification-manager/src/master/

DynamoDB tables

Standard Config Table Per Service

Configuration tags

{
	configTag: "ActivitySwitchboardServiceName"
	configKey: "ActivitySwitchboardServiceName"
	configValue: {eg: "ActivitySwitchboard"}
}

NotificationGroups

  • Groups many notificatons together
  • Simplifies management of similar notifications
  • Allows for consolidation of notifications at notification group level

Fields

notificationGroupId
(partition key)
comes from: {receiverTag}_{groupingId}
eg receiverTag: ContactMethodEmail
eg groupingId: {userId}, cannot include underscores
uniqueId
(sort key)
given by the receiver service, expected to be unique partition key. Partition key is set by receiver so up to receiver to make sure this is unique
eg for emails Service - User Contact Manager creates this as: {userContactId}_{uuid}, userContactId is ContactMethodEmail_{uuid created by Email service}, this allows filtering for a specific email record using beginsWith
notificationGroupName
string name set by reciever service, optional
notificationIds
String Set of notificationIds in this group (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html)
consolidated
true|false
optional, if excluded (or value not true), defaults to false
consolidatedType
overview|detailed
overview sends a count of each type of notification, detailed lists each activity message
consolidatedFrequency
not sure, maybe use some sort of standard like cron
consolidatedNextSendDue
timestamp for next due time to send notification
consolidatedSendIfEmpty
true|false
additionalData
set by the creating service, gets added to notifications sent to the receiver
eg: can include the actual userId and used to make the groupingId
timeDisabled
timestamp when disabled or 0 for enabled

Notifications

  • no sort key

Fields

notificationId
(partition key)
hash of object containing notificationGroupId, serviceName, msgTag, notificationName, triggers
notificationGroupId
serviceName
msgTag
notificationName
string name set by reciever service, optional
triggers
array/list of triggers that must match for this notification to happen, see #Triggers structure
timeDisabled
timestamp when disabled or 0 for enabled

PendingConsolidation

Fields

notificationGroupId
(partition key)
time
(sort key)
comes from {timestamp activity handled in Activity Switchboard}_{small random UUID}
adding the UUID to ensure no clashing records with the same timestamp and notificationGroupId
activityMsg
copy of the message delivered from Activity Switchboard

Triggers structure

Record of the triggers for a notification, saved in Notifications table

[
	{
		"propertyName": {can be a nested property, use dot notation}
		"valueType": property|attribute
		"value": {string or number}
		"values": {array/list of values}
	},
	..
]

value or values array

Either value or values should be set, not both, if values is used it means any of the elements in the values array can match.

To achieve this on Activity Switchboard a new activity group is created for each element, each activity group has the full list of other triggers, and one option from this trigger's values array. If a notification has multiple values type triggers than a new trigger group on Activity Switchboard is created for each combination.

Consolidated notifications

How to trigger processing for time based consolidations

  • ....
  • maybe can use some sort of queue to store a list of NotificationGroup’s that are due to be sent (either because consolidatedSendIfEmpty == true or there are some activities waiting to be processed)

Formating the notification body

  • Initially the format will be hardwired and simple, but in the future we could create templates for formating the notification body
  • The notificationBody is currently sent to receiver as a JSON stringified object containing all activityMsgs

Ideas

  • overview notifications currently count per notification, but could be extended to do aggregates on a per notification, per field level
  • If set to overview maybe can store just aggregate/s needed for the consolidated notification, at the moment store entire messages, create the overview once when sending notification

Working documents

Working documents - Notification Manager