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

Add missing Experience Platform Connector events to Core Components #949

Merged
merged 44 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e4d42a6
CIF-2905: Remove event collector from product recs
laurentiumagureanu Aug 9, 2022
fec8647
CIF-2905: use custom event to load MSE
laurentiumagureanu Aug 9, 2022
a79ca08
CIF-2905: Add Experience connector hook
laurentiumagureanu Aug 9, 2022
55382f6
CIF-2905: Add missing license headers
laurentiumagureanu Aug 9, 2022
ef8942f
CIF-2905: Create experience connector extension
laurentiumagureanu Aug 10, 2022
13cd614
CIF-2905: Remove events collector
laurentiumagureanu Aug 10, 2022
bf90fe4
CIF-2905: Reintroduce MSE for event producing
laurentiumagureanu Aug 10, 2022
bc0dc15
CIF-2905: Add README to platform connector
laurentiumagureanu Aug 10, 2022
569f621
CIF-2905: Import event handlers from source library
laurentiumagureanu Aug 12, 2022
f588d53
Revert "CIF-2905: Remove event collector from product recs"
laurentiumagureanu Aug 12, 2022
7f6cb4c
CIF-2905: Add deprecation notice to collector lib
laurentiumagureanu Aug 12, 2022
2e82230
CIF-2905: Fix missing license header error
laurentiumagureanu Aug 12, 2022
b45aa97
CIF-2898: Add add to cart storefront event
laurentiumagureanu Aug 16, 2022
c311a15
CIF-2898: Add add-to-cart storefront event
laurentiumagureanu Aug 17, 2022
df2ffda
CIF-2898: add pricing to storefront productContext
laurentiumagureanu Aug 17, 2022
051fb54
Merge branch 'issue/CIF-2905' into issue/CIF-2898
laurentiumagureanu Aug 17, 2022
f80b724
CIF-2898: Update storefront libraries
laurentiumagureanu Aug 17, 2022
8b080b8
CIF-2898: Fix eslint check
laurentiumagureanu Aug 17, 2022
dd135b8
CIF-2898: Fix Karma
laurentiumagureanu Aug 17, 2022
e99d9ce
CIF-2898: Fix Karma tests
laurentiumagureanu Aug 17, 2022
d33f5b0
CIF-2898: Fix formatting
laurentiumagureanu Aug 17, 2022
3e2c75f
Remove unused code
laurentiumagureanu Aug 17, 2022
0e2444f
CIF-2898: introduce search unit id and search request id
buuhuu Aug 30, 2022
07402bf
CIF-2898: remove categories from search result context as we search o…
buuhuu Aug 30, 2022
c8b2748
CIF-2898: emit search request and search result events
buuhuu Aug 30, 2022
99954f6
update imports
buuhuu Aug 30, 2022
efdb9a3
CIF-2954: refactor events collector to remove duplicated sdk
buuhuu Aug 31, 2022
26a6c79
CIF-2898: support more add to cart events
buuhuu Aug 31, 2022
c49d089
Merge remote-tracking branch 'origin/master' into issue/CIF-2898
buuhuu Aug 31, 2022
b0b4ed9
releng: add jest for experience platform connector to ci
buuhuu Aug 31, 2022
7e53bb1
releng: fix typo
buuhuu Aug 31, 2022
78e1f67
releng: fix typo
buuhuu Aug 31, 2022
ffae03b
CIF-2898: use StorefrontInstanceContext to provide mse to product rec…
buuhuu Aug 31, 2022
022f818
fix and add tests
buuhuu Sep 1, 2022
1fc9caa
fix style
buuhuu Sep 1, 2022
29feaf7
fix for grouped products
buuhuu Sep 1, 2022
f70837f
add more karma tests
buuhuu Sep 1, 2022
1a41ea4
bundled products, improved readme
buuhuu Sep 1, 2022
6eb028a
fix search request and response
buuhuu Sep 2, 2022
4131d12
Merge branch 'master' into issue/CIF-2898
buuhuu Sep 2, 2022
dbad109
initialise the storefrontinstance context with available basic data
buuhuu Sep 9, 2022
75a5aaf
fix code style
buuhuu Sep 9, 2022
871444c
CIF-2898 - Add missing Experience Platform Connector events to Core C…
LSantha Sep 21, 2022
181aadb
Merge branch 'master' into issue/CIF-2898
LSantha Sep 21, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2022 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.commerce.core.components.internal.storefrontcontext;

import com.adobe.cq.commerce.core.components.storefrontcontext.Pricing;
import com.adobe.cq.commerce.magento.graphql.ProductInterface;

public class PricingImpl implements Pricing {
private final ProductInterface product;

public PricingImpl(ProductInterface product) {
this.product = product;
}

@Override
public Double getSpecialPrice() {
return product.getPriceRange().getMinimumPrice().getFinalPrice().getValue();
}

@Override
public Double getRegularPrice() {
return product.getPriceRange().getMinimumPrice().getRegularPrice().getValue();
}

@Override
public String getCurrencyCode() {
return product.getPriceRange().getMinimumPrice().getFinalPrice().getCurrency().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@

import org.apache.sling.api.resource.Resource;

import com.adobe.cq.commerce.core.components.storefrontcontext.Pricing;
import com.adobe.cq.commerce.core.components.storefrontcontext.ProductStorefrontContext;
import com.adobe.cq.commerce.magento.graphql.ProductInterface;

public class ProductStorefrontContextImpl extends AbstractCommerceStorefrontContext implements ProductStorefrontContext {
public class ProductStorefrontContextImpl extends AbstractCommerceStorefrontContext
implements ProductStorefrontContext {

private final ProductInterface product;
private Pricing pricing = null;

public ProductStorefrontContextImpl(ProductInterface product, Resource resource) {
super(resource);
Expand All @@ -43,4 +46,12 @@ public String getSku() {
public String getName() {
return product.getName();
}

@Override
public Pricing getPricing() {
if (pricing == null) {
pricing = new PricingImpl(product);
}
return pricing;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2022 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.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
package com.adobe.cq.commerce.core.components.storefrontcontext;

public interface Pricing {

Double getSpecialPrice();
buuhuu marked this conversation as resolved.
Show resolved Hide resolved

Double getRegularPrice();

String getCurrencyCode();

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public interface ProductStorefrontContext extends CommerceStorefrontContext {

String getName();

default Pricing getPricing() {
return null;
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@Version("2.0.0")
@Version("2.1.0")
package com.adobe.cq.commerce.core.components.storefrontcontext;

import org.osgi.annotation.versioning.Version;
import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"productId": 0,
"sku": "MJ01",
"name": "Beaumont Summit Kit"
}
"name": "Beaumont Summit Kit",
"pricing": {
"specialPrice": 58.0,
"regularPrice": 58.0,
"currencyCode": "USD"
}
}
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