Skip to content

Commit

Permalink
Add disable-set-cookie header to /targeting/graphql (#186)
Browse files Browse the repository at this point in the history
* add disable-set-cookie header to targeting/graphql

* DTSHOPSEOL-2059: make `disable-set-cookie=true` permanent header for visitor info requests

* DTSHOPSEOL-2059: tech dept.
* Fix local/prod build
* Update identity/README.md

* DTSHOPSEOL-2059: replace double quotes with single

* DTSHOPSEOL-2059: update babel plugin

* DTSHOPSEOL-2059: remove flow for build script

---------

Co-authored-by: Spencer Sablan <[email protected]>
Co-authored-by: Yehor Anisimov <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2023
1 parent c16d527 commit c94e90a
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ],
Expand Down
14 changes: 13 additions & 1 deletion build-identity-iframe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* @flow */
const path = require('path');

const HtmlWebpackPlugin = require('html-webpack-plugin');
Expand Down Expand Up @@ -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');
}
});


29 changes: 25 additions & 4 deletions iframes/identity/README.md
Original file line number Diff line number Diff line change
@@ -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`
* `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
2 changes: 2 additions & 0 deletions iframes/identity/userInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions webpack.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } ],
Expand All @@ -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',
Expand All @@ -65,7 +66,7 @@ const webpackConfig = {
} ]
},
devServer: {
disableHostCheck: true
allowedHosts: ['paypal.com', 'localhost.paypal.com']
}
};

Expand Down

0 comments on commit c94e90a

Please sign in to comment.