@trycourier/courier
Advanced tools
Comparing version 3.10.1 to 3.12.0
@@ -8,2 +8,11 @@ # Change Log | ||
## [3.12.0] - 2022-03-31 | ||
- adds support for message trace id (`message.metadata.trace_id`) | ||
## [3.11.0] - 2022-03-23 | ||
- adds support for `audiences` | ||
## [3.10.1] - 2022-03-20 | ||
@@ -228,3 +237,5 @@ - adds support for messages timeout (`message.timeout`) | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.9.0...HEAD | ||
[unreleased]: https://github.com/trycourier/courier-node/compare/v3.11.0...HEAD | ||
[v3.11.0]: https://github.com/trycourier/courier-node/compare/v3.10.0...v3.11.0 | ||
[v3.10.0]: https://github.com/trycourier/courier-node/compare/v3.9.0...v3.10.0 | ||
[v3.9.0]: https://github.com/trycourier/courier-node/compare/v3.8.0...v3.9.0 | ||
@@ -231,0 +242,0 @@ [v3.8.0]: https://github.com/trycourier/courier-node/compare/v3.7.0...v3.8.0 |
@@ -40,2 +40,3 @@ "use strict"; | ||
exports.client = void 0; | ||
var audiences_1 = require("./audiences"); | ||
var automations_1 = require("./automations"); | ||
@@ -102,4 +103,4 @@ var brands_1 = require("./brands"); | ||
status: params === null || params === void 0 ? void 0 : params.status, | ||
tags: params === null || params === void 0 ? void 0 : params.tags | ||
} | ||
tags: params === null || params === void 0 ? void 0 : params.tags, | ||
}, | ||
})]; | ||
@@ -116,2 +117,3 @@ case 1: | ||
addRecipientToLists: profile_1.addRecipientToLists(options), | ||
audiences: audiences_1.audiences(options), | ||
automations: automations_1.automations(options), | ||
@@ -137,4 +139,4 @@ bulk: bulk_1.bulk(options), | ||
replaceProfile: profile_1.replaceProfile(options), | ||
send: send_1.send(options) | ||
send: send_1.send(options), | ||
}; | ||
}; |
@@ -225,2 +225,6 @@ export interface IBrandSnippet { | ||
}; | ||
export interface AudienceRecipient { | ||
audience_id: string; | ||
data?: MessageData; | ||
} | ||
export interface UserRecipient extends UserRecipientType { | ||
@@ -234,3 +238,3 @@ data?: MessageData; | ||
} | ||
export declare type Recipient = ListRecipient | ListPatternRecipient | UserRecipient; | ||
export declare type Recipient = AudienceRecipient | ListRecipient | ListPatternRecipient | UserRecipient; | ||
export declare type MessageRecipient = Recipient | Recipient[]; | ||
@@ -341,2 +345,3 @@ export interface ElementalContentSugar { | ||
}; | ||
trace_id?: string; | ||
} | ||
@@ -343,0 +348,0 @@ export interface ContentMessage extends BaseMessage { |
import { AxiosRequestConfig } from "axios"; | ||
import { ICourierClientAudiences } from "./audiences/types"; | ||
import { ICourierClientAutomations } from "./automations/types"; | ||
@@ -289,2 +290,3 @@ import { ICourierClientBulk } from "./bulk/types"; | ||
addRecipientToLists: (params: ICourierProfileListsPostParameters) => Promise<ICourierProfilePostResponse>; | ||
audiences: ICourierClientAudiences; | ||
automations: ICourierClientAutomations; | ||
@@ -291,0 +293,0 @@ bulk: ICourierClientBulk; |
{ | ||
"name": "@trycourier/courier", | ||
"version": "3.10.1", | ||
"version": "3.12.0", | ||
"description": "A node.js module for communicating with the Courier REST API.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -186,2 +186,25 @@ [![Courier: Your Complete Communication Stack](https://marketing-assets-public.s3.us-west-1.amazonaws.com/github_nodejs.png)](https://courier.com) | ||
}); | ||
// Example: send a basic message with a trace id | ||
const { requestId } = await courier.send({ | ||
message: { | ||
to: { | ||
data: { | ||
name: "Marty", | ||
}, | ||
email: "marty_mcfly@email.com", | ||
}, | ||
content: { | ||
title: "Back to the Future", | ||
body: "Oh my {{name}}, we need 1.21 Gigawatts!", | ||
}, | ||
routing: { | ||
method: "single", | ||
channels: ["email"], | ||
}, | ||
metadata: { | ||
trace_id: "ravenclaw-for-the-win" | ||
}, | ||
}, | ||
}); | ||
``` | ||
@@ -623,2 +646,38 @@ | ||
### Audiences | ||
Audiences APIs are used to create, get, update, and delete audiences. A Courier Audience is a dynamic group of users (created using Courier's Profile API) that matches a set of criteria. Audience is reactive to changes in the user's profile. As you change user profile using `profiles` API, the audience will be updated accordingly. You will not have to maintain a list of users in your audience. Courier takes care of that for you. If you have potentially large set of users, you first create an audience and then use the audience's id to retrieve the list of users. Once you satified with the calculated list of users, you can use the `audienceId` to send notification using `send` API. | ||
```ts | ||
// Example: create audience which would allow sending notification to all users that match the given filter criteria | ||
const { audienceId } = await courier.audiences.put({ | ||
id: "<AUDIENCE_ID>", | ||
filter: { | ||
"operator": "EQ", | ||
"path": "title", | ||
"value": "Software Engineer", | ||
}, | ||
}); | ||
// To retrieve list of members in a given audience, you can use the following: | ||
const { items: audienceMembers } = await courier.audiences.listMembers( | ||
audienceId | ||
); | ||
// To send a notification to all users that match the given filter criteria, you can use the following: | ||
const { requestId } = await courier.send({ | ||
message: { | ||
template: "<TEMPLATE_OR_EVENT_ID>", // This can be inline content as well | ||
to: { | ||
audience_id: audienceId, | ||
}, | ||
data: {}, // optional | ||
brand_id: "<BRAND_ID>", //optional | ||
routing: {}, | ||
channels: {}, // optional | ||
providers: {}, // optional | ||
}, | ||
}); | ||
``` | ||
## License | ||
@@ -625,0 +684,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133988
42
2510
688