@ezs/analytics
Advanced tools
Comparing version
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.8.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/analytics@1.7.2...@ezs/analytics@1.8.0) (2020-07-29) | ||
### Features | ||
* add array support to [combine] ([3cc2555](https://github.com/Inist-CNRS/ezs/commit/3cc2555c830e35a8101606d9cd29165ac0fe2189)) | ||
## [1.7.2](https://github.com/Inist-CNRS/ezs/compare/@ezs/analytics@1.7.1...@ezs/analytics@1.7.2) (2020-07-27) | ||
@@ -8,0 +19,0 @@ |
@@ -127,16 +127,22 @@ "use strict"; | ||
const path = this.getParam('path'); | ||
const key = (0, _lodash.default)(data, path); | ||
const validKey = Boolean(key); | ||
const pathVal = (0, _lodash.default)(data, path); | ||
const keys = [].concat(pathVal).filter(Boolean); | ||
if (!validKey) { | ||
if (keys.length === 0) { | ||
return feed.send(data); | ||
} | ||
const value = await this.store.get(key); | ||
const values = await Promise.all(keys.map(key => this.store.get(key))); | ||
if (value) { | ||
(0, _lodash2.default)(data, path, value); | ||
if (values.length && Array.isArray(pathVal)) { | ||
(0, _lodash2.default)(data, path, values); | ||
} else if (values.length && !Array.isArray(pathVal)) { | ||
(0, _lodash2.default)(data, path, values.shift()); | ||
} else if (Array.isArray(pathVal)) { | ||
(0, _lodash2.default)(data, path, pathVal.map(id => ({ | ||
id | ||
}))); | ||
} else { | ||
(0, _lodash2.default)(data, path, { | ||
id: key | ||
id: pathVal | ||
}); | ||
@@ -143,0 +149,0 @@ } |
@@ -14,6 +14,6 @@ "use strict"; | ||
var _store = require("@ezs/store"); | ||
var _core = _interopRequireDefault(require("./core")); | ||
var _store = require("@ezs/store"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,8 +41,6 @@ | ||
(0, _lodash2.default)(obj, path, value); | ||
feed.send(obj); | ||
return feed.send(obj); | ||
} catch (e) { | ||
feed.send(e); | ||
return feed.send(e); | ||
} | ||
return; | ||
} | ||
@@ -49,0 +47,0 @@ /** |
{ | ||
"name": "@ezs/analytics", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Analytics statements for EZS", | ||
@@ -49,3 +49,3 @@ "directories": { | ||
}, | ||
"gitHead": "0f65b74c14136a32a5814931e63af84f5f9c62c5", | ||
"gitHead": "7aa0ac603ac5be3141c6fdc7130cef98cdf9fe35", | ||
"devDependencies": { | ||
@@ -52,0 +52,0 @@ "@ezs/core": "1.2.2" |
144293
0.42%3377
0.15%