diff --git a/CHANGELOG.md b/CHANGELOG.md index b261d4d4b9..5659f1fd9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.74.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.74.0...v1.74.1) (2024-08-08) + + +### Bug Fixes + +* sendgrid read root traits ([#3642](https://github.com/rudderlabs/rudder-transformer/issues/3642)) ([5acad70](https://github.com/rudderlabs/rudder-transformer/commit/5acad707d3125f3d50380d886f5fecb1406836cd)) + ## [1.74.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.73.1...v1.74.0) (2024-08-05) diff --git a/package-lock.json b/package-lock.json index 4e7201190e..b5db5aa72e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.74.0", + "version": "1.74.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.74.0", + "version": "1.74.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "0.7.24", diff --git a/package.json b/package.json index 93aeed71d3..dce50ee36d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.74.0", + "version": "1.74.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { diff --git a/src/v0/destinations/sendgrid/util.js b/src/v0/destinations/sendgrid/util.js index 1edb480516..28c9aae6d2 100644 --- a/src/v0/destinations/sendgrid/util.js +++ b/src/v0/destinations/sendgrid/util.js @@ -478,7 +478,7 @@ const fetchCustomFields = async ({ destination, metadata }) => { */ const getCustomFields = async ({ message, destination, metadata }) => { const customFields = {}; - const payload = get(message, 'context.traits'); + const payload = get(message, 'context.traits') || get(message, 'traits'); const { customFieldsMapping } = destination.Config; const fieldsMapping = getHashFromArray(customFieldsMapping, 'from', 'to', false); const fields = Object.keys(fieldsMapping); diff --git a/test/integrations/destinations/sendgrid/processor/data.ts b/test/integrations/destinations/sendgrid/processor/data.ts index b1550787b5..4c5ca7f48f 100644 --- a/test/integrations/destinations/sendgrid/processor/data.ts +++ b/test/integrations/destinations/sendgrid/processor/data.ts @@ -1541,4 +1541,137 @@ export const data = [ }, }, }, + { + name: 'sendgrid', + description: 'Identify call traits at root and listId given', + feature: 'processor', + module: 'destination', + version: 'v0', + input: { + request: { + body: [ + { + destination: { + ID: '2HOQOO6wWKaKjeQrEABXgiH6cmU', + Config: { + IPPoolName: '', + apiKey: 'apikey', + attachments: [ + { + content: '', + contentId: '', + disposition: '', + filename: '', + type: '', + }, + ], + clickTracking: true, + listId: 'list123', + clickTrackingEnableText: true, + contents: [ + { + type: 'text/html', + value: + '

Hello from Twilio SendGrid!

Sending with the email service trusted by developers and marketers for time-savings, scalability, and delivery expertise.

%open-track%

', + }, + ], + customFieldsMapping: [ + { + from: 'name', + to: 'user_name', + }, + ], + eventDelivery: false, + eventDeliveryTS: 1668424218224, + eventNamesSettings: [ + { + event: 'open', + }, + ], + footer: false, + fromEmail: 'a@g.com', + fromName: '', + ganalytics: false, + group: '', + groupsToDisplay: [ + { + groupId: '', + }, + ], + html: '', + mailFromTraits: false, + openTracking: false, + openTrackingSubstitutionTag: '', + replyToEmail: '', + replyToName: '', + sandboxMode: false, + subject: 'hello there from webflow', + subscriptionTracking: false, + substitutionTag: '', + templateId: '', + text: '', + }, + }, + message: { + type: 'identify', + userId: 'user@1', + context: { + traits: { + age: '25', + city: 'Surat', + name: 'rudder test', + email: 'test@rudderstack.com', + phone: '+91 9876543210', + lastName: 'test', + firstName: 'rudder', + state: 'Gujarat', + }, + }, + }, + }, + ], + }, + }, + output: { + response: { + status: 200, + body: [ + { + output: { + body: { + XML: {}, + FORM: {}, + JSON: { + contactDetails: { + email: 'test@rudderstack.com', + last_name: 'test', + first_name: 'rudder', + unique_name: 'rudder test', + phone_number: '+91 9876543210', + custom_fields: { + w1_T: 'rudder test', + }, + }, + contactListIds: 'list123', + }, + JSON_ARRAY: {}, + }, + type: 'REST', + userId: '', + files: {}, + method: 'PUT', + params: {}, + headers: { + 'Content-Type': 'application/json', + Authorization: 'Bearer apikey', + }, + version: '1', + endpoint: 'https://api.sendgrid.com/v3/marketing/contacts', + }, + statusCode: 200, + }, + ], + }, + }, + }, ];