Skip to content

Commit

Permalink
Add storefront context directly to ACDL
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 committed Mar 15, 2024
1 parent aff7f83 commit 0ea2624
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 64 deletions.
62 changes: 0 additions & 62 deletions scripts/commerce-events.js

This file was deleted.

31 changes: 29 additions & 2 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
// eslint-disable-next-line import/no-cycle
import { sampleRUM } from './aem.js';
import initCommerceEvents from './commerce-events.js';
import { getConfigValue } from './configs.js';

// Core Web Vitals RUM collection
sampleRUM('cwv');

// add more delayed functionality here
initCommerceEvents();

// Load Commerce events SDK and collector
const config = {
environmentId: await getConfigValue('commerce-environment-id'),
environment: await getConfigValue('commerce-environment'),
storeUrl: await getConfigValue('commerce-store-url'),
websiteId: await getConfigValue('commerce-website-id'),
websiteCode: await getConfigValue('commerce-website-code'),
storeId: await getConfigValue('commerce-store-id'),
storeCode: await getConfigValue('commerce-store-code'),
storeViewId: await getConfigValue('commerce-store-view-id'),
storeViewCode: await getConfigValue('commerce-store-view-code'),
websiteName: await getConfigValue('commerce-website-name'),
storeName: await getConfigValue('commerce-store-name'),
storeViewName: await getConfigValue('commerce-store-view-name'),
baseCurrencyCode: await getConfigValue('commerce-base-currency-code'),
storeViewCurrencyCode: await getConfigValue('commerce-base-currency-code'),
storefrontTemplate: 'Franklin',
};

window.adobeDataLayer.push(
{ storefrontInstanceContext: config },
{ eventForwardingContext: { commerce: true, aep: false } },
);

// Load events SDK and collector
import('./commerce-events-sdk.js');
import('./commerce-events-collector.js');

0 comments on commit 0ea2624

Please sign in to comment.