Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discount expiry notifier - segment and save only successes and failures #2673

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

david-pepper
Copy link
Contributor

@david-pepper david-pepper commented Feb 4, 2025

What does this change?

  • segment successes from failures and save to separate file paths in S3:
Screenshot 2025-02-04 at 15 18 03 Screenshot 2025-02-04 at 15 15 55

Transformation details

input

{
  "discountExpiresOnDate": "2025-03-08",
  "expiringDiscountsToProcess": [
    {
      "firstName": "David",
      "nextPaymentDate": "2025-02-27",
      "paymentAmount": 1.23,
      "paymentCurrency": "GBP",
      "paymentFrequency": "Month",
      "productName": "Supporter Plus",
      "sfContactId": "0039E00001HiIGlQAN",
      "subName": "A-S00886188",
      "workEmail": "david.pepper+david@guardian.co.uk"
    },
    {
      "firstName": "Graham",
      "nextPaymentDate": "2025-02-29",
      "paymentAmount": 4.56,
      "paymentCurrency": "USD",
      "paymentFrequency": "Month",
      "productName": "Supporter Plus",
      "sfContactId": "0039E00001HwhM9QAJ",
      "subName": "A-S00886159",
      "workEmail": "graham.hopgood@guardian.co.uk"
    }
  ],
  "discountProcessingAttempts": [
    {
      "detail": {
        "firstName": "David",
        "nextPaymentDate": "2025-02-27",
        "paymentAmount": 1.23,
        "paymentCurrency": "GBP",
        "paymentFrequency": "Month",
        "productName": "Supporter Plus",
        "sfContactId": "0039E00001HiIGlQAN",
        "subName": "A-S00886188",
        "workEmail": "david.pepper+david@guardian.co.uk",
        "status": "Active"
      },
      "emailSendAttempt": {
        "status": "success",
        "payload": {
          "To": {
            "Address": "david.pepper+david@guardian.co.uk",
            "ContactAttributes": {
              "SubscriberAttributes": {
                "EmailAddress": "david.pepper+david@guardian.co.uk",
                "paymentAmount": "£1.23",
                "first_name": "David",
                "date_of_payment": "27 February 2025",
                "paymentFrequency": "Month"
              }
            }
          },
          "DataExtensionName": "subscription-cancelled-email",
          "SfContactId": "0039E00001HiIGlQAN"
        },
        "response": {
          "$metadata": {
            "httpStatusCode": 200,
            "requestId": "e3169587-b8ba-5ca9-8051-f59b8e9f9f0d",
            "attempts": 1,
            "totalRetryDelay": 0
          },
          "MD5OfMessageBody": "3a34f52dc4eea65b255147eb4c374de8",
          "MessageId": "a4c0986a-52b6-4b5c-aac7-63a9a75d5b3c"
        }
      }
    },
    {
      "detail": {
        "firstName": "Graham",
        "nextPaymentDate": "2025-02-29",
        "paymentAmount": 4.56,
        "paymentCurrency": "USD",
        "paymentFrequency": "Month",
        "productName": "Supporter Plus",
        "sfContactId": "0039E00001HwhM9QAJ",
        "subName": "A-S00886159",
        "workEmail": "graham.hopgood@guardian.co.uk",
        "status": "Active"
      },
      "emailSendAttempt": {
        "status": "error",
        "payload": {
          "To": {
            "Address": "graham.hopgood@guardian.co.uk",
            "ContactAttributes": {
              "SubscriberAttributes": {
                "EmailAddress": "graham.hopgood@guardian.co.uk",
                "paymentAmount": "$4.56",
                "first_name": "Graham",
                "date_of_payment": "01 March 2025",
                "paymentFrequency": "Month"
              }
            }
          },
          "DataExtensionName": "subscription-cancelled-email",
          "SfContactId": "0039E00001HwhM9QAJ"
        },
        "response": {
          "name": "QueueDoesNotExist",
          "$fault": "client",
          "$metadata": {
            "httpStatusCode": 400,
            "requestId": "e40dbcd0-46ca-5fcd-9ded-dccc70efbc24",
            "attempts": 1,
            "totalRetryDelay": 0
          },
          "__type": "com.amazonaws.sqs#QueueDoesNotExist",
          "Code": "AWS.SimpleQueueService.NonExistentQueue",
          "Type": "Sender"
        }
      }
    }
  ]
}

