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

EventCollectorContextProvider missing context values when setting storefront instance #1003

Open
MichaelHeinzman opened this issue Jan 26, 2024 · 0 comments

Comments

@MichaelHeinzman
Copy link

MichaelHeinzman commented Jan 26, 2024

Expected Behaviour

  1. StorefrontInstanceContext requires the following fields in the snowplow schema for
    iglu:com.adobe.magento.entity/storefront-instance/jsonschema/3-0-1

    "environmentId",
    "environment",
    "storeUrl",
    "websiteId",
    "storeId",
    "storeViewId",
    "websiteName",
    "storeName",
    "storeViewName",
    "baseCurrencyCode",
    "storeViewCurrencyCode"

  2. Expected behavior is the EventCollectorContextProvider has these fields in the context when applying mse.context.setStorefrontInstance(context).

  3. Expected add-to-cart event storefront instance to include these fields but only saw baseCurrencyCode and storeViewCurrencyCode.

There's also another issue where the cart context in mse will not be set before this runs. Causing the product page view event to fail since it requires the shopping cart context to be set before it publishes. I had to change the file to grab the cart and update shopping cart context.

Actual Behaviour

  1. It only has baseCurrencyCode and storeViewCurrencyCode in the context.

Reproduce Scenario (including but not limited to)

  1. Implement EventCollectorContextProvider and try to send an add-to-cart event.
  2. Check the snowplow schema and storefront instance will only have two fields in data when schema expects more listed above.

Fix for the issue

  1. Created custom ExperiencePlatformConnector from the source code and added fields to the graphql query and when setting the storefront instance context.

Changes made to graphql query

import { gql } from '@apollo/client';
export default gql`
query DataServicesStorefrontInstanceContext {
dataServicesStorefrontInstanceContext {
catalog_extension_version
environment
environment_id
store_code
store_id
store_name
store_url
store_view_code
store_view_id
store_view_name
website_code
website_id
website_name
}
storeConfig {
base_currency_code
store_code
}
}

Changes made to Storefront Instance context

storeConfigQuery().then(({ data }) => {
const {
environment,
environment_id,
website_id,
website_code,
website_name,
store_url,
store_id,
store_code,
store_name,
store_view_id,
store_view_code,
store_view_name,
catalog_extension_version
} = data.dataServicesStorefrontInstanceContext;
const { base_currency_code } = data.storeConfig;
const context = {
environmentId: environment_id,
environment,
storeUrl: store_url,
websiteId: website_id,
websiteCode: website_code,
storeId: store_id,
storeCode: store_code,
storeViewId: store_view_id,
storeViewCode: store_view_code,
websiteName: website_name,
storeName: store_name,
storeViewName: store_view_name,
baseCurrencyCode: base_currency_code,
storeViewCurrencyCode: base_currency_code,
catalogExtensionVersion: catalog_extension_version
};

mse.context.setStorefrontInstance(context);

});
`;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant