@suprsend/node-sdk 1.1.0 → 1.1.2
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/README.md +5 -94
- package/dist/brands.js +245 -0
- package/dist/event.js +6 -1
- package/dist/index.js +3 -0
- package/dist/language_codes.js +200 -0
- package/dist/request_json/event.json +5 -0
- package/dist/request_json/workflow.json +5 -0
- package/dist/signature.js +6 -5
- package/dist/subscriber.js +12 -1
- package/dist/subscriber_helper.js +26 -2
- package/dist/utils.js +28 -1
- package/dist/workflow.js +5 -0
- package/package.json +1 -1
- package/src/brands.js +120 -0
- package/src/event.js +4 -0
- package/src/index.js +4 -0
- package/src/language_codes.js +188 -0
- package/src/request_json/event.json +5 -0
- package/src/request_json/workflow.json +5 -0
- package/src/signature.js +5 -4
- package/src/subscriber.js +13 -1
- package/src/subscriber_helper.js +23 -0
- package/src/utils.js +13 -0
- package/src/workflow.js +4 -0
package/README.md
CHANGED
|
@@ -3,109 +3,20 @@ This package can be included in a node project to easily integrate with `Suprsen
|
|
|
3
3
|
|
|
4
4
|
Refer full documentation [here](https://docs.suprsend.com/docs/node)
|
|
5
5
|
|
|
6
|
-
We're working towards creating SDK in other languages as well.
|
|
7
|
-
|
|
8
|
-
### Suprsend SDKs available in following languages
|
|
9
|
-
* node (`suprsend-node-sdk`)
|
|
10
|
-
* python3 >= 3.7 (`suprsend-py-sdk`)
|
|
11
|
-
|
|
12
6
|
### Installation
|
|
13
7
|
`suprsend-node-sdk` is available as npm package. You can install using npm or yarn.
|
|
14
|
-
|
|
15
|
-
Using npm:
|
|
16
8
|
```bash
|
|
17
9
|
npm install @suprsend/node-sdk
|
|
18
10
|
```
|
|
19
|
-
Using yarn:
|
|
20
|
-
```bash
|
|
21
|
-
yarn add @suprsend/node-sdk
|
|
22
|
-
```
|
|
23
11
|
|
|
24
|
-
###
|
|
12
|
+
### Initialization
|
|
25
13
|
Initialize the Suprsend SDK
|
|
26
14
|
```node
|
|
27
|
-
const Suprsend = require("@suprsend/node-sdk");
|
|
15
|
+
const {Suprsend} = require("@suprsend/node-sdk");
|
|
28
16
|
|
|
29
17
|
// Initialize SDK
|
|
30
|
-
const supr_client = new Suprsend("
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Following example shows a sample request for triggering a workflow.
|
|
34
|
-
It triggers a notification to a user with id: `distinct_id`,
|
|
35
|
-
email: `user@example.com` & androidpush-token: `__android_push_token__`
|
|
36
|
-
using template `purchase-made` and notification_category `system`
|
|
37
|
-
|
|
38
|
-
```node
|
|
39
|
-
// Prepare Workflow body
|
|
40
|
-
const workflow_body = {
|
|
41
|
-
"name": "Purchase Workflow",
|
|
42
|
-
"template": "purchase-made",
|
|
43
|
-
"notification_category": "system",
|
|
44
|
-
"delay": "15m",
|
|
45
|
-
"users": [
|
|
46
|
-
{
|
|
47
|
-
"distinct_id": "0f988f74-6982-41c5-8752-facb6911fb08",
|
|
48
|
-
"$email": ["user@example.com"],
|
|
49
|
-
"$androidpush": ["__android_push_token__"],
|
|
50
|
-
}
|
|
51
|
-
],
|
|
52
|
-
"data": {
|
|
53
|
-
"template": {
|
|
54
|
-
"first_name": "User",
|
|
55
|
-
"spend_amount": "$10"
|
|
56
|
-
},
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Trigger workflow
|
|
61
|
-
const response = supr_client.trigger_workflow(workflow_body); // returns promise
|
|
62
|
-
response.then((res) => console.log("response", res));
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
When you call `supr_client.trigger_workflow`, the SDK internally makes an HTTP call to SuprSend
|
|
66
|
-
Platform to register this request, and you'll receive a promise which resolve to response indicating
|
|
67
|
-
the acceptance status.
|
|
68
|
-
|
|
69
|
-
Note: The actual processing/execution of workflow happens asynchronously.
|
|
70
|
-
|
|
71
|
-
```node
|
|
72
|
-
// If the call succeeds, response will looks like:
|
|
73
|
-
{
|
|
74
|
-
"success": true,
|
|
75
|
-
"status_code": 202,
|
|
76
|
-
"message": "Accepted",
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// In case the call fails. You will receive a response with success=false
|
|
80
|
-
{
|
|
81
|
-
"success": false,
|
|
82
|
-
"status": 400,
|
|
83
|
-
"message": "error message",
|
|
84
|
-
}
|
|
18
|
+
const supr_client = new Suprsend("workspace_key", "workspace_secret");
|
|
85
19
|
```
|
|
86
20
|
|
|
87
|
-
###
|
|
88
|
-
|
|
89
|
-
To add one or more Attachments to a Notification (viz. Email, Whatsapp),
|
|
90
|
-
call `supr_client.add_attachment(...)` for each file.
|
|
91
|
-
Ensure that file_path is proper, otherwise it will raise error.
|
|
92
|
-
```node
|
|
93
|
-
// this snippet can be used to add attachment to workflow_body.
|
|
94
|
-
const file_path = "/home/user/billing.pdf"
|
|
95
|
-
supr_client.add_attachment(workflow_body, file_path);
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
#### Attachment structure
|
|
99
|
-
The `add_attachment(...)` call appends below structure to `data->'$attachments'`
|
|
100
|
-
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"filename": "billing.pdf",
|
|
104
|
-
"contentType": "application/pdf",
|
|
105
|
-
"data": "Q29uZ3JhdHVsYXRpb25zLCB5b3UgY2FuIGJhc2U2NCBkZWNvZGUh",
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
Where
|
|
109
|
-
* `filename` - name of file.
|
|
110
|
-
* `contentType` - MIME-type of file content.
|
|
111
|
-
* `data` - base64-encoded content of file.
|
|
21
|
+
### License
|
|
22
|
+
MIT © [https://github.com/suprsend](https://github.com/https://github.com/suprsend)
|
package/dist/brands.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
+
|
|
18
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
|
+
|
|
20
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
21
|
+
|
|
22
|
+
var _signature = _interopRequireDefault(require("./signature"));
|
|
23
|
+
|
|
24
|
+
var _utils = require("./utils");
|
|
25
|
+
|
|
26
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
27
|
+
|
|
28
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
+
|
|
30
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
31
|
+
|
|
32
|
+
var BrandsApi = /*#__PURE__*/function () {
|
|
33
|
+
function BrandsApi(config) {
|
|
34
|
+
(0, _classCallCheck2["default"])(this, BrandsApi);
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.list_url = this.__list_url();
|
|
37
|
+
this.__headers = this.__common_headers();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
(0, _createClass2["default"])(BrandsApi, [{
|
|
41
|
+
key: "__list_url",
|
|
42
|
+
value: function __list_url() {
|
|
43
|
+
var list_uri_template = "".concat(this.config.base_url, "v1/brand/");
|
|
44
|
+
return list_uri_template;
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "__common_headers",
|
|
48
|
+
value: function __common_headers() {
|
|
49
|
+
return {
|
|
50
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
51
|
+
"User-Agent": this.config.user_agent
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "cleaned_limit_offset",
|
|
56
|
+
value: function cleaned_limit_offset(limit, offset) {
|
|
57
|
+
var cleaned_limit = typeof limit === "number" && limit > 0 && limit <= 1000 ? limit : 20;
|
|
58
|
+
var cleaned_offset = typeof offset === "number" && offset >= 0 ? offset : 0;
|
|
59
|
+
return [cleaned_limit, cleaned_offset];
|
|
60
|
+
}
|
|
61
|
+
}, {
|
|
62
|
+
key: "__dynamic_headers",
|
|
63
|
+
value: function __dynamic_headers() {
|
|
64
|
+
return {
|
|
65
|
+
Date: new Date().toUTCString()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "list",
|
|
70
|
+
value: function () {
|
|
71
|
+
var _list = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
72
|
+
var kwargs,
|
|
73
|
+
limit,
|
|
74
|
+
offset,
|
|
75
|
+
_this$cleaned_limit_o,
|
|
76
|
+
_this$cleaned_limit_o2,
|
|
77
|
+
cleaned_limit,
|
|
78
|
+
cleaner_offset,
|
|
79
|
+
final_url_obj,
|
|
80
|
+
final_url_string,
|
|
81
|
+
headers,
|
|
82
|
+
signature,
|
|
83
|
+
response,
|
|
84
|
+
_args = arguments;
|
|
85
|
+
|
|
86
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
87
|
+
while (1) {
|
|
88
|
+
switch (_context.prev = _context.next) {
|
|
89
|
+
case 0:
|
|
90
|
+
kwargs = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
91
|
+
limit = kwargs === null || kwargs === void 0 ? void 0 : kwargs.limit;
|
|
92
|
+
offset = kwargs === null || kwargs === void 0 ? void 0 : kwargs.offset;
|
|
93
|
+
_this$cleaned_limit_o = this.cleaned_limit_offset(limit, offset), _this$cleaned_limit_o2 = (0, _slicedToArray2["default"])(_this$cleaned_limit_o, 2), cleaned_limit = _this$cleaned_limit_o2[0], cleaner_offset = _this$cleaned_limit_o2[1];
|
|
94
|
+
final_url_obj = new URL(this.list_url);
|
|
95
|
+
final_url_obj.searchParams.append("limit", cleaned_limit);
|
|
96
|
+
final_url_obj.searchParams.append("offset", cleaner_offset);
|
|
97
|
+
final_url_string = final_url_obj.href;
|
|
98
|
+
headers = _objectSpread(_objectSpread({}, this.__headers), this.__dynamic_headers());
|
|
99
|
+
signature = (0, _signature["default"])(final_url_string, "GET", "", headers, this.config.workspace_secret);
|
|
100
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
101
|
+
_context.prev = 11;
|
|
102
|
+
_context.next = 14;
|
|
103
|
+
return _axios["default"].get(final_url_string, {
|
|
104
|
+
headers: headers
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
case 14:
|
|
108
|
+
response = _context.sent;
|
|
109
|
+
return _context.abrupt("return", response.data);
|
|
110
|
+
|
|
111
|
+
case 18:
|
|
112
|
+
_context.prev = 18;
|
|
113
|
+
_context.t0 = _context["catch"](11);
|
|
114
|
+
throw new _utils.SuprsendApiError(_context.t0);
|
|
115
|
+
|
|
116
|
+
case 21:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context.stop();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, _callee, this, [[11, 18]]);
|
|
122
|
+
}));
|
|
123
|
+
|
|
124
|
+
function list() {
|
|
125
|
+
return _list.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return list;
|
|
129
|
+
}()
|
|
130
|
+
}, {
|
|
131
|
+
key: "detail_url",
|
|
132
|
+
value: function detail_url() {
|
|
133
|
+
var brand_id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
134
|
+
var cleaned_brand_id = brand_id.toString().trim();
|
|
135
|
+
var brand_id_encoded = encodeURI(cleaned_brand_id);
|
|
136
|
+
var url = "".concat(this.list_url).concat(brand_id_encoded, "/");
|
|
137
|
+
return url;
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "get",
|
|
141
|
+
value: function () {
|
|
142
|
+
var _get = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
143
|
+
var brand_id,
|
|
144
|
+
url,
|
|
145
|
+
headers,
|
|
146
|
+
signature,
|
|
147
|
+
response,
|
|
148
|
+
_args2 = arguments;
|
|
149
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
150
|
+
while (1) {
|
|
151
|
+
switch (_context2.prev = _context2.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
brand_id = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : "";
|
|
154
|
+
url = this.detail_url(brand_id);
|
|
155
|
+
headers = _objectSpread(_objectSpread({}, this.__headers), this.__dynamic_headers());
|
|
156
|
+
signature = (0, _signature["default"])(url, "GET", "", headers, this.config.workspace_secret);
|
|
157
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
158
|
+
_context2.prev = 5;
|
|
159
|
+
_context2.next = 8;
|
|
160
|
+
return _axios["default"].get(url, {
|
|
161
|
+
headers: headers
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
case 8:
|
|
165
|
+
response = _context2.sent;
|
|
166
|
+
return _context2.abrupt("return", response.data);
|
|
167
|
+
|
|
168
|
+
case 12:
|
|
169
|
+
_context2.prev = 12;
|
|
170
|
+
_context2.t0 = _context2["catch"](5);
|
|
171
|
+
throw new _utils.SuprsendApiError(_context2.t0);
|
|
172
|
+
|
|
173
|
+
case 15:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context2.stop();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, _callee2, this, [[5, 12]]);
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
function get() {
|
|
182
|
+
return _get.apply(this, arguments);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return get;
|
|
186
|
+
}()
|
|
187
|
+
}, {
|
|
188
|
+
key: "upsert",
|
|
189
|
+
value: function () {
|
|
190
|
+
var _upsert = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
191
|
+
var brand_id,
|
|
192
|
+
brand_payload,
|
|
193
|
+
url,
|
|
194
|
+
headers,
|
|
195
|
+
content_text,
|
|
196
|
+
signature,
|
|
197
|
+
response,
|
|
198
|
+
_args3 = arguments;
|
|
199
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
200
|
+
while (1) {
|
|
201
|
+
switch (_context3.prev = _context3.next) {
|
|
202
|
+
case 0:
|
|
203
|
+
brand_id = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : "";
|
|
204
|
+
brand_payload = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
205
|
+
url = this.detail_url(brand_id);
|
|
206
|
+
headers = _objectSpread(_objectSpread({}, this.__headers), this.__dynamic_headers());
|
|
207
|
+
content_text = JSON.stringify(brand_payload);
|
|
208
|
+
signature = (0, _signature["default"])(url, "POST", content_text, headers, this.config.workspace_secret);
|
|
209
|
+
headers["Authorization"] = "".concat(this.config.workspace_key, ":").concat(signature);
|
|
210
|
+
_context3.prev = 7;
|
|
211
|
+
_context3.next = 10;
|
|
212
|
+
return _axios["default"].post(url, content_text, {
|
|
213
|
+
headers: headers
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
case 10:
|
|
217
|
+
response = _context3.sent;
|
|
218
|
+
return _context3.abrupt("return", response.data);
|
|
219
|
+
|
|
220
|
+
case 14:
|
|
221
|
+
_context3.prev = 14;
|
|
222
|
+
_context3.t0 = _context3["catch"](7);
|
|
223
|
+
throw new _utils.SuprsendApiError(_context3.t0);
|
|
224
|
+
|
|
225
|
+
case 17:
|
|
226
|
+
case "end":
|
|
227
|
+
return _context3.stop();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, _callee3, this, [[7, 14]]);
|
|
231
|
+
}));
|
|
232
|
+
|
|
233
|
+
function upsert() {
|
|
234
|
+
return _upsert.apply(this, arguments);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return upsert;
|
|
238
|
+
}()
|
|
239
|
+
}]);
|
|
240
|
+
return BrandsApi;
|
|
241
|
+
}();
|
|
242
|
+
|
|
243
|
+
var _default = BrandsApi;
|
|
244
|
+
exports["default"] = _default;
|
|
245
|
+
module.exports = exports.default;
|
package/dist/event.js
CHANGED
|
@@ -42,7 +42,8 @@ var Event = /*#__PURE__*/function () {
|
|
|
42
42
|
this.distinct_id = distinct_id;
|
|
43
43
|
this.event_name = event_name;
|
|
44
44
|
this.properties = properties;
|
|
45
|
-
this.idempotency_key = kwargs === null || kwargs === void 0 ? void 0 : kwargs.idempotency_key;
|
|
45
|
+
this.idempotency_key = kwargs === null || kwargs === void 0 ? void 0 : kwargs.idempotency_key;
|
|
46
|
+
this.brand_id = kwargs === null || kwargs === void 0 ? void 0 : kwargs.brand_id; // --- validate
|
|
46
47
|
|
|
47
48
|
this.__validate_distinct_id();
|
|
48
49
|
|
|
@@ -135,6 +136,10 @@ var Event = /*#__PURE__*/function () {
|
|
|
135
136
|
event_dict["$idempotency_key"] = this.idempotency_key;
|
|
136
137
|
}
|
|
137
138
|
|
|
139
|
+
if (this.brand_id) {
|
|
140
|
+
event_dict["brand_id"] = this.brand_id;
|
|
141
|
+
}
|
|
142
|
+
|
|
138
143
|
event_dict = (0, _utils.validate_track_event_schema)(event_dict);
|
|
139
144
|
var apparent_size = (0, _utils.get_apparent_event_size)(event_dict, is_part_of_bulk);
|
|
140
145
|
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,8 @@ var _subscriber = _interopRequireDefault(require("./subscriber"));
|
|
|
41
41
|
|
|
42
42
|
var _subscribers_bulk = _interopRequireDefault(require("./subscribers_bulk"));
|
|
43
43
|
|
|
44
|
+
var _brands = _interopRequireDefault(require("./brands"));
|
|
45
|
+
|
|
44
46
|
var _constants = require("./constants");
|
|
45
47
|
|
|
46
48
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -66,6 +68,7 @@ var Suprsend = /*#__PURE__*/function () {
|
|
|
66
68
|
this._bulk_events = new _events_bulk.BulkEventsFactory(this);
|
|
67
69
|
this._bulk_users = new _subscribers_bulk["default"](this);
|
|
68
70
|
this._user = new _subscriber["default"](this);
|
|
71
|
+
this.brands = new _brands["default"](this);
|
|
69
72
|
|
|
70
73
|
this._validate();
|
|
71
74
|
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var LANG_CODE_NAME_MAPPING = {
|
|
13
|
+
aa: "Afar",
|
|
14
|
+
ab: "Abkhazian",
|
|
15
|
+
ae: "Avestan",
|
|
16
|
+
af: "Afrikaans",
|
|
17
|
+
ak: "Akan",
|
|
18
|
+
am: "Amharic",
|
|
19
|
+
an: "Aragonese",
|
|
20
|
+
ar: "Arabic",
|
|
21
|
+
as: "Assamese",
|
|
22
|
+
av: "Avaric",
|
|
23
|
+
ay: "Aymara",
|
|
24
|
+
az: "Azerbaijani",
|
|
25
|
+
ba: "Bashkir",
|
|
26
|
+
be: "Belarusian",
|
|
27
|
+
bg: "Bulgarian",
|
|
28
|
+
bi: "Bislama",
|
|
29
|
+
bm: "Bambara",
|
|
30
|
+
bn: "Bengali",
|
|
31
|
+
bo: "Tibetan",
|
|
32
|
+
br: "Breton",
|
|
33
|
+
bs: "Bosnian",
|
|
34
|
+
ca: "Catalan; Valencian",
|
|
35
|
+
ce: "Chechen",
|
|
36
|
+
ch: "Chamorro",
|
|
37
|
+
co: "Corsican",
|
|
38
|
+
cr: "Cree",
|
|
39
|
+
cs: "Czech",
|
|
40
|
+
cu: "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic",
|
|
41
|
+
cv: "Chuvash",
|
|
42
|
+
cy: "Welsh",
|
|
43
|
+
da: "Danish",
|
|
44
|
+
de: "German",
|
|
45
|
+
dv: "Divehi; Dhivehi; Maldivian",
|
|
46
|
+
dz: "Dzongkha",
|
|
47
|
+
ee: "Ewe",
|
|
48
|
+
el: "Greek, Modern (1453-)",
|
|
49
|
+
en: "English",
|
|
50
|
+
eo: "Esperanto",
|
|
51
|
+
es: "Spanish; Castilian",
|
|
52
|
+
et: "Estonian",
|
|
53
|
+
eu: "Basque",
|
|
54
|
+
fa: "Persian",
|
|
55
|
+
ff: "Fulah",
|
|
56
|
+
fi: "Finnish",
|
|
57
|
+
fj: "Fijian",
|
|
58
|
+
fo: "Faroese",
|
|
59
|
+
fr: "French",
|
|
60
|
+
fy: "Western Frisian",
|
|
61
|
+
ga: "Irish",
|
|
62
|
+
gd: "Gaelic; Scottish Gaelic",
|
|
63
|
+
gl: "Galician",
|
|
64
|
+
gn: "Guarani",
|
|
65
|
+
gu: "Gujarati",
|
|
66
|
+
gv: "Manx",
|
|
67
|
+
ha: "Hausa",
|
|
68
|
+
he: "Hebrew",
|
|
69
|
+
hi: "Hindi",
|
|
70
|
+
ho: "Hiri Motu",
|
|
71
|
+
hr: "Croatian",
|
|
72
|
+
ht: "Haitian; Haitian Creole",
|
|
73
|
+
hu: "Hungarian",
|
|
74
|
+
hy: "Armenian",
|
|
75
|
+
hz: "Herero",
|
|
76
|
+
ia: "Interlingua (International Auxiliary Language Association)",
|
|
77
|
+
id: "Indonesian",
|
|
78
|
+
ie: "Interlingue; Occidental",
|
|
79
|
+
ig: "Igbo",
|
|
80
|
+
ii: "Sichuan Yi; Nuosu",
|
|
81
|
+
ik: "Inupiaq",
|
|
82
|
+
io: "Ido",
|
|
83
|
+
is: "Icelandic",
|
|
84
|
+
it: "Italian",
|
|
85
|
+
iu: "Inuktitut",
|
|
86
|
+
ja: "Japanese",
|
|
87
|
+
jv: "Javanese",
|
|
88
|
+
ka: "Georgian",
|
|
89
|
+
kg: "Kongo",
|
|
90
|
+
ki: "Kikuyu; Gikuyu",
|
|
91
|
+
kj: "Kuanyama; Kwanyama",
|
|
92
|
+
kk: "Kazakh",
|
|
93
|
+
kl: "Kalaallisut; Greenlandic",
|
|
94
|
+
km: "Central Khmer",
|
|
95
|
+
kn: "Kannada",
|
|
96
|
+
ko: "Korean",
|
|
97
|
+
kr: "Kanuri",
|
|
98
|
+
ks: "Kashmiri",
|
|
99
|
+
ku: "Kurdish",
|
|
100
|
+
kv: "Komi",
|
|
101
|
+
kw: "Cornish",
|
|
102
|
+
ky: "Kirghiz; Kyrgyz",
|
|
103
|
+
la: "Latin",
|
|
104
|
+
lb: "Luxembourgish; Letzeburgesch",
|
|
105
|
+
lg: "Ganda",
|
|
106
|
+
li: "Limburgan; Limburger; Limburgish",
|
|
107
|
+
ln: "Lingala",
|
|
108
|
+
lo: "Lao",
|
|
109
|
+
lt: "Lithuanian",
|
|
110
|
+
lu: "Luba-Katanga",
|
|
111
|
+
lv: "Latvian",
|
|
112
|
+
mg: "Malagasy",
|
|
113
|
+
mh: "Marshallese",
|
|
114
|
+
mi: "Maori",
|
|
115
|
+
mk: "Macedonian",
|
|
116
|
+
ml: "Malayalam",
|
|
117
|
+
mn: "Mongolian",
|
|
118
|
+
mr: "Marathi",
|
|
119
|
+
ms: "Malay",
|
|
120
|
+
mt: "Maltese",
|
|
121
|
+
my: "Burmese",
|
|
122
|
+
na: "Nauru",
|
|
123
|
+
nb: "Bokmål, Norwegian; Norwegian Bokmål",
|
|
124
|
+
nd: "Ndebele, North; North Ndebele",
|
|
125
|
+
ne: "Nepali",
|
|
126
|
+
ng: "Ndonga",
|
|
127
|
+
nl: "Dutch; Flemish",
|
|
128
|
+
nn: "Norwegian Nynorsk; Nynorsk, Norwegian",
|
|
129
|
+
no: "Norwegian",
|
|
130
|
+
nr: "Ndebele, South; South Ndebele",
|
|
131
|
+
nv: "Navajo; Navaho",
|
|
132
|
+
ny: "Chichewa; Chewa; Nyanja",
|
|
133
|
+
oc: "Occitan (post 1500)",
|
|
134
|
+
oj: "Ojibwa",
|
|
135
|
+
om: "Oromo",
|
|
136
|
+
or: "Oriya",
|
|
137
|
+
os: "Ossetian; Ossetic",
|
|
138
|
+
pa: "Panjabi; Punjabi",
|
|
139
|
+
pi: "Pali",
|
|
140
|
+
pl: "Polish",
|
|
141
|
+
ps: "Pushto; Pashto",
|
|
142
|
+
pt: "Portuguese",
|
|
143
|
+
qu: "Quechua",
|
|
144
|
+
rm: "Romansh",
|
|
145
|
+
rn: "Rundi",
|
|
146
|
+
ro: "Romanian; Moldavian; Moldovan",
|
|
147
|
+
ru: "Russian",
|
|
148
|
+
rw: "Kinyarwanda",
|
|
149
|
+
sa: "Sanskrit",
|
|
150
|
+
sc: "Sardinian",
|
|
151
|
+
sd: "Sindhi",
|
|
152
|
+
se: "Northern Sami",
|
|
153
|
+
sg: "Sango",
|
|
154
|
+
si: "Sinhala; Sinhalese",
|
|
155
|
+
sk: "Slovak",
|
|
156
|
+
sl: "Slovenian",
|
|
157
|
+
sm: "Samoan",
|
|
158
|
+
sn: "Shona",
|
|
159
|
+
so: "Somali",
|
|
160
|
+
sq: "Albanian",
|
|
161
|
+
sr: "Serbian",
|
|
162
|
+
ss: "Swati",
|
|
163
|
+
st: "Sotho, Southern",
|
|
164
|
+
su: "Sundanese",
|
|
165
|
+
sv: "Swedish",
|
|
166
|
+
sw: "Swahili",
|
|
167
|
+
ta: "Tamil",
|
|
168
|
+
te: "Telugu",
|
|
169
|
+
tg: "Tajik",
|
|
170
|
+
th: "Thai",
|
|
171
|
+
ti: "Tigrinya",
|
|
172
|
+
tk: "Turkmen",
|
|
173
|
+
tl: "Tagalog",
|
|
174
|
+
tn: "Tswana",
|
|
175
|
+
to: "Tonga (Tonga Islands)",
|
|
176
|
+
tr: "Turkish",
|
|
177
|
+
ts: "Tsonga",
|
|
178
|
+
tt: "Tatar",
|
|
179
|
+
tw: "Twi",
|
|
180
|
+
ty: "Tahitian",
|
|
181
|
+
ug: "Uighur; Uyghur",
|
|
182
|
+
uk: "Ukrainian",
|
|
183
|
+
ur: "Urdu",
|
|
184
|
+
uz: "Uzbek",
|
|
185
|
+
ve: "Venda",
|
|
186
|
+
vi: "Vietnamese",
|
|
187
|
+
vo: "Volapük",
|
|
188
|
+
wa: "Walloon",
|
|
189
|
+
wo: "Wolof",
|
|
190
|
+
xh: "Xhosa",
|
|
191
|
+
yi: "Yiddish",
|
|
192
|
+
yo: "Yoruba",
|
|
193
|
+
za: "Zhuang; Chuang",
|
|
194
|
+
zh: "Chinese",
|
|
195
|
+
zu: "Zulu"
|
|
196
|
+
};
|
|
197
|
+
var ALL_LANG_CODES = (0, _toConsumableArray2["default"])(new Set(Object.keys(LANG_CODE_NAME_MAPPING)));
|
|
198
|
+
var _default = ALL_LANG_CODES;
|
|
199
|
+
exports["default"] = _default;
|
|
200
|
+
module.exports = exports.default;
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"maxLength": 64,
|
|
12
12
|
"description": "unique id provided by client for request"
|
|
13
13
|
},
|
|
14
|
+
"brand_id": {
|
|
15
|
+
"type": ["string", "null"],
|
|
16
|
+
"maxLength": 64,
|
|
17
|
+
"description": "brand id for workflow to be run in context of a brand"
|
|
18
|
+
},
|
|
14
19
|
"$insert_id": {
|
|
15
20
|
"type": "string",
|
|
16
21
|
"minLength": 36,
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"maxLength": 64,
|
|
12
12
|
"description": "unique id provided by client for request"
|
|
13
13
|
},
|
|
14
|
+
"brand_id": {
|
|
15
|
+
"type": ["string", "null"],
|
|
16
|
+
"maxLength": 64,
|
|
17
|
+
"description": "brand id for workflow to be run in context of a brand"
|
|
18
|
+
},
|
|
14
19
|
"name": {
|
|
15
20
|
"$ref": "#/definitions/non_empty_string",
|
|
16
21
|
"description": "name of workflow"
|
package/dist/signature.js
CHANGED
|
@@ -15,14 +15,15 @@ function get_path(url) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function get_request_signature(url, http_verb, content, headers, secret) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
18
|
+
var content_md5 = "";
|
|
19
|
+
var content_type = headers["Content-Type"] || "";
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
if (content) {
|
|
22
|
+
content_md5 = _crypto["default"].createHash("md5").update(content).digest("hex");
|
|
23
|
+
}
|
|
23
24
|
|
|
24
25
|
var request_uri = get_path(url);
|
|
25
|
-
var sign_string = http_verb + "\n" + content_md5 + "\n" +
|
|
26
|
+
var sign_string = http_verb + "\n" + content_md5 + "\n" + content_type + "\n" + headers["Date"] + "\n" + request_uri;
|
|
26
27
|
|
|
27
28
|
var hash = _crypto["default"].createHmac("sha256", secret).update(sign_string);
|
|
28
29
|
|
package/dist/subscriber.js
CHANGED
|
@@ -84,6 +84,7 @@ var Subscriber = /*#__PURE__*/function () {
|
|
|
84
84
|
this.__info = [];
|
|
85
85
|
this._append_count = 0;
|
|
86
86
|
this._remove_count = 0;
|
|
87
|
+
this._set_count = 0;
|
|
87
88
|
this._unset_count = 0;
|
|
88
89
|
this._events = [];
|
|
89
90
|
this._helper = new _subscriber_helper["default"](distinct_id, config.workspace_key);
|
|
@@ -139,7 +140,7 @@ var Subscriber = /*#__PURE__*/function () {
|
|
|
139
140
|
_iterator.f();
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
if (all_events.length === 0 || this._append_count > 0) {
|
|
143
|
+
if (all_events.length === 0 || this._append_count > 0 || this._set_count > 0) {
|
|
143
144
|
var user_identify_event = {
|
|
144
145
|
$insert_id: (0, _utils.uuid)(),
|
|
145
146
|
$time: (0, _utils.epoch_milliseconds)(),
|
|
@@ -300,6 +301,7 @@ var Subscriber = /*#__PURE__*/function () {
|
|
|
300
301
|
if (!(0, _utils.is_empty)(resp["event"])) {
|
|
301
302
|
this._events.push(resp["event"]);
|
|
302
303
|
|
|
304
|
+
this._set_count += resp["set"];
|
|
303
305
|
this._append_count += resp["append"];
|
|
304
306
|
this._remove_count += resp["remove"];
|
|
305
307
|
this._unset_count += resp["unset"];
|
|
@@ -397,6 +399,15 @@ var Subscriber = /*#__PURE__*/function () {
|
|
|
397
399
|
this._collect_event();
|
|
398
400
|
}
|
|
399
401
|
}
|
|
402
|
+
}, {
|
|
403
|
+
key: "set_preferred_language",
|
|
404
|
+
value: function set_preferred_language(lang_code) {
|
|
405
|
+
var caller = "set_preferred_language";
|
|
406
|
+
|
|
407
|
+
this._helper._set_preferred_language(lang_code, caller);
|
|
408
|
+
|
|
409
|
+
this._collect_event();
|
|
410
|
+
}
|
|
400
411
|
}, {
|
|
401
412
|
key: "add_email",
|
|
402
413
|
value: function add_email(email) {
|