Skip to content

Commit

Permalink
Add the message delayed event to Mandrill adapter and update schema v…
Browse files Browse the repository at this point in the history
…ersions (close #815)
  • Loading branch information
matus-tomlein committed Nov 13, 2023
1 parent 29f2672 commit 9f55f96
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 142 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Schema for a Mandrill message sent event",
"self": {
"vendor": "com.mandrill",
"name": "message_sent",
"format": "jsonschema",
"version": "1-0-1"
},

"type": "object",
"properties": {
"_id": {
"type": "string",
"description": "The unique identifier of the message that generated the event. This is not an event identifier, but rather a reference to the message ID for the email that was sent, opened, clicked, etc."
},
"msg": {
"type": "object",
"description": "Details about the message for which the event occurred. May be empty if the message that generated an open or click is older than 30 days, or when the message was not yet indexed when the event occurred.",
"properties": {
"_id": {
"type": "string",
"description": "The unique identifier assigned to each email sent via Mailchimp Transactional"
},
"_version": {
"type": "string"
},
"clicks": {
"type": "array",
"description": "An array of objects containing an item for each click recorded for the message."
},
"email": {
"type": "string",
"description": "The recipient's email address"
},
"metadata": {
"type": "object",
"description": "An array of the metadata key-value pairs that were applied to the message, if any",
"properties": {
"user_id": {
"type": "number"
}
},
"additionalProperties": true
},
"opens": {
"type": "array",
"description": "An array of objects containing an item for each time the message was opened. Each open includes the following keys"
},
"sender": {
"type": "string",
"description": "The sender's email address"
},
"state": {
"type": "string",
"description": "The state of the message (sent, rejected, spam, unsub, bounced, or soft-bounced)"
},
"subject": {
"type": "string",
"description": "The subject line of the message"
},
"tags": {
"type": "array",
"description": "An array of the tag names that were applied to the message, if any",
"items": {
"type": "string"
}
},
"ts": {
"type": "string",
"description": "The timestamp when the message was sent",
"format": "date-time"
},
"reject": {
"type": ["string", "null"]
},
"resends": {
"type": "array"
},
"smtp_events": {
"type": "array",
"description": "Array of JSON objects, each of which is an SMTP response received for the message.",
"items": {
"type": "object",
"properties": {
"ts": {
"type": "string",
"description": "The timestamp of the SMTP event",
"format": "date-time"
},
"type": {
"type": "string",
"description": "The type of SMTP event, such as sent or deferred"
},
"diag": {
"type": "string",
"description": "The SMTP diagnostic or response message returned by the receiving server"
},
"source_ip": {
"type": "string",
"description": "The Mailchimp Transactional IP address that attempted to send the message"
},
"destination_ip": {
"type": "string",
"description": "The remote IP address of the server Mailchimp Transactional connected to for message relay"
},
"size": {
"type": "integer",
"description": "The size of the message being relayed"
}
},
"additionalProperties": true
}
},
"subaccount": {
"type": ["string", "null"],
"description": "The subaccount from which the message originated; if no subaccount was used, the value will be null"
},
"template": {
"type": ["string", "null"],
"description": "The slug of the template used, if any. If no template was used, the value will be null"
}
},
"additionalProperties": true
},
"ts": {
"type": "string",
"description": "Timestamp when the event occurred",
"format": "date-time"
}
},
"additionalProperties": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class MandrillAdapterSpec extends Specification with CatsIO {
"event_vendor" -> "com.mandrill",
"event_name" -> "message_sent",
"event_format" -> "jsonschema",
"event_version" -> "1-0-0",
"event_version" -> "1-0-1",
"event" -> "unstruct",
"unstruct_event" -> json"""{"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0","data":{"schema":"iglu:com.mandrill/message_sent/jsonschema/1-0-0","data":{"msg":{"_version":"exampleaaaaaaaaaaaaaaa","subject":"This an example webhook message","email":"[email protected]","state":"sent","_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa","tags":["webhook-example"],"ts":"2013-04-04T21:13:19.000Z","clicks":[],"metadata":{"user_id":111},"sender":"[email protected]","opens":[]},"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa","ts":"2014-11-11T07:47:15.000Z"}}}""".noSpaces
"unstruct_event" -> json"""{"schema":"iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0","data":{"schema":"iglu:com.mandrill/message_sent/jsonschema/1-0-1","data":{"msg":{"_version":"exampleaaaaaaaaaaaaaaa","subject":"This an example webhook message","email":"[email protected]","state":"sent","_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa","tags":["webhook-example"],"ts":"2013-04-04T21:13:19.000Z","clicks":[],"metadata":{"user_id":111},"sender":"[email protected]","opens":[]},"_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa","ts":"2014-11-11T07:47:15.000Z"}}}""".noSpaces
)
BlackBoxTesting.runTest(input, expected)
}
Expand Down
19 changes: 10 additions & 9 deletions modules/common/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@
"recipient_unsubscribed": "iglu:com.mailgun/recipient_unsubscribed/jsonschema/1-0-0"
},
"mandrill": {
"message_bounced": "iglu:com.mandrill/message_bounced/jsonschema/1-0-1",
"message_clicked": "iglu:com.mandrill/message_clicked/jsonschema/1-0-1",
"message_delayed": "iglu:com.mandrill/message_delayed/jsonschema/1-0-1",
"message_marked_as_spam": "iglu:com.mandrill/message_marked_as_spam/jsonschema/1-0-1",
"message_opened": "iglu:com.mandrill/message_opened/jsonschema/1-0-1",
"message_rejected": "iglu:com.mandrill/message_rejected/jsonschema/1-0-0",
"message_sent": "iglu:com.mandrill/message_sent/jsonschema/1-0-0",
"message_soft_bounced": "iglu:com.mandrill/message_soft_bounced/jsonschema/1-0-1",
"recipient_unsubscribed": "iglu:com.mandrill/recipient_unsubscribed/jsonschema/1-0-1"
"message_bounced": "iglu:com.mandrill/message_bounced/jsonschema/1-0-2",
"message_clicked": "iglu:com.mandrill/message_clicked/jsonschema/1-0-2",
"message_delayed": "iglu:com.mandrill/message_delayed/jsonschema/1-0-2",
"message_delivered": "iglu:com.mandrill/message_delivered/jsonschema/1-0-0",
"message_marked_as_spam": "iglu:com.mandrill/message_marked_as_spam/jsonschema/1-0-2",
"message_opened": "iglu:com.mandrill/message_opened/jsonschema/1-0-2",
"message_rejected": "iglu:com.mandrill/message_rejected/jsonschema/1-0-1",
"message_sent": "iglu:com.mandrill/message_sent/jsonschema/1-0-1",
"message_soft_bounced": "iglu:com.mandrill/message_soft_bounced/jsonschema/1-0-2",
"recipient_unsubscribed": "iglu:com.mandrill/recipient_unsubscribed/jsonschema/1-0-2"
},
"marketo": {
"event": "iglu:com.marketo/event/jsonschema/2-0-0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ case class MandrillSchemas(
message_bounced: String,
message_clicked: String,
message_delayed: String,
message_delivered: String,
message_marked_as_spam: String,
message_opened: String,
message_rejected: String,
Expand All @@ -204,6 +205,7 @@ case class MandrillSchemas(
val messageBouncedSchemaKey: SchemaKey = AdapterConfigHelper.toSchemaKey(message_bounced, "message_bounced", "Mandrill")
val messageClickedSchemaKey: SchemaKey = AdapterConfigHelper.toSchemaKey(message_clicked, "message_clicked", "Mandrill")
val messageDelayedSchemaKey: SchemaKey = AdapterConfigHelper.toSchemaKey(message_delayed, "message_delayed", "Mandrill")
val messageDeliveredSchemaKey: SchemaKey = AdapterConfigHelper.toSchemaKey(message_delivered, "message_delivered", "Mandrill")
val messageMarkedAsSpamSchemaKey: SchemaKey =
AdapterConfigHelper.toSchemaKey(message_marked_as_spam, "message_marked_as_spam", "Mandrill")
val messageOpenedSchemaKey: SchemaKey = AdapterConfigHelper.toSchemaKey(message_opened, "message_opened", "Mandrill")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ case class MandrillAdapter(schemas: MandrillSchemas) extends Adapter {
"reject" -> schemas.messageRejectedSchemaKey,
"send" -> schemas.messageSentSchemaKey,
"soft_bounce" -> schemas.messageSoftBouncedSchemaKey,
"unsub" -> schemas.recipientUnsubscribedSchemaKey
"unsub" -> schemas.recipientUnsubscribedSchemaKey,
"delivered" -> schemas.messageDeliveredSchemaKey
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ object SpecHelpers extends CatsIO {
)

val mandrillSchemas = MandrillSchemas(
message_bounced = "iglu:com.mandrill/message_bounced/jsonschema/1-0-1",
message_clicked = "iglu:com.mandrill/message_clicked/jsonschema/1-0-1",
message_delayed = "iglu:com.mandrill/message_delayed/jsonschema/1-0-1",
message_marked_as_spam = "iglu:com.mandrill/message_marked_as_spam/jsonschema/1-0-1",
message_opened = "iglu:com.mandrill/message_opened/jsonschema/1-0-1",
message_rejected = "iglu:com.mandrill/message_rejected/jsonschema/1-0-0",
message_sent = "iglu:com.mandrill/message_sent/jsonschema/1-0-0",
message_soft_bounced = "iglu:com.mandrill/message_soft_bounced/jsonschema/1-0-1",
recipient_unsubscribed = "iglu:com.mandrill/recipient_unsubscribed/jsonschema/1-0-1"
message_bounced = "iglu:com.mandrill/message_bounced/jsonschema/1-0-2",
message_clicked = "iglu:com.mandrill/message_clicked/jsonschema/1-0-2",
message_delayed = "iglu:com.mandrill/message_delayed/jsonschema/1-0-2",
message_delivered = "iglu:com.mandrill/message_delivered/jsonschema/1-0-0",
message_marked_as_spam = "iglu:com.mandrill/message_marked_as_spam/jsonschema/1-0-2",
message_opened = "iglu:com.mandrill/message_opened/jsonschema/1-0-2",
message_rejected = "iglu:com.mandrill/message_rejected/jsonschema/1-0-1",
message_sent = "iglu:com.mandrill/message_sent/jsonschema/1-0-1",
message_soft_bounced = "iglu:com.mandrill/message_soft_bounced/jsonschema/1-0-2",
recipient_unsubscribed = "iglu:com.mandrill/recipient_unsubscribed/jsonschema/1-0-2"
)

val marketoSchemas = MarketoSchemas(
Expand Down
Loading

0 comments on commit 9f55f96

Please sign in to comment.