diff --git a/packages/storefront-events-collector/src/contexts/dataServicesExtension.ts b/packages/storefront-events-collector/src/contexts/dataServicesExtension.ts index 4d964f43..381d0e67 100644 --- a/packages/storefront-events-collector/src/contexts/dataServicesExtension.ts +++ b/packages/storefront-events-collector/src/contexts/dataServicesExtension.ts @@ -7,17 +7,13 @@ const createContext = (extension?: DataServicesExtension): DataServicesExtension const mse = window.magentoStorefrontEvents; const dataServicesExtensionCtx = extension ?? mse.context.getDataServicesExtension(); - if (!dataServicesExtensionCtx) { - return { - schema: schemas.DATA_SERVICES_EXTENSION_SCHEMA_URL, - data: {}, - }; - } - const context = { schema: schemas.DATA_SERVICES_EXTENSION_SCHEMA_URL, data: { - version: dataServicesExtensionCtx.version, + version: + dataServicesExtensionCtx?.version && dataServicesExtensionCtx.version !== "" + ? dataServicesExtensionCtx.version + : "unspecified", }, }; diff --git a/packages/storefront-events-collector/src/contexts/experiencePlatformConnectorExtension.ts b/packages/storefront-events-collector/src/contexts/experiencePlatformConnectorExtension.ts index de9c55bb..a3c3fb3b 100644 --- a/packages/storefront-events-collector/src/contexts/experiencePlatformConnectorExtension.ts +++ b/packages/storefront-events-collector/src/contexts/experiencePlatformConnectorExtension.ts @@ -16,24 +16,15 @@ const createContext = ( experiencePlatformConnectorExtension ?? mse.context.getExperiencePlatformConnectorExtension(); const aepContext = aep ?? mse.context.getAEP(); - const setupComplete = - aepContext && - aepContext.datastreamId && - aepContext.datastreamId !== "" && - aepContext.imsOrgId && - aepContext.imsOrgId !== ""; - - if (!experiencePlatformExtensionCtx) { - return { - schema: schemas.EXPERIENCE_PLATFORM_CONNECTOR_EXTENSION_SCHEMA_URL, - data: {}, - }; - } + const setupComplete = !!aepContext?.datastreamId && !!aepContext?.imsOrgId; const context = { schema: schemas.EXPERIENCE_PLATFORM_CONNECTOR_EXTENSION_SCHEMA_URL, data: { - version: experiencePlatformExtensionCtx.version, + version: + experiencePlatformExtensionCtx?.version && !!experiencePlatformExtensionCtx.version + ? experiencePlatformExtensionCtx.version + : "unspecified", setupComplete: !!setupComplete, }, }; diff --git a/packages/storefront-events-collector/src/contexts/extension.ts b/packages/storefront-events-collector/src/contexts/extension.ts index 963cbe94..dfe3a820 100644 --- a/packages/storefront-events-collector/src/contexts/extension.ts +++ b/packages/storefront-events-collector/src/contexts/extension.ts @@ -7,21 +7,13 @@ const createContext = (extension?: MagentoExtension): ExtensionContext => { const mse = window.magentoStorefrontEvents; const magentoExtensionCtx = extension ?? mse.context.getMagentoExtension(); - if (!magentoExtensionCtx) { - return { - schema: schemas.MAGENTO_EXTENSION_SCHEMA_URL, - data: {}, - }; - } - - const version = - magentoExtensionCtx.magentoExtensionVersion && magentoExtensionCtx.magentoExtensionVersion !== "" - ? magentoExtensionCtx.magentoExtensionVersion - : "unspecified"; const context = { schema: schemas.MAGENTO_EXTENSION_SCHEMA_URL, data: { - magentoExtensionVersion: version, + magentoExtensionVersion: + magentoExtensionCtx?.magentoExtensionVersion && magentoExtensionCtx.magentoExtensionVersion !== "" + ? magentoExtensionCtx.magentoExtensionVersion + : "unspecified", }, }; diff --git a/packages/storefront-events-collector/src/contexts/recommendationsExtension.ts b/packages/storefront-events-collector/src/contexts/recommendationsExtension.ts index 6ac328f5..3aa9aa49 100644 --- a/packages/storefront-events-collector/src/contexts/recommendationsExtension.ts +++ b/packages/storefront-events-collector/src/contexts/recommendationsExtension.ts @@ -7,17 +7,13 @@ const createContext = (extension?: RecommendationsExtension): RecommendationsExt const mse = window.magentoStorefrontEvents; const recommendationsExtensionCtx = extension ?? mse.context.getRecommendationsExtension(); - if (!recommendationsExtensionCtx) { - return { - schema: schemas.RECOMMENDATIONS_EXTENSION_SCHEMA_URL, - data: {}, - }; - } - const context = { schema: schemas.RECOMMENDATIONS_EXTENSION_SCHEMA_URL, data: { - version: recommendationsExtensionCtx.version, + version: + recommendationsExtensionCtx?.version && !!recommendationsExtensionCtx.version + ? recommendationsExtensionCtx.version + : "unspecified", }, }; diff --git a/packages/storefront-events-collector/src/contexts/searchExtension.ts b/packages/storefront-events-collector/src/contexts/searchExtension.ts index 695eb66f..853dac94 100644 --- a/packages/storefront-events-collector/src/contexts/searchExtension.ts +++ b/packages/storefront-events-collector/src/contexts/searchExtension.ts @@ -7,17 +7,13 @@ const createContext = (extension?: SearchExtension): SearchExtensionContext => { const mse = window.magentoStorefrontEvents; const searchExtensionCtx = extension ?? mse.context.getSearchExtension(); - if (!searchExtensionCtx) { - return { - schema: schemas.SEARCH_EXTENSION_SCHEMA_URL, - data: {}, - }; - } - const context = { schema: schemas.SEARCH_EXTENSION_SCHEMA_URL, data: { - version: searchExtensionCtx.version, + version: + searchExtensionCtx?.version && !!searchExtensionCtx.version + ? searchExtensionCtx.version + : "unspecified", }, };