The resolution of this issue has two objectives
- Fix the root cause of the initial issue
- Extend this "fix" to a more global approach of configuration override
1. Initial issue
autoData allow common configuration override like this :
autoData.init({ common: { tms: { name: 'tealium' }, plugins: { eventTracker: { attributePrefix: 'data-evt-', trigger: 'att1', attributes: ['att1_1', 'att1_2'] } } }, custom_template: { plugins: { eventTracker: { attributes: ['att2_1', 'att2_2'] } } } });
custom_template values override common ones. In this simple case, initialized eventTracker attributes are 'att2_1' and 'att2_2'. The issue appears when common arrays are wider (see below).
autoData.init({ common: { tms: { name: 'tealium' }, plugins: { eventTracker: { attributePrefix: 'data-evt-', trigger: 'att1', attributes: ['att1_1', 'att1_2'] } } }, custom_template: { plugins: { eventTracker: { attributes: ['att2_1'] } } } });
In this other case, initialized eventTracker attributes are 'att2_1' and 'att1_2'. They are like "merged" strangely , where it should be 'att1_1', 'att1_2' and 'att2_1' (really merged) OR 'att2_1' only (pure override).
To fix it, a merge is preferred. As common values, they shouldn't be removed on arrays. It introduce the final though :)
2. Configuration override revision
Using configuration override, arrays are merged pragmatically between common values and specific values. Strings are not affected.
autoData.init({ common: { tms: { name: 'tealium' }, plugins: { eventTracker: { attributePrefix: 'data-evt-', trigger: 'att1', attributes: ['att1_1', 'att1_2','att_generic'] } } }, custom_template: { plugins: { eventTracker: { attributes: ['att2_1', 'att2_2','att_generic'] } } } });
This configuration should result on 'att1_1', 'att1_2', 'att2_1', 'att2_2' and 'att_generic. It should remove duplicates values to be optimal.