Skip to content
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

CIF-2905: Experience Connector Extension #948

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions extensions/experience-platform-connector/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// eslint-disable-next-line header/header
const headerBlock = [
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
{
pattern: ' ~ Copyright \\d{4} Adobe',
template: ` ~ Copyright ${new Date().getFullYear()} Adobe`,
},
' ~',
' ~ Licensed under the Apache License, Version 2.0 (the "License");',
' ~ you may not use this file except in compliance with the License.',
' ~ You may obtain a copy of the License at',
' ~',
' ~ http://www.apache.org/licenses/LICENSE-2.0',
' ~',
' ~ Unless required by applicable law or agreed to in writing, software',
' ~ distributed under the License is distributed on an "AS IS" BASIS,',
' ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
' ~ See the License for the specific language governing permissions and',
' ~ limitations under the License.',
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~',
];

module.exports = {
settings: {
react: {
version: 'detect'
}
},
env: {
browser: true,
es6: true,
'jest/globals': true
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:jest/recommended'
],
parser: 'babel-eslint',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
process: true
},
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2018,
sourceType: 'module'
},
plugins: ['react', 'react-hooks', 'header', 'jest'],
rules: {
'no-console': ['warn', { allow: ['error', 'warn'] }],
'no-undef': 'error',
'no-unused-vars': 'warn',
'header/header': [2, 'block', headerBlock],
'no-var': 'error',
'one-var': ['error', 'never'],
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
// override the default which is more restrictive
'react/prop-types': ['warn', { ignore: ['children'] }],
strict: ['error', 'global'],
'jest/valid-describe': 'off'
}
};
7 changes: 7 additions & 0 deletions extensions/experience-platform-connector/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.*
target
coverage
*.iml
pom.xml
build-scripts
.npmrc
5 changes: 5 additions & 0 deletions extensions/experience-platform-connector/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.min.js
*.min-latest.js
**/dist/*.js
**/node/*
**/coverage/*
14 changes: 14 additions & 0 deletions extensions/experience-platform-connector/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve"
}
30 changes: 30 additions & 0 deletions extensions/experience-platform-connector/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
Copyright 2021 Adobe Systems Incorporated

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Experience Platform Connector

This Javascript library collects Storefront events and forwards them to AEP.

It exports the `useEventsCollector` React hook which subscribes to all storefront events.
This hook requires the Peregrine user context. So it must be used in a React component that is wrapped inside that context.
The hook takes the configuration as an argument:

```javascript
useEventsCollector({
aep: { orgId: 'IMS ORG ID', datastreamId: 'The ID of the datastream used in AEP' },
acds: false
});
```
16 changes: 16 additions & 0 deletions extensions/experience-platform-connector/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
module.exports = 'test-file-stub';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
module.exports = {
process(src) {
return src;
}
};
40 changes: 40 additions & 0 deletions extensions/experience-platform-connector/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// eslint-disable-next-line no-undef
const plugins = [
/**
* See:
* https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining
*/
['@babel/plugin-proposal-optional-chaining']
];

const presets = [['@babel/preset-react']];
// eslint-disable-next-line no-undef
module.exports = function(api) {
const envConfigs = {
development: {
plugins,
presets: [...presets, ['@babel/preset-env', { modules: false, targets: 'last 2 Chrome versions' }]]
},
test: {
plugins: [...plugins, ['babel-plugin-dynamic-import-node']],
presets: [...presets, ['@babel/preset-env', { modules: 'commonjs', targets: 'node 10' }]]
}
};

return envConfigs[Object.keys(envConfigs).indexOf(api.env()) !== -1 ? api.env() : 'development'];
};
35 changes: 35 additions & 0 deletions extensions/experience-platform-connector/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2019 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// eslint-disable-next-line no-undef
module.exports = {
collectCoverage: true,
moduleDirectories: ['node_modules', 'src/utils'],
coverageDirectory: '<rootDir>/coverage',
coverageReporters: ['json', 'lcov'],
coveragePathIgnorePatterns: ['<rootDir>/src/queries', '\\.(gql|graphql)$'],
testPathIgnorePatterns: ['<rootDir>/node_modules/', '__mocks__'],
reporters: ['default', ['jest-junit', { outputDirectory: './test-results' }]],
transform: {
'.+\\.json': './__mocks__/jsonTransform.js',
'.+\\.(js|jsx|ts|tsx)$': 'babel-jest'
},
moduleNameMapper: {
'\\.css$': 'identity-obj-proxy',
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/__mocks__/fileMock.js'
},
transformIgnorePatterns: ['node_modules/(?!@magento/)'],
};
Loading