From 7c9c6ac50266f461f43b410974bd0e0006400a8c Mon Sep 17 00:00:00 2001 From: Nina Ceban Ciocanu Date: Mon, 28 Oct 2024 17:20:17 +0200 Subject: [PATCH] PLATIR-44580 - Do not send empty meta.configOverrides as it invalidates server side config overrides (#1199) * dinamic datastream overrides is disabled if configOverrides key exists in meta * adding test * add isNotEmptyObject check --------- Co-authored-by: Nina Ciocanu --- src/utils/request/createRequestParams.js | 12 ++++++++++-- .../specs/Config Overrides/C7437530.js | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/utils/request/createRequestParams.js b/src/utils/request/createRequestParams.js index 2ff9e033f..6c091a9e3 100644 --- a/src/utils/request/createRequestParams.js +++ b/src/utils/request/createRequestParams.js @@ -9,6 +9,8 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +import {isEmptyObject} from "../index.js"; + /** * @typedef {{ datastreamId: string, [k: string]: Object }} Override * @typedef {Object} RequestPayload @@ -26,7 +28,13 @@ export default ({ localConfigOverrides, globalConfigOverrides, payload }) => { if (datastreamId) { requestParams.datastreamIdOverride = datastreamId; } - payload.mergeConfigOverride(globalConfigOverrides); - payload.mergeConfigOverride(localConfigOverridesWithoutDatastreamId); + + if (globalConfigOverrides && !isEmptyObject(globalConfigOverrides)) { + payload.mergeConfigOverride(globalConfigOverrides); + } + + if (localConfigOverridesWithoutDatastreamId && !isEmptyObject(localConfigOverridesWithoutDatastreamId)) { + payload.mergeConfigOverride(localConfigOverridesWithoutDatastreamId); + } return requestParams; }; diff --git a/test/functional/specs/Config Overrides/C7437530.js b/test/functional/specs/Config Overrides/C7437530.js index 700d861da..ae89bae74 100644 --- a/test/functional/specs/Config Overrides/C7437530.js +++ b/test/functional/specs/Config Overrides/C7437530.js @@ -73,6 +73,25 @@ test("Test C7437530: `sendEvent` can receive config overrides in command options await t.expect(request.meta.state.domain).ok(); }); +test("Test C7437530: `sendEvent` doesn't contain empty configOverrides if edgeConfigOverrides are not in options", async () => { + const alloy = createAlloyProxy(); + await alloy.configure(config); + await alloy.sendEvent({}); + + await responseStatus(networkLogger.edgeEndpointLogs.requests, [200, 207]); + + await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(1); + + const request = JSON.parse( + networkLogger.edgeEndpointLogs.requests[0].request.body, + ); + + await t + .expect(request.events[0].xdm.implementationDetails.name) + .eql("https://ns.adobe.com/experience/alloy"); + await t.expect(request.meta.configOverrides).eql(undefined); +}); + test("Test C7437530: `sendEvent` can receive config overrides from configure", async () => { const alloy = createAlloyProxy(); await alloy.configure(