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(