@segment/action-destinations 3.261.0 → 3.262.0-staging-dbf2c12ff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/destinations/amazon-ads/utils.d.ts +25 -0
  2. package/dist/destinations/amazon-ads/utils.js +8 -0
  3. package/dist/destinations/amazon-ads/utils.js.map +1 -0
  4. package/dist/destinations/customerio/utils.d.ts +1 -1
  5. package/dist/destinations/engage/utils/track.d.ts +17 -17
  6. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +36 -0
  7. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js +3 -0
  8. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js.map +1 -0
  9. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.d.ts +5 -0
  10. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +452 -0
  11. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -0
  12. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +22 -0
  13. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js +3 -0
  14. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js.map +1 -0
  15. package/dist/destinations/engage-messaging-twilio/sendSms/index.d.ts +5 -0
  16. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +131 -0
  17. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -0
  18. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +23 -0
  19. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +131 -0
  20. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +1 -0
  21. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +24 -0
  22. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js +3 -0
  23. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +1 -0
  24. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.d.ts +5 -0
  25. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +133 -0
  26. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -0
  27. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +21 -0
  28. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +75 -0
  29. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +1 -0
  30. package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +24 -0
  31. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +111 -0
  32. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +1 -0
  33. package/dist/destinations/hubspot/helperFunctions.d.ts +7 -0
  34. package/dist/destinations/hubspot/helperFunctions.js +27 -0
  35. package/dist/destinations/hubspot/helperFunctions.js.map +1 -0
  36. package/dist/destinations/inleads-ai/index.js +5 -4
  37. package/dist/destinations/inleads-ai/index.js.map +1 -1
  38. package/dist/destinations/koala/identify/index.js +6 -1
  39. package/dist/destinations/koala/identify/index.js.map +1 -1
  40. package/dist/destinations/mixpanel/utils.d.ts +13 -0
  41. package/dist/destinations/mixpanel/utils.js +117 -0
  42. package/dist/destinations/mixpanel/utils.js.map +1 -0
  43. package/dist/destinations/snap-conversions-api/snap-capi-properties.d.ts +30 -0
  44. package/dist/destinations/snap-conversions-api/snap-capi-properties.js +316 -0
  45. package/dist/destinations/snap-conversions-api/snap-capi-properties.js.map +1 -0
  46. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.d.ts +3 -0
  47. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js +34 -0
  48. package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js.map +1 -0
  49. package/dist/destinations/vernst-test/generated-types.d.ts +2 -0
  50. package/dist/destinations/vernst-test/generated-types.js +3 -0
  51. package/dist/destinations/vernst-test/generated-types.js.map +1 -0
  52. package/dist/destinations/vernst-test/index.d.ts +4 -0
  53. package/dist/destinations/vernst-test/index.js +20 -0
  54. package/dist/destinations/vernst-test/index.js.map +1 -0
  55. package/dist/destinations/vernst-test/pingWebhook/generated-types.d.ts +3 -0
  56. package/dist/destinations/vernst-test/pingWebhook/generated-types.js +3 -0
  57. package/dist/destinations/vernst-test/pingWebhook/generated-types.js.map +1 -0
  58. package/dist/destinations/vernst-test/pingWebhook/index.d.ts +5 -0
  59. package/dist/destinations/vernst-test/pingWebhook/index.js +21 -0
  60. package/dist/destinations/vernst-test/pingWebhook/index.js.map +1 -0
  61. package/package.json +3 -3
