@segment/analytics.js-integration-segmentio
Advanced tools
Comparing version 4.3.1 to 4.4.0
@@ -0,1 +1,10 @@ | ||
4.4.0 / 2020-02-05 | ||
================== | ||
* Removes the `bundledConfigIds` _setting_ and instead generates `bundledConfigIds` using the intersection | ||
of `bundled` destinations and the new `maybeBundledConfigIds` setting. `bundledConfigIds` and `unbundledConfigIds` | ||
is still appended to event metadata. This change is meant to ensure that `bundledConfigIds` only includes the | ||
subset of destinations that is generated at runtime for the `bundled` array. | ||
* Fixes the use of `const` from a previous release. | ||
4.3.0 / 2020-01-13 | ||
@@ -2,0 +11,0 @@ ================== |
@@ -21,3 +21,3 @@ 'use strict'; | ||
const json = JSON; | ||
var json = JSON; | ||
@@ -68,3 +68,5 @@ /** | ||
.option('addBundledMetadata', false) | ||
.option('unbundledIntegrations', [])); | ||
.option('unbundledIntegrations', [])) | ||
.option('unbundledConfigIds', []) | ||
.option('maybeBundledConfigIds', {}); | ||
@@ -320,7 +322,27 @@ /** | ||
var bundled = keys(this.analytics.Integrations); | ||
var maybeBundledConfigIds = this.options.maybeBundledConfigIds | ||
// Generate a list of bundled config IDs using the intersection of | ||
// bundled destination names and maybe bundled config IDs. | ||
var bundledConfigIds = [] | ||
for (var i = 0; i < bundled.length; i++) { | ||
var name = bundled[i] | ||
if (!maybeBundledConfigIds) { | ||
break | ||
} | ||
if (!maybeBundledConfigIds[name]) { | ||
continue | ||
} | ||
for (var j = 0; j < maybeBundledConfigIds[name].length; j++) { | ||
var id = maybeBundledConfigIds[name][j] | ||
bundledConfigIds.push(id) | ||
} | ||
} | ||
msg._metadata = msg._metadata || {}; | ||
msg._metadata.bundled = bundled; | ||
msg._metadata.unbundled = this.options.unbundledIntegrations; | ||
msg._metadata.bundledConfigIds = this.options.bundledConfigIds; | ||
msg._metadata.unbundledConfigIds = this.options.unbundledConfigIds; | ||
msg._metadata.bundledIds = bundledConfigIds; | ||
} | ||
@@ -327,0 +349,0 @@ this.debug('normalized %o', msg); |
{ | ||
"name": "@segment/analytics.js-integration-segmentio", | ||
"description": "The Segmentio analytics.js integration.", | ||
"version": "4.3.1", | ||
"version": "4.4.0", | ||
"keywords": [ | ||
@@ -60,3 +60,3 @@ "analytics.js", | ||
}, | ||
"gitHead": "cf751050547b0078836c01946c2c2d69f1e4e322" | ||
"gitHead": "a441a1f29ac8783557d79b872f7e99d6e517b543" | ||
} |
@@ -452,4 +452,5 @@ 'use strict'; | ||
ajs.use(integration('other')); | ||
ajs.use(integration('another')); | ||
ajs.add(segment); | ||
ajs.initialize({ other: {} }); | ||
ajs.initialize({ other: {}, another: {} }); | ||
}); | ||
@@ -463,3 +464,3 @@ | ||
assert(object._metadata); | ||
assert.deepEqual(object._metadata.bundled, ['Segment.io', 'other']); | ||
assert.deepEqual(object._metadata.bundled, ['Segment.io', 'other', 'another']); | ||
}); | ||
@@ -483,2 +484,29 @@ | ||
}); | ||
it('should generate and add a list of bundled destination config ids when `addBundledMetadata` is set', function() { | ||
segment.options.addBundledMetadata = true; | ||
segment.options.maybeBundledConfigIds = { | ||
'other': ['config21'], | ||
'slack': ['slack99'] // should be ignored | ||
}; | ||
segment.normalize(object); | ||
assert(object); | ||
assert(object._metadata); | ||
assert.deepEqual(object._metadata.bundledIds, ['config21']); | ||
}); | ||
it('should generate a list of multiple bundled destination config ids when `addBundledMetadata` is set', function() { | ||
segment.options.addBundledMetadata = true; | ||
segment.options.maybeBundledConfigIds = { | ||
'other': ['config21'], | ||
'another': ['anotherConfig99'], | ||
'slack': ['slack99'] // should be ignored | ||
}; | ||
segment.normalize(object); | ||
assert(object); | ||
assert(object._metadata); | ||
assert.deepEqual(object._metadata.bundledIds, ['config21', 'anotherConfig99']); | ||
}); | ||
}); | ||
@@ -485,0 +513,0 @@ |
84699
2050