Skip to content

Commit

Permalink
Add Adobe client data layer (#2852)
Browse files Browse the repository at this point in the history
* Add Adobe client data layer

* Clean up

* Update package description

Co-authored-by: deloreyj <deloreyjmi@gmail.com>

* Move definition to the effect

* Don't parse acdl minified code

* Include react as peerDep

* Bump peregrine peerdep to a caret

* Revert eb59d1c

Revert to tilde. Release script doesn't handle carets well, and this isn't significant.

Co-authored-by: deloreyj <deloreyjmi@gmail.com>
Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com>
Co-authored-by: Dev Patil <depatil@adobe.com>
  • Loading branch information
4 people authored Dec 16, 2020
1 parent 6ec0c58 commit ec4c86e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 1 deletion.
16 changes: 16 additions & 0 deletions packages/extensions/venia-adobe-data-layer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { useEffect } = require('react');

module.exports = original => props => {
useEffect(() => {
// define the global as soon as possible
globalThis.adobeDataLayer = globalThis.adobeDataLayer || [];

// import the library as late as possible
import(/* webpackChunkName: "acdl" */
/* webpackMode: "lazy" */
/* webpackPrefetch: true */
'@adobe/adobe-client-data-layer');
}, []);

return original(props);
};
7 changes: 7 additions & 0 deletions packages/extensions/venia-adobe-data-layer/intercept.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = targets => {
const { talons } = targets.of('@magento/peregrine');

talons.tap(({ App }) => {
App.useApp.wrapWith('@magento/venia-adobe-data-layer');
});
};
26 changes: 26 additions & 0 deletions packages/extensions/venia-adobe-data-layer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@magento/venia-adobe-data-layer",
"version": "0.0.1",
"publishConfig": {
"access": "public"
},
"description": "Provides Adobe Client Data Layer support in PWA Studio",
"main": "./index.js",
"scripts": {
"clean": " "
},
"repository": "github:magento/pwa-studio",
"license": "(OSL-3.0 OR AFL-3.0)",
"dependencies": {
"@adobe/adobe-client-data-layer": "~1.1.3"
},
"peerDependencies": {
"@magento/peregrine": "~8.0.0",
"react": "~16.9.0"
},
"pwa-studio": {
"targets": {
"intercept": "./intercept"
}
}
}
1 change: 1 addition & 0 deletions packages/venia-concept/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@magento/pagebuilder": "~3.0.0",
"@magento/peregrine": "~8.0.0",
"@magento/upward-security-headers": "~1.0.0",
"@magento/venia-adobe-data-layer": "~0.0.1",
"@magento/venia-ui": "~5.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.1",
"@storybook/react": "~5.2.6",
Expand Down
5 changes: 4 additions & 1 deletion packages/venia-concept/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ module.exports = async env => {

const possibleTypes = await getPossibleTypes();

config.module.noParse = [/braintree\-web\-drop\-in/];
config.module.noParse = [
/@adobe\/adobe\-client\-data\-layer/,
/braintree\-web\-drop\-in/
];
config.plugins = [
...config.plugins,
new DefinePlugin({
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# yarn lockfile v1


"@adobe/adobe-client-data-layer@~1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@adobe/adobe-client-data-layer/-/adobe-client-data-layer-1.1.3.tgz#1b3746407d789a24858348c96ca32493933928fc"
integrity sha512-pEYEHprHaaIJROe6QRuTme7sUN46bn2/jpGUBeqfd8cTL+sNsOUTcg3TN7bCAnwunS4Y7NAMs6cXHEeksAgNPA==
dependencies:
lodash "^4.17.15"

"@adobe/apollo-link-mutation-queue@~1.0.2":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@adobe/apollo-link-mutation-queue/-/apollo-link-mutation-queue-1.0.2.tgz#0c589ffb970b9917ba52c38812740c613c0a40da"
Expand Down

0 comments on commit ec4c86e

Please sign in to comment.