@trycourier/courier 3.12.0 → 3.13.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.
- package/CHANGELOG.md +3 -0
- package/README.md +67 -3
- package/lib/send/types.d.ts +20 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased][unreleased]
|
|
7
7
|
|
|
8
|
+
- adds support for granular timeouts for channel and providers
|
|
9
|
+
- adds support for change and provider utm metadata (`channels.metadata.utm` and `providers.metadata.utm`) that augments action blocks links
|
|
10
|
+
|
|
8
11
|
## [3.12.0] - 2022-03-31
|
|
9
12
|
|
|
10
13
|
- adds support for message trace id (`message.metadata.trace_id`)
|
package/README.md
CHANGED
|
@@ -240,6 +240,70 @@ async function run() {
|
|
|
240
240
|
});
|
|
241
241
|
console.log(requestId);
|
|
242
242
|
|
|
243
|
+
// Example: send message with utm metadata
|
|
244
|
+
const { requestId } = await courier.send({
|
|
245
|
+
message: {
|
|
246
|
+
template: "<TEMPLATE_OR_EVENT_ID>",
|
|
247
|
+
to: {...},
|
|
248
|
+
routing: {
|
|
249
|
+
method: "single",
|
|
250
|
+
channels: ["email"],
|
|
251
|
+
},
|
|
252
|
+
channels: {
|
|
253
|
+
email: {
|
|
254
|
+
routing_method: "all",
|
|
255
|
+
providers: ["sendgrid", "sns"],
|
|
256
|
+
metadata: {
|
|
257
|
+
utm: {
|
|
258
|
+
medium: "f",
|
|
259
|
+
campaign: "g",
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
providers: {
|
|
265
|
+
sns: {
|
|
266
|
+
metadata: {
|
|
267
|
+
utm: {
|
|
268
|
+
medium: "h",
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
}, // optional
|
|
273
|
+
metadata: {
|
|
274
|
+
utm: {
|
|
275
|
+
source: "a",
|
|
276
|
+
medium: "b",
|
|
277
|
+
campaign: "c",
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
timeout: {
|
|
281
|
+
message: 300000,
|
|
282
|
+
channel: {
|
|
283
|
+
email: 1000 // 1 second
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* If the template or content contains any action blocks, the hyperlinks will be augmented with utm compliant query parameters.
|
|
291
|
+
*
|
|
292
|
+
* The resulting link of an action block sent through sendgrid would be:
|
|
293
|
+
* www.example.com?utm_source=a&utm_medium=f&utm_campaign=g
|
|
294
|
+
*
|
|
295
|
+
* While the resulting link of an action block sent through sns would be:
|
|
296
|
+
* www.example.com?utm_source=a&utm_medium=h&utm_campaign=g
|
|
297
|
+
*
|
|
298
|
+
* Notice that provider metadata supersedes channel metadata and channel metadata supersedes message metadata
|
|
299
|
+
*
|
|
300
|
+
**/
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* If the message includes a timeout property we will start timing out messages after the first attempt.
|
|
304
|
+
* We are able to timeout complete channels or specific providers.
|
|
305
|
+
**/
|
|
306
|
+
|
|
243
307
|
// Example: get a message status
|
|
244
308
|
const messageStatus = await courier.getMessage(requestId);
|
|
245
309
|
console.log(messageStatus);
|
|
@@ -651,9 +715,9 @@ Audiences APIs are used to create, get, update, and delete audiences. A Courier
|
|
|
651
715
|
const { audienceId } = await courier.audiences.put({
|
|
652
716
|
id: "<AUDIENCE_ID>",
|
|
653
717
|
filter: {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
718
|
+
operator: "EQ",
|
|
719
|
+
path: "title",
|
|
720
|
+
value: "Software Engineer",
|
|
657
721
|
},
|
|
658
722
|
});
|
|
659
723
|
|
package/lib/send/types.d.ts
CHANGED
|
@@ -241,8 +241,12 @@ export interface ElementalContentSugar {
|
|
|
241
241
|
title?: string;
|
|
242
242
|
}
|
|
243
243
|
export interface Timeout {
|
|
244
|
-
provider?:
|
|
245
|
-
|
|
244
|
+
provider?: {
|
|
245
|
+
[provider: string]: number;
|
|
246
|
+
};
|
|
247
|
+
channel?: {
|
|
248
|
+
[channel: string]: number;
|
|
249
|
+
};
|
|
246
250
|
message?: number;
|
|
247
251
|
escalation?: number;
|
|
248
252
|
criteria?: "no-escalation" | "delivered" | "viewed" | "engaged";
|
|
@@ -311,6 +315,9 @@ export interface MessageChannels {
|
|
|
311
315
|
channel?: number;
|
|
312
316
|
};
|
|
313
317
|
override?: MessageChannelEmailOverride | MessageChannelPushOverride;
|
|
318
|
+
metadata?: {
|
|
319
|
+
utm?: UTM;
|
|
320
|
+
};
|
|
314
321
|
};
|
|
315
322
|
}
|
|
316
323
|
export interface Routing {
|
|
@@ -329,17 +336,21 @@ export interface RoutingStrategyProvider<T = Record<string, any>> {
|
|
|
329
336
|
name: string;
|
|
330
337
|
config?: T;
|
|
331
338
|
if?: string;
|
|
339
|
+
metadata?: {
|
|
340
|
+
utm?: UTM;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
export interface UTM {
|
|
344
|
+
source?: string;
|
|
345
|
+
medium?: string;
|
|
346
|
+
campaign?: string;
|
|
347
|
+
term?: string;
|
|
348
|
+
content?: string;
|
|
332
349
|
}
|
|
333
350
|
export interface MessageMetadata {
|
|
334
351
|
event?: string;
|
|
335
352
|
tags?: string[];
|
|
336
|
-
utm?:
|
|
337
|
-
source?: string;
|
|
338
|
-
medium?: string;
|
|
339
|
-
campaign?: string;
|
|
340
|
-
term?: string;
|
|
341
|
-
content?: string;
|
|
342
|
-
};
|
|
353
|
+
utm?: UTM;
|
|
343
354
|
trace_id?: string;
|
|
344
355
|
}
|
|
345
356
|
export interface ContentMessage extends BaseMessage {
|