Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 11 additions & 3 deletions examples/events/example-contexts/mock-storefront-context.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## Storefront context
## Storefront context

> [!WARNING]
> `storeCode` and `storeViewCode` are required fields of the storefront context in all events. Beginning in 2025 any events without `storeCode` or `storeViewCode` will fail validation.
> [!NOTE]
> If you are using Adobe Commerce Optimizer (ACO), the `viewId` and `locale` fields are required in the storefront context. These correspond to the `AC-View-Id` and `AC-Source-Locale` header values respectively.
>
> For more information on these headers, see the [Adobe Commerce Services API documentation](https://developer.adobe.com/commerce/services/optimizer/merchandising-services/using-the-api/#headers).

> [!TIP]
> If you are not using ACO, these fields can be left blank or null.

### Used

Expand All @@ -11,6 +16,8 @@

[Storefront schema](../../../packages/storefront-events-sdk/src/types/schemas/storefrontInstance.ts)



### Mock data

```javascript
Expand All @@ -31,5 +38,6 @@ const mockStorefrontCtx = {
baseCurrencyCode: "USD",
storeViewCurrencyCode: "USD",
storefrontTemplate: "Other",
viewId: "12345678-1234-1234-1234-123456789abc"
};
```
2 changes: 0 additions & 2 deletions examples/events/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## Commerce events examples
> [!WARNING]
> `storeCode` and `storeViewCode` are required fields of the storefront context in all events. Beginning in 2025 any events without `storeCode` or `storeViewCode` will fail validation.

### Event purposes and usage

Expand Down
4 changes: 4 additions & 0 deletions examples/events/snowplow-debugger/storefront-instance.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"storefrontTemplate": {
"type": "string",
"maxLength": 256
},
"viewId": {
"type": "string",
"maxLength": 256
}
},
"additionalProperties": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const createContext = (storefront?: StorefrontInstance): StorefrontContext => {
websiteName: storefrontCtx.websiteName,
websiteId: storefrontCtx.websiteId,
storefrontTemplate: storefrontCtx.storefrontTemplate,
viewId: storefrontCtx.viewId,
};

const context: StorefrontContext = {
Expand Down
2 changes: 1 addition & 1 deletion packages/storefront-events-collector/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const schemas = {
SEARCH_RESULT_SUGGESTION_SCHEMA_URL: "iglu:com.adobe.magento.entity/search-result-suggestion/jsonschema/1-0-1",
SHOPPING_CART_SCHEMA_URL: "iglu:com.adobe.magento.entity/shopping-cart/jsonschema/3-0-0",
SHOPPER_SCHEMA_URL: "iglu:com.adobe.magento.entity/shopper/jsonschema/1-0-0",
STOREFRONT_INSTANCE_SCHEMA_URL: "iglu:com.adobe.magento.entity/storefront-instance/jsonschema/3-0-2",
STOREFRONT_INSTANCE_SCHEMA_URL: "iglu:com.adobe.magento.entity/storefront-instance/jsonschema/3-0-3",
};

export default schemas;
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ type Storefront = {
websiteId: number;
websiteName: string;
storefrontTemplate?: "Luma" | "EDS" | "Hyva" | "AEM CIF" | "Franklin" | "PWA Studio" | "Other";
viewId?: string | null;
};

type Tracker = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const mockStorefrontCtx = {
websiteId: 333333,
websiteName: "website",
storefrontTemplate: "EDS",
viewId: "12345678-1234-1234-1234-123456789abc",
};

const mockCcdmStorefrontCtx = {
Expand All @@ -150,6 +151,7 @@ const mockCcdmStorefrontCtx = {
websiteCode: "",
websiteId: 333333,
websiteName: "website",
viewId: "12345678-1234-1234-1234-123456789abc",
//storefrontTemplate: "EDS",
};

Expand All @@ -170,6 +172,7 @@ const mockCcdmStorefrontProcessedCtx = {
websiteCode: "WEBSITE_CODE",
websiteId: 333333,
websiteName: "website",
viewId: "12345678-1234-1234-1234-123456789abc",
//storefrontTemplate: "EDS",
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ const mockStorefront: StorefrontInstance = {
websiteId: 333333,
websiteName: "website",
storefrontTemplate: "EDS",
viewId: "12345678-1234-1234-1234-123456789abc",
};

const mockShopper: Shopper = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export type StorefrontInstance = {
catalogExtensionVersion?: string | null;
locale?: string | null; // this field should stay null
storefrontTemplate?: "Luma" | "EDS" | "Hyva" | "AEM CIF" | "Franklin" | "PWA Studio" | "Other";
viewId?: string | null; // catalog view identifier
};
1 change: 1 addition & 0 deletions packages/storefront-events-sdk/tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export const generateStorefrontInstanceContext = (overrides?: Partial<Storefront
storeViewName: "Test store view",
websiteId: 12345,
websiteName: "test website name",
viewId: "12345678-1234-1234-1234-123456789abc",
...overrides,
});

Expand Down