-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add storefront events SDK and collector #21
Changes from all commits
d759a55
66cc0f5
491aed4
dd7bf08
aff7f83
0ea2624
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const fs = require('fs'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @herzog31 you can probably add this file to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion. Fix available in #45. |
||
const path = require('path'); | ||
|
||
fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-event-collector/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-collector.js')); | ||
fs.copyFileSync(path.resolve(__dirname, './node_modules/@adobe/magento-storefront-events-sdk/dist/index.js'), path.resolve(__dirname, './scripts/commerce-events-sdk.js')); |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
// eslint-disable-next-line import/no-cycle | ||
import { sampleRUM } from './aem.js'; | ||
import { getConfigValue } from './configs.js'; | ||
|
||
// Core Web Vitals RUM collection | ||
sampleRUM('cwv'); | ||
|
||
// add more delayed functionality here | ||
|
||
// 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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @herzog31 Since this is all delayed, does it mean that any event occurring after 3s will not be collected ? E.g. if the user clicks away or closes the window before this is loaded ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user leaves the page before this is loaded, the events will not be collected. That's correct and unfortunately a known limitation. There are some ideas to fix this in https://git.corp.adobe.com/mabecker/acdl2 which can persist events in session storage to make sure they can be collected on the next page. But this will take some more work and will be added to the mainline ACDL in the near future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@herzog31 Is it ok to use versions 1.8.0 for
@adobe/magento-storefront-event-collector
and@adobe/magento-storefront-events-sdk
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you can use newer versions.