Skip to content

Commit

Permalink
DINT-1119: better extension version tracking (#119)
Browse files Browse the repository at this point in the history
Co-authored-by: ani hammond <ani hammond>
  • Loading branch information
aniham authored Sep 9, 2023
1 parent f2936b7 commit 9cf8048
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down
16 changes: 4 additions & 12 deletions packages/storefront-events-collector/src/contexts/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
};

Expand Down

0 comments on commit 9cf8048

Please # to comment.