Skip to content

Conversation

@sirugh
Copy link
Collaborator

@sirugh sirugh commented Apr 11, 2025

Configuration was previously a bit confusing. We had configs, configs-stage and configs-dev. This was a bit duplicative.

image

These sheets were used to manage which commerce endpoint your browser would request from. But we conflated Edge Delivery environments (prod/preview) with Commerce environments (prod/stage).

This is no longer the case. Now, regardless of whether you are on aem.live or aem.page or localhost, you will use a single config file.

This may affect how you work. Now, if you want to connect to a different backend environment your options are:

  1. Manually change your session storage config entry values or
  2. Create a local config.json file in the root of your code directory, matching the expected JSON

Additionally, if you wish to use this functionality on your own fork, please inspect this code for what changes you might need to apply.

Notable things:

  1. Change to how and when config is initalized/loaded.
  2. Change to how you use getConfigValue (no longer async, so no need for await).
  3. Change to how multi-store works, and how it determines which store and what config to use
  4. Change to how you work locally (using local config.json) noted above.

We hope this change reduces confusion and complexity :)

Mulstistore Configuration

The key of the public configuration, outside default becomes the root path.

Example

{
  "public": {
    "default": {
      "commerce-core-endpoint": "https://www.aemshop.net/graphql",
      "commerce-endpoint": "https://www.aemshop.net/cs-graphql",
      "headers": {
        "cs": {
          "Magento-Customer-Group": "b6589fc6ab0dc82cf12099d1c2d40ab994e8410c",
          "Magento-Store-Code": "main_website_store",
          "Magento-Store-View-Code": "default",
          "Magento-Website-Code": "base",
          "x-api-key": "4dfa19c9fe6f4cccade55cc5b3da94f7",
          "Magento-Environment-Id": "f38a0de0-764b-41fa-bd2c-5bc2f3c7b39a"
        }
      },
      "analytics": {
        "base-currency-code": "USD",
        "environment": "Production",
        "store-id": 1,
        "store-name": "Main Website Store",
        "store-url": "https://www.aemshop.net",
        "store-view-id": 1,
        "store-view-name": "Default Store View",
        "website-id": 1,
        "website-name": "Main Website"
      }
    },
    "/drafts/multistore/en/": {},
    "/drafts/multistore/en_ca/": {
      "headers": {
        "all": {
          "Store": "en_ca"
        },
        "cs": {
          "Magento-Store-Code": "ca_store",
          "Magento-Store-View-Code": "en_ca",
          "Magento-Website-Code": "ca_website"
        }
      },
      "analytics": {
        "base-currency-code": "CAD"
      }
    }
  }
}

TODO:

After merge:

  • Publish docs
  • Remove configs(-*).xlsx from sharepoint
  • Remove analytics-config.xlsx from sharepoint

Test URLs:

sirugh and others added 26 commits April 8, 2025 15:06
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
…ncy. Enhanced the applyConfigOverrides function to directly update headers based on metadata, simplifying the logic for applying config overrides. Added JSDoc comments for better documentation of functions. Removed unnecessary complexity in getValue function.
…zation. Replaced the previous root path and JSON fetch logic with a simplified configuration object that directly retrieves values using getConfigValue. This enhances clarity and maintainability of the analytics setup.
….json

- Introduced a new public configuration section in default-config.json, including endpoints and headers for commerce and analytics.
- Updated footer and fragment components to utilize new config functions for improved modularity.
- Refactored commerce.js to leverage the new getRootPath function for fetching placeholders.
- Enhanced configs.js with isConfigRooted function to streamline root path checks.
…ents for improved accuracy in matching the deepest path.
…tead of window object. This change improves encapsulation and maintains consistency in accessing the root path.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Co-authored-by: Stephen <sirugh@users.noreply.github.com>
…ions and enhance link decoration logic. Introduced async config retrieval and improved error handling for localized links.
…move unnecessary intercepts. Simplified the test structure by eliminating redundant checks and focusing on session storage updates.
@aem-code-sync
Copy link

aem-code-sync bot commented Apr 11, 2025

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

@aem-code-sync
Copy link

aem-code-sync bot commented Apr 11, 2025

Page Scores Audits Google
📱 / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
🖥️ / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@sirugh sirugh mentioned this pull request Apr 11, 2025
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
Signed-off-by: Stephen Rugh <rugh@adobe.com>
…ialization and error handling. Introduced private state variables for config management, added new utility functions, and updated exports. Updated scripts/scripts.js to initialize configuration on page load.
Signed-off-by: Stephen Rugh <rugh@adobe.com>
@devpatil7
Copy link
Collaborator

QA Approved.

@sirugh sirugh merged commit c211652 into main Apr 15, 2025
3 checks passed
@sirugh sirugh deleted the one-config branch April 15, 2025 15:17
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.

5 participants