@segment/action-destinations 3.267.0 → 3.267.1-staging-56c8f3280

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 (93) hide show
  1. package/dist/destinations/amazon-ads/generated-types.d.ts +9 -0
  2. package/dist/destinations/amazon-ads/index.d.ts +2 -2
  3. package/dist/destinations/amazon-ads/index.js +164 -6
  4. package/dist/destinations/amazon-ads/index.js.map +1 -1
  5. package/dist/destinations/amazon-ads/syncAudiences/generated-types.d.ts +13 -0
  6. package/dist/destinations/amazon-ads/syncAudiences/index.js +201 -7
  7. package/dist/destinations/amazon-ads/syncAudiences/index.js.map +1 -1
  8. package/dist/destinations/amazon-ads/types.d.ts +25 -0
  9. package/dist/destinations/amazon-ads/utils.d.ts +31 -0
  10. package/dist/destinations/amazon-ads/utils.js +18 -0
  11. package/dist/destinations/amazon-ads/utils.js.map +1 -0
  12. package/dist/destinations/engage/utils/track.d.ts +17 -17
  13. package/dist/destinations/engage-messaging-sendgrid/index.d.ts +4 -3
  14. package/dist/destinations/engage-messaging-sendgrid/index.js +68 -16
  15. package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
  16. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.d.ts +22 -0
  17. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js +189 -0
  18. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js.map +1 -0
  19. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +16 -0
  20. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js +3 -0
  21. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
  22. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.d.ts +5 -0
  23. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +29 -0
  24. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
  25. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +43 -0
  26. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +419 -0
  27. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -0
  28. package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.d.ts +12 -0
  29. package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js +3 -0
  30. package/dist/destinations/engage-messaging-sendgrid/sendEmail/UnlayerResponse.js.map +1 -0
  31. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +56 -0
  32. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js +3 -0
  33. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.js.map +1 -0
  34. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.d.ts +5 -0
  35. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +258 -0
  36. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -0
  37. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.d.ts +1 -0
  38. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js +23 -0
  39. package/dist/destinations/engage-messaging-sendgrid/sendEmail/insertEmailPreviewText.js.map +1 -0
  40. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.d.ts +1 -0
  41. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js +14 -0
  42. package/dist/destinations/engage-messaging-sendgrid/sendEmail/isRestrictedDomain.js.map +1 -0
  43. package/dist/destinations/engage-messaging-twilio/index.d.ts +4 -3
  44. package/dist/destinations/engage-messaging-twilio/index.js +169 -15
  45. package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
  46. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.d.ts +29 -0
  47. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js +169 -0
  48. package/dist/destinations/engage-messaging-twilio/sendMobilePush/PushSender.js.map +1 -0
  49. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +39 -0
  50. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js +3 -0
  51. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.js.map +1 -0
  52. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.d.ts +5 -0
  53. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +251 -0
  54. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -0
  55. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.d.ts +9 -0
  56. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js +72 -0
  57. package/dist/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.js.map +1 -0
  58. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.d.ts +27 -0
  59. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js +3 -0
  60. package/dist/destinations/engage-messaging-twilio/sendSms/generated-types.js.map +1 -0
  61. package/dist/destinations/engage-messaging-twilio/sendSms/index.d.ts +5 -0
  62. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +163 -0
  63. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -0
  64. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +9 -0
  65. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js +89 -0
  66. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -0
  67. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +25 -0
  68. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js +3 -0
  69. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +1 -0
  70. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.d.ts +5 -0
  71. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +137 -0
  72. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -0
  73. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.d.ts +16 -0
  74. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js +71 -0
  75. package/dist/destinations/engage-messaging-twilio/utils/PhoneMessageSender.js.map +1 -0
  76. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.d.ts +16 -0
  77. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js +115 -0
  78. package/dist/destinations/engage-messaging-twilio/utils/TwilioMessageSender.js.map +1 -0
  79. package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +2 -0
  80. package/dist/destinations/engage-messaging-twilio/utils/index.js +15 -0
  81. package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
  82. package/dist/destinations/engage-messaging-twilio/utils/types.d.ts +23 -0
  83. package/dist/destinations/engage-messaging-twilio/utils/types.js +3 -0
  84. package/dist/destinations/engage-messaging-twilio/utils/types.js.map +1 -0
  85. package/dist/destinations/index.js.map +1 -1
  86. package/dist/destinations/moloco-rmp/common/convert.js +29 -17
  87. package/dist/destinations/moloco-rmp/common/convert.js.map +1 -1
  88. package/dist/destinations/xtremepush/identify/index.js +2 -2
  89. package/dist/destinations/xtremepush/identify/index.js.map +1 -1
  90. package/dist/destinations/xtremepush/index.js.map +1 -1
  91. package/dist/destinations/xtremepush/track/index.js +2 -2
  92. package/dist/destinations/xtremepush/track/index.js.map +1 -1
  93. package/package.json +4 -4
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PushSender = exports.MobilePushExtIdTypes = void 0;
10
+ const utils_1 = require("../utils");
11
+ const actions_shared_1 = require("@segment/actions-shared");
12
+ const actions_core_1 = require("@segment/actions-core");
13
+ var MobilePushExtIdTypes;
14
+ (function (MobilePushExtIdTypes) {
15
+ MobilePushExtIdTypes["IOS"] = "ios.push_token";
16
+ MobilePushExtIdTypes["ANDROID"] = "android.push_token";
17
+ })(MobilePushExtIdTypes = exports.MobilePushExtIdTypes || (exports.MobilePushExtIdTypes = {}));
18
+ class PushSender extends utils_1.TwilioMessageSender {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.supportedTemplateTypes = ['twilio/text', 'twilio/media'];
22
+ this.DEFAULT_HOSTNAME = 'push.ashburn.us1.twilio.com';
23
+ }
24
+ getChannelType() {
25
+ return 'mobilepush';
26
+ }
27
+ isSupportedExternalId(externalId) {
28
+ return PushSender.externalIdTypes.includes(externalId.type);
29
+ }
30
+ get twilioHostname() {
31
+ return this.settings.twilioHostname?.length ? this.settings.twilioHostname : this.DEFAULT_HOSTNAME;
32
+ }
33
+ get twilioToken() {
34
+ return Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
35
+ }
36
+ async beforeSend(recepients) {
37
+ if (this.payload.send && recepients.length > 0) {
38
+ this.bodyCustomDataBundle = await this.getBody();
39
+ }
40
+ }
41
+ async sendToRecepient(recipientDevice) {
42
+ const { requestBody, customData } = this.bodyCustomDataBundle;
43
+ const webhookUrl = this.getWebhookUrlWithParams(recipientDevice.type, recipientDevice.id);
44
+ const body = new URLSearchParams(requestBody);
45
+ if (recipientDevice?.type?.toLowerCase() === MobilePushExtIdTypes.IOS) {
46
+ body.append('Recipients', JSON.stringify({
47
+ apn: [{ addr: recipientDevice.id }]
48
+ }));
49
+ }
50
+ else {
51
+ body.append('Recipients', JSON.stringify({
52
+ fcm: [{ addr: recipientDevice.id }]
53
+ }));
54
+ }
55
+ body.append('CustomData', JSON.stringify({
56
+ ...customData,
57
+ __segment_internal_external_id_key__: recipientDevice.type,
58
+ __segment_internal_external_id_value__: recipientDevice.id
59
+ }));
60
+ if (webhookUrl) {
61
+ body.append('DeliveryCallbackUrl', webhookUrl);
62
+ }
63
+ this.statsSet('message_body_size', body?.toString().length);
64
+ const res = await this.request(`https://${this.twilioHostname}/v1/Services/${this.payload.from}/Notifications`, {
65
+ method: 'POST',
66
+ headers: {
67
+ authorization: `Basic ${this.twilioToken}`
68
+ },
69
+ body
70
+ });
71
+ return res;
72
+ }
73
+ async getBody() {
74
+ let templateTypes;
75
+ if (this.payload.contentSid) {
76
+ templateTypes = await this.getContentTemplateTypes();
77
+ }
78
+ const profile = { traits: this.payload.traits };
79
+ const parsedTemplateContent = await this.parseContent({
80
+ title: this.payload.customizations?.title,
81
+ body: this.payload.customizations?.body || templateTypes?.body,
82
+ media: this.payload.customizations?.media || templateTypes?.media,
83
+ link: this.payload.customizations?.link
84
+ }, profile);
85
+ const tapActionButtons = this.payload.customizations?.tapActionButtons ?? [];
86
+ const parsedTapActionButtons = await Promise.all(tapActionButtons.map(async (button) => {
87
+ return {
88
+ ...button,
89
+ onTap: this.getTapActionPreset(button.onTap, button.link),
90
+ ...(await this.parseContent({ link: button.link, text: button.text }, profile))
91
+ };
92
+ }));
93
+ const badgeAmount = this.payload.customizations?.badgeAmount ?? 1;
94
+ const badgeStrategy = this.payload.customizations?.badgeStrategy ?? 'inc';
95
+ try {
96
+ const customData = this.removeEmpties({
97
+ ...this.payload.customArgs,
98
+ space_id: this.settings.spaceId,
99
+ badgeAmount,
100
+ badgeStrategy,
101
+ media: parsedTemplateContent.media?.length ? parsedTemplateContent.media : undefined,
102
+ link: parsedTemplateContent.link?.length ? parsedTemplateContent.link : undefined,
103
+ tapActionButtons: parsedTapActionButtons
104
+ });
105
+ const body = this.removeEmpties({
106
+ Body: parsedTemplateContent.body,
107
+ Action: this.getTapActionPreset(this.payload.customizations?.tapAction, this.payload.customizations?.link),
108
+ Title: parsedTemplateContent.title,
109
+ Sound: this.payload.customizations?.sound,
110
+ Priority: this.payload.customizations?.priority,
111
+ TimeToLive: this.payload.customizations?.ttl,
112
+ FcmPayload: this.getFcmNotificationOverrides(badgeAmount),
113
+ ApnPayload: {
114
+ aps: {
115
+ 'mutable-content': 1,
116
+ badge: badgeAmount
117
+ }
118
+ }
119
+ });
120
+ const requestBody = new URLSearchParams({
121
+ ...body,
122
+ FcmPayload: JSON.stringify(body.FcmPayload),
123
+ ApnPayload: JSON.stringify(body.ApnPayload)
124
+ });
125
+ return { requestBody, customData };
126
+ }
127
+ catch (error) {
128
+ this.rethrowIntegrationError(error, () => new actions_core_1.PayloadValidationError('Unable to construct Push API request body'));
129
+ }
130
+ }
131
+ getFcmNotificationOverrides(badgeAmount) {
132
+ if (this.payload.googleApiVersion === 'v1') {
133
+ return {
134
+ android: {
135
+ mutable_content: true,
136
+ notification: {
137
+ badge: badgeAmount
138
+ }
139
+ }
140
+ };
141
+ }
142
+ return {
143
+ mutable_content: true,
144
+ notification: {
145
+ badge: badgeAmount
146
+ }
147
+ };
148
+ }
149
+ getTapActionPreset(tapAction, link) {
150
+ if (link?.length && tapAction === 'open_app') {
151
+ return 'deep_link';
152
+ }
153
+ return tapAction;
154
+ }
155
+ removeEmpties(obj) {
156
+ return JSON.parse(JSON.stringify(obj, (_, value) => {
157
+ if (value == null || value?.length === 0 || (typeof value === 'object' && Object.keys(value).length === 0)) {
158
+ return undefined;
159
+ }
160
+ return value;
161
+ }));
162
+ }
163
+ }
164
+ PushSender.externalIdTypes = Object.values(MobilePushExtIdTypes);
165
+ __decorate([
166
+ actions_shared_1.track()
167
+ ], PushSender.prototype, "getBody", null);
168
+ exports.PushSender = PushSender;
169
+ //# sourceMappingURL=PushSender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PushSender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendMobilePush/PushSender.ts"],"names":[],"mappings":";;;;;;;;;AAEA,oCAA8C;AAC9C,4DAAsD;AAGtD,wDAA8D;AAS9D,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,8CAAsB,CAAA;IACtB,sDAA8B,CAAA;AAChC,CAAC,EAHW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAG/B;AAED,MAAa,UAAW,SAAQ,2BAAgC;IAAhE;;QASW,2BAAsB,GAAa,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;QACnE,qBAAgB,GAAG,6BAA6B,CAAA;IAwL1D,CAAC;IAhMC,cAAc;QACZ,OAAO,YAAY,CAAA;IACrB,CAAC;IACD,qBAAqB,CAAC,UAA8B;QAClD,OAAO,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAW,CAAC,CAAA;IACpE,CAAC;IAKD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAA;IACpG,CAAC;IACD,IAAI,WAAW;QAEb,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAuB;QACtC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9C,IAAI,CAAC,oBAAoB,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;SACjD;IACH,CAAC;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CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;gBAC1G,OAAO,SAAS,CAAA;aACjB;YACD,OAAO,KAAK,CAAA;QACd,CAAC,CAAC,CACH,CAAA;IACH,CAAC;;AAhMe,0BAAe,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;AA4ErE;IADC,sBAAK,EAAE;yCAuEP;AAnJH,gCAkMC"}
@@ -0,0 +1,39 @@
1
+ export interface Payload {
2
+ contentSid?: string;
3
+ from: string;
4
+ customizations?: {
5
+ title?: string;
6
+ body?: string;
7
+ media?: string[];
8
+ tapAction?: string;
9
+ link?: string;
10
+ sound?: string;
11
+ priority?: string;
12
+ badgeAmount?: number;
13
+ badgeStrategy?: string;
14
+ ttl?: number;
15
+ tapActionButtons?: {
16
+ id: string;
17
+ text: string;
18
+ onTap: string;
19
+ link?: string;
20
+ }[];
21
+ };
22
+ customArgs?: {
23
+ [k: string]: unknown;
24
+ };
25
+ connectionOverrides?: string;
26
+ send?: boolean;
27
+ segmentComputationId?: string;
28
+ externalIds?: {
29
+ id?: string;
30
+ type?: string;
31
+ channelType?: string;
32
+ subscriptionStatus?: string;
33
+ }[];
34
+ traits?: {
35
+ [k: string]: unknown;
36
+ };
37
+ eventOccurredTS?: string;
38
+ googleApiVersion?: string;
39
+ }
@@ -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-twilio/sendMobilePush/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ export declare const actionDefinition: ActionDefinition<Settings, Payload>;
5
+ export default actionDefinition;
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionDefinition = void 0;
4
+ const PushSender_1 = require("./PushSender");
5
+ exports.actionDefinition = {
6
+ title: 'Send Mobile Push Notification',
7
+ description: 'Send a push notification to a mobile device using Twilio',
8
+ defaultSubscription: 'type = "track" and event = "Audience Entered"',
9
+ fields: {
10
+ contentSid: {
11
+ label: 'Content template Sid',
12
+ description: 'The template to be sent',
13
+ type: 'string',
14
+ required: false
15
+ },
16
+ from: {
17
+ label: 'From',
18
+ description: 'The Push Service Sid to send the push notification from.',
19
+ type: 'string',
20
+ required: true
21
+ },
22
+ customizations: {
23
+ label: 'Customizations',
24
+ description: 'Customizations for the notification',
25
+ type: 'object',
26
+ properties: {
27
+ title: {
28
+ label: 'Notification title',
29
+ description: 'The title to be displayed for your notification',
30
+ type: 'string',
31
+ required: false
32
+ },
33
+ body: {
34
+ label: 'Notification body',
35
+ description: 'The body to be displayed for your notification',
36
+ type: 'string',
37
+ required: false
38
+ },
39
+ media: {
40
+ label: 'Media urls',
41
+ description: 'Media to display in notification',
42
+ type: 'string',
43
+ required: false,
44
+ multiple: true
45
+ },
46
+ tapAction: {
47
+ label: 'Notification open action',
48
+ description: 'Sets the notification click action/category: open_app, open_url, deep_link, or a custom string',
49
+ type: 'string',
50
+ required: false
51
+ },
52
+ link: {
53
+ label: 'Notification Link',
54
+ description: 'Deep link or URL to navigate to when the notification is tapped',
55
+ type: 'string',
56
+ required: false
57
+ },
58
+ sound: {
59
+ label: 'Notification sound',
60
+ description: 'Sets the sound played when the notification arrives',
61
+ type: 'string',
62
+ required: false
63
+ },
64
+ priority: {
65
+ label: 'Notification priority',
66
+ description: 'Sets the priority of the message',
67
+ type: 'string',
68
+ required: false,
69
+ choices: [
70
+ { label: 'low', value: 'low' },
71
+ { label: 'high', value: 'high' }
72
+ ]
73
+ },
74
+ badgeAmount: {
75
+ label: 'Badge amount',
76
+ description: 'The badge count which is used in combination with badge strategy to determine the final badge',
77
+ type: 'number',
78
+ default: 1,
79
+ required: false
80
+ },
81
+ badgeStrategy: {
82
+ label: 'Badge strategy',
83
+ description: 'Sets the badge count strategy in the notification',
84
+ type: 'string',
85
+ required: false,
86
+ default: 'inc',
87
+ choices: [
88
+ {
89
+ value: 'inc',
90
+ label: 'increment'
91
+ },
92
+ {
93
+ value: 'dec',
94
+ label: 'decrement'
95
+ },
96
+ {
97
+ value: 'set',
98
+ label: 'set'
99
+ }
100
+ ]
101
+ },
102
+ ttl: {
103
+ label: 'Time to live',
104
+ description: 'Sets the time to live for the notification',
105
+ type: 'number',
106
+ required: false
107
+ },
108
+ tapActionButtons: {
109
+ label: 'Tap action buttons',
110
+ description: 'Sets the buttons to show when interacting with a notification',
111
+ required: false,
112
+ type: 'object',
113
+ multiple: true,
114
+ properties: {
115
+ id: {
116
+ label: 'Id',
117
+ description: 'Button id',
118
+ type: 'string',
119
+ required: true
120
+ },
121
+ text: {
122
+ label: 'Text',
123
+ description: 'Button text',
124
+ type: 'string',
125
+ required: true
126
+ },
127
+ onTap: {
128
+ label: 'Tap action',
129
+ description: 'The action to perform when this button is tapped: open_app, open_url, deep_link, or a custom string',
130
+ type: 'string',
131
+ required: true
132
+ },
133
+ link: {
134
+ label: 'Link',
135
+ description: 'Deep link or URL to navigate to when this button is tapped',
136
+ type: 'string',
137
+ required: false
138
+ }
139
+ }
140
+ }
141
+ }
142
+ },
143
+ customArgs: {
144
+ label: 'Custom Arguments',
145
+ description: 'Additional custom arguments that will be opaquely sent back on webhook events',
146
+ type: 'object',
147
+ required: false
148
+ },
149
+ connectionOverrides: {
150
+ label: 'Connection Overrides',
151
+ description: 'Connection overrides are configuration supported by twilio webhook services. Must be passed as fragments on the callback url',
152
+ type: 'string',
153
+ required: false
154
+ },
155
+ send: {
156
+ label: 'Send Notification',
157
+ description: 'Whether or not the notification should actually get sent.',
158
+ type: 'boolean',
159
+ required: false,
160
+ default: false
161
+ },
162
+ segmentComputationId: {
163
+ label: 'Segment Computation ID',
164
+ description: 'Segment computation ID',
165
+ type: 'string',
166
+ required: false,
167
+ default: {
168
+ '@path': '$.context.personas.computation_id'
169
+ }
170
+ },
171
+ externalIds: {
172
+ label: 'External IDs',
173
+ description: 'An array of user profile identity information.',
174
+ type: 'object',
175
+ multiple: true,
176
+ properties: {
177
+ id: {
178
+ label: 'ID',
179
+ description: 'A unique identifier for the collection.',
180
+ type: 'string'
181
+ },
182
+ type: {
183
+ label: 'type',
184
+ description: 'The external ID contact type.',
185
+ type: 'string'
186
+ },
187
+ channelType: {
188
+ label: 'type',
189
+ description: 'The external ID contact channel type (SMS, WHATSAPP, etc).',
190
+ type: 'string'
191
+ },
192
+ subscriptionStatus: {
193
+ label: 'ID',
194
+ description: 'The subscription status for the identity.',
195
+ type: 'string'
196
+ }
197
+ },
198
+ default: {
199
+ '@arrayPath': [
200
+ '$.external_ids',
201
+ {
202
+ id: {
203
+ '@path': '$.id'
204
+ },
205
+ type: {
206
+ '@path': '$.type'
207
+ },
208
+ channelType: {
209
+ '@path': '$.channelType'
210
+ },
211
+ subscriptionStatus: {
212
+ '@path': '$.isSubscribed'
213
+ }
214
+ }
215
+ ]
216
+ }
217
+ },
218
+ traits: {
219
+ label: 'Traits',
220
+ description: "A user profile's traits",
221
+ type: 'object',
222
+ required: false,
223
+ default: { '@path': '$.properties' }
224
+ },
225
+ eventOccurredTS: {
226
+ label: 'Event Timestamp',
227
+ description: 'Time of when the actual event happened.',
228
+ type: 'string',
229
+ required: false,
230
+ default: {
231
+ '@path': '$.timestamp'
232
+ }
233
+ },
234
+ googleApiVersion: {
235
+ label: 'Google Api Version',
236
+ description: 'Controls the notification payload format',
237
+ type: 'string',
238
+ required: false,
239
+ choices: [
240
+ { label: 'legacy', value: 'legacy' },
241
+ { label: 'v1', value: 'v1' }
242
+ ],
243
+ default: 'legacy'
244
+ }
245
+ },
246
+ perform: async (request, data) => {
247
+ return new PushSender_1.PushSender(request, data).perform();
248
+ }
249
+ };
250
+ exports.default = exports.actionDefinition;
251
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendMobilePush/index.ts"],"names":[],"mappings":";;;AAIA,6CAAyC;AAE5B,QAAA,gBAAgB,GAAwC;IACnE,KAAK,EAAE,+BAA+B;IACtC,WAAW,EAAE,0DAA0D;IACvE,mBAAmB,EAAE,+CAA+C;IACpE,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EAAE,yBAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;SAChB;QACD,IAAI,EAAE;YACJ,KAAK,EAAE,MAAM;YACb,WAAW,EAAE,0DAA0D;YACvE,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,cAAc,EAAE;YACd,KAAK,EAAE,gBAAgB;YACvB,WAAW,EAAE,qCAAqC;YAClD,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,KAAK,EAAE;oBACL,KAAK,EAAE,oBAAoB;oBAC3B,WAAW,EAAE,iDAAiD;oBAC9D,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,KAAK;iBAChB;gBACD,IAAI,EAAE;oBACJ,KAAK,EAAE,mBAAmB;oBAC1B,WAAW,EAAE,gDAAgD;oBAC7D,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,KAAK;iBAChB;gBACD,KAAK,EAAE;oBACL,KAAK,EAAE,YAAY;oBACnB,WAAW,EAAE,kCAAkC;oBAC/C,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,KAAK;oBACf,QAAQ,EAAE,IAAI;iBACf;gBACD,SAAS,EAAE;oBACT,KAAK,EAAE,0BAA0B;oBACjC,WAAW,EAAE,gGAAgG;oBAC7G,IAAI,EAAE,QAAQ;oBACd,QAAQ,EAAE,KAAK;iBAChB;gBACD,IAAI,EAAE;oBACJ,KAAK,EAAE,mBAAmB;oBAC1B,WAAW,EA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AAE,KAAK;YACf,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;gBACpC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;aAC7B;YACD,OAAO,EAAE,QAAQ;SAClB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC/B,OAAO,IAAI,uBAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;IAChD,CAAC;CACF,CAAA;AAED,kBAAe,wBAAgB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Payload } from './generated-types';
2
+ import { PhoneMessageSender } from '../utils';
3
+ import { ExtId } from '@segment/actions-shared';
4
+ export declare class SmsMessageSender extends PhoneMessageSender<Payload> {
5
+ supportedTemplateTypes: string[];
6
+ getBody(phone: string): Promise<URLSearchParams>;
7
+ getChannelType(): string;
8
+ isSupportedExternalId(externalId: ExtId<Payload>): boolean;
9
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SmsMessageSender = void 0;
10
+ const actions_core_1 = require("@segment/actions-core");
11
+ const utils_1 = require("../utils");
12
+ const actions_shared_1 = require("@segment/actions-shared");
13
+ class SmsMessageSender extends utils_1.PhoneMessageSender {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.supportedTemplateTypes = ['twilio/text', 'twilio/media'];
17
+ }
18
+ async getBody(phone) {
19
+ if (!this.payload.body && !this.payload.contentSid) {
20
+ throw new actions_core_1.PayloadValidationError('Unable to process sms, no body provided and no content sid provided');
21
+ }
22
+ let traits;
23
+ if (this.payload.traitEnrichment) {
24
+ traits = this.payload?.traits ? this.payload?.traits : {};
25
+ }
26
+ else {
27
+ traits = await this.getProfileTraits();
28
+ }
29
+ const profile = {
30
+ user_id: this.payload.userId ?? undefined,
31
+ phone,
32
+ traits
33
+ };
34
+ let parsedBody;
35
+ let parsedMedia = [];
36
+ if (this.payload.contentSid) {
37
+ const data = await this.getContentTemplateTypes();
38
+ const parsed = await this.parseContent(data, profile);
39
+ parsedBody = parsed.body;
40
+ parsedMedia = parsed.media;
41
+ }
42
+ else {
43
+ const parsed = await this.parseContent({ body: this.payload.body ?? '', media: this.payload.media ?? [] }, profile);
44
+ parsedBody = parsed.body;
45
+ parsedMedia = parsed.media;
46
+ }
47
+ const body = new URLSearchParams({
48
+ Body: parsedBody,
49
+ From: this.payload.from,
50
+ To: phone,
51
+ ShortenUrls: 'true'
52
+ });
53
+ parsedMedia?.forEach((media) => {
54
+ body.append('MediaUrl', media);
55
+ });
56
+ return body;
57
+ }
58
+ getChannelType() {
59
+ return 'sms';
60
+ }
61
+ isSupportedExternalId(externalId) {
62
+ if (externalId.type !== 'phone') {
63
+ return false;
64
+ }
65
+ return !externalId.channelType || externalId.channelType.toLowerCase() === this.getChannelType();
66
+ }
67
+ }
68
+ __decorate([
69
+ actions_shared_1.track()
70
+ ], SmsMessageSender.prototype, "getBody", null);
71
+ exports.SmsMessageSender = SmsMessageSender;
72
+ //# sourceMappingURL=SmsMessageSender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmsMessageSender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendSms/SmsMessageSender.ts"],"names":[],"mappings":";;;;;;;;;AAEA,wDAA8D;AAC9D,oCAA6C;AAC7C,4DAAsD;AAEtD,M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,CACR,CAAA;YACD,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA;YACxB,WAAW,GAAG,MAAM,CAAC,KAAK,CAAA;SAC3B;QAED,MAAM,IAAI,GAAG,IAAI,eAAe,CAAC;YAC/B,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,EAAE,EAAE,KAAK;YACT,WAAW,EAAE,MAAM;SACpB,CAAC,CAAA;QAEF,WAAW,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;QAChC,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,cAAc;QACZ,OAAO,KAAK,CAAA;IACd,CAAC;IAED,qBAAqB,CAAC,UAA0B;QAC9C,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO,EAAE;YAC/B,OAAO,KAAK,CAAA;SACb;QACD,OAAO,CAAC,UAAU,CAAC,WAAW,IAAI,UAAU,CAAC,WAAW,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,CAAA;IAClG,CAAC;CACF;AA7DC;IADC,sBAAK,EAAE;+CAkDP;AArDH,4CAiEC"}
@@ -0,0 +1,27 @@
1
+ export interface Payload {
2
+ userId?: string;
3
+ toNumber?: string;
4
+ from: string;
5
+ body?: string;
6
+ media?: string[];
7
+ contentSid?: string;
8
+ customArgs?: {
9
+ [k: string]: unknown;
10
+ };
11
+ connectionOverrides?: string;
12
+ send?: boolean;
13
+ traitEnrichment?: boolean;
14
+ sendBasedOnOptOut?: boolean;
15
+ segmentComputationId?: string;
16
+ externalIds?: {
17
+ id?: string;
18
+ type?: string;
19
+ channelType?: string;
20
+ subscriptionStatus?: string;
21
+ }[];
22
+ traits?: {
23
+ [k: string]: unknown;
24
+ };
25
+ eventOccurredTS?: string;
26
+ messageId?: string;
27
+ }
@@ -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-twilio/sendSms/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ export declare const actionDefinition: ActionDefinition<Settings, Payload>;
5
+ export default actionDefinition;