Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

parcelLab-archive/emarsys-recommendation-updates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What does it do?

Processes amarsys recomnendation updates from emarsys-recommendation-updates SQS and updates EmarsysReommendaions DynamoDB Table

Expects SQS messages with the following SQS body attribute:

{
  "user_id": Number,
  "payload": {
    "event_type": String, // one of ['add', 'delete'],
    "email_hash": String, // SHA256 hash of email address of customer
    // required for 'add*' events only ! - the product recommendation will be presented to the customers in our communication
    "predictSecret": String, 
    "predictUserID": String
  }
}

Updates EmarsysRecommendations DynamoDB table that uses event_type and user_id as the primary key. Moves unprocessable SQS messages to emarsys-recommendation-updates-failed deadletter SQS queue after 3 unssucessful receives.

Event Types

  • add - adds or overwrites subscriber entry without letting the entry expire automatically
  • delete - delete subscriber

How do I run it locally ?

This Lambda application is using AWS SAM to configure, bootstrap and deploy the whole SQS->Lambda->DynamoDB infrastructure (see ./template.yml).

To run this locally you will need to have the AWS SAM CLI installed and Docker (if you want to invoke the Lambda locally)

# Build Lambdas with AWS SAM
sam build
# Invoke Lambda with example event (see ./events/* for other test events)
# Note: The event will be running against the actual production DynamoDB
sam local invoke --event events/add-event-sqs.json

How do I run the automated tests ?

All automated tests are placed in ./__tests__ and are executed with Jest.

npm test

About

Code base for emarsys-recommendation-updates

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published