-
Notifications
You must be signed in to change notification settings - Fork 13
[CDX-379] Validate testCells #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0e7c6e8
f31da08
82bc312
7964938
b044467
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,7 +130,7 @@ class ConstructorIO { | |
| clientId: clientId || client_id, | ||
| userId, | ||
| segments, | ||
| testCells, | ||
| testCells: helpers.toValidTestCells(testCells), | ||
|
||
| fetch: fetchFromOptions || fetch, | ||
| trackingSendDelay, | ||
| sendTrackingEvents, | ||
|
|
@@ -179,7 +179,7 @@ class ConstructorIO { | |
| } | ||
|
|
||
| if (testCells) { | ||
| this.options.testCells = testCells; | ||
| this.options.testCells = helpers.toValidTestCells(testCells); | ||
| } | ||
|
Comment on lines
181
to
183
|
||
|
|
||
| if (typeof sendTrackingEvents === 'boolean') { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -373,6 +373,23 @@ const utils = { | |
|
|
||
| truncateString: (string, maxLength) => string.slice(0, maxLength), | ||
|
|
||
| // Filter testCells to only include entries with non-empty string values | ||
|
||
| toValidTestCells: (testCells) => { | ||
| if (!testCells || typeof testCells !== 'object' || Array.isArray(testCells)) { | ||
| return {}; | ||
| } | ||
|
|
||
| const filtered = {}; | ||
|
|
||
| Object.keys(testCells).forEach((key) => { | ||
| if (typeof testCells[key] === 'string' && testCells[key].trim() !== '') { | ||
| filtered[key] = testCells[key]; | ||
| } | ||
| }); | ||
|
|
||
| return filtered; | ||
| }, | ||
|
|
||
| getBehaviorUrl: (mediaServiceUrl) => { | ||
| const baseUrl = new URL(mediaServiceUrl); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.