diff --git a/babel.config.js b/babel.config.js index 972ada17..f01ece39 100644 --- a/babel.config.js +++ b/babel.config.js @@ -21,7 +21,7 @@ module.exports = { '@babel/flow' ], 'plugins': [ - 'babel-plugin-transform-es2015-modules-commonjs', + '@babel/plugin-transform-modules-commonjs', [ '@babel/plugin-syntax-dynamic-import', { 'loose': true } ], [ '@babel/plugin-proposal-decorators', { 'loose': true, 'legacy': true } ], [ '@babel/plugin-proposal-class-properties', { 'loose': true } ], diff --git a/build-identity-iframe.js b/build-identity-iframe.js index d099f100..c6f82974 100644 --- a/build-identity-iframe.js +++ b/build-identity-iframe.js @@ -1,4 +1,3 @@ -/* @flow */ const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -68,6 +67,19 @@ compiler.run((err, stats) => { if (err) { console.error(err); } + if (stats.hasErrors()) { + console.log(stats.toString({ + colors: true, + stats: 'errors-only' + })); + } else { + console.log(stats.toString({ + colors: true, + outputPath: true + })); + console.log() + console.log('Identity iframe build succeed'); + } }); diff --git a/iframes/identity/README.md b/iframes/identity/README.md index ef662bc3..57a8c1f8 100644 --- a/iframes/identity/README.md +++ b/iframes/identity/README.md @@ -1,9 +1,30 @@ # Identity Iframe -This iframe is designed to identify user country. +This iframe is designed to identify user country and user info. -This iframe is served by **musenodeweb** +It is served by **musenodeweb** Iframe Url: -* `https://www.paypal.com/muse/identity/index.html` -* `https://www.paypal.com/muse/identity/v2/index.html` \ No newline at end of file +* `https://www.paypal.com/muse/identity/v2/index.html` + +### Local debugging +For local check run following command: + +``` +npm run identity:dev +``` + +By default, iframe is served on URL http://localhost:8080/muse2/ + +Shopping analytics accepts following parameters: + +``` +ShoppingAnalytics({ + paramsToIdentityUrl: ()=> 'http://localhost:8080/muse2/', +}); +``` + +### Deploy process +1. Run `npm run build-identity-iframe` +2. Copy content of `dist/identity/` in `musenodeweb/public/identity/v2/` +3. Deploy `musenodeweb` in production \ No newline at end of file diff --git a/iframes/identity/userInfo.js b/iframes/identity/userInfo.js index 9d375be1..cc63a5ce 100644 --- a/iframes/identity/userInfo.js +++ b/iframes/identity/userInfo.js @@ -16,6 +16,8 @@ export const fetchVisitorInfo = ({ deviceInfo, country }) => { }) } + fetchOptions.headers["disable-set-cookie"] = true + return fetch(`/targeting/graphql`, fetchOptions) .then(res => { if (res.status !== 200) { diff --git a/package.json b/package.json index c7002d6b..8d54afd0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,8 @@ "jest": "^29.3.1", "jest-environment-jsdom": "^29.3.1", "webpack": "^4.41.2", - "webpack-cli": "^4.7.2" + "webpack-cli": "^4.7.2", + "babel-plugin-transform-inline-environment-variables": "0.4.4" }, "dependencies": { "@krakenjs/belter": "^2.0.1", diff --git a/webpack.dev.mjs b/webpack.dev.mjs index 1fa2b22e..9479af3b 100644 --- a/webpack.dev.mjs +++ b/webpack.dev.mjs @@ -33,7 +33,7 @@ const babelConfig = { ], 'plugins': [ [ 'transform-inline-environment-variables' ], - 'babel-plugin-transform-es2015-modules-commonjs', + '@babel/plugin-transform-modules-commonjs', [ '@babel/plugin-syntax-dynamic-import', { 'loose': true } ], [ '@babel/plugin-proposal-decorators', { 'loose': true, 'legacy': true } ], [ '@babel/plugin-proposal-class-properties', { 'loose': true } ], @@ -45,6 +45,7 @@ const babelConfig = { const webpackConfig = { mode: 'development', entry: path.resolve(__dirname, 'iframes/identity/identity.js'), + devtool: 'source-map', output: { path: path.resolve(__dirname, 'dist/identity'), filename: 'identity.js', @@ -65,7 +66,7 @@ const webpackConfig = { } ] }, devServer: { - disableHostCheck: true + allowedHosts: ['paypal.com', 'localhost.paypal.com'] } };