successes

[
  {
    "detail": {
      "firstName": "David",
      "nextPaymentDate": "2025-02-27",
      "paymentAmount": 1.23,
      "paymentCurrency": "GBP",
      "paymentFrequency": "Month",
      "productName": "Supporter Plus",
      "sfContactId": "0039E00001HiIGlQAN",
      "subName": "A-S00886188",
      "workEmail": "david.pepper+david@guardian.co.uk",
      "status": "Active"
    },
    "emailSendAttempt": {
      "status": "success",
      "payload": {
        "To": {
          "Address": "david.pepper+david@guardian.co.uk",
          "ContactAttributes": {
            "SubscriberAttributes": {
              "EmailAddress": "david.pepper+david@guardian.co.uk",
              "paymentAmount": "£1.23",
              "first_name": "David",
              "date_of_payment": "27 February 2025",
              "paymentFrequency": "Month"
            }
          }
        },
        "DataExtensionName": "subscription-cancelled-email",
        "SfContactId": "0039E00001HiIGlQAN"
      },
      "response": {
        "$metadata": {
          "httpStatusCode": 200,
          "requestId": "e3169587-b8ba-5ca9-8051-f59b8e9f9f0d",
          "attempts": 1,
          "totalRetryDelay": 0
        },
        "MD5OfMessageBody": "3a34f52dc4eea65b255147eb4c374de8",
        "MessageId": "a4c0986a-52b6-4b5c-aac7-63a9a75d5b3c"
      }
    }
  }
]

failures

[
  {
    "detail": {
      "firstName": "Graham",
      "nextPaymentDate": "2025-02-29",
      "paymentAmount": 4.56,
      "paymentCurrency": "USD",
      "paymentFrequency": "Month",
      "productName": "Supporter Plus",
      "sfContactId": "0039E00001HwhM9QAJ",
      "subName": "A-S00886159",
      "workEmail": "graham.hopgood@guardian.co.uk",
      "status": "Active"
    },
    "emailSendAttempt": {
      "status": "error",
      "payload": {
        "To": {
          "Address": "graham.hopgood@guardian.co.uk",
          "ContactAttributes": {
            "SubscriberAttributes": {
              "EmailAddress": "graham.hopgood@guardian.co.uk",
              "paymentAmount": "$4.56",
              "first_name": "Graham",
              "date_of_payment": "01 March 2025",
              "paymentFrequency": "Month"
            }
          }
        },
        "DataExtensionName": "subscription-cancelled-email",
        "SfContactId": "0039E00001HwhM9QAJ"
      },
      "response": {
        "name": "QueueDoesNotExist",
        "$fault": "client",
        "$metadata": {
          "httpStatusCode": 400,
          "requestId": "c11e44e8-85f2-598d-bbc9-24f4ab5ab62c",
          "attempts": 1,
          "totalRetryDelay": 0
        },
        "__type": "com.amazonaws.sqs#QueueDoesNotExist",
        "Code": "AWS.SimpleQueueService.NonExistentQueue",
        "Type": "Sender"
      }
    }
  }
]

How to test

  • simulate an error, e.g. by trying to post to a queue name that doesn't exist, and verify that the payload of successes and failures are split and saved in line with the file paths displayed above

@david-pepper david-pepper marked this pull request as ready for review February 4, 2025 15:30
@david-pepper david-pepper changed the title Discount expiry notifier save only successes and failures Discount expiry notifier - segment and save only successes and failures Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant