@segment/action-destinations 3.181.0 → 3.183.0

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 (155) hide show
  1. package/dist/destinations/app-fit/config.d.ts +3 -0
  2. package/dist/destinations/app-fit/config.js +7 -0
  3. package/dist/destinations/app-fit/config.js.map +1 -0
  4. package/dist/destinations/app-fit/generated-types.d.ts +3 -0
  5. package/dist/destinations/app-fit/generated-types.js +3 -0
  6. package/dist/destinations/app-fit/generated-types.js.map +1 -0
  7. package/dist/destinations/app-fit/index.d.ts +4 -0
  8. package/dist/destinations/app-fit/index.js +39 -0
  9. package/dist/destinations/app-fit/index.js.map +1 -0
  10. package/dist/destinations/app-fit/track/generated-types.d.ts +13 -0
  11. package/dist/destinations/app-fit/track/generated-types.js +3 -0
  12. package/dist/destinations/app-fit/track/generated-types.js.map +1 -0
  13. package/dist/destinations/app-fit/track/index.d.ts +5 -0
  14. package/dist/destinations/app-fit/track/index.js +109 -0
  15. package/dist/destinations/app-fit/track/index.js.map +1 -0
  16. package/dist/destinations/engage-messaging-sendgrid/index.js +3 -1
  17. package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
  18. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.d.ts +15 -0
  19. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js +3 -0
  20. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/generated-types.js.map +1 -0
  21. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.d.ts +5 -0
  22. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js +28 -0
  23. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/index.js.map +1 -0
  24. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +12 -0
  25. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +38 -12
  26. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -1
  27. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.d.ts +20 -0
  28. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.js +108 -0
  29. package/dist/destinations/engage-messaging-sendgrid/utils/api-lookups.js.map +1 -0
  30. package/dist/destinations/engage-messaging-sendgrid/utils/types.d.ts +6 -0
  31. package/dist/destinations/engage-messaging-sendgrid/utils/types.js +3 -0
  32. package/dist/destinations/engage-messaging-sendgrid/utils/types.js.map +1 -0
  33. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.d.ts +1 -0
  34. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js +3 -0
  35. package/dist/destinations/engage-messaging-twilio/operationTracking/GenericMethodDecorator.js.map +1 -0
  36. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.d.ts +46 -0
  37. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js +46 -0
  38. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDecorator.js.map +1 -0
  39. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.d.ts +12 -0
  40. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js +23 -0
  41. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationDuration.js.map +1 -0
  42. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.d.ts +12 -0
  43. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js +35 -0
  44. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationErrorHandler.js.map +1 -0
  45. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.d.ts +10 -0
  46. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js +29 -0
  47. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationFinallyHooks.js.map +1 -0
  48. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.d.ts +30 -0
  49. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js +107 -0
  50. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationLogger.js.map +1 -0
  51. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.d.ts +39 -0
  52. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js +130 -0
  53. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationStats.js.map +1 -0
  54. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.d.ts +1 -0
  55. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js +377 -0
  56. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTracker.test.js.map +1 -0
  57. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.d.ts +23 -0
  58. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js +49 -0
  59. package/dist/destinations/engage-messaging-twilio/operationTracking/OperationTree.js.map +1 -0
  60. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.d.ts +6 -0
  61. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js +3 -0
  62. package/dist/destinations/engage-messaging-twilio/operationTracking/TrackedError.js.map +1 -0
  63. package/dist/destinations/engage-messaging-twilio/operationTracking/index.d.ts +10 -0
  64. package/dist/destinations/engage-messaging-twilio/operationTracking/index.js +23 -0
  65. package/dist/destinations/engage-messaging-twilio/operationTracking/index.js.map +1 -0
  66. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.d.ts +21 -0
  67. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js +99 -0
  68. package/dist/destinations/engage-messaging-twilio/operationTracking/wrapTryCatchFinallyPromisable.js.map +1 -0
  69. package/dist/destinations/engage-messaging-twilio/sendMobilePush/generated-types.d.ts +1 -1
  70. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js +7 -25
  71. package/dist/destinations/engage-messaging-twilio/sendMobilePush/index.js.map +1 -1
  72. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.d.ts +1 -1
  73. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js +31 -25
  74. package/dist/destinations/engage-messaging-twilio/sendMobilePush/push-sender.js.map +1 -1
  75. package/dist/destinations/engage-messaging-twilio/sendSms/index.js +1 -1
  76. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
  77. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +1 -1
  78. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +20 -10
  79. package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +1 -1
  80. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +1 -1
  81. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +1 -1
  82. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +1 -1
  83. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +42 -36
  84. package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +1 -1
  85. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.d.ts +12 -0
  86. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js +31 -0
  87. package/dist/destinations/engage-messaging-twilio/utils/IntegrationErrorWrapper.js.map +1 -0
  88. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.d.ts +15 -0
  89. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js +36 -0
  90. package/dist/destinations/engage-messaging-twilio/utils/MessageLogger.js.map +1 -0
  91. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.d.ts +14 -0
  92. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js +78 -0
  93. package/dist/destinations/engage-messaging-twilio/utils/MessageStats.js.map +1 -0
  94. package/dist/destinations/engage-messaging-twilio/utils/index.d.ts +6 -0
  95. package/dist/destinations/engage-messaging-twilio/utils/index.js +19 -0
  96. package/dist/destinations/engage-messaging-twilio/utils/index.js.map +1 -0
  97. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.d.ts +1 -0
  98. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js +8 -0
  99. package/dist/destinations/engage-messaging-twilio/utils/isDestinationActionService.js.map +1 -0
  100. package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +21 -54
  101. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +112 -225
  102. package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +1 -1
  103. package/dist/destinations/engage-messaging-twilio/utils/phone-message.d.ts +7 -0
  104. package/dist/destinations/engage-messaging-twilio/utils/phone-message.js +30 -33
  105. package/dist/destinations/engage-messaging-twilio/utils/phone-message.js.map +1 -1
  106. package/dist/destinations/engage-messaging-twilio/utils/track.d.ts +45 -0
  107. package/dist/destinations/engage-messaging-twilio/utils/track.js +9 -0
  108. package/dist/destinations/engage-messaging-twilio/utils/track.js.map +1 -0
  109. package/dist/destinations/hubspot/generated-types.d.ts +1 -0
  110. package/dist/destinations/hubspot/index.js +7 -1
  111. package/dist/destinations/hubspot/index.js.map +1 -1
  112. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +9 -1
  113. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
  114. package/dist/destinations/index.js +3 -0
  115. package/dist/destinations/index.js.map +1 -1
  116. package/dist/destinations/insider/trackEvent/index.js +1 -1
  117. package/dist/destinations/insider/trackEvent/index.js.map +1 -1
  118. package/dist/destinations/listrak/generated-types.d.ts +4 -0
  119. package/dist/destinations/listrak/generated-types.js +3 -0
  120. package/dist/destinations/listrak/generated-types.js.map +1 -0
  121. package/dist/destinations/listrak/index.d.ts +4 -0
  122. package/dist/destinations/listrak/index.js +55 -0
  123. package/dist/destinations/listrak/index.js.map +1 -0
  124. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.d.ts +8 -0
  125. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js +3 -0
  126. package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.js.map +1 -0
  127. package/dist/destinations/listrak/updateEmailContactProfileFields/index.d.ts +13 -0
  128. package/dist/destinations/listrak/updateEmailContactProfileFields/index.js +77 -0
  129. package/dist/destinations/listrak/updateEmailContactProfileFields/index.js.map +1 -0
  130. package/dist/destinations/liveramp-audiences/audienceEntered/index.js +1 -1
  131. package/dist/destinations/liveramp-audiences/audienceEntered/index.js.map +1 -1
  132. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.d.ts +2 -2
  133. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js +6 -2
  134. package/dist/destinations/liveramp-audiences/audienceEntered/sftp.js.map +1 -1
  135. package/dist/destinations/liveramp-audiences/index.js +1 -1
  136. package/dist/destinations/liveramp-audiences/index.js.map +1 -1
  137. package/dist/destinations/m3ter/auth.d.ts +7 -0
  138. package/dist/destinations/m3ter/auth.js +16 -0
  139. package/dist/destinations/m3ter/auth.js.map +1 -0
  140. package/dist/destinations/m3ter/constants.d.ts +4 -0
  141. package/dist/destinations/m3ter/constants.js +8 -0
  142. package/dist/destinations/m3ter/constants.js.map +1 -0
  143. package/dist/destinations/m3ter/generated-types.d.ts +5 -0
  144. package/dist/destinations/m3ter/generated-types.js +3 -0
  145. package/dist/destinations/m3ter/generated-types.js.map +1 -0
  146. package/dist/destinations/m3ter/index.d.ts +4 -0
  147. package/dist/destinations/m3ter/index.js +68 -0
  148. package/dist/destinations/m3ter/index.js.map +1 -0
  149. package/dist/destinations/m3ter/submitMeasurements/generated-types.d.ts +32 -0
  150. package/dist/destinations/m3ter/submitMeasurements/generated-types.js +3 -0
  151. package/dist/destinations/m3ter/submitMeasurements/generated-types.js.map +1 -0
  152. package/dist/destinations/m3ter/submitMeasurements/index.d.ts +5 -0
  153. package/dist/destinations/m3ter/submitMeasurements/index.js +116 -0
  154. package/dist/destinations/m3ter/submitMeasurements/index.js.map +1 -0
  155. package/package.json +4 -4
@@ -1,61 +1,64 @@
1
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
+ };
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDestinationActionService = exports.wrapPromisable = exports.MessageSender = exports.FLAGON_NAME_LOG_ERROR = exports.FLAGON_NAME_LOG_INFO = void 0;
9
+ exports.MessageSender = void 0;
4
10
  const liquidjs_1 = require("liquidjs");
5
11
  const actions_core_1 = require("@segment/actions-core");
12
+ const track_1 = require("./track");
13
+ const isDestinationActionService_1 = require("./isDestinationActionService");
14
+ const MessageLogger_1 = require("./MessageLogger");
15
+ const MessageStats_1 = require("./MessageStats");
16
+ const IntegrationErrorWrapper_1 = require("./IntegrationErrorWrapper");
6
17
  const Liquid = new liquidjs_1.Liquid();
7
- exports.FLAGON_NAME_LOG_INFO = 'engage-messaging-log-info';
8
- exports.FLAGON_NAME_LOG_ERROR = 'engage-messaging-log-error';
9
18
  class MessageSender {
10
- constructor(request, executeInput, logDetails = {}) {
11
- this.request = request;
19
+ constructor(requestRaw, executeInput) {
20
+ this.requestRaw = requestRaw;
12
21
  this.executeInput = executeInput;
13
- this.logDetails = logDetails;
22
+ this.logger = new MessageLogger_1.MessageLogger(this);
23
+ this.statsClient = new MessageStats_1.MessageStats(this);
14
24
  this.payload = executeInput.payload;
15
25
  this.settings = executeInput.settings;
16
- this.statsClient = executeInput.statsContext?.statsClient;
17
- this.tags = executeInput.statsContext?.tags ?? [];
18
26
  if (!this.settings.region) {
19
27
  this.settings.region = 'us-west-1';
20
28
  }
21
- this.tags.push(`space_id:${this.settings.spaceId}`, `projectid:${this.settings.sourceId}`, `region:${this.settings.region}`, `channel:${this.getChannelType()}`);
22
- this.logger = executeInput.logger;
23
29
  }
24
- async send() {
25
- this.beforeSend();
26
- return this.logWrap(this.doSend.bind(this), {
27
- operationName: 'Destination Action',
28
- stats: {
29
- onStart: () => [{ metric: 'destination_action_start' }],
30
- onEnd: (r) => [
31
- { metric: 'destination_action_end', extraTags: r.error ? ['error:true', 'reason:' + r.error] : undefined }
32
- ]
33
- }
30
+ async request(url, options) {
31
+ const op = this.currentOperation;
32
+ op?.onFinally.push(() => {
33
+ const respError = op?.error;
34
+ const response = respError?.response || op.result;
35
+ const response_code = response?.data?.code || respError?.code;
36
+ if (response_code)
37
+ op.tags.push(`response_code:${response_code}`);
38
+ const response_status = response?.data?.status || respError?.status;
39
+ if (response_status)
40
+ op.tags.push(`response_status:${response_status}`);
34
41
  });
42
+ return this.requestRaw(url, options);
43
+ }
44
+ async perform() {
45
+ this.beforeSend();
46
+ return this.doSend();
35
47
  }
36
48
  async parseContent(content, profile) {
37
- try {
38
- const parsedEntries = await Promise.all(Object.entries(content).map(async ([key, val]) => {
39
- if (val == null) {
40
- return [key, val];
41
- }
42
- if (Array.isArray(val)) {
43
- val = await Promise.all(val.map((item) => Liquid.parseAndRender(item, { profile })));
44
- }
45
- else {
46
- val = await Liquid.parseAndRender(val, { profile });
47
- }
49
+ const parsedEntries = await Promise.all(Object.entries(content).map(async ([key, val]) => {
50
+ if (val == null) {
48
51
  return [key, val];
49
- }));
50
- return Object.fromEntries(parsedEntries);
51
- }
52
- catch (error) {
53
- this.logDetails['error'] = error instanceof Error ? error.message : error?.toString();
54
- this.logError(`unable to parse templating - ${this.settings.spaceId}`);
55
- this.tags.push('reason:invalid_liquid');
56
- this.stats('incr', 'error', 1);
57
- throw new actions_core_1.PayloadValidationError(`Unable to parse templating in ${this.getChannelType()}`);
58
- }
52
+ }
53
+ if (Array.isArray(val)) {
54
+ val = await Promise.all(val.map((item) => Liquid.parseAndRender(item, { profile })));
55
+ }
56
+ else {
57
+ val = await Liquid.parseAndRender(val, { profile });
58
+ }
59
+ return [key, val];
60
+ }));
61
+ return Object.fromEntries(parsedEntries);
59
62
  }
60
63
  redactPii(pii) {
61
64
  if (!pii) {
@@ -67,95 +70,41 @@ class MessageSender {
67
70
  return pii.substring(0, 3) + '***' + pii.substring(pii.length - 3);
68
71
  }
69
72
  isFeatureActive(featureName, getDefault) {
70
- if (isDestinationActionService())
73
+ if (isDestinationActionService_1.isDestinationActionService())
71
74
  return true;
72
75
  if (!this.executeInput.features || !(featureName in this.executeInput.features))
73
76
  return getDefault?.();
74
77
  return this.executeInput.features[featureName];
75
78
  }
76
- logInfo(...msgs) {
77
- if (!this.isFeatureActive(exports.FLAGON_NAME_LOG_INFO, () => false))
78
- return;
79
- const [firstMsg, ...rest] = msgs;
80
- this.logger?.info(`TE Messaging: ${this.getChannelType().toUpperCase()} ${firstMsg}`, ...rest, JSON.stringify(this.logDetails));
79
+ logInfo(msg, metadata) {
80
+ this.logger.logInfo(msg, metadata);
81
81
  }
82
- logError(error, ...msgs) {
83
- if (!this.isFeatureActive(exports.FLAGON_NAME_LOG_ERROR, () => false))
84
- return;
85
- const [firstMsg, ...rest] = msgs;
86
- if (typeof error === 'string') {
87
- this.logger?.error(`TE Messaging: ${this.getChannelType().toUpperCase()} ${error}`, ...msgs, JSON.stringify(this.logDetails));
88
- }
89
- else {
90
- this.logger?.error(`TE Messaging: ${this.getChannelType().toUpperCase()} ${firstMsg}`, ...rest, error instanceof Error ? error.message : error?.toString(), JSON.stringify(this.logDetails));
91
- }
82
+ logError(msg, metadata) {
83
+ this.logger.logError(msg, metadata);
92
84
  }
93
- stats(...args) {
94
- if (!this.statsClient)
95
- return;
96
- const statsArgs = args[0];
97
- const [statsMethod, metric, value, extraTags] = statsArgs instanceof Object
98
- ? [statsArgs.method, statsArgs.metric, statsArgs.value, statsArgs.extraTags]
99
- : args;
100
- let statsFunc = this.statsClient?.[statsMethod || 'incr'].bind(this.statsClient);
101
- if (!statsFunc)
102
- switch (statsMethod ||
103
- 'incr') {
104
- case 'incr':
105
- statsFunc = this.statsClient?.incr.bind(this.statsClient);
106
- break;
107
- break;
108
- case 'histogram':
109
- statsFunc = this.statsClient?.histogram.bind(this.statsClient);
110
- break;
111
- break;
112
- case 'set':
113
- statsFunc = this.statsClient?.set.bind(this.statsClient);
114
- break;
115
- break;
116
- default:
117
- break;
85
+ logOnError(logMessage) {
86
+ const op = this.currentOperation;
87
+ op?.onFinally.push(() => {
88
+ if (op.error) {
89
+ const msg = typeof logMessage === 'function' ? logMessage(op) : logMessage;
90
+ op.logs.push(msg);
118
91
  }
119
- statsFunc?.(`actions_personas_messaging_twilio.${metric}`, typeof value === 'undefined' ? 1 : value, [
120
- ...this.tags,
121
- ...(extraTags ?? [])
122
- ]);
92
+ });
123
93
  }
124
- statsIncrement(metric, value, extraTags) {
125
- this.stats({ method: 'incr', metric, value, extraTags });
94
+ statsIncr(metric, value, tags) {
95
+ this.statsClient.stats({ method: 'incr', metric, value, tags });
126
96
  }
127
- statsHistogram(metric, value, extraTags) {
128
- this.stats({ method: 'histogram', metric, value, extraTags });
97
+ statsHistogram(metric, value, tags) {
98
+ this.statsClient.stats({ method: 'histogram', metric, value, tags });
129
99
  }
130
- statsSet(metric, value, extraTags) {
131
- this.stats({ method: 'set', metric, value, extraTags });
100
+ statsSet(metric, value, tags) {
101
+ this.statsClient.stats({ method: 'set', metric, value, tags });
132
102
  }
133
- logWrap(fn, args) {
134
- const start = Date.now();
135
- return wrapPromisable(fn, {
136
- onStart: () => {
137
- this.logInfo('Starting: ', args.operationName);
138
- const statsStart = args.stats?.onStart?.();
139
- if (statsStart)
140
- for (const statsArgs of statsStart) {
141
- this.stats(statsArgs);
142
- }
143
- },
144
- onFinally: (fin) => {
145
- const duration = Date.now() - start;
146
- if ('result' in fin) {
147
- this.logInfo('Success: ', args.operationName, `Duration: ${duration} ms`);
148
- }
149
- else {
150
- this.logError(fin.error, 'Failed: ', args.operationName, `Duration: ${duration} ms`);
151
- }
152
- const statsEnd = args.stats?.onEnd?.({ ...fin, duration });
153
- if (statsEnd)
154
- for (const statsArgs of statsEnd) {
155
- this.stats(statsArgs);
156
- }
157
- }
158
- });
103
+ get logDetails() {
104
+ return this.logger.logDetails;
105
+ }
106
+ get tags() {
107
+ return this.statsClient.tags;
159
108
  }
160
109
  beforeSend() {
161
110
  Object.assign(this.logDetails, {
@@ -171,35 +120,25 @@ class MessageSender {
171
120
  });
172
121
  if ('userId' in this.payload)
173
122
  this.logDetails.userId = this.payload.userId;
123
+ if ('deliveryAttempt' in this.executeInput['rawData'])
124
+ this.currentOperation?.tags.push(`delivery_attempt:${this.executeInput['rawData'].deliveryAttempt}`);
174
125
  }
175
126
  async getContentTemplateTypes() {
176
- let template;
177
- try {
178
- if (!this.payload.contentSid) {
179
- throw new actions_core_1.PayloadValidationError('Content SID not in payload');
180
- }
181
- const twilioToken = Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
182
- const response = await this.request(`https://content.twilio.com/v1/Content/${this.payload.contentSid}`, {
183
- method: 'GET',
184
- headers: {
185
- authorization: `Basic ${twilioToken}`
186
- }
187
- });
188
- template = (await response.json());
189
- }
190
- catch (error) {
191
- this.tags.push('reason:get_content_template');
192
- this.stats('incr', 'error', 1);
193
- this.logError(`failed request to fetch content template from Twilio Content API - ${this.settings.spaceId} - ${error}, ${JSON.stringify(error)})}`);
194
- throw new actions_core_1.IntegrationError('Unable to fetch content template', 'Twilio Content API request failure', 500);
127
+ if (!this.payload.contentSid) {
128
+ throw new actions_core_1.PayloadValidationError('Content SID not in payload');
195
129
  }
130
+ const twilioToken = Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
131
+ const response = await this.request(`https://content.twilio.com/v1/Content/${this.payload.contentSid}`, {
132
+ method: 'GET',
133
+ headers: {
134
+ authorization: `Basic ${twilioToken}`
135
+ }
136
+ });
137
+ const template = (await response.json());
196
138
  return this.extractTemplateTypes(template);
197
139
  }
198
140
  extractTemplateTypes(template) {
199
141
  if (!template.types) {
200
- this.logError(`template from Twilio Content API does not contain a template type - ${this.settings.spaceId} - [${JSON.stringify(template)}]`);
201
- this.tags.push('reason:invalid_template_type');
202
- this.stats('incr', 'error', 1);
203
142
  throw new actions_core_1.IntegrationError('Template from Twilio Content API does not contain any template types', `NO_CONTENT_TYPES`, 400);
204
143
  }
205
144
  const type = Object.keys(template.types)[0];
@@ -207,9 +146,6 @@ class MessageSender {
207
146
  return { body: template.types[type].body, media: template.types[type].media };
208
147
  }
209
148
  else {
210
- this.logError(`unsupported content template type '${type}' - ${this.settings.spaceId}`);
211
- this.tags.push('reason:invalid_template_type');
212
- this.stats('incr', 'error', 1);
213
149
  throw new actions_core_1.IntegrationError(`Sending templates with '${type}' content type is not supported by ${this.getChannelType()}`, 'UNSUPPORTED_CONTENT_TYPE', 400);
214
150
  }
215
151
  }
@@ -223,94 +159,45 @@ class MessageSender {
223
159
  __segment_internal_external_id_value__: externalIdValue
224
160
  };
225
161
  if (webhookUrl && customArgs) {
226
- try {
227
- const webhookUrlWithParams = new URL(webhookUrl);
228
- for (const key of Object.keys(customArgs)) {
229
- webhookUrlWithParams.searchParams.append(key, String(customArgs[key]));
230
- }
231
- webhookUrlWithParams.hash = connectionOverrides || defaultConnectionOverrides;
232
- return webhookUrlWithParams.toString();
233
- }
234
- catch (error) {
235
- this.logDetails['webhook-custom-args'] = this.payload.customArgs;
236
- this.logError(`invalid webhook url - ${this.settings.spaceId}`);
237
- throw new actions_core_1.PayloadValidationError('Invalid webhook url arguments');
162
+ this.logOnError(() => JSON.stringify(customArgs));
163
+ const webhookUrlWithParams = new URL(webhookUrl);
164
+ for (const key of Object.keys(customArgs)) {
165
+ webhookUrlWithParams.searchParams.append(key, String(customArgs[key]));
238
166
  }
167
+ webhookUrlWithParams.hash = connectionOverrides || defaultConnectionOverrides;
168
+ return webhookUrlWithParams.toString();
239
169
  }
240
170
  return null;
241
171
  }
242
- getRethrowableError(error, apiName = 'Twilio Programmable API') {
243
- let errorToRethrow = error;
244
- if (error instanceof Object) {
245
- const twilioApiError = error;
246
- this.logDetails['twilioApiError_response_data'] = twilioApiError.response?.data;
247
- this.logDetails['twilio-request-id'] = twilioApiError.response?.headers?.get('twilio-request-id');
248
- this.logDetails['error'] = twilioApiError.response;
249
- this.logError(`${apiName} error - ${this.settings.spaceId}`);
250
- const statusCode = twilioApiError.status || twilioApiError.response?.data?.status;
251
- this.tags.push(`twilio_status_code:${statusCode}`);
252
- this.stats('incr', 'response', 1);
253
- if (!twilioApiError.status) {
254
- errorToRethrow = new actions_core_1.IntegrationError(twilioApiError.response?.data?.message || twilioApiError.message, (twilioApiError.response?.data?.code || statusCode)?.toString() || 'Twilio Api Request Error', statusCode);
255
- }
256
- const errorCode = twilioApiError.response?.data?.code;
257
- if (errorCode === 63018 || statusCode === 429) {
258
- this.stats('incr', 'rate_limited', 1);
259
- }
260
- }
261
- return errorToRethrow;
262
- }
263
- rethrowError(error, apiName = 'Twilio Programmable API') {
264
- throw this.getRethrowableError(error, apiName);
172
+ rethrowIntegrationError(error, getWrapper) {
173
+ throw IntegrationErrorWrapper_1.IntegrationErrorWrapper.wrap(error, getWrapper, this.currentOperation);
265
174
  }
266
175
  }
267
- exports.MessageSender = MessageSender;
268
176
  MessageSender.nonSendableStatuses = ['unsubscribed', 'did not subscribed', 'false'];
269
177
  MessageSender.sendableStatuses = ['subscribed', 'true'];
270
- function wrapPromisable(fn, args) {
271
- args.onStart?.();
272
- let finallyRes = undefined;
273
- try {
274
- const res = fn();
275
- if (isPromise(res))
276
- return (async () => {
277
- try {
278
- const unpromiseRes = await res;
279
- finallyRes = { result: unpromiseRes };
280
- args.onSuccess?.(unpromiseRes);
281
- return unpromiseRes;
282
- }
283
- catch (error) {
284
- finallyRes = { error };
285
- if (!args.onCatch)
286
- throw error;
287
- return args.onCatch(error);
288
- }
289
- finally {
290
- args.onFinally?.(finallyRes);
291
- }
292
- })();
293
- finallyRes = { result: res };
294
- args.onSuccess?.(res);
295
- return res;
296
- }
297
- catch (error) {
298
- finallyRes = { error };
299
- if (!args.onCatch)
300
- throw error;
301
- return args.onCatch(error);
302
- }
303
- finally {
304
- if (finallyRes)
305
- args.onFinally?.(finallyRes);
306
- }
307
- }
308
- exports.wrapPromisable = wrapPromisable;
309
- function isPromise(obj) {
310
- return obj instanceof Object && 'then' in obj && typeof obj.then === 'function';
311
- }
312
- function isDestinationActionService() {
313
- return (process.env.DESTINATIONS_ACTION_SERVICE === 'true' || process.env.SERVICE_NAME === 'destination-actions-service');
314
- }
315
- exports.isDestinationActionService = isDestinationActionService;
178
+ __decorate([
179
+ track_1.track()
180
+ ], MessageSender.prototype, "request", null);
181
+ __decorate([
182
+ track_1.track()
183
+ ], MessageSender.prototype, "perform", null);
184
+ __decorate([
185
+ track_1.track({
186
+ wrapIntegrationError: () => new actions_core_1.PayloadValidationError('Unable to parse templating, invalid liquid')
187
+ })
188
+ ], MessageSender.prototype, "parseContent", null);
189
+ __decorate([
190
+ track_1.track({
191
+ wrapIntegrationError: () => ['Unable to fetch content template', 'Twilio Content API request failure', 500]
192
+ })
193
+ ], MessageSender.prototype, "getContentTemplateTypes", null);
194
+ __decorate([
195
+ track_1.track()
196
+ ], MessageSender.prototype, "extractTemplateTypes", null);
197
+ __decorate([
198
+ track_1.track({
199
+ wrapIntegrationError: () => new actions_core_1.PayloadValidationError('Invalid webhook url arguments')
200
+ })
201
+ ], MessageSender.prototype, "getWebhookUrlWithParams", null);
202
+ exports.MessageSender = MessageSender;
316
203
  //# sourceMappingURL=message-sender.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/message-sender.ts"],"names":[],"mappings":";;;AAAA,uCAA6C;AAI7C,wDAAgG;AAKhG,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAKhB,QAA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AAE,CAAA;oBACrC,IAAI,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,CAAA;oBAC9B,OAAO,YAAY,CAAA;iBACpB;gBAAC,OAAO,KAAK,EAAE;oBACd,UAAU,GAAG,EAAE,KAAK,EAAE,CAAA;oBACtB,IAAI,CAAC,IAAI,CAAC,OAAO;wBAAE,MAAM,KAAK,CAAA;oBAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;iBAC3B;wBAAS;oBACR,IAAI,CAAC,SAAS,EAAE,CAAC,UAAW,CAAC,CAAA;iBAC9B;YACH,CAAC,CAAC,EAAc,CAAA;QAElB,UAAU,GAAG,EAAE,MAAM,EAAE,GAAiB,EAAE,CAAA;QAC1C,IAAI,CAAC,SAAS,EAAE,CAAC,GAAiB,CAAC,CAAA;QACnC,OAAO,GAAG,CAAA;KACX;IAAC,OAAO,KAAK,EAAE;QACd,UAAU,GAAG,EAAE,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,MAAM,KAAK,CAAA;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;KAC3B;YAAS;QACR,IAAI,UAAU;YAEZ,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,CAAA;KAC/B;AACH,CAAC;AA1CD,wCA0CC;AAYD,SAAS,SAAS,CAAc,GAAY;IAO1C,OAAO,GAAG,YAAY,MAAM,IAAI,MAAM,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AACjF,CAAC;AASD,SAAgB,0BAA0B;IAExC,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,6BAA6B,CACjH,CAAA;AACH,CAAC;AALD,gEAKC"}
1
+ {"version":3,"file":"message-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/message-sender.ts"],"names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AAC,IAAI,GAAG,mBAAmB,IAAI,0BAA0B,CAAA;YAC7E,OAAO,oBAAoB,CAAC,QAAQ,EAAE,CAAA;SACvC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAED,uBAAuB,CACrB,KAAc,EACd,UAAmF;QAEnF,MAAM,iDAAuB,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAC9E,CAAC;;AA1Oe,iCAAmB,GAAG,CAAC,cAAc,EAAE,oBAAoB,EAAE,OAAO,CAAC,CAAA;AACrE,8BAAgB,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAezD;IADC,aAAK,EAAE;4CAcP;AAMD;IADC,aAAK,EAAE;4CAIP;AAQD;IAHC,aAAK,CAAC;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,IAAI,qCAAsB,CAAC,4CAA4C,CAAC;KACrG,CAAC;iDAqBD;AAoFD;IAHC,aAAK,CAAC;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,kCAAkC,EAAE,oCAAoC,EAAE,GAAG,CAAC;KAC5G,CAAC;4DAmBD;AAGD;IADC,aAAK,EAAE;yDAoBP;AAKD;IAHC,aAAK,CAAC;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,IAAI,qCAAsB,CAAC,+BAA+B,CAAC;KACxF,CAAC;4DAiCD;AAzOH,sCAiPC"}
@@ -1,6 +1,13 @@
1
1
  import { MessageSender } from './message-sender';
2
2
  import type { Payload as SmsPayload } from '../sendSms/generated-types';
3
3
  import type { Payload as WhatsappPayload } from '../sendWhatsApp/generated-types';
4
+ export declare enum SendabilityStatus {
5
+ NoSenderPhone = "no_sender_phone",
6
+ ShouldSend = "should_send",
7
+ NotSubscribed = "not_subscribed",
8
+ SendDisabled = "send_disabled",
9
+ InvalidSubscriptionStatus = "invalid_subscription_status"
10
+ }
4
11
  export declare abstract class PhoneMessage<Payload extends SmsPayload | WhatsappPayload> extends MessageSender<Payload> {
5
12
  private readonly EXTERNAL_ID_KEY;
6
13
  private readonly DEFAULT_HOSTNAME;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PhoneMessage = void 0;
3
+ exports.PhoneMessage = exports.SendabilityStatus = void 0;
4
4
  const message_sender_1 = require("./message-sender");
5
+ const operationTracking_1 = require("../operationTracking");
5
6
  var SendabilityStatus;
6
7
  (function (SendabilityStatus) {
7
8
  SendabilityStatus["NoSenderPhone"] = "no_sender_phone";
8
9
  SendabilityStatus["ShouldSend"] = "should_send";
9
- SendabilityStatus["DoNotSend"] = "do_not_send";
10
+ SendabilityStatus["NotSubscribed"] = "not_subscribed";
10
11
  SendabilityStatus["SendDisabled"] = "send_disabled";
11
12
  SendabilityStatus["InvalidSubscriptionStatus"] = "invalid_subscription_status";
12
- })(SendabilityStatus || (SendabilityStatus = {}));
13
+ })(SendabilityStatus = exports.SendabilityStatus || (exports.SendabilityStatus = {}));
13
14
  class PhoneMessage extends message_sender_1.MessageSender {
14
15
  constructor() {
15
16
  super(...arguments);
@@ -19,46 +20,45 @@ class PhoneMessage extends message_sender_1.MessageSender {
19
20
  }
20
21
  async doSend() {
21
22
  const { phone, sendabilityStatus } = this.getSendabilityPayload();
22
- if (sendabilityStatus !== SendabilityStatus.ShouldSend || !phone) {
23
- this.logInfo(`Not sending message, because sendabilityStatus: ${sendabilityStatus}, phone: ${this.redactPii(phone)}`);
23
+ this.currentOperation?.tags.push('sendability_status:' + sendabilityStatus);
24
+ if (sendabilityStatus !== SendabilityStatus.ShouldSend) {
25
+ this.currentOperation?.logs.push(`Not sending message, because sendabilityStatus: ${sendabilityStatus}, phone: ${this.redactPii(phone)}`);
24
26
  return;
25
27
  }
26
- this.logInfo('Getting content Body');
28
+ else {
29
+ this.currentOperation?.logs.push(`Sending message to phone: ${this.redactPii(phone)}`);
30
+ }
31
+ const op = this.currentOperation;
32
+ this.currentOperation?.onFinally.push(() => {
33
+ const error = op.error;
34
+ if (error)
35
+ op.tags.push('not_sent_reason:error_operation_' + operationTracking_1.OperationDecorator.getOperationName(error.trackedContext || op));
36
+ });
27
37
  const body = await this.getBody(phone);
28
38
  const webhookUrlWithParams = this.getWebhookUrlWithParams(this.EXTERNAL_ID_KEY, phone, this.DEFAULT_CONNECTION_OVERRIDES);
29
39
  if (webhookUrlWithParams)
30
40
  body.append('StatusCallback', webhookUrlWithParams);
31
41
  const twilioHostname = this.settings.twilioHostname ?? this.DEFAULT_HOSTNAME;
32
42
  const twilioToken = Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
33
- this.stats('set', 'message_body_size', body?.toString().length);
34
- try {
35
- this.logInfo('Sending message to Twilio API');
36
- const response = await this.request(`https://${twilioHostname}/2010-04-01/Accounts/${this.settings.twilioAccountSID}/Messages.json`, {
37
- method: 'POST',
38
- headers: {
39
- authorization: `Basic ${twilioToken}`
40
- },
41
- body
42
- });
43
- this.tags.push(`twilio_status_code:${response.status}`);
44
- this.stats('incr', 'response', 1);
45
- if (this.payload.eventOccurredTS != undefined) {
46
- this.stats('histogram', 'eventDeliveryTS', Date.now() - new Date(this.payload.eventOccurredTS).getTime());
47
- }
48
- this.logDetails['twilio-request-id'] = response.headers?.get('twilio-request-id');
49
- this.logInfo('Message sent successfully');
50
- return response;
51
- }
52
- catch (error) {
53
- this.rethrowError(error);
43
+ this.statsSet('message_body_size', body?.toString().length);
44
+ const response = await this.request(`https://${twilioHostname}/2010-04-01/Accounts/${this.settings.twilioAccountSID}/Messages.json`, {
45
+ method: 'POST',
46
+ headers: {
47
+ authorization: `Basic ${twilioToken}`
48
+ },
49
+ body
50
+ });
51
+ if (this.payload.eventOccurredTS != undefined) {
52
+ this.statsHistogram('eventDeliveryTS', Date.now() - new Date(this.payload.eventOccurredTS).getTime());
54
53
  }
54
+ this.logDetails['twilio-request-id'] = response.headers?.get('twilio-request-id');
55
+ return response;
55
56
  }
56
57
  isValidExternalId(externalId) {
57
58
  return externalId.type === 'phone' && this.getChannelType() === externalId.channelType?.toLowerCase();
58
59
  }
59
60
  getSendabilityPayload() {
60
61
  if (!this.payload.send) {
61
- this.stats('incr', 'send-disabled', 1);
62
62
  return { sendabilityStatus: SendabilityStatus.SendDisabled, phone: undefined };
63
63
  }
64
64
  const validExtIds = this.payload.externalIds?.filter((extId) => this.isValidExternalId(extId));
@@ -76,19 +76,16 @@ class PhoneMessage extends message_sender_1.MessageSender {
76
76
  .map((extId) => extId.subscriptionStatus)
77
77
  .join(', ')}`);
78
78
  }
79
- let status = SendabilityStatus.DoNotSend;
79
+ let status = SendabilityStatus.NotSubscribed;
80
80
  const phone = this.payload.toNumber || firstSubscribedExtId?.id;
81
81
  if (firstSubscribedExtId) {
82
- this.stats('incr', 'subscribed', 1);
83
82
  status = phone ? SendabilityStatus.ShouldSend : SendabilityStatus.NoSenderPhone;
84
83
  }
85
84
  else if (hasInvalidStatuses) {
86
- this.stats('incr', 'invalid_subscription_status', 1);
87
85
  status = SendabilityStatus.InvalidSubscriptionStatus;
88
86
  }
89
87
  else if (validExtIds && validExtIds.length > 0) {
90
- this.stats('incr', 'notsubscribed', 1);
91
- status = SendabilityStatus.DoNotSend;
88
+ status = SendabilityStatus.NotSubscribed;
92
89
  }
93
90
  else {
94
91
  status = SendabilityStatus.NoSenderPhone;
@@ -1 +1 @@
1
- {"version":3,"file":"phone-message.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/phone-message.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAIhD,IAAK,iBAMJ;AAND,WAAK,iBAAiB;IACpB,sDAAiC,CAAA;IACjC,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,mDAA8B,CAAA;IAC9B,8EAAyD,CAAA;AAC3D,CAAC,EANI,iBAAiB,KAAjB,iBAAiB,QAMrB;AAID,MAAsB,YAA2D,SAAQ,8BAAsB;IAA/G;;QACmB,oBAAe,GAAG,OAAO,CAAA;QAC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M,EAAE,YAAY,EAAE,CAAC,CAAC,CAAA;YACnC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,aAAa,CAAA;SAChF;aAAM,IAAI,kBAAkB,EAAE;YAC7B,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,6BAA6B,EAAE,CAAC,CAAC,CAAA;YACpD,MAAM,GAAG,iBAAiB,CAAC,yBAAyB,CAAA;SACrD;aAAM,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE;YAChD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAA;YACtC,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAA;SACrC;aAAM;YACL,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAA;SACzC;QAED,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IAC7C,CAAC;CACF;AAhID,oCAgIC"}
1
+ {"version":3,"file":"phone-message.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/phone-message.ts"],"names":[],"mappings":";;;AACA,qDAAgD;AAGhD,4DAAuE;AAGvE,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,sDAAiC,CAAA;IACjC,+CAA0B,CAAA;IAC1B,qDAAgC,CAAA;IAChC,mDAA8B,CAAA;IAC9B,8EAAyD,CAAA;AAC3D,CAAC,EANW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAM5B;AAID,MAAsB,YAA2D,SAAQ,8BAAsB;IAA/G;;QACmB,oBAAe,GAAG,OAAO,CAAA;QACzB,qBAAgB,GAAG,gBAAgB,CAAA;QACnC,iCAA4B,GAAG,aAAa,CAAA;IA4H/D,CAAC;IAxHC,KAAK,CAAC,MAAM;QACV,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,qBAAqB,EAA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