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: add plugin system and experimentation plugin to the site #405

Merged
merged 18 commits into from
Nov 6, 2023

Conversation

ramboz
Copy link
Collaborator

@ramboz ramboz commented Oct 26, 2023

As discussed with @trieloff during our recent workshop, I'm adding the plugin system and the experimentation plugin to the website.

Description

  1. Adds the minimal plugin system proposal from feat: a minimal plugin and template system aem-boilerplate#254
  2. Adds the experimentation plugin from https://github.com/adobe/aem-experience-decisioning/tree/plugin-api
  3. Instrument the existing performance.js as a plugin

Related Issue

adobe/aem-boilerplate#254

Motivation and Context

The goal is to instrument a half-dozen sites so we can validate the current implementation and test it against real use cases in prod.

How Has This Been Tested?

The plugin system has been tested on 2 websites, and the experimentation plugin has a demo site to test the various use cases. I also added a demo experiment in the drafts: https://plugin-system--helix-website--adobe.hlx.page/drafts/ramboz/test-experiment/
It changes the label in the CTA.

Screenshots (if appropriate):

Screenshot 2023-10-26 at 4 29 32 PM Screenshot 2023-10-26 at 4 29 45 PM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

git-subtree-dir: plugins/experience-decisioning
git-subtree-split: 72ddbdb84bd53bee39da1a70aa17318065ea481e
e6f6479 Merge branch 'main' into plugin-api
9028520 fix: possible css leaking into pill overlay
162aab2 fix: improve anonymization for better gdpr/hippa compliance (#3)

git-subtree-dir: plugins/experience-decisioning
git-subtree-split: e6f6479ea2b305452ed84bc4cd48f50197d5edb2
@aem-code-sync
Copy link

aem-code-sync bot commented Oct 26, 2023

Hello, I'm the AEM Code Sync Bot and I will run some test suites that validate the page speed.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-run PSI Checks

@ramboz ramboz changed the title Plugin system feat: add plugin system and experimentation plugin to the site Oct 26, 2023
@aem-code-sync
Copy link

aem-code-sync bot commented Oct 26, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

1268232 feat: add possibility to config prod hosts to disable the overlay pill

git-subtree-dir: plugins/experience-decisioning
git-subtree-split: 126823275dd83b088e5394890cb79d1ed4d76b61
@@ -18,8 +19,7 @@
export function sampleRUM(checkpoint, data = {}) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changes to sampleRUM are just me copying over the latest from the aem boilerplate.

* @param {string} [cssPath] An optional CSS file to load
* @param {object[]} [args] Parameters to be passed to the default export when it is called
*/
async function loadModule(name, jsPath, cssPath, ...args) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the JS/CSS loading logic from loadBlock, extracted to a dedicated method so the plugins can leverage it as well to load their JS/CSS files as needed

* @param {Element} block The block element
* @returns {Object} The block config (blockName, cssPath and jsPath)
*/
function getBlockConfig(block) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This lets us override the default block loading path via methods pushed to window.hlx.patchBlockConfig.
The experimentation plugin expects it to be here to work since it patches the block path for block experiments

@@ -660,9 +683,3 @@ if (window.location.hostname === 'www.hlx.live') {
*/

loadPage(document);

if (window.name.includes('performance')) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was moved and added as a simple plugin

@aem-code-sync
Copy link

aem-code-sync bot commented Oct 27, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link

aem-code-sync bot commented Oct 27, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@ramboz
Copy link
Collaborator Author

ramboz commented Oct 30, 2023

@trieloff @kptdobe @davidnuescheler Let me know your thoughts on the PR.

@ramboz ramboz marked this pull request as ready for review October 30, 2023 07:53
@aem-code-sync
Copy link

aem-code-sync bot commented Oct 30, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link

aem-code-sync bot commented Nov 1, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link
Contributor

@trieloff trieloff left a comment

Choose a reason for hiding this comment

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

Ok from my side. I'd like to run targeted content that shows 24 hours prior to our Discord events and advertises them.

9d1d32a feat: add support for direct experiment manfiest url in the metadata

git-subtree-dir: plugins/experimentation
git-subtree-split: 9d1d32a74efefe41a34bcfc0838bfec7ad566268
Copy link

aem-code-sync bot commented Nov 6, 2023

Page Scores Audits Google
/drafts/ramboz/test-experiment/ PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@ramboz ramboz merged commit 9e94f98 into main Nov 6, 2023
3 checks passed
@ramboz ramboz deleted the plugin-system branch November 6, 2023 17:15
Copy link
Contributor

@trieloff trieloff left a comment

Choose a reason for hiding this comment

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

Just a few comments on the plugin system.

[...this.#plugins.entries()]
.filter(([, plugin]) => plugin.condition
&& !plugin.condition(document, plugin.options, executionContext))
.map(([id]) => this.#plugins.delete(id));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is highly unusual: not just does the .map function have a side-effect, it also modifies the very base of its operation.

In this case either a forEach or a reduce (you re-assign the result to this.#plugins) would work better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point!

.filter(([, plugin]) => plugin.condition
&& !plugin.condition(document, plugin.options, executionContext))
.map(([id]) => this.#plugins.delete(id));
return Promise.all([...this.#plugins.entries()]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need a Promise.all()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because the plugin executions can all be async, so we return a proper promise that you can await in the caller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants