@engage_so/core 1.6.0 → 1.7.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 (2) hide show
  1. package/index.js +15 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -69,7 +69,7 @@ const init = (o) => {
69
69
 
70
70
  const identify = async (o) => {
71
71
  if (!o) {
72
- throw new EngageError('You need to pass an object with at least an id and email.')
72
+ throw new EngageError('You need to pass an object with at least an id.')
73
73
  }
74
74
  if (!o.id) {
75
75
  throw new EngageError('ID missing.')
@@ -77,7 +77,7 @@ const identify = async (o) => {
77
77
  if (o.email && !/^\S+@\S+$/.test(o.email)) {
78
78
  throw new EngageError('Email invalid.')
79
79
  }
80
- const allowed = ['id', 'is_account', 'email', 'number', 'created_at', 'device_token', 'device_platform', 'first_name', 'last_name']
80
+ const allowed = ['id', 'is_account', 'email', 'number', 'created_at', 'device_token', 'device_platform', 'first_name', 'last_name', 'tz']
81
81
  const params = {
82
82
  meta: {}
83
83
  }
@@ -102,7 +102,7 @@ const addAttribute = async (uid, data) => {
102
102
  if (!Object.keys(data).length) {
103
103
  throw new EngageError('Attributes missing.')
104
104
  }
105
- const notMeta = ['created_at', 'is_account', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name']
105
+ const notMeta = ['created_at', 'is_account', 'number', 'device_token', 'device_platform', 'email', 'first_name', 'last_name', 'tz', 'app_version', 'app_build', 'app_last_active']
106
106
  const params = { meta: {} }
107
107
  for (const k in data) {
108
108
  if (notMeta.includes(k)) {
@@ -136,6 +136,17 @@ const track = async (uid, data) => {
136
136
  return _request(`${root}/users/${uid}/events`, data, 'POST')
137
137
  }
138
138
 
139
+ const merge = async (source, destination) => {
140
+ if (!source) {
141
+ throw new EngageError('Source ID missing.')
142
+ }
143
+ if (!destination) {
144
+ throw new EngageError('Destination ID missing.')
145
+ }
146
+
147
+ return _request(`${root}/users/merge`, { source, destination }, 'POST')
148
+ }
149
+
139
150
  const addToAccount = async (uid, gid, role) => {
140
151
  if (!uid) {
141
152
  throw new EngageError('User id missing.')
@@ -195,6 +206,7 @@ module.exports = {
195
206
  identify,
196
207
  addAttribute,
197
208
  track,
209
+ merge,
198
210
  request,
199
211
  addToAccount,
200
212
  removeFromAccount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engage_so/core",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Event driven customer segmentation and targeted engagement.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,5 +18,5 @@
18
18
  "devDependencies": {
19
19
  "jest": "^26.4.2"
20
20
  },
21
- "gitHead": "7db0b36d47cee47daf1bb9412ced6bec0f23462b"
21
+ "gitHead": "049446915da38864772b6f1bd5b5547c4362b7a7"
22
22
  }