Skip to content

Commit

Permalink
PLATIR-44580 - Do not send empty meta.configOverrides as it invalidat…
Browse files Browse the repository at this point in the history
…es 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 <[email protected]>
  • Loading branch information
ninaceban and Nina Ciocanu authored Oct 28, 2024
1 parent 2e11930 commit 7c9c6ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils/request/createRequestParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
};
19 changes: 19 additions & 0 deletions test/functional/specs/Config Overrides/C7437530.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7c9c6ac

Please sign in to comment.