Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Dynamic Web Content was slow to load due to always initializing after the page hit event being fired, which could take upwards of 1.5s. This PR moves the request for DWC to just before the page hit event being fired, but includes all the same parameters as the page hit event as well as the request for DWC. In this way, we can properly identify the contact and render the DWC on the page without having to wait for the page hit event to finish. In my testing, this resulted in a 76% increase in DWC rendering time (down to ~600ms from ~2500 ms)
Additionally, we now set the
Access-Control-Max-Age
header on response toOPTIONS
requests made usingMauticJS.makeCORSRequest()
. This will save ~ 200ms during the page load on external pages that make CORS requests to Mautic, as the browser will now cache theOPTIONS
response for 10 min (a hard limit set by Chrome). Previously, it was caching the response for 5s.Additionally, a bug is fixed where Campaign events were being triggered and logged for non-campaign based DWC. Previously we were checking that a campaign "Request Dynamic Content" decision applied to the requested DWC slot name, and just bypassing it if it did not match. (If you were requesting a slot named
blog
and your campaign served a slot namedsomething-else
, thesomething-else
decision would be logged in thecampaign_lead_event_log
for the active contact.) This PR fixes that by setting the event status to false and returning false in the check, to prevent going further down the campaign path.Steps to test this PR: