Skip to content
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

feat: update v2 of experimentation engine #595

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ window.hlx.plugins.add('performance', {

window.hlx.plugins.add('experimentation', {
condition: () => document.head.querySelector('[name^="experiment"],[name^="campaign-"],[name^="audience-"]')
|| document.head.querySelector('[property^="campaign:-"],[property^="audience:-"]')
|| document.head.querySelector('[property^="campaign:-"],[property^="audience:-"],[property^="campaign-"],[property^="audience-"]')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, it's <meta property="campaign:-…"> or <meta name="campaign-…">, property without : is something I haven't encountered yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I added that because I was thinking the user could omit the :, and declare as Audience Desktop. Then I realized it is better to have the norm that : should be required. I will revert this.

For <meta property="campaign:-..>, I am going to remove the hyphen here too, and only keep [property^="campaign:"],[property^="audience:"]. As the hyphen comes from the space, and should not considered as the condition.

|| document.querySelector('.section[class*="experiment-"],.section[class*="audience-"],.section[class*="campaign-"]')
|| [...document.querySelectorAll('.section-metadata div')].some((d) => d.textContent.match(/Experiment|Campaign|Audience/i)),
options: { audiences: AUDIENCES },
Expand Down
Loading