Skip to content

EventCollectorContextProvider missing context values when setting storefront instance #1003

Open
@MichaelHeinzman

Description

@MichaelHeinzman

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);

});
`;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions