-
Notifications
You must be signed in to change notification settings - Fork 139
[STRATCONN-588] Generate bundledConfigIds #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e74b839 to
9d2e22a
Compare
integrations/segmentio/lib/index.js
Outdated
| msg._metadata.bundledConfigIds = bundledConfigIds; | ||
| msg._metadata.unbundled = this.options.unbundledIntegrations; | ||
| msg._metadata.bundledConfigIds = this.options.bundledConfigIds; | ||
| msg._metadata.unbundledConfigIds = this.options.unbundledConfigIds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided not to ignore empty bundledConfigIds and unbundledConfigIds arrays so it is clear when an event was tracked using this new version of segmentio.
| var Queue = require('@segment/localstorage-retry'); | ||
|
|
||
| const json = JSON; | ||
| var json = JSON; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unintentionally switched to const in #553.
| if (!maybeBundledConfigIds) { | ||
| break | ||
| } | ||
| if (!maybeBundledConfigIds[name]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the casing is the same of destination names in maybeBundledConfigIds and analytics.Integrations e.g. Google Analytics === Google Analytics vs google-analytics.. but perhaps something to double check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, the casing here is the same but they depend on two different sources.
- `bundled` depends on the name that is defined within the integration code itself: https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/google-analytics/lib/index.js#L37
- `bundledConfigIDs` depends on the defintiion creation name: https://github.com/segmentio/ajs-renderer/pull/256/files#diff-ca733fb7a822baffec24f4f426ccb07fce89f5b4d5856f848be4845d1d40e12bR44
The chance of these being different is unlikely but possible. Fwiw, the integration wouldn't receive the proper settings if the name within the integration code doesn't match the destination creation name because settings are keyed by the definition creation name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Gabe's comment, I spot checked a few destinations which I know have undergone name changes and the name defined in integration code marched the definition creation name.
|
|
||
| // Generate a list of bundled config IDs using the intersection of | ||
| // bundled destination names and maybe bundled config IDs. | ||
| var bundledConfigIds = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think var bundledConfigIds = [] should be defined outside of his conditional for clarity. This works currently because of use of var vs let/const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so -- msg._metadata.bundledConfigIds (L343) is defined within the conditional. I'm also mimicking the scope of bundled.
Co-authored-by: Marcus Ericsson <36717+mericsson@users.noreply.github.com>
| .option('unbundledConfigIds', []) | ||
| .option('maybeBundledConfigIds', {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were to conditionally add these arrays in ajs-renderer we would still default to empty values here. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I agree.
| } | ||
|
|
||
| for (var j = 0; j < maybeBundledConfigIds[name].length; j++) { | ||
| var id = maybeBundledConfigIds[name][j] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we maybe want to see if maybeBundledConfigIds[name] has more than one configId? In example case where maybeBundledConfigIds looks like the below, wouldn't we want to collect stats since that would mean they have multiple device mode configs of a destination in device mode, which is not allowed?
maybeBundledConfigIds: {
Fullstory: [ config1, config2]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment here regarding this https://github.com/segmentio/ajs-renderer/pull/256/files#r577105220
integrations/segmentio/lib/index.js
Outdated
| msg._metadata.unbundled = this.options.unbundledIntegrations; | ||
| msg._metadata.bundledConfigIds = this.options.bundledConfigIds; | ||
| msg._metadata.bundledConfigIds = bundledConfigIds; | ||
| msg._metadata.unbundledConfigIds = this.options.unbundledConfigIds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unbundledConfigIds is not used in data plane so it could be removed later on.
integrations/segmentio/package.json
Outdated
| "name": "@segment/analytics.js-integration-segmentio", | ||
| "description": "The Segmentio analytics.js integration.", | ||
| "version": "4.3.1", | ||
| "version": "4.4.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should this be 4.4.0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, thanks for catching,
| var bundledConfigIds = [] | ||
| for (var i = 0; i < bundled.length; i++) { | ||
| var name = bundled[i] | ||
| if (!maybeBundledConfigIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be clearer if this conditional was outside of the loop since it does not depend on anything in bundled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd have to refactor and wrap the for-loop in a conditional. I can go either way but was trying to avoid nested conditionals.
if (maybeBundledConfigIds) {
for (var i = 0; i < bundled.length; i++) { ... }
}
mericsson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm - just one code cleanliness issue #555 (comment)
What does this PR do?
This pull request builds a list of
bundleddsbased on the intersection betweenbundledandmaybeBundledConfigIds.bundledIdsis then appended to each event's metadata object.The related ajs-renderer change can be found here: https://github.com/segmentio/ajs-renderer/pull/256.
Example metadata object

601c3fef8942cb2ad5d70cdfis the FullStory instance that is not Connection Mode configurable because there is only a browser integration.601c3c238942cb7cb5d70cdeis the Google Analytics instance configured in Device Mode.601c4f8164b0701d3b6b78cdis the HubSpot instance that is not Connection Mode configurable, but defaults to Device Mode because it's an a.js source.601c40c46b6df7898d069abfis the Amplitude instance that is configured explicitly in Cloud Mode.Are there breaking changes in this PR?
No. We specifically are adding new metadata fields to avoid introducing breaking changes to
bundledandunbundled.Testing
ajs-rendererchange.Any background context you want to provide?
Is there parity with the server-side/android/iOS integration components (if applicable)?
Does this require a new integration setting? If so, please explain how the new setting works
Links to helpful docs and other external resources