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 all 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
41 changes: 35 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jobs:
- codecov/upload:
flags: jest

jest-extension:
jest-extension-product-recs:
docker:
- image: cimg/node:lts-browsers
steps:
Expand Down Expand Up @@ -216,6 +216,27 @@ jobs:
- codecov/upload:
flags: jest

jest-extension-experience-platform-connector:
docker:
- image: cimg/node:lts-browsers
steps:
- checkout
- run:
name: Provision (Extension)
command: |
npm install
working_directory: ./extensions/experience-platform-connector
- run:
name: Run Unit Tests (Jest)
command: npm run ci
working_directory: ./extensions/experience-platform-connector
- store_test_results:
path: ./extensions/experience-platform-connector/test-results
- store_artifacts:
path: ./extensions/experience-platform-connector/test-results
- codecov/upload:
flags: jest

integration-test-655:
executor: test_executor_655
environment:
Expand Down Expand Up @@ -318,7 +339,11 @@ workflows:
filters:
tags:
only: /.*/
- jest-extension:
- jest-extension-product-recs:
filters:
tags:
only: /.*/
- jest-extension-experience-platform-connector:
filters:
tags:
only: /.*/
Expand All @@ -333,7 +358,8 @@ workflows:
- build-java-8
- karma
- jest
- jest-extension
- jest-extension-product-recs
- jest-extension-experience-platform-connector
- integration-test-cloudready-with-addon:
context:
- CIF Artifactory Cloud
Expand All @@ -345,7 +371,8 @@ workflows:
- build-java-8
- karma
- jest
- jest-extension
- jest-extension-product-recs
- jest-extension-experience-platform-connector
- selenium-chrome-655:
context:
- CIF Artifactory Cloud
Expand All @@ -357,7 +384,8 @@ workflows:
- build-java-8
- karma
- jest
- jest-extension
- jest-extension-product-recs
- jest-extension-experience-platform-connector
- selenium-chrome-cloudready-with-addon:
context:
- CIF Artifactory Cloud
Expand All @@ -369,7 +397,8 @@ workflows:
- build-java-8
- karma
- jest
- jest-extension
- jest-extension-product-recs
- jest-extension-experience-platform-connector
- release:
context:
- CIF Artifactory Cloud
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ default Double getPrice() {
throw new UnsupportedOperationException();
}

@JsonProperty("xdm:discountAmount")
default Double getDiscountAmount() {
return null;
}

@JsonProperty("xdm:currencyCode")
default String getCurrency() {
throw new UnsupportedOperationException();
Expand Down
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.datalayer;

import org.osgi.annotation.versioning.Version;
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public Double getDataLayerPrice() {
return null;
}

@JsonIgnore
public Double getDataLayerDiscountAmount() {
return null;
}

@JsonIgnore
public String getDataLayerCurrency() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public Double getPrice() {
return component.getDataLayerPrice();
}

@Override
public Double getDiscountAmount() {
return component.getDataLayerDiscountAmount();
}

@Override
public String getCurrency() {
return component.getDataLayerCurrency();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ public Double getDataLayerPrice() {
return this.getPriceRange() != null ? this.getPriceRange().getFinalPrice() : null;
}

@Override
public Double getDataLayerDiscountAmount() {
return this.getPriceRange() != null ? this.getPriceRange().getDiscountAmount() : null;
}

@Override
public String getDataLayerCurrency() {
return this.getPriceRange() != null ? this.getPriceRange().getCurrency() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.adobe.cq.commerce.core.components.models.common.Price;
import com.adobe.cq.commerce.core.components.models.product.GroupItem;
import com.adobe.cq.commerce.core.components.storefrontcontext.ProductStorefrontContext;

public class GroupItemImpl implements GroupItem {

Expand All @@ -25,6 +26,7 @@ public class GroupItemImpl implements GroupItem {
private Price priceRange;
private Double defaultQuantity;
private Boolean virtualProduct;
private ProductStorefrontContext context;

@Override
public String getName() {
Expand Down Expand Up @@ -70,4 +72,13 @@ public Boolean isVirtualProduct() {
public void setVirtualProduct(Boolean virtualProduct) {
this.virtualProduct = virtualProduct;
}

@Override
public ProductStorefrontContext getStorefrontContext() {
return context;
}

public void setStorefrontContext(ProductStorefrontContext context) {
this.context = context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ private GroupItem mapGroupedProductItem(com.adobe.cq.commerce.magento.graphql.Gr
groupedProductItem.setPriceRange(new PriceImpl(product.getPriceRange(), locale));
groupedProductItem.setDefaultQuantity(item.getQty());
groupedProductItem.setVirtualProduct(product instanceof VirtualProduct);
groupedProductItem.setStorefrontContext(new ProductStorefrontContextImpl(product, this.resource));

return groupedProductItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ public Double getDataLayerPrice() {
return getPriceRange() != null ? getPriceRange().getFinalPrice() : null;
}

@Override
public Double getDataLayerDiscountAmount() {
return getPriceRange() != null ? getPriceRange().getDiscountAmount() : null;
}

@Override
public String getDataLayerCurrency() {
return getPriceRange() != null ? getPriceRange().getCurrency() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Collection;
import java.util.Map;
import java.util.UUID;

import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class SearchResultsImpl extends ProductCollectionImpl implements SearchRe
static final String RESOURCE_TYPE_V2 = "core/cif/components/commerce/searchresults/v2/searchresults";

private String searchTerm;
String searchRequestId = UUID.randomUUID().toString();

@PostConstruct
protected void initModel() {
Expand Down Expand Up @@ -109,11 +111,11 @@ public SearchResultsSet getSearchResultsSet() {

@Override
public SearchStorefrontContext getSearchStorefrontContext() {
return new SearchStorefrontContextImpl(getSearchResultsSet().getSearchOptions(), resource);
return new SearchStorefrontContextImpl(getSearchResultsSet().getSearchOptions(), searchRequestId, getId(), resource);
}

@Override
public SearchResultsStorefrontContext getSearchResultsStorefrontContext() {
return new SearchResultsStorefrontContextImpl(getSearchResultsSet(), resource);
return new SearchResultsStorefrontContextImpl(getSearchResultsSet(), searchRequestId, getId(), resource);
}
}
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
Expand Up @@ -19,34 +19,36 @@
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;

import com.adobe.cq.commerce.core.components.storefrontcontext.SearchFacet;
import com.adobe.cq.commerce.core.components.storefrontcontext.SearchResultCategory;
import com.adobe.cq.commerce.core.components.storefrontcontext.SearchResultProduct;
import com.adobe.cq.commerce.core.components.storefrontcontext.SearchResultSuggestion;
import com.adobe.cq.commerce.core.components.storefrontcontext.SearchResultsStorefrontContext;
import com.adobe.cq.commerce.core.search.models.SearchAggregation;
import com.adobe.cq.commerce.core.search.models.SearchResultsSet;

public class SearchResultsStorefrontContextImpl extends AbstractCommerceStorefrontContext implements SearchResultsStorefrontContext {

private final SearchResultsSet searchResultsSet;
private final String unitId;
private final String requestId;

public SearchResultsStorefrontContextImpl(SearchResultsSet searchResultsSet, Resource resource) {
public SearchResultsStorefrontContextImpl(SearchResultsSet searchResultsSet, String requestId, String unitId, Resource resource) {
super(resource);
this.searchResultsSet = searchResultsSet;
this.unitId = unitId;
this.requestId = requestId;
}

@Override
public String getSearchUnitId() {
return StringUtils.EMPTY;
return unitId;
}

@Override
public String getSearchRequestId() {
return StringUtils.EMPTY;
return requestId;
}

@Override
Expand All @@ -57,17 +59,6 @@ public List<SearchResultProduct> getProducts() {

@Override
public List<SearchResultCategory> getCategories() {
SearchAggregation searchAggregationOptions = searchResultsSet
.getSearchAggregations().stream()
.filter(a -> a.getIdentifier().equals("category_id"))
.findFirst()
.orElse(null);

if (searchAggregationOptions != null) {
return searchAggregationOptions.getOptions().stream()
.map(SearchResultCategoryImpl::new).collect(Collectors.toList());
}

return Collections.emptyList();
}

Expand All @@ -88,6 +79,7 @@ public int getPerPage() {

@Override
public List<SearchFacet> getFacets() {
// TODO: return the facets as we have them available in our result set
return null;
}

Expand Down
Loading