@@ -0,0 +1,25 @@
1
+ import { HTTPError } from '@segment/actions-core';
2
+ export declare class AmazonAdsError extends HTTPError {
3
+ response: Response & {
4
+ data: {
5
+ status: string;
6
+ message: string;
7
+ };
8
+ };
9
+ }
10
+ export interface AudiencePayload {
11
+ name: string;
12
+ description: string;
13
+ countryCode?: string;
14
+ targetResource: {
15
+ advertiserId: string;
16
+ };
17
+ metadata: {
18
+ externalAudienceId: string;
19
+ ttl?: number;
20
+ audienceFees?: {
21
+ cpmCents: number;
22
+ currency: string;
23
+ }[];
24
+ };
25
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmazonAdsError = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ class AmazonAdsError extends actions_core_1.HTTPError {
6
+ }
7
+ exports.AmazonAdsError = AmazonAdsError;
8
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/destinations/amazon-ads/utils.ts"],"names":[],"mappings":";;;AAAA,wDAAiD;AAEjD,MAAa,cAAe,SAAQ,wBAAS;CAO5C;AAPD,wCAOC"}
@@ -1,6 +1,6 @@
1
1
  export declare const trackApiEndpoint: ({ accountRegion }: {
2
2
  accountRegion?: string | undefined;
3
- }) => "https://track-eu.customer.io" | "https://track.customer.io";
3
+ }) => "https://track.customer.io" | "https://track-eu.customer.io";
4
4
  export declare enum AccountRegion {
5
5
  US = "US \uD83C\uDDFA\uD83C\uDDF8",
6
6
  EU = "EU \uD83C\uDDEA\uD83C\uDDFA"
@@ -1,12 +1,12 @@
1
1
  import { ContextFromDecorator } from './operationTracking';
2
2
  export declare const track: ((decoratorArgs?: ({
3
+ shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
4
+ } & {
3
5
  onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
4
- } & import("./operationTracking").OperationLoggerDecoratorArgs & {
6
+ } & {
5
7
  onTry?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
6
8
  onFinally?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
7
- } & {
8
- shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
9
- } & {
9
+ } & import("./operationTracking").OperationLoggerDecoratorArgs & {
10
10
  wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
11
11
  }) | undefined) => import("./operationTracking").GenericMethodDecorator<(this: any, ...args: any[]) => any>) & {
12
12
  getCurrentOperation(classInstance: any): (import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
@@ -15,8 +15,13 @@ export declare const track: ((decoratorArgs?: ({
15
15
  }) | undefined;
16
16
  } & {
17
17
  _contextType: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & {
18
- start?: number | undefined;
19
- duration?: number | undefined;
18
+ tags: string[];
19
+ sharedContext: {
20
+ tags: string[];
21
+ };
22
+ decoratorArgs?: {
23
+ shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
24
+ } | undefined;
20
25
  } & {
21
26
  decoratorArgs?: {
22
27
  onError?: ((ctx: import("./operationTracking").OperationErrorHandlerContext<import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>>) => void) | undefined;
@@ -25,10 +30,8 @@ export declare const track: ((decoratorArgs?: ({
25
30
  parent?: (import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any> & any) | undefined;
26
31
  sharedContext: {};
27
32
  } & {
28
- logs: string[];
29
- logMetadata?: Record<string, unknown> | undefined;
30
- decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
31
- sharedContext: import("./operationTracking").OperationLoggerSharedContext;
33
+ start?: number | undefined;
34
+ duration?: number | undefined;
32
35
  } & {
33
36
  onFinally: (() => void)[];
34
37
  decoratorArgs?: {
@@ -36,13 +39,10 @@ export declare const track: ((decoratorArgs?: ({
36
39
  onFinally?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => void) | undefined;
37
40
  } | undefined;
38
41
  } & {
39
- tags: string[];
40
- sharedContext: {
41
- tags: string[];
42
- };
43
- decoratorArgs?: {
44
- shouldStats?: ((args: import("./operationTracking").OperationStatsEventArgs) => boolean | void) | undefined;
45
- } | undefined;
42
+ logs: string[];
43
+ logMetadata?: Record<string, unknown> | undefined;
44
+ decoratorArgs?: import("./operationTracking").OperationLoggerDecoratorArgs | undefined;
45
+ sharedContext: import("./operationTracking").OperationLoggerSharedContext;
46
46
  } & {
47
47
  decoratorArgs?: {
48
48
  wrapIntegrationError?: ((ctx: import("./operationTracking").TryCatchFinallyContext<(this: any, ...args: any[]) => any>) => import("@segment/actions-core/*").IntegrationError | [message: string, code: string, status: number]) | undefined;
@@ -0,0 +1,36 @@
1
+ export interface Payload {
2
+ send?: boolean;
3
+ traitEnrichment?: boolean;
4
+ userId?: string;
5
+ toEmail?: string;
6
+ fromDomain?: string | null;
7
+ fromEmail: string;
8
+ fromName: string;
9
+ replyToEqualsFrom?: boolean;
10
+ replyToEmail: string;
11
+ replyToName: string;
12
+ bcc: string;
13
+ previewText?: string;
14
+ subject: string;
15
+ body?: string;
16
+ bodyUrl?: string;
17
+ bodyType: string;
18
+ bodyHtml?: string;
19
+ groupId?: string;
20
+ externalIds?: {
21
+ id?: string;
22
+ type?: string;
23
+ subscriptionStatus?: string;
24
+ groups?: {
25
+ id?: string;
26
+ isSubscribed?: boolean;
27
+ }[];
28
+ }[];
29
+ customArgs?: {
30
+ [k: string]: unknown;
31
+ };
32
+ traits?: {
33
+ [k: string]: unknown;
34
+ };
35
+ eventOccurredTS?: string;
36
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-sendgrid/sendEmail/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ declare const action: ActionDefinition<Settings, Payload>;
5
+ export default action;
@@ -0,0 +1,452 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const actions_core_1 = require("@segment/actions-core");
7
+ const liquidjs_1 = require("liquidjs");
8
+ const cheerio_1 = __importDefault(require("cheerio"));
9
+ const escape_goat_1 = require("escape-goat");
10
+ const Liquid = new liquidjs_1.Liquid();
11
+ const insertEmailPreviewText = (html, previewText) => {
12
+ const $ = cheerio_1.default.load(html);
13
+ $('body').prepend(`
14
+ <div style='display: none; max-height: 0px; overflow: hidden;'>
15
+ ${escape_goat_1.htmlEscape(previewText)}
16
+ </div>
17
+
18
+ <div style='display: none; max-height: 0px; overflow: hidden;'>
19
+ ${'&nbsp;&zwnj;'.repeat(13)}&nbsp;
20
+ </div>
21
+ `);
22
+ return $.html();
23
+ };
24
+ const getProfileApiEndpoint = (environment, region) => {
25
+ const domainName = region === 'eu-west-1' ? 'profiles.euw1.segment' : 'profiles.segment';
26
+ const topLevelName = environment === 'production' ? 'com' : 'build';
27
+ return `https://${domainName}.${topLevelName}`;
28
+ };
29
+ const fetchProfileTraits = async (request, settings, profileId, statsClient, tags, logger) => {
30
+ try {
31
+ const endpoint = getProfileApiEndpoint(settings.profileApiEnvironment, settings.region);
32
+ const response = await request(`${endpoint}/v1/spaces/${settings.spaceId}/collections/users/profiles/user_id:${profileId}/traits?limit=200`, {
33
+ headers: {
34
+ authorization: `Basic ${Buffer.from(settings.profileApiAccessToken + ':').toString('base64')}`,
35
+ 'content-type': 'application/json'
36
+ }
37
+ });
38
+ tags.push(`profile_status_code:${response.status}`);
39
+ statsClient?.incr('actions-personas-messaging-sendgrid.profile_invoked', 1, tags);
40
+ const body = await response.json();
41
+ return body.traits;
42
+ }
43
+ catch (error) {
44
+ logger?.error(`TE Messaging: Email profile traits request failure - ${settings.spaceId} - [${error}]`);
45
+ tags.push('reason:profile_error');
46
+ statsClient?.incr('actions-personas-messaging-sendgrid.error', 1, tags);
47
+ throw new actions_core_1.IntegrationError('Unable to get profile traits for the email message', 'Email trait fetch failure', 500);
48
+ }
49
+ };
50
+ const isRestrictedDomain = (email) => {
51
+ const restricted = ['gmailx.com', 'yahoox.com', 'aolx.com', 'hotmailx.com'];
52
+ const matches = /^.+@(.+)$/.exec(email.toLowerCase());
53
+ if (!matches) {
54
+ return false;
55
+ }
56
+ const domain = matches[1];
57
+ return restricted.includes(domain);
58
+ };
59
+ const generateEmailHtml = async (request, settings, design, statsClient, tags, logger) => {
60
+ try {
61
+ statsClient?.incr('actions-personas-messaging-sendgrid.unlayer_request', 1, tags);
62
+ const response = await request('https://api.unlayer.com/v2/export/html', {
63
+ method: 'POST',
64
+ headers: {
65
+ authorization: `Basic ${Buffer.from(`${settings.unlayerApiKey}:`).toString('base64')}`,
66
+ 'content-type': 'application/json'
67
+ },
68
+ body: JSON.stringify({
69
+ displayMode: 'email',
70
+ design: JSON.parse(design)
71
+ })
72
+ });
73
+ const body = await response.json();
74
+ return body.data.html;
75
+ }
76
+ catch (error) {
77
+ logger?.error(`TE Messaging: Email export request failure - ${settings.spaceId} - [${error}]`);
78
+ tags.push('reason:generate_email_html');
79
+ statsClient?.incr('actions-personas-messaging-sendgrid.error', 1, tags);
80
+ throw new actions_core_1.IntegrationError('Unable to export email as HTML', 'Export HTML failure', 400);
81
+ }
82
+ };
83
+ const parseTemplating = async (content, profile, contentType, statsClient, tags, settings, logger) => {
84
+ try {
85
+ const parsedContent = await Liquid.parseAndRender(content, { profile });
86
+ return parsedContent;
87
+ }
88
+ catch (error) {
89
+ logger?.error(`TE Messaging: Email templating parse failure - ${settings.spaceId} - [${error}]`);
90
+ tags.push('reason:parse_templating');
91
+ statsClient?.incr('actions-personas-messaging-sendgrid.error', 1, tags);
92
+ throw new actions_core_1.IntegrationError(`Unable to parse templating in email ${contentType}`, `${contentType} templating parse failure`, 400);
93
+ }
94
+ };
95
+ const EXTERNAL_ID_KEY = 'email';
96
+ const action = {
97
+ title: 'Send Email',
98
+ description: 'Sends Email to a user powered by SendGrid',
99
+ defaultSubscription: 'type = "track" and event = "Audience Entered"',
100
+ fields: {
101
+ send: {
102
+ label: 'Send Message',
103
+ description: 'Whether or not the message should actually get sent.',
104
+ type: 'boolean',
105
+ required: false,
106
+ default: false
107
+ },
108
+ traitEnrichment: {
109
+ label: 'Trait Enrich',
110
+ description: 'Whether or not trait enrich from event (i.e without profile api call)',
111
+ type: 'boolean',
112
+ required: false,
113
+ default: true
114
+ },
115
+ userId: {
116
+ label: 'User ID',
117
+ description: 'User ID in Segment',
118
+ type: 'string',
119
+ required: false,
120
+ default: { '@path': '$.userId' }
121
+ },
122
+ toEmail: {
123
+ label: 'Test Email',
124
+ description: 'Email to send to when testing',
125
+ type: 'string'
126
+ },
127
+ fromDomain: {
128
+ label: 'From Domain',
129
+ description: 'Verified domain in Sendgrid',
130
+ type: 'string',
131
+ allowNull: true
132
+ },
133
+ fromEmail: {
134
+ label: 'From Email',
135
+ description: 'From Email',
136
+ type: 'string',
137
+ required: true
138
+ },
139
+ fromName: {
140
+ label: 'From Name',
141
+ description: 'From Name displayed to end user email',
142
+ type: 'string',
143
+ required: true
144
+ },
145
+ replyToEqualsFrom: {
146
+ label: 'Reply To Equals From',
147
+ description: 'Whether "reply to" settings are the same as "from"',
148
+ type: 'boolean'
149
+ },
150
+ replyToEmail: {
151
+ label: 'Reply To Email',
152
+ description: 'The Email used by user to Reply To',
153
+ type: 'string',
154
+ required: true
155
+ },
156
+ replyToName: {
157
+ label: 'Reply To Name',
158
+ description: 'The Name used by user to Reply To',
159
+ type: 'string',
160
+ required: true
161
+ },
162
+ bcc: {
163
+ label: 'BCC',
164
+ description: 'BCC list of emails',
165
+ type: 'string',
166
+ required: true
167
+ },
168
+ previewText: {
169
+ label: 'Preview Text',
170
+ description: 'Preview Text',
171
+ type: 'string'
172
+ },
173
+ subject: {
174
+ label: 'Subject',
175
+ description: 'Subject for the email to be sent',
176
+ type: 'string',
177
+ required: true
178
+ },
179
+ body: {
180
+ label: 'Body',
181
+ description: 'The message body',
182
+ type: 'text'
183
+ },
184
+ bodyUrl: {
185
+ label: 'Body URL',
186
+ description: 'URL to the message body',
187
+ type: 'text'
188
+ },
189
+ bodyType: {
190
+ label: 'Body Type',
191
+ description: 'The type of body which is used generally html | design',
192
+ type: 'string',
193
+ required: true
194
+ },
195
+ bodyHtml: {
196
+ label: 'Body Html',
197
+ description: 'The HTML content of the body',
198
+ type: 'string'
199
+ },
200
+ groupId: {
201
+ label: 'Group ID',
202
+ description: 'Subscription group ID',
203
+ type: 'string'
204
+ },
205
+ externalIds: {
206
+ label: 'External IDs',
207
+ description: 'An array of user profile identity information.',
208
+ type: 'object',
209
+ multiple: true,
210
+ properties: {
211
+ id: {
212
+ label: 'ID',
213
+ description: 'A unique identifier for the collection.',
214
+ type: 'string'
215
+ },
216
+ type: {
217
+ label: 'type',
218
+ description: 'The external ID contact type.',
219
+ type: 'string'
220
+ },
221
+ subscriptionStatus: {
222
+ label: 'ID',
223
+ description: 'The subscription status for the identity.',
224
+ type: 'string'
225
+ },
226
+ groups: {
227
+ label: 'Subscription Groups',
228
+ description: 'Subscription groups and their statuses for this id.',
229
+ type: 'object',
230
+ multiple: true,
231
+ properties: {
232
+ id: {
233
+ label: 'Subscription group id',
234
+ type: 'string'
235
+ },
236
+ isSubscribed: {
237
+ label: 'status',
238
+ description: 'Group subscription status true is subscribed, false is unsubscribed or did-not-subscribe',
239
+ type: 'boolean'
240
+ }
241
+ }
242
+ }
243
+ },
244
+ default: {
245
+ '@arrayPath': [
246
+ '$.external_ids',
247
+ {
248
+ id: {
249
+ '@path': '$.id'
250
+ },
251
+ type: {
252
+ '@path': '$.type'
253
+ },
254
+ subscriptionStatus: {
255
+ '@path': '$.isSubscribed'
256
+ },
257
+ groups: {
258
+ '@path': '$.groups'
259
+ }
260
+ }
261
+ ]
262
+ }
263
+ },
264
+ customArgs: {
265
+ label: 'Custom Args',
266
+ description: 'Additional custom args that we be passed back opaquely on webhook events',
267
+ type: 'object',
268
+ required: false
269
+ },
270
+ traits: {
271
+ label: 'Traits',
272
+ description: "A user profile's traits",
273
+ type: 'object',
274
+ required: false,
275
+ default: { '@path': '$.properties' }
276
+ },
277
+ eventOccurredTS: {
278
+ label: 'Event Timestamp',
279
+ description: 'Time of when the actual event happened.',
280
+ type: 'string',
281
+ required: false,
282
+ default: {
283
+ '@path': '$.timestamp'
284
+ }
285
+ }
286
+ },
287
+ perform: async (request, { settings, payload, statsContext, logger }) => {
288
+ const statsClient = statsContext?.statsClient;
289
+ const tags = statsContext?.tags ?? [];
290
+ if (!settings.region) {
291
+ settings.region = 'us-west-2';
292
+ }
293
+ tags.push(`space_id:${settings.spaceId}`, `projectid:${settings.sourceId}`, `region:${settings.region}`);
294
+ if (!payload.send) {
295
+ logger?.info(`TE Messaging: Email send disabled - ${settings.spaceId}`);
296
+ statsClient?.incr('actions-personas-messaging-sendgrid.send-disabled', 1, tags);
297
+ return;
298
+ }
299
+ const emailProfile = payload?.externalIds?.find((meta) => meta.type === 'email');
300
+ if (!emailProfile?.subscriptionStatus ||
301
+ ['unsubscribed', 'did not subscribed', 'false'].includes(emailProfile.subscriptionStatus)) {
302
+ logger?.info(`TE Messaging: Email recipient not subscribed or external ids were omitted from request - ${settings.spaceId}`);
303
+ statsClient?.incr('actions-personas-messaging-sendgrid.notsubscribed', 1, tags);
304
+ return;
305
+ }
306
+ else if (['subscribed', 'true'].includes(emailProfile?.subscriptionStatus)) {
307
+ statsClient?.incr('actions-personas-messaging-sendgrid.subscribed', 1, tags);
308
+ if (payload.groupId && payload.groupId.length !== 0) {
309
+ const group = (payload.externalIds ?? [])
310
+ .flatMap((externalId) => externalId.groups)
311
+ .find((group) => group?.id === payload.groupId);
312
+ if (!group) {
313
+ statsClient?.incr('actions-personas-messaging-sendgrid.group_notfound', 1, tags);
314
+ return;
315
+ }
316
+ else if (!group.isSubscribed) {
317
+ statsClient?.incr('actions-personas-messaging-sendgrid.group_notsubscribed', 1, tags);
318
+ return;
319
+ }
320
+ statsClient?.incr('actions-personas-messaging-sendgrid.group_subscribed', 1, tags);
321
+ }
322
+ let traits;
323
+ if (payload.traitEnrichment) {
324
+ traits = payload?.traits ? payload?.traits : JSON.parse('{}');
325
+ }
326
+ else {
327
+ if (!payload.userId) {
328
+ logger?.error(`TE Messaging: Unable to process email, no userId provided and trait enrichment disabled - ${settings.spaceId}`);
329
+ tags.push('reason:missing_user_id');
330
+ statsClient?.incr('actions-personas-messaging-sendgrid.error', 1, tags);
331
+ throw new actions_core_1.IntegrationError('Unable to process email, no userId provided and trait enrichment disabled', 'Invalid parameters', 400);
332
+ }
333
+ traits = await fetchProfileTraits(request, settings, payload.userId, statsClient, tags, logger);
334
+ }
335
+ const profile = {
336
+ email: emailProfile.id,
337
+ traits
338
+ };
339
+ const toEmail = payload.toEmail || profile.email;
340
+ if (!toEmail) {
341
+ return;
342
+ }
343
+ if (isRestrictedDomain(toEmail)) {
344
+ logger?.error(`TE Messaging: Emails with gmailx.com, yahoox.com, aolx.com, and hotmailx.com domains are blocked - ${settings.spaceId}`);
345
+ tags.push('reason:restricted_domain');
346
+ statsClient?.incr('actions-personas-messaging-sendgrid.error', 1, tags);
347
+ throw new actions_core_1.IntegrationError('Emails with gmailx.com, yahoox.com, aolx.com, and hotmailx.com domains are blocked.', 'Invalid input', 400);
348
+ }
349
+ let name;
350
+ if (traits.first_name && traits.last_name) {
351
+ name = `${traits.first_name} ${traits.last_name}`;
352
+ }
353
+ else if (traits.firstName && traits.lastName) {
354
+ name = `${traits.firstName} ${traits.lastName}`;
355
+ }
356
+ else if (traits.name) {
357
+ name = traits.name;
358
+ }
359
+ else {
360
+ name = traits.first_name || traits.last_name || traits.firstName || traits.lastName || 'User';
361
+ }
362
+ const bcc = JSON.parse(payload.bcc ?? '[]');
363
+ const parsedSubject = await parseTemplating(payload.subject, profile, 'Subject', statsClient, tags, settings, logger);
364
+ let parsedBodyHtml;
365
+ if (payload.bodyUrl && settings.unlayerApiKey) {
366
+ const { content: body } = await request(payload.bodyUrl, { method: 'GET', skipResponseCloning: true });
367
+ const bodyHtml = payload.bodyType === 'html'
368
+ ? body
369
+ : await generateEmailHtml(request, settings, body, statsClient, tags, logger);
370
+ parsedBodyHtml = await parseTemplating(bodyHtml, profile, 'Body', statsClient, tags, settings, logger);
371
+ }
372
+ else {
373
+ parsedBodyHtml = await parseTemplating(payload.bodyHtml ?? '', profile, 'Body HTML', statsClient, tags, settings, logger);
374
+ }
375
+ if (payload.bodyType === 'design' && payload.previewText) {
376
+ const parsedPreviewText = await parseTemplating(payload.previewText, profile, 'Preview text', statsClient, tags, settings, logger);
377
+ parsedBodyHtml = insertEmailPreviewText(parsedBodyHtml, parsedPreviewText);
378
+ }
379
+ try {
380
+ statsClient?.incr('actions-personas-messaging-sendgrid.request', 1, tags);
381
+ const req = {
382
+ method: 'post',
383
+ headers: {
384
+ authorization: `Bearer ${settings.sendGridApiKey}`
385
+ },
386
+ json: {
387
+ personalizations: [
388
+ {
389
+ to: [
390
+ {
391
+ email: toEmail,
392
+ name: name
393
+ }
394
+ ],
395
+ bcc: bcc.length > 0 ? bcc : undefined,
396
+ custom_args: {
397
+ ...payload.customArgs,
398
+ source_id: settings.sourceId,
399
+ space_id: settings.spaceId,
400
+ user_id: payload.userId ?? undefined,
401
+ __segment_internal_external_id_key__: EXTERNAL_ID_KEY,
402
+ __segment_internal_external_id_value__: profile[EXTERNAL_ID_KEY]
403
+ }
404
+ }
405
+ ],
406
+ from: {
407
+ email: payload.fromEmail,
408
+ name: payload.fromName
409
+ },
410
+ reply_to: {
411
+ email: payload.replyToEmail,
412
+ name: payload.replyToName
413
+ },
414
+ subject: parsedSubject,
415
+ content: [
416
+ {
417
+ type: 'text/html',
418
+ value: parsedBodyHtml
419
+ }
420
+ ],
421
+ tracking_settings: {
422
+ subscription_tracking: {
423
+ enable: true,
424
+ substitution_tag: '[unsubscribe]'
425
+ }
426
+ }
427
+ }
428
+ };
429
+ statsClient?.set('actions-personas-messaging-sendgrid.request_body_size', JSON.stringify(req).length, tags);
430
+ const response = await request('https://api.sendgrid.com/v3/mail/send', req);
431
+ tags.push(`sendgrid_status_code:${response.status}`);
432
+ statsClient?.incr('actions-personas-messaging-sendgrid.response', 1, tags);
433
+ if (payload?.eventOccurredTS != undefined) {
434
+ statsClient?.histogram('actions-personas-messaging-sendgrid.eventDeliveryTS', Date.now() - new Date(payload?.eventOccurredTS).getTime(), tags);
435
+ }
436
+ return response;
437
+ }
438
+ catch (error) {
439
+ logger?.error(`TE Messaging: Email message request failure - ${settings.spaceId} - [${error}]`);
440
+ statsClient?.incr('actions-personas-messaging-sendgrid.request-failure', 1, tags);
441
+ throw new actions_core_1.IntegrationError('Unable to send email message', 'SendGrid API request failure', 500);
442
+ }
443
+ }
444
+ else {
445
+ logger?.error(`TE Messaging: Email subscription status invalid "${emailProfile.subscriptionStatus}" - ${settings.spaceId}`);
446
+ statsClient?.incr('actions-personas-messaging-sendgrid.sendgrid-error', 1, tags);
447
+ throw new actions_core_1.IntegrationError(`Failed to process the subscription state: "${emailProfile.subscriptionStatus}"`, 'Invalid subscriptionStatus value', 400);
448
+ }
449
+ }
450
+ };
451
+ exports.default = action;
452
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-sendgrid/sendEmail/index.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0F;AAG1F,uCAA6C;AAC7C,sDAA6B;AAC7B,6CAAwC;AAExC,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAI7B,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,WAAmB,EAAU,EAAE;IAC3E,MAAM,CAAC,GAAG,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAG5B,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;;QAEZ,wBAAU,CAAC,WAAW,CAAC;;;;QAIvB,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;;GAE9B,CAAC,CAAA;IAEF,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;AACjB,CAAC,CAAA;AAGD,MAAM,qBAAqB,GAAG,CAAC,WAAmB,EAAE,MAAe,EAAU,EAAE;IAC7E,MAAM,UAAU,GAAG,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,kBAAkB,CAAA;IACxF,MAAM,YAAY,GAAG,WAAW,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAA;IACnE,OAAO,WAAW,UAAU,IAAI,YAAY,EAAE,CAAA;AAChD,CAA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,SAAS,EAAE;oBACzC,WAAW,EAAE,SAAS,CACpB,qDAAqD,EACrD,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC,OAAO,EAAE,EACzD,IAAI,CACL,CAAA;iBACF;gBACD,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAc,EAAE;gBACvB,MAAM,EAAE,KAAK,CAAC,iDAAiD,QAAQ,CAAC,OAAO,OAAO,KAAK,GAAG,CAAC,CAAA;gBAC/F,WAAW,EAAE,IAAI,CAAC,qDAAqD,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;gBACjF,MAAM,IAAI,+BAAgB,CAAC,8BAA8B,EAAE,8BAA8B,EAAE,GAAG,CAAC,CAAA;aAChG;SACF;aAAM;YACL,MAAM,EAAE,KAAK,CACX,oDAAoD,YAAY,CAAC,kBAAkB,OAAO,QAAQ,CAAC,OAAO,EAAE,CAC7G,CAAA;YACD,WAAW,EAAE,IAAI,CAAC,oDAAoD,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;YAChF,MAAM,IAAI,+BAAgB,CACxB,8CAA8C,YAAY,CAAC,kBAAkB,GAAG,EAChF,kCAAkC,EAClC,GAAG,CACJ,CAAA;SACF;IACH,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,22 @@
1
+ export interface Payload {
2
+ userId?: string;
3
+ toNumber?: string;
4
+ from: string;
5
+ body?: string;
6
+ contentSid?: string;
7
+ customArgs?: {
8
+ [k: string]: unknown;
9
+ };
10
+ connectionOverrides?: string;
11
+ send?: boolean;
12
+ traitEnrichment?: boolean;
13
+ externalIds?: {
14
+ id?: string;
15
+ type?: string;
16
+ subscriptionStatus?: string;
17
+ }[];
18
+ traits?: {
19
+ [k: string]: unknown;
20
+ };
21
+ eventOccurredTS?: string;
22
+ }