Skip to content

Commit d6f4cff

Browse files
authored
PDCL-1333 - remove event name validation logic (#804)
1 parent af8fd3f commit d6f4cff

File tree

4 files changed

+5
-52
lines changed

4 files changed

+5
-52
lines changed

src/components/DataCollector/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ governing permissions and limitations under the License.
1212

1313
import validateUserEventOptions from "./validateUserEventOptions";
1414

15-
const createDataCollector = ({ eventManager, logger }) => {
15+
const createDataCollector = ({ eventManager }) => {
1616
return {
1717
commands: {
1818
sendEvent: {
1919
documentationUri: "https://adobe.ly/2r0uUjh",
2020
optionsValidator: options => {
21-
return validateUserEventOptions({ options, logger });
21+
return validateUserEventOptions({ options });
2222
},
2323
run: options => {
2424
const {

src/components/DataCollector/validateUserEventOptions.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import { validateIdentityMap } from "../../utils";
1515
/**
1616
* Verifies user provided event options.
1717
* @param {*} options The user event options to validate
18-
* @param {*} logger
1918
* @returns {*} Validated options
2019
*/
21-
export default ({ options, logger }) => {
20+
export default ({ options }) => {
2221
const eventOptionsValidator = objectOf({
2322
type: string(),
2423
xdm: objectOf({
@@ -30,10 +29,5 @@ export default ({ options, logger }) => {
3029
decisionScopes: arrayOf(string()),
3130
datasetId: string()
3231
}).required();
33-
const validatedOptions = eventOptionsValidator(options);
34-
const { type, xdm } = validatedOptions;
35-
if (xdm && !xdm.eventType && !type) {
36-
logger.warn("No type or xdm.eventType specified.");
37-
}
38-
return validatedOptions;
32+
return eventOptionsValidator(options);
3933
};

test/unit/specs/components/DataCollector/index.spec.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { noop } from "../../../../../src/utils";
1414

1515
describe("Event Command", () => {
1616
let event;
17-
let logger;
1817
let eventManager;
1918
let sendEventCommand;
2019
beforeEach(() => {
@@ -25,7 +24,6 @@ describe("Event Command", () => {
2524
"mergeXdm",
2625
"mergeMeta"
2726
]);
28-
logger = jasmine.createSpyObj("logger", ["warn"]);
2927

3028
eventManager = {
3129
createEvent() {
@@ -40,8 +38,7 @@ describe("Event Command", () => {
4038
};
4139

4240
const dataCollector = createDataCollector({
43-
eventManager,
44-
logger
41+
eventManager
4542
});
4643
sendEventCommand = dataCollector.commands.sendEvent;
4744
});

test/unit/specs/components/DataCollector/validateUserEventOptions.spec.js

-38
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,4 @@ describe("DataCollector::validateUserEventOptions", () => {
5656
}).toThrowError();
5757
});
5858
});
59-
it("logs warning when event type is required and missing", () => {
60-
const options = { xdm: { test: "" } };
61-
const logger = {
62-
warn: jasmine.createSpy()
63-
};
64-
validateUserEventOptions({ options, logger });
65-
expect(logger.warn).toHaveBeenCalledWith(
66-
"No type or xdm.eventType specified."
67-
);
68-
});
69-
it("does not throw errors when event options are valid", () => {
70-
[
71-
{},
72-
{ xdm: { eventType: "test" } },
73-
{ type: "test", xdm: { test: "" } },
74-
{ renderDecisions: true },
75-
{ data: { test: "" } },
76-
{ renderDecisions: true, data: { test: "" } },
77-
{ decisionScopes: ["test"] },
78-
{ datasetId: "12432ewfr12" },
79-
{
80-
xdm: {
81-
eventType: "test",
82-
identityMap: {
83-
namespace1: [
84-
{ id: "123", primary: true, authenticatedState: "authenticated" },
85-
{ id: "3" }
86-
],
87-
namespace2: [{ id: "23", authenticatedState: "ambiguous" }]
88-
}
89-
}
90-
}
91-
].forEach(options => {
92-
expect(() => {
93-
validateUserEventOptions({ options });
94-
}).not.toThrowError();
95-
});
96-
});
9759
});

0 commit comments

Comments
 (0)