{"_id":"@adobe/commerce-events-sdk","_rev":"66-049995262f65e9b4d62e0f023b7e617b","name":"@adobe/commerce-events-sdk","dist-tags":{"latest":"0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19","qa":"0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c"},"versions":{"0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"e491dd5a685db85ef6d0005ba5bc4a9d2dafe765","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19.tgz","fileCount":44,"integrity":"sha512-Q3IivzkaeEAC3zXWv4mUtZ/pN77R5eG+8zmAO1w+BzI1fsZjaIyG4ZRIvKGen8cwp6grUyvsMfKJebK7LNw80g==","signatures":[{"sig":"MEYCIQD5igKkptnhpFfeKDsqGz1FclEstmpFRumeDte87JeqwQIhAOKIjsQC3f+YmNfbEf6xROdJbUvF1159rvSo5f/Jvy8v","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100613,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiux0BACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpnlA/9F6JZip67VIixQN2kUSKCDLSinQ6JVkCSnbW0ljXFUhNX6Sbg\r\nQolGosirSqUtErHKqC5cokEPgTCZgcls2MX7hezqO8WGhcLv+TY0feZmkHhy\r\nJRZKFqavkZy/40PN2oEYce9YASJM/OaA84Joqu4ct36xU2PnLg8VaPDVEAek\r\n932kKjU+3G4C2cKLHfPnjLMBwPWBpa8xubQMZ4xslXjsb4pBEXT5adtIgPrH\r\nx7KKGDiYBpZr1LoVW0vRZQd6gtDNrcomiymW9/tQWbFt2SHJ3BcRgFtCtXe5\r\nF3gXXUiPFXS+J6fxqx5gsYBmKb+DLDqJmeBcCYgBczonEbMyjjvDaTrODOWN\r\n7G7FYDrFXtzmwyBmF1MId4HXbBTsCplnoSY+wJvIR09qixMkZvH/rFRiGzsN\r\n/TqitMHXZfRBzE7IdkE/9LNW5zWf4zdio9i9ipH1RyzBpjOhav40Slnun9V4\r\nFWhKBunPtrlaNKEGqs1iWkZYGM0WGUd836hJyulKw7MwNKqP4lp8rswRpQXD\r\nq/mFMb5AhMlaUmwMOkz2yk6VD7j5kvfbWJ/HiTWcqU+4jdceflPD6eHqb4Nc\r\nO8KnKC5bpNy/BSzJOl/IdrjwG2JJivTMui3vlqmbg5mCzL8QtH8mxmILoM9h\r\nzYpuEk6dFRANhCZCoNT2okC242yrLeooky8=\r\n=pexb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19_1656429825147_0.8825395276451122","host":"s3://npm-registry-packages"}},"0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"8b86ac04e9235c2b59057bc221aa1b652f02f6bf","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6.tgz","fileCount":44,"integrity":"sha512-7HMuUkEBMP/PV9oLQ0qqyu6sLQuu75Et4eCEOWzpttnpOD/5tOt3nYhyrrrbYURZP3C6/no5vjmE6mdNIRzVww==","signatures":[{"sig":"MEQCICFpyq2CMB/n8gJmKfYNKJtatXn+wsxX6aAMdQKkmQEIAiBAfMPBm8EQ123NID8jIK9keP70uNLqVhtGdObhIvFB7A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100613,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiuyO2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGRxAAmDok4V4X452BkSbNSHl+USeZd+JO2oxeJfvA/5LEOlZ0vl/k\r\nhPl+4zeBCEQ8Fpv1WHH/8EGBS9CYV9afQKaqlUU3G1+dmbnPpUpIaMSrCb+Q\r\nTvXN4BLC7mZjovo5TER1yRfFpTrvwIde1/pM7E69lU4tB0Tc7hkUc1VW7g1E\r\n4mGVs+bOZ7BUICDjRADV20my9irsVa10lpf5X0FMAXlCCetNzMx3jDm7ms7J\r\n0JpVhV+ZQjdJiLZ///y43X7deBD4Qpm00pdpKLv1XM398EY6Q6InjLSs4xxf\r\nqX6nQPsCmThQ2elSAxWW7r5U5PLGk0NepsxowsQcuizSGNkzIw/pSa3SyO5V\r\n1EUx4Lbl6DLuo/bGASUvYm2ZOE79P+rHTm9+e+wuVdAFqHky3j1+5veWJgtS\r\nxBBe3+5Dh8EFMmfUBJTJDAtTuZ/l7/i7hVnV6k64bs0EldW6i8T0CIAqAXDr\r\ntP4EEruf1GXf/A6d2Cy5ZpWqRgJbVCgb944ibT00Jbd5aArWQf23dwbzAcg0\r\nSWnQF18wk8yrKhQOqYuF1NnIhfPwKuR2/JYx2HeuOVyQlVSIcZsKHx7+t+r2\r\nbZ99lgJiEjyEv2oV2PMM8NHaqAVOyKu8Ta0u91p12goMiB6XCsFzXw+Twob1\r\nX8aMBHVj/Zb9j4o9BdcsGUrfJYARM5Ko+5g=\r\n=gg/R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Magento Storefront Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][magento] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Magento Storefront Event Collector][collector] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Magento Storefront Event Collector.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/magento-storefront-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/magento-storefront-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/magento-storefront-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/magento-storefront-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/magento-storefront-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/magento-storefront-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/magento-storefront-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/magento-storefront-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/magento-storefront-events-sdk/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/magento-storefront-events-sdk/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fmagento-storefront-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/magento-storefront-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/magento-storefront-events-sdk/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[magento]: https://magento.com\n[collector]: https://github.com/adobe/magento-storefront-event-collector\n[unpkg]: https://unpkg.com/@adobe/magento-storefront-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/magento-storefront-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/magento-storefront-events-sdk/issues\n","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6_1656431542576_0.8286439265846424","host":"s3://npm-registry-packages"}},"0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"addef50fd2b37c54d390b446752c9a947f93301a","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb.tgz","fileCount":44,"integrity":"sha512-fUeU3rtqwMy0Ax8G3hF0wWFzQQ/7nrAs14XJf4pHl/LH3btLVNxoLPovhIFwTFPeV7rvgpOaSyR2+RTC26BIBQ==","signatures":[{"sig":"MEYCIQDiRsBYga3RaFdGq+pWh+EAbii00psOYBtrAAI+ZaKCewIhAMNlAfz/obaW0tTE4+l7HRBSBi+g5oO011blXaBB2xat","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100613,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiuyifACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqpEA//ccttkZm3gvz6DRIOPPdb4+Wx3ktPwwtiFMF9KsJGHb+RGTjn\r\noT8Czqe1iWm5wZxyptH1h9KwM3NuLUbB8hsXDxR6lr9KmKnNhoc+JYGbmkuH\r\ndC1kzNh4OOoiM3RJ9qCsOjEpjJ7Ynv7hAaAS9q87SNlZf754fgnsi8h05ob5\r\nLNlznRnelpxpqcriAajH3Hi6sRgSv9/beeoAKcfloqBJeEUGj041v1lbkXfe\r\n+7qk831sfM5kGfd+lFQFlvNLoi6JLXCUD+X/Lerw/nu9MGNR9RIpSbVCkCgR\r\nUpX0IpA8x6OHR5zxrknAt620TMZUswsAiEt8mdOGp9g8v/f9Hp9FvxHXdfpX\r\nxVz496KwILtSllfvkfamGfAx5fryFLqTEmYNJ0A4zub0MaGgnAUjmQH6ot9S\r\nql5BPEnQDDY7zidYS1FR8fx0w7+KH5iL8HhuhGFDRDfWdj0ci1+1FC1BgsIQ\r\nG9b7yh47JpHEKYAh5BIJbQKrS9jwk1KWcxb8Y/VJuj/IAKZZafEH34kQpWLC\r\nTeXlBTHDpO3m6GNd32sI1BD1iDp22KWPTNRLpw5MIn+UyD7DmUh8L8Woa5oR\r\n2egmEYOGIYadOuJsi7XQMM4YdVm6wXuYAdhCUhS+24cmyl7zcyMPRMprZOfx\r\nBLGmFRKOKg+z5HE/gYIiXCy+f8mUD5301MU=\r\n=iSiO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Magento Storefront Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][magento] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Magento Storefront Event Collector][collector] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Magento Storefront Event Collector.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/magento-storefront-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/magento-storefront-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/magento-storefront-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/magento-storefront-events-sdk/blob/main/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/magento-storefront-events-sdk/blob/main/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/magento-storefront-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/magento-storefront-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/magento-storefront-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/magento-storefront-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/magento-storefront-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/magento-storefront-events-sdk/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/magento-storefront-events-sdk/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fmagento-storefront-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/magento-storefront-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/magento-storefront-events-sdk/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[magento]: https://magento.com\n[collector]: https://github.com/adobe/magento-storefront-event-collector\n[unpkg]: https://unpkg.com/@adobe/magento-storefront-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/magento-storefront-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/magento-storefront-events-sdk/issues\n","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb_1656432799165_0.7133209484708192","host":"s3://npm-registry-packages"}},"0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"dfde015a4782edb296a1384b384fc8f9cb83b431","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856.tgz","fileCount":44,"integrity":"sha512-ykvaAj7Q4WCHO/9Bb5BEkI7KpO1N177K3ALHVnY7FzYEEFxx2CEKTevC4lfeyJwyiH43q0weRhmkVlyFYTyb3w==","signatures":[{"sig":"MEQCIBrXKvTavkUZ9+UGPrmoNPL+562lIfAbEVm2pqpcuVNHAiALKAtD/dMER42SNq/LfmdanJS9kRpRTunYQg/Ooephfg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":100966,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiu3PYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpFXg//c2AzNkRJ8TYSBdQDJRgqYxo66QlKhwFT/rmmLTauOES4qHFv\r\n9KfG9FGog+WXMifLSiqe+Ti4uh0cjRhsXRBmrtXUictev+1W5kqg/jZnF4XV\r\n0QieCdKqJo5eXqU62Iv60qSfcmlA7CyCXSgJqyGAB55OW2y/JwCf9aSJZ0nC\r\nbGTHEmU+6Q5v+yVnk8Aepbx23+FnJnA2WN7x5ex7FjatGJDkcksHfhV0Zvax\r\nEWUnub6kU1K4jdMIIwtPegq8GO8mV8u5ZxjJFPhUYYBf3Z0oKfXHO519o2tX\r\nyHUaWTv8K6+3dszO/Y4rQyxK9evulpkUyf35oNBtcKp4+DSaAlKd6oHG74r1\r\nCQfpfgzZWVsQsh42Hn84i3DmP2sSZKX5hy9cMcPaMs8FVBPbpYLo+kNo0nXk\r\nVWdNFmE5ULl/IIcUAEzppCusggSH+khIfXX43MiHLgUGkzYW2yoiReRPQpjy\r\no+8YrOJOQa1oZ255xk48h1em+z3J/96oTeAPPdnKb0ibC0tcC2T5i+Fo/Yv8\r\nU0bnfHgXjYWofRg+UgTgAdR1b3uo+xgIn5KEN9jTfQESGVgI6J055DW4b/3t\r\nEb7DWvWh9dkq1FiT5idCL9Z8J/3FFK+LoqRx+7ZhH8kABoanHyIfZfLfoK8K\r\nxsSlIFg3NewJ7V23nLtH0fK9u23lBWrZLRI=\r\n=93f/\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856_1656452056314_0.09421457256529187","host":"s3://npm-registry-packages"}},"0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"2fed13cf0222e3a1aacab3e58a3e8640f408cf1c","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e.tgz","fileCount":77,"integrity":"sha512-lTYAkiNDqD3MWM2N24JWEzdxDpHoAEs7b1oa0uhmOjyB13ItvaWyyPlAPwStyKUVTsMlYHnvd1jhLSrU4cwZKw==","signatures":[{"sig":"MEQCIGc6Ss8HdEIwx5dQy3qxou4xhwdVnjGSJ8d6dG/yuxa5AiAhp2jI4ogqKb1NtapjCbU1X0/NUBxojQS5mE/AtoLhmg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127177,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivJQNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpdWw//e5d5XUmXQauMbqw1oPtlX4QuuZx8FUZ5TzOJ6M8k7TxzTcoQ\r\npYaiSBl0TnPwzJ+fw4TYZ8EF8OCe21HeomiDsUe1ppy4oIH+To7x4iWLnf9u\r\n+vnZJFfv6On0CMQAYRx7Hb58STb1nYfZArJK6OGyjhatOz80zcmH9XWQQ5uT\r\n6SgbkMSBHbvfiJ6NGOPV2sh85u5MF6v1K+z7PRDe//JKL6Nm/Wk26VahqNgm\r\nvoiJeMsvbtyKJSjFDq3tbKaGsSqIajgZl8+BVCec4QjfySa9NS0P/aVUoCXJ\r\n6qWqaRLNEUCc+J+6cDLuZbrY2s6rpH0M1/iT/BwMcqFfMShTuHOuRz/rR4Sj\r\nUjnKgoEZP1j4LsQEyQpKhqjqjz1lfDjalcSkzyprI4XFe3KQhko/8oOCFMT0\r\nPAtA8JO4XpUxsPaNN3s3oKD7s7S50q0Gv2UOKIpBREr9DVFsbvvQ1E59GtDQ\r\nNOMKaVv11HnoGSqK2MI5FaALZBOHvR3rqDZcoai1bQIl2lxFLgrwP3OpMLNT\r\n2oFGaeD07t8UrG+jofQi8jdWXdTZeCE2uoAqYslWxtzYCxSjNtK5xZqwl+rt\r\nGj5tly6/Z9dEbfdyJbwGq9zLZFDfyWEMl7kKo8ynrI6ukzw2DpMbZ6Buf6QE\r\nIPmzBsbVkC3cArTuckIMWuGuxuhFXfkbelg=\r\n=lETH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e_1656525837660_0.5381099028278442","host":"s3://npm-registry-packages"}},"0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"89a20d7dc8cd581be1b986c703a27286ebbc6d11","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e.tgz","fileCount":77,"integrity":"sha512-31LioEivXmmDPNnV0tAcN8Z6fB6qXl/iXk8faW+j+fsvKfuRTWPbUV2SrxIU7fS2dMlxaQ8RaWOiR5jlhVIAig==","signatures":[{"sig":"MEUCIGxZUemfdtf427afXeAuEAI/qJ1NKRn9Anzf14sodFCVAiEArucbnko+cuaG2WL9FSl3Vj3wKvay5rXciLmmWC1kYBM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127187,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivJY8ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmracg/+MontRBiyKrsGRrE5i4V96O/mWq4E2VjpLeC08l+yAkLm4TZN\r\nHa2DCKpcBbSI2uObGj9QvRAXqdBdJT6WoRdqf5paAzv5mK5fWNK4gbUO1oz1\r\nfBv3+sinYvvnwhJ69avsWivX+mFBk1GAAicINCa3jD9bcagKz2QLj6o+41YV\r\n3ViqPOuoajEKBuqMlAxhrfH23qX7rAFs8zUU2opfTe/YeDQf1cJicM7DdzUm\r\nf49ZBdZGXm29Z6yckN7WuS7zF7oy5XbUeKAFNk3E7OgLH/Ullp6MkdJRU80U\r\nCLpD7XW2am5BXVaIivbiqH1BYk10Mx+0pGHN/mKu884q0H667CrckwZ0st/2\r\n2omW7hkCBrFU5b5HmEIpjKEI/ZQK8GTrU90/2Rhj0S1AceewG6BV/zM/waAL\r\nsgB0bT7pqV7Z6RWHT4HII9bwaJclKXAu8SVVQD2QGR8tRv0Prm9w2Sh2O+x2\r\nq4NOvUkIIsFrLsGArsQwiPJphNn4sMWaWH7r4IsqRWWcOZtcyE0zrMHhPU/e\r\n1j1G7zVNtWUv2zty0qlMLrHvdfJ1f1u16zygAdd1kEl9MvTdgKZWY82dpT0G\r\n1r2uwML43JPr/y3yU06LAhI+OJ+gq8HSQJaPtn2rmV5nO2/DK3QlPiRUBSMW\r\nDvNw4vSv4MKk0XkHjPk2Wo7eCQUweyYiLOE=\r\n=6ZlF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e_1656526396363_0.18741185002488625","host":"s3://npm-registry-packages"}},"0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"330a892259a8088d9af899166cc003f60ec6d5ef","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc.tgz","fileCount":77,"integrity":"sha512-v6IRdnfhzbYuuxvY4mFZsrIkcExGuGyJPBfBd4mPbPFVj4GOhqYWnwos+A9SZR7faQV7HbUMDcOdf2S8iw3Stg==","signatures":[{"sig":"MEYCIQDeLmWp7yi3F7ttu1HoQAWaL1UnnihakSAxNq5uw+ZrAwIhAIHO4yz69esrsOuYkAYHDO2kvZAKjmo+5uxRBTMy7V1I","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127243,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJizciwACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp/Yw/8DPGkLcJfnlV3agRpjxYg6bLmw8L7QLVkUtxLhDmzg939DwuA\r\nDj3FPcZBUowkQmA7FkftX1KxPuNxCUpoae+FVwbiOuEjTCjmihF40spEua0k\r\neGvVMkOrAISHAHMUPeTeor0wD/gg4j/zzR0p6a8IUiuu3Dnz5EJYO9GEXfRJ\r\nticY5ukQiGG2FS63bza8+ZeELsXlmdjT6BD1hZBqwaZ9ZqKqj6BKcNEKlHEI\r\nupEsQpnrN9hJwOcSOX7zU/jnWOj5GXycnlYtTiS/NbjcbxWAM6QRliEDhpS9\r\nagpdUbNbRQJK0XzXEV3wqSz+FjjEUiIHL0zeqWN7ajn6CM0iGe6GBRDtWYoK\r\nvmOaUiL6KRC3AVdXOuO89ux0rUFW+HYvArxOeh1CJQkh3CNUoOPYluE+1m8k\r\n2zwIRjS3pKe2PWTHSvqTjFkx80iV0NxCZogKFs/wUajfNPRchIzYU4EmgDUo\r\nR+tqVoyaHRapc2lGDHIKPv5FSfAWA3z7XADw95aOe+YP2AGkjLT0WzifBtx1\r\n4S4xpxcL4jol8ChVS0qKwc+hf/q3Dqmd7++D4YPpMgdqDD6yupWO3XelcLYH\r\nKLazQZA8lCFlcUuSDB9rCns81XMxDxfea+UBubcRoO44eJB+jo8F/mpOTIaM\r\nab5ZUgl2vx81s3TcizrA3HJE6PQd4p79dLQ=\r\n=FOuz\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc_1657653424606_0.4235696688389481","host":"s3://npm-registry-packages"}},"0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"fdd73525ce171acd14970b57529362bfdc4248ee","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e.tgz","fileCount":77,"integrity":"sha512-X2mqVBTkTbUbYw+jY4rF3e7+D+7kCTEPY5WL3kaY1ceXyT+Sc43K7bU3uWR1ozeQ+hAzdN+2A0S0uTIn6fsf/g==","signatures":[{"sig":"MEUCIQC83H1yLbDnluxdHnJptExCNs0AjYH4FNj/sMHlTZNF+AIgS3b6R6dEemcX5bAIDf0inT0t1MXn7RPWhMOI1Vv3Mik=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127243,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0FGAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrmKA//aktp57PcqvqAjtSjBqON5pmfaufxOOnRFiHNcqCPNLOYFp/5\r\nwDK0NK4lAlVVkrsMFOM4YPFMKYCpwWUn4pLGQURQBoNqvQp2t4VKWWTsc+Ea\r\nrmkuDIiELVJQZDMxDNQgQn+8OfT4aJYFPgtWdpuzUx7rBEZtFobVGnARg/pw\r\n2uZs7kqIJU8LNCivoUARnEQGBAbKulajlOe/pQ7bsv4NL3ORGPzkqRrWtfIx\r\nP3XzJRD47L1Jz7Cs2fcIb+NaU0EJXrgLEgt3TcjuWc/xAmNUs2/DtgyfXBJF\r\nTA/WtkDmn5iLEqzdQtTuRNg7A0Wrka6d1rdOeoa5MkqzS8Sh0P2zscHh1s42\r\nVuUi9bxnutm4OSP+YK+XQFn+0tZOgWl9RDP4Y1k87pVXYZ0wswLz77QD4Nd8\r\nzT5s0RZul6A1ZRFnBlDjwDEqP1HUi+It+wxgAaNhqzDMOA//iM1ro3yvm5G3\r\nq60cCeHRxWioggJdViYxiCL2l1CN45rMmZhSUgCsgqn98QN6pfe5XNGp6BHr\r\nhxmKoeWxjsQNNsJli5YTDhVEIWY5CFIEI8LYODdkcHVBa6bit4UTqTH+8MaA\r\n5OqilfDYSSF4tChp8xVWgtdl9GYvG04BqcqAkNAVA6+SJ1+4KTj/s1FRDbkr\r\nNrDo4MBaZ2+QxGzx8iiEKaEiPjSu8zJDWbM=\r\n=ADDt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-prettier":"^8.5.0","eslint-plugin-prettier":"^4.0.0","@typescript-eslint/parser":"^4.33.0","cz-conventional-changelog":"^3.0.1","@typescript-eslint/eslint-plugin":"^4.33.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e_1657819519914_0.6778058099639108","host":"s3://npm-registry-packages"}},"0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"b373a45c125018443e0185bfcf009f47db13a645","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7.tgz","fileCount":77,"integrity":"sha512-x39I1Qz5Rp6nemEmv+v/ec4LeWcRDfqxTvIwdh7CTCstbqpInMTdRk3dCgg2XhpVvLzPDg5Z/1y9rH9Em2HGGQ==","signatures":[{"sig":"MEYCIQC0ID/cRBnAYqR+6lnFRCBe0IBa8cZebtz7kIa/aQpCegIhAIN84LCp1v4D+IqlcDjeYweTImTf5Bh63lkBr0VVM3hw","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":127089,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0NQyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqigg/9FKPEMAEM1X80jUp2WNjdNUzOu+qUQdbHj5XQgWMaKOXHI7EO\r\nNFbT5KlqA5G0Mlsan4BHe6awUHABr/tJFZ9ZzmwQ2+LHN2WaiysYJfR3qcaI\r\nV1ndY4aTz07y1m/zCycIqOnHAx8JSZj7IEv0/6NuMHqjd/kzT7L2H3RYQKJT\r\naheRQCnBJ9My0RhcdlsyrxmlAuZrdytha9XTiNigitKCNiKTTtxzPqFRi8kr\r\n/xr0YU0fOMLO9QTMT+ikEJ7bYXcDfrZyFZmUQi4hOiXEXkl2GOS0VrOt3+ct\r\nIxoBfmmJxzWPDyRG6ixHxReBEvCJkDTlkNgdPP2uLd5UGZmFYWlTA4EX3AhE\r\nydw08r6/kRb9RDUnsWmK/wzAxNGkPWxKJPBYK7wGjm/zYhUmXw0V2FvZ68ju\r\n6dgyau3El3yGM+kq7wvhclxXjh+vr/zaEEgwHGxwWfhpLY9RVDE8ZZk8Clbd\r\n01EUfeqX3oGfuoKXPjeJsSHJmmkrflGVoXnRUbnCttC8NAT2Qvagxov6K/+T\r\n44aj9P1FPWjkLHP2m/k4zQ75ww6idxxOK6tzuju3X1enuN/8ADJixOYgFG2h\r\nYUt/x+2O3Enm3l5u5o9ucfpSzjetQhP8Sw0qyCrBh4WDwHsX9fydsVjvrdXP\r\nCOzq3qvQyzmPAlqSsowq/6FA8MUgPgT9Q/Y=\r\n=oUBg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7_1657852978543_0.7282070036059336","host":"s3://npm-registry-packages"}},"0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"d332593549641fe0f3a49ff957a8240bd7b16737","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64.tgz","fileCount":76,"integrity":"sha512-WAZ7/eIrLblpHgrGzHGs8fG2BKfZkEHBTfuvlO+eqeMtqKyQEfiInDSzda9MAmNuSWh1iDdP1jyzwcaDulEaEQ==","signatures":[{"sig":"MEUCIQCtzN6UQBLEjGp2GZJzSdKWP5kfRMMQ1kySFTjPeyg+ygIgFsiwGZCzFDMspzY8vCnvHrtrk5LEZV4DMsVxyM3DnQQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249128,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0cudACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoBXQ//S9kpN4B1We7RW5zLj0F0X6k3hSOX7yoH8HDtx4zL5Lcb6M0+\r\nesRG21rwqIvtOP6jP23+jP3jKpgxMMTaaIqBYDm65gvV4s2UaHGzdh9Irm1c\r\npBWXX9HtLwQ6e9ahT2T6d4Xb9M0wjmwjYOSY75tutnL1XgBoPzm0D7GMoRJr\r\nVsRB+9N3A41pcekvIonKdWn5TFt0DWopga+ZJtezIL/GYeSVHHFnTKNNBzO/\r\n5Cv5YPvxPtdTkJZFVKwnGNSpz4MS+9G8SgI6d80N4YwJn20MCc0U16vA0+iq\r\n3/7InVDBANi+nPFO3Rub02vbS5UssjG1HEk9t19ZX5FP26/BOUXd/Nhpqzq/\r\nBL3Jj2+BQ/G/jA1Dn0vpFkGIzI4KVeQiOk9DmR6TCIBy9GY2T9+STqUynfBE\r\n+VRuF9t//zWQqtIKQW67Eghw1IqctpNO1iu+SHI2BEqx12czpD9wTxHl42VO\r\ncgYG4CawPOLRrnjb8yzAZgnVkCE47kHZOObZ6vf8dkYntUUdsC/DL6kyjRNY\r\nTGJSnoC3yO2+tzdxSwkNsw28VHJ8kJjGl2uG2yvnTWPNuyryFEtmrSE4l6qk\r\n+mpy4hjgWyBwkLee1SNdNDKSo8PlgNblt0InbsZhNClx71U+0oWoHwIDW0A4\r\nx0cGKtd/0nNc7Xl6I7LunchICJHtZeH42tw=\r\n=5wjb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64_1657916317260_0.20589971917733596","host":"s3://npm-registry-packages"}},"0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"44c1284989cc434c4e7b56023a04a93eb4ff7cd4","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617.tgz","fileCount":76,"integrity":"sha512-+Czxl24HhKG5moSMXUM92SHLXYlOHPqIbwe9vO2ZphaPe+Vutmpv5f0GKs6y2V7FJYkW1gHsTqsHdtZtRzBnKg==","signatures":[{"sig":"MEUCIEI7xUc/UF86i8CwASBOXycWUDs42nQm0qBSa5Wmcn1zAiEA4tBViUMrghsg4owo0g9avaMTPDsNGDhtoAqO6nGp+c8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249128,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi2Z2hACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmox4g//cEsuF9VCGtB3tTKAmvehzitibnhHlG2EjkYg4ZvKpQTEJVdQ\r\nrWh8/05W3yE04yiE0JvXThMQDSJ4OWY2BSN0dYGUPs6nQ4WjcvoNZwR1Iktw\r\nKqJRSF8ffPQYokGPOaZzU0M6Vv3K1FgMx2RxG5wDtCVvKZtxaHUa5S2vDNqY\r\n5HoM+SUgfk9n30lvl3PlFMBWTsL9sSfYZqFp0mAiFvJFkWckg7RdhnUgRnHl\r\n//pu8D4LV7diOcmZrfZ/gOsd6aQtO/wO6YK3Z4mFBLsIFJmfC6j9QD8ZncxZ\r\nQ6x5lynhfVBdYBHpbhtxRINIhnKozrmISN2POX4F3oFV1B1/+RHWObcc+peY\r\nUI83N5z6FX7VcadYMLwbAaFOHWuDbp0FUWkLO5YJOxsD2vzzO/Wzpjj4xYzh\r\nizvYXWtEBFTn6O91Nbj2OMNXYeLNbQPSVIT+Gcws9ybP2H7+SKAtOrFKAVZr\r\naCqsz51KKCcVXEbhFU9swP5rWeD7KrTmkw7hOyenSqNa7VZ66Y5d+VjpvCG+\r\nq4KsjZxc+EG08S3/c+9tSmn6d/QbiSucOIkLt8cxMll8oigCPxDWMMumBzcZ\r\nMKlBAgwz/hOcPFD4R0xgRkh4ptigiYxVxBM70I4cfDIZOFT0x/nhEWjQZTbg\r\n1VZ1va/ypaT/Nf4c6/LoQZ+70gGwzz4WXVw=\r\n=1iTg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617_1658428833617_0.24586811810041542","host":"s3://npm-registry-packages"}},"0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"8bfdff1f98a98792da58d6d233ff1432885b9c24","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d.tgz","fileCount":76,"integrity":"sha512-8X0Dp3nlsMsOwmvTq2t3H1Rs3sk400fIU1ISyAeI4sr7qYWjAgBl1ej3G6DzZzynNnTf+44v5s/3fQ61fOcBhw==","signatures":[{"sig":"MEYCIQDa1tLI2l4d5IDiK4M/EFDskwWIRWKp0o4HRgRfTUycfQIhAPnK4qnHHw4pnzBXvyiyq3NGvkx6l0dT5L/3MoRM8ZmH","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4ZRdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmozcA/8CvYNKPGA746ySuqCZVA8dCdzmdnexOT/Ft4PGdnvW7gUuE8j\r\nI7UsBKTbpK6K9cxS6s2awcEXbUn+n0sT9bifRovwtBacWG6laUgGNaGMcgWF\r\nzpEOKw3G6XcBrIZGbDYjPif/yg2p/UXezANEhoB8Vtws8WHVuv07Icr04LM1\r\nUW8TF7sgDp+QuDPynzuBZq8Cxcf9BL6Ua4o1gm01p9VI8M2QBy/YPVwQ84ul\r\nfz130sCJoOzQrWlLfbfS6+yUXAv0yS5flt83tDNpviWoqrnb9qIKIgd7DY2d\r\ndvN7DQ3OUftJ1ReZVnLvMCox6/Nb4S7iI56i6Ny2QitGkuIfPL7BTXVbKAnj\r\nO1qM2sYtjigyuRYGDHVreOsSt/EJZXedGvQM6Fy6SW0uj1osyV2jG/uZjKyL\r\nJLss7U4o56MGlk08rUhyU3fUeYzi7G7bkBUrvwsPhLHANaXaaOyiZqrmJ0io\r\npRllZGqgdLaerWoIfxPDIHWUMheLhJ0dWEjT1Req5J5BsQovTlqrQhWbTxNt\r\njG1FW0cudioB/e3BRWXM1iOtrV7hnOg9mosiiSvHsU6vZhho2nv35UoQwSXQ\r\nyw/XpzXW3cHDsodcFQC/Hu6YBE7nSVkaZ4ShgjMhP1v95ekY3Ndrwh/hOqJk\r\nTCBHvqwlfsYpfeEIGoI7FNjdD8hxtTj4xlo=\r\n=y/SS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d_1658950749157_0.5415999301773085","host":"s3://npm-registry-packages"}},"0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"881262275f172840b334ca0bd302d55e65c9398d","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29.tgz","fileCount":76,"integrity":"sha512-k5hznobiIcKcpCKXwmMW1RpP7WLBLo7mhImwZ6KIv2u5Sr2wyk2Jctfl9v1gs0mMdj+MGMJJ0OtUKtIgMWF2vg==","signatures":[{"sig":"MEQCIF9vlyW2AF66DKHVFm9kDMoUA3CDhZcMI5RLIDBfJ3HYAiAD5BXsZB8io55A2av56WRZs63//jMisOtxBttUF4rktQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4ZXMACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrMdhAAhNUdPkVwsrbQu4lYDzhYv8l24o4HaEmlSFIPrOgq5LpFibSe\r\nc+DkJ0CFNZYd/LsX3Z6Bv5GgLey1gcH7Lt1EZtPq5PsBfBVnm7NCV2U76ZUl\r\n2qSRk1TPOljjFiF8n7SVd+hIjl9vAiwcFrFh7pbOez/eepZ1K0d9NVDoMm4t\r\nc8eAvHYFP/x6NSyyTyLiaNlJDcQRIGCUTiCyvTLZyCiBUbuXaW5rm9sRS2yY\r\nGNNJchcdWnWcv0vfjoPkxchc/3ECgj8wv01EogeXUrEpVMXUOnyoroCoFqpu\r\nhCWAmRYKDDV96xTsRqUMrmd4opCNIXSt+qGp6oJrH+jLKN2iP8CGvEwebefe\r\nwYwpcptxZL2uBOOmkBlpKKmQlq1xDnbq7aslZGM2Pu4uSKLRaOYdKC5Bz3Fs\r\nFxc2BUmtboQi2YxtJ2L7XMz6ioBDak0CNik/NXMhisMYoCmB38OVsKC4yl9h\r\nTOsYTP8bSpWfyh4QQap19xPkee88Z3nnD6fOzQVgRqc7LIagf4YNQgP/CFij\r\nqPiT3iUf1gW+Tqnb/UbZOI7rRZWFBK95UZwMNzwWvR1uuk9pXUxEzRskGJTU\r\nPeGqBCoYWFUCJPKQvLiqylD2mMmbUUPs+lmTWbF1qV1TM0rc2USYPJt/wfVo\r\nOgZ+DRO3jtaJkIsK4tojAL2rREodEq+tChM=\r\n=OZJE\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29_1658951116528_0.9340649827338368","host":"s3://npm-registry-packages"}},"0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"725cd98bc72a3a108ede1e18a5b79d8a09d62e93","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3.tgz","fileCount":76,"integrity":"sha512-4b+mDOK22lznyUBbApEE6hMlsjnDg9u+DGR6AcPYiokDYUDpJDRd2D7RCFXNxE1BFjVPzQjlvCeTaZ37Id4yMQ==","signatures":[{"sig":"MEUCIQC1V1fRh8+VzUU8vWUlqUpWtpbycJA9BMntN7F7Vz+VbwIgA8XAJvyxKEFGpnFzVj6Cg4H2hEeR25QQ2PENjMqmGkU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249128,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4qGOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmodKxAAnvAXA5h9Fe8cX1FLsAAYkFWZHn0xO5HOa7T93qH/RlJPQsd1\r\nYCLQLhBJhjPad5FznSUuicaEH5AsE8pQ/aNbRczRTkgxDJuVrxDxgWTctDOy\r\neAU8tIiL64Fp8QMqG3xlf3mrv5PFWO5FJdjbVxbgZuHpavAN9AbH208hBSJ3\r\n++k/5Z3feabm+fFXpPnMGVihmo7jZBZUlicGG3zfFNB6cowcs1OCQ4ejWBBH\r\nFHv3qGYg//VRkiX8iVmuH1LaShuHBG5SaJTFSbQvqarvm3nawRE74VqJnkXN\r\noun+IhG1X4qzHYfz77hc1vZcl4OBVOiwYcJSNfKKiYXcmEx5sTiQjvtglpja\r\nJ3Gc5nQLs/dU5B60N5+eBeRoWuU1URv/tG3U2yEs6DzHi4ljarpepUC62VX6\r\nySl81ca9OEsHVS52QHoXWRrTIFO+BC9Zgvm3LX38aMDywkZVqI4cCx95ChFK\r\n+XW1/89KQkrnlZ7H7R9Rr5BVyL1EpmbkIdwA0H+6dfvXb75F0yJtg49nis2f\r\nKZVhwWYh23kdL9AgMYgBOFWtQ6W3pByh7AvBO3Z1bDHCVL10G4j7eSIsQ8GY\r\nYxkr7iSdyydRbCIP5wQVrnBvfGFwMCVQN540YgZeO7eRsgDul140nGYPz3pc\r\n56IM8v5mNEixLtHpA42UF3km/a/mZ9U/kPA=\r\n=M9gt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3_1659019662534_0.4378708843159598","host":"s3://npm-registry-packages"}},"0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"a0393faf25223ae077c46ed2a567063d5dff2847","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467.tgz","fileCount":76,"integrity":"sha512-WM3iVbD5/lqsvMMXfzT6Uzhe59lHW71DJx8bHdt9E4Z57/RXjGtX5N/3tWu42sBD9ByTlt4zA0BG9J3rTf2ynw==","signatures":[{"sig":"MEYCIQDIWqJzoH71yiOhxlkHKChr3IYzXNXnbNN4bLOsqP2wBwIhAM+mODVO2A2mkqTWmOThgQViPBJVigq4ArcSDbPMEYBG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi4sfvACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmos8w/+I2K7bflKoaV2CADArSjkMYCGwz5/ge5ZJ5ORaO5UP0LUbW2v\r\nLnSM3b0zIYuaKL7sA8tcBJk3Kz03z0WevQG6t1rizF89rUIQP6dhWxbMtvj4\r\nN/nvP6sP7+7Cu+p/kwenQssNVdpyGTea9yo9NaMOIMZRto6cTjLnsOBwDd7s\r\nJrDImTA0LWN94i1xoLSYx2BYSwORxosYSde7dai+BO2X4Y12A3JGX65yfzhQ\r\nnhmaFRDgPqSKAclLAUjnPkKOPLgWGS5pq1QPA60iQMlv7A0varul/PRtysNy\r\neF0SM+4EfVqF6BftVdsqeVpnYFT7gGtkMGxluXnBUy8CMhe9bAxOCrFO22lQ\r\nOtE1G/Lo3oJKgbKE7qgE9BxZCo6fxNqRf57nQa3KJm7U1y04QlgmA04k7+nE\r\nOFrut8gEX5apNRwxQ1YtHi8790ZgMHI2siome1cs0bq0B4KBhGso/+J8TSm7\r\nKySPubhRjWOgovM+3PSNe20mpRui3GqvE+Oz8OfQvkfyFiDl8jBGt2e+0FzK\r\nDVk5mqYMjhTASy9/DPoJZG7zph+GMyrrRbkCWvGWRH2yUeH7RDpSmmLyn9pI\r\niw+ZW257P7O22I4QGJ4vqXC/ffM3qQXZucK9mEH/d0MazEOK8WjiavLjEu38\r\n80hc4fpgrtzoCzeEuoWPjgR+ehcilUlUvdM=\r\n=FaLN\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467_1659029487093_0.17065277870139894","host":"s3://npm-registry-packages"}},"0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"5e915f2602c509f1c664e696c3f6bd20b2209156","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3.tgz","fileCount":76,"integrity":"sha512-5gBqtBCIGdvvk+vmIudhch0QCoXyNEVgukhY6IoY8p3eItqxhnUg9813YGXk7oqEZqWkN0WKe7EaFjLUHv0b/A==","signatures":[{"sig":"MEUCIQC9wI5wTX2t5f59qbuugdweLcLqZFQKtk2CasuYfGN3igIgUqQ2JcW1y8Ci4/HO6QEBDNynHBYMwiYKbriEYiL9lbE=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6UxdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmofeA//Sn6mfOvP8GiQO7kiLTUl10IGGgatOM1zfQFDtvivFXkyHQ5Z\r\nlgB6kD07wdWGRjnf4pLxhp+tN8mLvUQ64ixcduyz522gag4kJw44XdjOZRrK\r\n+3Y+MAdpGGL48vBKPAe+tLwJTgi2z6fPIu72oyMN45CEPDTQQIiCmFguevHU\r\nr9rpsrw2M+2t5Tu/jAPnpyrm2H3ajsgRzyibLoLB3H0xJvgIamOK76plFLrt\r\nOibO0A4nX4IQS6NuMUDxRljBUSrCi+z11oyAQKrLc4/KNb13xmj2BgMuSEv5\r\nGrGoEA8JsnpLrpj53/bvpoEQsSUVRbHX4uLnvMUBhUFtb2VaUxCOiqFbyaUJ\r\nQHBYUchmWbQgRlO0HTx41hNTDPQ2xqZ04jLlWV3ZBjdBoZqDAR9ZE3FyHXBg\r\nyC45kq5OKpz+uEqpChPQp33mJ6gON1zOL44UZmMt4wt+fUgtTKcUiMi2gOOD\r\nztaFgPTiR+W/YqkeIKKybKtctkxx2WbEQnAKge87bHpZnTxml8rGUZYrvqyu\r\nxkA13PHDIpy0zr5kCk9m/nTYQYfLFx7HDcSlSTpApM0YXHmk133LemNNsN/c\r\n7j/cJ9HEsUJBau/yycv8arjD5KYWD7SP7utEj8GtDZpROOGzMgvczdrxWdmt\r\nI4tS0Tg7/sed+EiFKnzpB428WMCekjOsBC8=\r\n=R9Fg\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3_1659456604755_0.9981552374019242","host":"s3://npm-registry-packages"}},"0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"1a39504f5fd2e839e3cbfbe3382682c122868680","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a.tgz","fileCount":76,"integrity":"sha512-QNsi5V8FGyyWNY/zAXic7e76B/4a1jkDotF627ATr5Zu0kiiDMqY3rSXnMnTOw7wI7M3nlwaT40kW+Ky4SNT8g==","signatures":[{"sig":"MEUCIEMFTolcTc2AF/HlLdVS0tkdVoJ/Fn4czQKF7dweFG/CAiEA4+Lb7RynwvrZDd9UGXtjOAvWnUFp0oV+gDmv5w7g2/o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6WE6ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoEdBAAgeKZg5OcaUkgHpUwCMAWTYFZe+9wVJ8RFcy9R6Q4Uy/wYCuI\r\nWURfU/GKX0h1zml7/o0rmKXPn1k8cbIMQr+Y8ts00lDZqKHECa5o+GIXTkTH\r\nNRHedkQ0RCJ6kZTjf6JBAKqRSCX3xHzYM2BqVvJa+LzwtI6k9JB9Zfq1C1lK\r\nJxV558XXB+5qgSE9E1vnlTesY/RBsxfz7WWyEPpJDKJ1LLXPH1u/WhaTblbG\r\nkeHx0x7TEreEi200isnRUiQkHphxUdMmZQiYNEnr/wuyiV8WZNs63twVdtb2\r\ny3hTugYL8YqnA6ZRXlBvhA4jFVaQqju5PG2Awn86lgoWP+FmecI1YGcf3kjd\r\nkvntkac35+zQnxC/qw30RmXUxSh6Q9NECeHmI7DDZbUle8IPebsYw4pNwMoj\r\nC0w4uPnBEd/hldO/+UtjAAhaM9LhHFb6OvyaEWZ64AgNDI7bDryb5ib1KIoz\r\nt81BlafcvxZ4f8gjnpb7lk2nSmKEoXCg1Jjh0pL3WM1FV15JKJHqMW+QpQrj\r\nEQ8G7P81Znf2CB/p5F1Koc2J6BLLahxspFpXI8uIvWw9nr+G4WXRthmTChDl\r\nC+8gpZdWRh8Vd+fRYgJYXtPCoG1A8K5UdRJU3S/tmPpk175SMCAeN5oB3eYD\r\njafQ+abHsQcgB7GFqRtPVVtFsg29aPVjsjc=\r\n=sVb1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a_1659461946052_0.4905329272099872","host":"s3://npm-registry-packages"}},"0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"7282692e300b27ad13e01d6a864c26fbc1dd74fd","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f.tgz","fileCount":76,"integrity":"sha512-YIdxIHb59wsMpUV23houkMAedpMDChE8PLkBHI9+2yks/bS8gUTcrGuvWmbkBPlb3140lEHOwrQuy/NpGj4bmw==","signatures":[{"sig":"MEUCIQDdGnhYrbLbxC9xCew/ySLJ2xQVjEkAocpb7i363XA0mgIgLpO72UkbmjwkwdYQoPVx+BTWMr126N8tc4TrnqG5ZMg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6XhyACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZKxAAgju973jjWO/PJKZhsDVGN3gB2y9jRN5qSeukqOMtQiEvAMC4\r\nCxxQx0m4oadrjt4Wp4gB6olEioJNX7xL+xfUiiq1Rb+DVqQSf2kdJoo8+/68\r\n/2sXWu4vosmwDg+X/ziTaQtef1gZvdQ2iSgQ7zQWFiiv9vqUuMPuOW9jZWbK\r\n7gl+uB+9m7v7TXAl2mA8YuaFBkexHFpPyWi50DhGNwz0omEEDL13qilw21Yh\r\nmXz/gla4+/uT4TRQw2j8DLUXztUfR5cSfLlNbz0TkaWXvOI7DtvLsZJxUUOq\r\n10o2TSHVEL0aTCfqAoQcxwmTWt+D53jg5hou/K2R5RX0myS6MLrKVDvNq/V7\r\nevTV3ueg7V9zqYHRlq8+uEcRUC4nOoOakPcqJ97cB0mRFvjtTp9jpfmZvKwd\r\nfT1yYB5yE4TVjqRl13spSm0EtSKk0u9VguSzUI0cBpFdvA9uhUqTAm9dVRKI\r\nQHkIZzm0pA1P5qMU9HM7ppDBBQ4j8C+X+YUXZNNVIFXzB1wFCjr77lzrj+Fe\r\n2i+Bc4QDRXp3GJwiaW3PYbsfqfaHIL2TWzJNGBCA69hAob/nxljc6/vIPzCm\r\nWj8EgOLjJmLBiiQ+M3ZyVXQ5tIv/PTbhB42L0rKgtwtJERazQDF8Mu2/ZXyY\r\n/prvJdhSJeTTToJQ/37fkI8vvIttQRe82hI=\r\n=tiWH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f_1659467890376_0.8719033836796373","host":"s3://npm-registry-packages"}},"0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"eb02c78ac223d3b5d226fe3c18fa355f12357930","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186.tgz","fileCount":76,"integrity":"sha512-Xkv/wt0Ao1fYUH+eKhGY5bD7wXjfNtmoBVrM/GWl7GXRpF0ZUGvGyyLEidxAgwt/+5tYgowIhZY+GKfE5l0wDA==","signatures":[{"sig":"MEYCIQDiNBrB2gR2JDzHYANOeUNZP2sBfdNg1LKung+eyubjdgIhANujzsj3VsObPTbP88yc3vzGCFpAHU6P5JMSpB2wwa3u","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6X6rACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqr4w//bB2sh1E3qlGqt3ULiwnrm/li/xlV1dt/gE/nXQmrgoBc/t4O\r\n+Mf6j8EFwOwtNihVvdBJPdAI36GmWp2B/15elCrEULZeE13Nd23fn6GYWiew\r\nRLzv3pOP9vFNebVnrF4jRTjBFAs6hWCUjTX8DKsITQx1nKDdyrAXnp9ejE1f\r\nV1n/RIRatXagK2QWMWQav8Tt5dl4iC6OCBhtNWMbHRBiPCZo6VAKXj4xSUdX\r\nTUVJwbBmCrfgyr0qNle7rHmIb4R90KxADilb6yVdu5gH2SZQ7j233beNGK6d\r\n8p9kX9XEsMy+5AlhBAJLVC2AaMmqPPw6lDYEJSjsuqSbBO1kpsoap6TqOLbQ\r\nNFPtTBEB0Zbu3tWOPZZl1ZCu72aruaGPNbPBSGqTYGWlUpkpE+MrJ86G80X2\r\n/IlDN7npvR3PKbAke+K/hDBZ9uFs8xmZiGRblijf7ObD5VnhFlyqeqG3d9bB\r\ntytZZw2A3N7RZh1mt8RJ2mPuSUM4FUwV01xrwy9AKq5JhrCz9jNyU5OjI3n9\r\nxi4CElviwkovnycU2UufIZe8NrRPKXhgvePbxnQmZXIO9q04WbBaHj8e/OyW\r\ni3frBqmLyM59cpDVgFsv62MIGNxR7vI8P4AYtZLt2sjlkMlC0cP4v04IilNS\r\nbHaVg1ZtHlgZLyvq8ldtPkX8+2rtksXtF1s=\r\n=Ly3a\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186_1659469482887_0.43128762447532054","host":"s3://npm-registry-packages"}},"0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"464d13ba8466b0394574a1ae172951344fc11d2f","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62.tgz","fileCount":76,"integrity":"sha512-B5CD70u/FJBCknGgm2AjEtHvmpr0wcCQCbwjkF6jf1EI3QIyv7PWCNtHnOz6JwsPAkpuZlZAkVBqlBV4zr2egg==","signatures":[{"sig":"MEUCIEc8cQEbM80vPviUZ0R0OM51fypg7GtK4LVx/TgpCaiXAiEAt1hxXoBAiOPi0RlDGnyDKiZjbySk65bHQqRdBF/8i2w=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6o2TACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmroug//fJzceule035IX5tq6mX5T2KDaTHvRzg+Stfxb8bVqkRHCR+S\r\nrxMhgy36Mfuxj0ASLuzKoCYPP4mbwwoxpjdAiTrfi1mE+RyjsVz0kxptp26S\r\niyBeUEs0A+0z9zbCI0lS5CThr4h6KCCd5umV7udxRwmlmyLSp8z7GoOmAmIV\r\nllsheZbKgLOcdYczb4e2x/B1HvgUUq2Ea1otN0IHYRq1dHHfqMLhQC2Vext3\r\nCrfvk4pgvHIeoefovulgqVU2R6nAcuLqDxSCp/kVypchRvP+ZjD3bnd/o0mC\r\neierIstQZLxn/GJp8QFQWEDwFNFRKb/pwAuxPtQSHhIZgpcbqgVp3GSwQbPp\r\n6LmInrIQ9mvHQvmFLmcchtWoSyPhdU4HPmuujIUWM/H0T5rV7mW72iWKj9N9\r\nrodGMnXDff/HGjpZrnV1uSXRytavqOfKwk4T7G1gRlcH3GmCHvd/nq59xjvw\r\npEr0V76SQBPAVTblgwOozkX6VI58O3Pdx4yIkXHhs3P3BgNljFKSG8bOJ2bM\r\ntmCmM6FtGP0whZCD4dOkzmJhQb1aogrekDeSV4Vga2Vogg9cNegVneD2951D\r\nfmIUjvId8YX0Dmuf4QUAKdX3adKPm6kp0NTZvMXzI/EXgzuaAxUSVutPANak\r\nRlZTcNuVyq4WxssTxW6kTM+d6hpCYq2Hm98=\r\n=+cxa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62_1659538835444_0.6382400856775492","host":"s3://npm-registry-packages"}},"0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"c1cc2d5c3812702a5823c93cba001445c1abbaca","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca.tgz","fileCount":76,"integrity":"sha512-XAaR+mgTqUHnC+026YoEnO7pmOwlXQjkPmSuukMx+W1+vk1XRSuHpWbfQs3GvcwPqswPFYCzRfO3uLlNDUVM1g==","signatures":[{"sig":"MEYCIQCkJqwBjXjTu1iJT1xBMwi7pwzlT4xoTpbt4+q/gh5p8wIhAJGlzHs5Gn08odXlryo15EdsCh47csUwG9Do27yXF4OG","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6pU2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp+kg//Yb6VoFfBjBGP6G8Gq9IaEOMvOyOtvVCoOJ/KRQWULPB1eXsy\r\nnN8L405RwoKscMQBXLOvW0Yhw7PvrOyX+zePvXI5uQRkwPppoQMdZySCsTCs\r\neEWpw2B7FqCc6QYm+LW3EeP92cZpcAxtw7hSQnOs+UKv5a39HXmmIbE/gavp\r\nM7Fyk/YMPdDd0h6jPbM2oY4dips8hhu04ORVSiMZjW7op7FeiS37jWsjeAV/\r\nalONuEGoacu7Mvuxhm4d8X3IxlwCTKcrWDtvcC5p/veKFeSmzCgA+ICaFPpd\r\nZpsS+lMVp2hSWmiXXSY02YsDEBZDVlXi+9zuSz6bPwhDuq40JfVT8E4oCQ6B\r\nBHDn0HbP1O7AtmgIj9zQwslCvuzUMugxBBSdM5iZyKNchvbSc9vKKDkliJpX\r\nPsrQb8nX4LjlqJHWDT90pV3mLZZMWJSMC6kVqxnMbSzk0l225jIvvdGUEq4K\r\nwb/77fLPZWim6yHu+JSJfdl9dbG4eJ1QVvPu/n/v3wWERlyt/Ian2U4EHk8Y\r\n1N/2T35dfmGbnIG4ljF4L7N81jJT5BFjv64Gs30H+adNpIDIuuFaVzo19aes\r\n6ii8pnf8bovA9kSwezxDRs2vdP1RcP+7SMO4fipdDNJIub14mSU+L/hX0Z1h\r\nuUFK6AUyPz85YqnMPY4bfhSGz2JFXwld5/c=\r\n=NyFA\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca_1659540790164_0.0012291410458229457","host":"s3://npm-registry-packages"}},"0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"7ba6c58380daf024fbf29fc42c970e24640530e9","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2.tgz","fileCount":76,"integrity":"sha512-qZ7iwu7QhQGob9Tszzi79J+GFHNVLpJ+K0mlUx4mZXD38Wz2OaaLxIaWiuPs7SGdHtWkviFoEamViY36HSCG4Q==","signatures":[{"sig":"MEUCIQDwlz4RdqWc/oQ3GK6emHS7ak4ZjUA97IxeAjbKSr0dJQIgTdoE4eMnxAgBAPIuXvFpj4iZr/Hnv/qQdTUBgae0Ga8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6phkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmoqrw//WPxvNO8iPHPKSIHSc9GtPMqxIKtJXDG7TKkAaeU01CPMNjFg\r\nQPQf/AMQDd2GwLBoSdO0y5lutGWDBamLPGzlEacPTzc9vuMvmEKRi/zjQOXx\r\nuqM4rpp4bw9CTStb56HK0VGJh5PE9CWomD5ogyeSgarhQxOTyhEfiUg5H+ON\r\neoHzJHn5MPq0DUDZx7Tn6512MksAcEEgAZVK+X6mxhpxeGIm0enEZCjHr4F+\r\nrrzLFNz5rYlUQ6l2ckU0z4OJRStQB6ewafAQCY1zLuf7/BjfoqwVi22spkGm\r\nNb+FeXimlCRKO3/wKom7Hv5z+jY5ffFQgoiptFVg5dt9+70l4SYLrCVWT7xI\r\nYYOWLNbd/zwbrmk7cqcq8ZWe17LCjxQTxeGqQbW1uh4KtZM7DPtM70Fh68Nd\r\nOA5Xrqk1Df0R1ICMtkLEdfk2S4Hxu5RZEPzcrxigRdQ/gRgor+2tf0cm6YNz\r\nD407qaWQl3VpNNeFA7sPoe2F3J8SXjB/PC97hsM4Xh09R4wvjRHBRvHdGHiS\r\nBnALEqsLE+lwP4hGK1ITfqymvRcoFhM/NgDhm5WGsVlCGJyoVJJuWv2sEdeq\r\nZGb/sqO+ah+1aaxI2VwNFkDBtngl1Ht6SgeB3k4p43vCEigIOk3jqCC+slIO\r\nM50CdCypjthaLcyfdCZ28f0U+DwDSz610/s=\r\n=pdCb\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2_1659541604333_0.07972727115269573","host":"s3://npm-registry-packages"}},"0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"5ae7ed51a4a5475d3ee7f7b7026d011cc43a4e0d","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92.tgz","fileCount":76,"integrity":"sha512-JjyAO/GKEFSZz64ZwZX1iZccw8RDukPYDAXyFCpnu6Vv3cRUYTyI9GppChBjfYorRWjn6M+XMGhIHSNuLWYsfQ==","signatures":[{"sig":"MEUCIBZZTzSiBzFukLOIcJzX946zyIAqdnKbzDR407s8DJrPAiEAw0zieIci10n7sDCCUECMLtkddHzmUNpwzbva0OEZpWs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":249271,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi6qFqACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoC5w//bsL3ZRcXFG+Q+bEd43uOEZTrmXHaiOQYUN5TMFTHY3XDsPSf\r\nH42TIgytKmIiIB5wfk3BvfBqgAvXAaxnDkXWIYkdQsgDguxDF+jszkp8XN54\r\nKcsGXvNRHn/QM/D/ziCVUOPpzC9H9HnPECcjYQqQpbbrwxZknyrl8p6R/NP9\r\n629+ctT7TIppuwck60JbOkJa+w/Bo27YOtrlVFT2QtXGJFmjcvXZNi2HwnQl\r\nl+OjBtNysPJAePV9UbS1D5iKUdXlmumf4fdr8e+fmE+LTvwD7FI6B+fcBXIH\r\nP2Ce/nCAvuyjDW6XC4xNvaTnoLY6WqfJdosnt1v6Ezb5CHXdwxtWxWYL4/Hq\r\nrTARnPW5ipACn2j7FuD+xnQQ4tin3+QhtJq1kAjsYn5nYxYlvWza+CYnJ7e+\r\nCZVGafPhq1y2hshC+ViSOTw454hDMUyJ8abVvjSxTKa2aPWOHqhbjWjiI7tr\r\nbjzm3+s2tfX8lfzqsE6thV3vtL6+sK+KXQIJ/LJru44yzV+W7r7mwIAqbwDE\r\nbKynhg0CGB5wKOwBB3WUN4/dlBI1SJijc9vn2qPeKc6vt68ak8wiKKn+BcNB\r\nUo+foMa83AcHaS73XsclGsQh6f9nyG1vsybaVy/rfgFoVT4kD82zPjOKSF4w\r\ngwwQ67YWERx/kPJqQhdeHiKwMxW6kHh8bnQ=\r\n=yzAu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92_1659543914776_0.023785386723185198","host":"s3://npm-registry-packages"}},"0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"4a26c14672d75f26f3d5b9c8d6f502c613850f9b","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498.tgz","fileCount":76,"integrity":"sha512-qfCLJksRyB86I34y6ra066DTsmPDvGiLhMtLbiYvDaoS+/ZZAWrw5fL8G4wtDMKY7ua4DG3pFs4BlpRW3GZ8Aw==","signatures":[{"sig":"MEUCIBr1ZX7Iza0yjdaWdiaGfTYpQqEHfzXiV3IglZZf5s2KAiEAvxDPzcLIUABBmDVGWyzcL71eEizgdHLR3jxFqiP/RBg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":247801,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi9SjJACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoGeBAAl6X4wjee8M3DF6nFB1SJesR7zxUQOIxekQWX9LluVI8T5LnX\r\nIC9AC4uqb2gmt1fMsqjZA2VsAFIdLLMdcIKtmN5o0TkstHBCBB8uWQqQvPYQ\r\nNktbEtIjy7hpI8XkBWnEL+PcWT7uSlRuDbkf5IOkTfXZS9z69a8PGCag29eB\r\nE1idis/+z4OzwNhkKR/LzWLXdrt/KFXw316bUqTk/Tm7TgZ8sPo8VAm2M6ps\r\ncmeEIcAibddW+W7htDcM4fbSEg83LvUHCHcvhLVEmZZi6TeXK6umudOlyWAg\r\nKR4PN8oNxyp5CPp2tnq4pEdNqQDVB1a9MhNcEqGY9Pa9MmSjJIvmrRtL1LYR\r\noln9P7kGg77avBGiK2W7bkoes87WDcmWUR5TMCzwIV0kThJEn9lgdZdCTzsJ\r\nRv1HboMSb3yeecGzpBZ66CGgAbihcs3QxtiPQZjF9mN5HVjmqwddbmOHnmzw\r\nexrJat/rOv4RrF5w1wtrJAhLXoITXShqKXTRDOsrI7RIsxK6w9jli3B6EBqT\r\nyW1rMMjVhlMgv4M2KvE/d5NfrinRYdEsEEQikfmB0YYBE+RgLpMuGLf9Xkin\r\nar9k+ClZPLqrnIqiiGhI6DCtjqxGqcHwB9U9mbGo/+XNHII81sezlEYAeLf8\r\n20Xj4tWBDLRNM5nG69uyc8pYLXCKm7VXby4=\r\n=eirP\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498_1660233929673_0.9657339954925064","host":"s3://npm-registry-packages"}},"0.0.0-01fb35b52a036c00ce1c608125b568942dc67560":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-01fb35b52a036c00ce1c608125b568942dc67560","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-01fb35b52a036c00ce1c608125b568942dc67560","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"6762fdb8c0195bf9e30821b66f406e6193e46b76","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-01fb35b52a036c00ce1c608125b568942dc67560.tgz","fileCount":76,"integrity":"sha512-32tNytNgPCOOFb0fwgIbrOvxu5e3ihEOQe54EBfH5R7MPPlAPLeH4Aq5hhC07OxiJHNAsx1dRgIBw/96fWpgbw==","signatures":[{"sig":"MEUCIQChgPGrDvLlV5KebvCsI9dXu+/28zoqxBmirp1R8NOeHAIgX1Al3SW1uPIhfPxzyrU/VVQ6hYVB3kMOGb7YcmsQcjs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":247880,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/kxeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoqiQ//bGcgUIgcWVcoi/t1oI2bFhLONPKLIYlzlRsBE+cNieSD8xfb\r\n2CT2hgC1gZ5+s6JFHXK2hTMYlNuALmOXY9F2ErkHFBxONq920xdMzpNZvzWg\r\nokJ/8I+2dkx7Elvspes+lTgvnwfKDOuSsUO4bZTEV/9idEgjaZbGGbzN2yFG\r\no53mqDI2ixLKlnu359lGhElEvtBcJf7JyKl1hYC1ytAf3SO33FUdi5bGHWP0\r\nsjO9JuSxfUSmYFaUL4nhYs6H4QkFaHWl/zkcNJkzxvCfIm+6EWgrQ8itwWuV\r\nSIc6TWsv7qe3neh3kt6a6DSpDuab9/CQLT3ze3WYYgjH74dpZnGpxwl1AkNH\r\nISu6h0NimwfB7l2asODPg9AKgrj0m9PCVins8Z7xeDjfbmlD6vdbQoJBmY0O\r\nLCz2cieqS8CjIFu6BnW8N199YZMcIPaOX93O5da26Sg1ZnHW0sd8QsH+t0sI\r\nqmuuOlsA1Vv5d62TllD20wjAxhgenI626kWEo4dPhQF8cPr9ToD1XIMVbbNE\r\ntp981hg4NYsXRSyk0IFd6AMTegfQsuatC57gblZYTj6hq8bzkAaY88Xs79Jl\r\nV5GCZx6mzo8qbmZH4GyqFDk3atR2GqaiUTUQEVb0eK3Ovz+VxTozBaHscIrL\r\nS7Ag8qesCgdXTeABH6D6Dbe1AmfX4mbwMiA=\r\n=tK/W\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-01fb35b52a036c00ce1c608125b568942dc67560_1660832862477_0.5489290451145024","host":"s3://npm-registry-packages"}},"0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"92624dd665163e64b9463fd88a1fda12adde68ae","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d.tgz","fileCount":76,"integrity":"sha512-U26bA72lF6TvuDYy7+gB0+KILc85AqBsjPuABoEdXTYw+6gNyl+sGkNckCz6DBRawGinSP6Jbd5iUaze5ZNjQA==","signatures":[{"sig":"MEUCIEDd5pCVmJbO0CeB4FcCv/BUjS/1d+czyVnfRQGAMdmwAiEA/4TqsQZ6NonRcN6EECYo2jvXEChShC/Sxd8Vwt2t0kU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":247880,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi/kxmACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpmBw/+MqNhKAxkkcSfNQEBl2mHMgefy+m7U0/d4F8HnM8NKBSbL3tG\r\n3a3hmkKD8UZlfrbnuhSlfPUqgwF+LhT7/81FHjaUz6R+hZLW7fGO8cULyD0H\r\nQZ1pIBs4ixUoUNCM6tKW5pV9KPsOkhuZIKYHVMiL/TUuA5L6EEk1JOyVMKgt\r\nBsP7Lh+y733derxXqzAAMxSiCUGZqqZWzoN5vKc2Fgis1JoVTjjCkwhvSHRW\r\ng7hFD52gInO3xUGu5aSbVFaglBnVRELZyGacGrnduMiB4rgp7AQzGA3K+UB7\r\niGnyyhZ++lOjWwSf3LxH5g9UfxuNnd+7nJSzH0hSXZFa4j3cik+1fP6PF/vT\r\nls7kUjRwx2cIsexjinAs6FYhZVUgm7zQxYP9QWC6+P+cDFBTFpQl1pD+BJYi\r\nm86B6TPEsYAvff/naW0lo7kDSl1h+S1tXZebknhjzQXJ00nqOD6ZKLGgblKa\r\nZkaAn/YygWIoy4nDgeq0O80z4C6TS09pdl43YJPynBqFEudo5G0Ij38aLQky\r\nftLJloKuy9ab0wXHxuCcrbc41mjx+XeqQNl49dvCzKgUOJojishvKkntxVsc\r\nqnePkPFoXlfNwx5czg8N23b6naXXNPBxTzd8noLSptYuHYpBq0+gJU/NmEnm\r\nF5kLJdVqAAalY5dfaCae+NXjWNdu5s33OCA=\r\n=jOYe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./dist/index.js","types":"./dist/types/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"module":"./dist/index.js","readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"dev":"webpack serve --config webpack.dev.js","lint":"eslint .","test":"jest --coverage","build":"webpack --config webpack.prod.js","start":"webpack serve --config webpack.dev.js","format":"prettier --check \"./**/*.{ts,tsx,js,css,json,md}\"","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"webpack --config webpack.qa.js","lint:fix":"eslint --fix .","build:dev":"webpack --config webpack.dev.js","build:prod":"webpack --config webpack.prod.js","format:fix":"prettier --write  \"./**/*.{ts,tsx,js,css,json,md}\"","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","ts-jest":"^26.5.6","webpack":"^5.72.1","prettier":"^2.6.2","tsconfig":"*","cross-env":"^7.0.3","ts-loader":"^9.3.0","typescript":"^4.7.2","@types/jest":"^26.0.24","sass-loader":"^11.1.1","webpack-cli":"^4.9.2","babel-loader":"^8.2.5","webpack-merge":"^5.8.0","standard-version":"^9.5.0","webpack-dev-server":"^4.9.0","html-webpack-plugin":"^5.5.0","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","cz-conventional-changelog":"^3.0.1"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d_1660832870384_0.747062792198496","host":"s3://npm-registry-packages"}},"0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"b762ee96a3a6d51cd67db41d1086f1625a8e918f","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505.tgz","fileCount":10,"integrity":"sha512-fJG6g9+RS8+nHbew+sQjGxYg9FYVwFtRVq7WlJPJuQIgjenqX6E1b7iqDJksjsciy9aJqEbG2/QC4MQSTd7BjA==","signatures":[{"sig":"MEQCIEAd5pfeqeBtyz97LU+x/bt9ch1gTlIwYotEvEh14jP5AiAEWZpXcRLJgZ1/aQugzLaFXJP7JQ3Bjbb3PBXe0Pu0vQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":114745,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjGk4mACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpP2w/+Ic7gev1BeYCGQiLDMJBf25THhikEubccBA07YoSSt46Ui78X\r\nxaGGFlCKYyM8/ZP2cIIiAMnzrhmdZCLBMzm1GvgPNiehTC8aMcweqX02Nf/x\r\noYkcr5h1K2RGvSlMoi9xp+/1zvnIeE399MEwMGFLFHWXCDr83G8/JhaB81KH\r\npNO2wZaesGkQJFcfETA2DKf/pTyvTK//IRLdGzPzY5EfRvkQz/mIhslqk0rZ\r\nqzBKOw2IP8gD8ZAJcHb4OOaBDRRwuPzRceEasjmjovMY1R+f+JFwGz4mHVA3\r\nLm99Gbz7lTFDCCLTy1ybrXj7AXa3KF3ELy50TLSS8uf+bb5kveNuC94CXpaY\r\njLNesxTTYFsJuXMFj0TJQW6OOH+n9qbxdhWEpqAm94jaUe6pkcLcvyn1UFOi\r\nQqFQpHQtiMNan4smuGR1gEcJXwgabsVkXBKRwNMCQuMwU1NLGPQ/BGgo3SH5\r\nd5Iz5E6o2HqZaTaJsPTBLWeDUUqyYxsBnIvY87AkQHCZURb3xrUjJkk3ctcr\r\nHtrLjSK4nTE56TPXANTOkck3aXpKvE1MHcOiXi0edKE/K9L0Vxo7qAV+MLf7\r\n4mjr7pRZDb1CceOwBAKxAs4ILZep0zORViq2oDeBf6+huDsk+cwIm14D+Txb\r\nOfrPGQ0iiH86aj/nDXJeNUuc8Isvao+90yA=\r\n=Ioay\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505_1662668326463_0.5205039329077581","host":"s3://npm-registry-packages"}},"0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"ff1a319b8b4105a89d12da7fc7ba959165b25634","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266.tgz","fileCount":10,"integrity":"sha512-v15ixmSGUvTok3+LtnNWjonh86NsopXHKqdmb1lapypshnU56Dau5f1BlTyBY5csVJQMRGTBMJNEaxEJ5sjUVg==","signatures":[{"sig":"MEYCIQDLSofqJwSS8MgNZt/EchcKzyK2VGT9rjT2CyOJx8wbWAIhAPm0UF+FbL6gsKv7KF4m9fzbi+NqNCGM/yMBWPuGbW0O","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":114745,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjHtLbACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqJtg//eGAbG1mvHKWeKGMHTtuD+n6vinRnjOxE1jkUhaB5h8dV5t1L\r\nF9hCbQ798UkAo/J7gORBjT5T4FAUhl5McyZHUsvPujFOFqp6oyw9d7ymAtaM\r\nA8CUcibiIXR8ZglQ9tp607BoJhGWcCq9lcPccBIWfU5Ig0zBJJB4j/Wfp1K5\r\nrjmY/eGeX0KpPAH2IBFt83sLwdwLnysxnHxPIRyPArlT7g+eVZO9XLD/sYyX\r\nNw0hA1c/+yMZ+67NBd+CGKvFmFtB2tCbpYDjpkxwY7Oa70QTa5bkpJMKU1n0\r\nrq5oksNgkCfy1qcNONcFvpIOQUmjkBumqWt+GS+NQUWG+2h7jKKkyCbQoZhF\r\nxiU4I/UR+duM/BdHtIyaEiDbSLazVel4yEqx+pOBclLca8pNB7FpTSVmEPXn\r\nM0wRZ6hSVs56pLtkGxhJ/RB3cPSISLh/lC5hF0npQaFWE6daJsjJV5wHE+/0\r\nLh2DkWhKOG4JcYUdYSNqQaZkF6gyOZ8sTb528BJgqtf7f+R0CZJuwUI7BI4u\r\nNACBUfQ8h4AVO1i3qT+/zLo8t3dHVEIiyCPjGQrs3tEqUkV7oNRT/K3rGrxr\r\nT11KBzfM7diZBAlbtloUJslLLaAojZvE2miW1GGUymPZxQIAFmpCiiu4PNoV\r\n3C7agvmLiRfspF+lOooE7iCeKWvAF4cqSYk=\r\n=b/5U\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266_1662964443122_0.9661338907538923","host":"s3://npm-registry-packages"}},"0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"ee0bc960f8ed56ca19c46730d5a17b31e3cc6f5f","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6.tgz","fileCount":10,"integrity":"sha512-PWq/EUIUxO3o5QF4tcVH4KdIJdpOZjRtY5b/Y8WYferLktffQM6mZrUCRuHEp9+Az8A3LNgiNj0JhhLsZV+KmA==","signatures":[{"sig":"MEQCIFtk0mdg2ljIBluzKi2rTammZzq1Z3VmhOdw4g4e7XhaAiAGvv9PWnBxUihWgx02wKWywEcdAqk+1EDS5lEFnNi3kA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":115954,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjIKknACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmps5A/9G32F3y73CH16iH7qlF8te1dyjMtF7c9zVhNl+mX0J+c6Bcwf\r\nzG60PEb8yu334IFX2pmeM9PlBNtchj0/u0C8AsVlpPnqIKCYEZfEF+4emBTv\r\nLDUynzoFKxdB6UEnOdxpBnFrd7KD5Z8mZ35tiPtZ1AwlsugMZqsy2V//zAUc\r\nLQ8FjeTgs4XHoZAcarqUGqhk1+EvFMDMl0TV2SVOdKGz7g7963vVp6dl7of4\r\nwqNT0IhqK2QP40bvsxBmir53jiQn4JBdTRHvmOHDQyLAtrwlkIcQJt9PyFTg\r\nBwqcbyVAaRAZphZQvWGvA6qdJwbtp0gxgeE9yviYGsDt9k6LGKQqzY5p/qTT\r\ncihyzOg54eYGHD8CxD/yMaWSXxYQPA4vw6tX7GB+Rl+mFVUIJ1E5NdPwHaBI\r\nCBcEl7s8i2FzEo2CdElGn3cSH5muRdSNsp6y+l4DjnwVOTo2Y4cclE0qj+kr\r\nVhWwVhzNKWYokuq0njodVbxJ2j9ivDkAYRrzsNXbAyWIMHA4gxMd403HKAny\r\n99GOkF/ZriDo+FgpOI4WRBGBEg3IKH1f6IxNZE7/AcRueZ2tWjLfDx3vezUT\r\nCgX9TSXdIOb2FbjeZVle9dJz8Mql3p8mDUYbuZGUtdONEuguIOK9VNOwp+5V\r\nX3a+aO1U249TIqLbvlHkUcyF8D+esn4wdgA=\r\n=qz5R\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6_1663084839238_0.18169829865102138","host":"s3://npm-registry-packages"}},"0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"899ebbbd336a05343bab3cb174c207383059dc95","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057.tgz","fileCount":10,"integrity":"sha512-hl/63ng9Y9Bg1V9KgXqdURwhT2m/utfbk9hr7IiJhtj1VN9glYwKQoeWymWRTL3SQeYvr28QzYpSLiMsOzfsLg==","signatures":[{"sig":"MEQCIEfaNy/tx+GaJoVa9Xzh6T8qZH7GJ8mOLn7h/N33hrvbAiB++eO4bTmkNIuy0Ym1wSikjfWVUptSGeKZoZSCQgSbpg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":116584,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKMIoACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpgYRAAmY8/MarzVl6cRlKztaPLwJWhE95pfsur5UAN8NBU+zZrnmxa\r\nOcFMg3IHy3V4qc+cFRcsgMjIvqNl4niaskHKvF5EE4AYk1MfM/dFnMIavGCU\r\nR2zjionICmsyrlJvZVosoV+w8k1am1nGWq2V+D5uWDiwFNDlKk9PmhAuaYih\r\n7HhiqlWdJINBGL83MXsyPB7F8rpfU5KJ0Mqckw+MEDnus045Ubd9FVJzgEyY\r\ndaKNmQVisesfH60lm3lBvXV9edPPTpsz4udRua95iS6/di2qpXKLAvj53c2z\r\nQC3OVhltisVVtff+8fPAPhbP6QOK4pdlUOVxbOigpFwK4GCGQJYe953AiGn4\r\nKcaAD6KJsA4RcEur9zLcIBy+5byHmy5gxTNiufJD1EUDjXXOAjI6cz6Ub2vH\r\nESNXvB+jBob1adk6pNc3PKtH7lwvmkuf0X1psWd6u4gP7VVRcFmXhvduSd/Z\r\n+NU477UvCtT2tgjXcQwY7Yk7vprATVf+LK1/yD2UudE7jlQvju4vugzcWKpH\r\n/Zbs+EvaUNjLcJYVXx0UvPMgcomatuS8HOH4uSShREo1W+IZJ7dz07S+zmgq\r\nmJMi5GQJpBnJ7IWU1GSyXJRzqcJjIO9EENRvvX4bqiRxeln4gH99KJgmWGxZ\r\nwAClSIKFmPtKZLQRgSvZDVLd99L6UnHtUCw=\r\n=wvwy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057_1663615527882_0.2251786898744268","host":"s3://npm-registry-packages"}},"0.0.0-6704b8e6445473ccf046eef692069c849bf4c564":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-6704b8e6445473ccf046eef692069c849bf4c564","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-6704b8e6445473ccf046eef692069c849bf4c564","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"6494dfd90ec430ee9e6cfa103bd4ee810577f0e0","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-6704b8e6445473ccf046eef692069c849bf4c564.tgz","fileCount":10,"integrity":"sha512-0WmEXoCbqcgQH3CjH3frIAcs3gwIhvpU5vfgLpH/b4CuYsDfpjvSZViCJAPTh4KoD35h9VAz7biIj8o49leung==","signatures":[{"sig":"MEUCIF+cJYQA9B5YhYSrz81ed/vNOjToU30MavcUcQ9933nrAiEA2sqJzTEUJThn9vTVeWXS/bopMHWamspaqc6KpphCIm0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":116584,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKMqYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmqwhw/+N6vohJxK750KwCYpAjESM91DBnIX914EQffw3t43hk46I+ib\r\n3FtFPxaZoGYtLrPY2wVUW5VVxCFRrncMub41f4q0jK3imVMfYh5yEvZwIjDN\r\ni/X4NmefRI3LU7eXy/oY2xyx3kLTkh11IF225Aw75OebTq4e2LYVaVoEg5FK\r\nQbn5028FONC+rsjUM8qmzMOxpELzts1NS5FVasyTZX+tdmzI3TFbQqq1+LEi\r\nJoX+pdesiZYT7BgV9nCMo2FkTdCMWrMbz4ThYGHN1bGcKfjeFhGabRYI0yhy\r\nKoRFhYkurVXQCDLtTht2R0Wqyp7lQQPKDpC8z812aY0Hzv2RhTu/eJP25YIQ\r\n5akpxykDR22a3koWqyFSzlnQt1MMTYMVlYBOMLhKScv5HrkaGrq5FEwZxuE+\r\nMueJTyUHRW9MGFF4TEtsbXFGj+29+k78hU0p/CP+kLE7t/swIU7rpZE9EbCH\r\nPRJ6Q/RKmI2KYQWedb5UY5enwhhvpmhyc7DwRmWceQjQys6SiDNKzF5e8Fv+\r\nIkY6/ablbtXvbZJceW3R2++ce4ZgK98/geI/xMrfNP7PxwRUrDQvekdXKl4J\r\njF+uIOtvmqQpnDuWnh++oadDZtOll9jWN/t1kBrYe0ZezTyMzuHoEw/mrRrA\r\nDIyYWq6fnt4g4bPj3DmmmdGkXTGh7bre/aI=\r\n=pDZ4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-6704b8e6445473ccf046eef692069c849bf4c564_1663617688390_0.49721382633586253","host":"s3://npm-registry-packages"}},"0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"970adbe270ef17abb5bbaabd36fb4843e82132ff","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9.tgz","fileCount":10,"integrity":"sha512-cVVS987AodLA3rSxFOa3tHg5LMAn+5kGfx2q7OcDLeOEpQtECoYqxqMOD9z//g9k40wMAkVoCkhv7oBgisBMUw==","signatures":[{"sig":"MEUCIDS7PXPjAl/4/Ku0mk9iDOSEgqbKT1lorgqGTroFA/C+AiEApNobHe0naPrq0rDM4K3BxSJa4V4Mxg69WFcEZHTrK0M=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":117298,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKg6QACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp6WQ/+Led3qOvtR8rUX+nZArZtnQ7kfXdN3WFqxc13qH7s4OHsKiHO\r\nQSVyvS289riNyyageP5zTjPeVa4CmgDrj9lkujbYBDXItHwvLdCWPfRuVeus\r\nI3cI5CofngyyqHvdONs2Msasqzn2efrrdseW5oHjDE9X0Ur7FrAfdp8OJfsT\r\nGsmYC9d6U362SMNxwnwROKw8gM4aIAo3XD2EfzqVAeZJYNP6xDnK5w1QV16f\r\nkMzJRZot9Hu1os1Ublrf6QOz4LjezkbVrktKD0rFi8ThohMTtmnF3Ns5Y4gk\r\nzrMaJfu5fpaR84Y1iWEgHbGWIDcmj6WzDnzmQfoBUcjNDmCKKKI7Rw8uQ/Ms\r\nLVYuMYZiybWiUp7gB+uNT7RtMIMWCAt/iDDvAHqDRSL9p97gDobqzjHwsaKM\r\nA1V9hvxxqYFQGOEPGUO8+ulx3eymeZ1QDQgvBodOJjlFz6gWGM6Pu1frzqPQ\r\nCLaQALO62kJFmDs8YrEoCL5bw/9Oc8fF9yxDe0TWr2Ye3DEFU5xOetQyNX18\r\nC1W9GulaGy7X6wjSFsg6MwnrdWPj9PhMxUWH7reCMLEQot6tsI59DrZOhHOo\r\nrKB2QNP/8Tku3rKmyKrmZ4dgQ0JpkVFeLHu4Bt/+bPQ/Fzl9VyZv6AQxHAj5\r\nDHkKixjEJphHUc/Rs0ASzVrprJ9KBhMW/eA=\r\n=cpr0\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9_1663700624652_0.16429645811357507","host":"s3://npm-registry-packages"}},"0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"5a61ee208c0c371dbe7a9c199dc69f834e82d1ab","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f.tgz","fileCount":10,"integrity":"sha512-33Ejc5z3xWEgfXqT5TNrJ0w68G/dSKZDehpESsk9Zh+l0ClWKFlpl25OrON12tR+7jZ5G7J4fAGFm+ZhtUSJWQ==","signatures":[{"sig":"MEYCIQDDfoytDSX1hpZtrxb5KHD0q1APNSWShtNficiaDSNctAIhAMzTSE9jHjxOjkGa/1dWOAeLh33Op3HGYYyjNHsSZ1ye","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjKxuRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmovpg//Upk34D7C8agOgqJ9FiAkYW2cIWtGb9GZ+YxahmxgYKoNPVmJ\r\nJnpf6Z22qo2BpoCoW95ynO5GmUdh3rMF9COmR7gHgLqJFoacUwDzYJ5j+9Hy\r\nPCS8IVMjstKH1duiCGOClIfcrYT3gLTvHiAlZZMTTOzJVlaQW+e+QkWIjDwp\r\nMWlyQ4FzWYC5rhNvSAS4EbQBwc5OPgufK0EQpQAMsT6OGpR0h5GyMnDwFXZV\r\n1SDuxT4wRTaxb+8RgTJTKK1T4D0yujvTMyXpg2gltD9OxdrwDOE84OH3WVGS\r\nMPvq5gsKgP1NnntzdLDIR9TUqw+/jNvAYeLud7xI+Z9RHIEq/qnObJgF9KLa\r\n90H9SrwtfirMqGhOKZD5RDHZaCXOQ0baFlQykSVyoGAczlrqW3jV8Cy1uy6W\r\nqImBy5XblY1HxsW7/e7pNEGG/sRmxvUA/eG5OVaPtcTWBSg8Ci92QCZCPQRq\r\nsm7WmKZ72hqkX6Tu7v5l3iiYXFK+BvPt2xyhyYktYX16XHGTHhuL4c7i8pwD\r\nveDYvg7noSmqbq+JwT0g5I0cIA6guRO2Moyy6rtKiBkpDA+EQhs4spkMk0kK\r\n9XlTmWev6ed2m3vORJXb0xqslqDKKaDlquhEVsBRzXCV3ebZabMk7S4ygHa4\r\n3iDtql7gksRx8dT4CscNTUlNii3HuvqoF9I=\r\n=6Sd1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f_1663769489342_0.026762882771845575","host":"s3://npm-registry-packages"}},"0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"ce05adf99b741e50ad6d6a436a4ba20e3b17ffaf","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715.tgz","fileCount":10,"integrity":"sha512-pFLAVFBxJlOTwAPDNyMbF76bf8bK2XSpbaWNNJlPy2r1M4bivYuTujUMUk6Ggxy48/flk4R+6iBFF6oL33Uuiw==","signatures":[{"sig":"MEQCIGh6Do0oBeWE1sQdMFKwx0OyVnVu3XCwqy9qlpQlDFwMAiAk2nzi2aHdz02j0UbhiBMU1so4bLD2JTP0xnRKYGoyiA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjMcG2ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqmAQ//WruxbhP4e9KJyTXJlrISJdGLjVclbsd5obj7TyCCIIZf6zDu\r\n7aWnyEgNZ+3f8YMwmftmKDhBraMkxA3daIu2fYx74AQBO2IfzEPpzuLYQGT9\r\nSJWJmJDOL/km3xun9Ux4MfRkkDijff6/aGMuWGwVLSqGiPgpdSd3VYWQMfsY\r\nydymQBkCrrFPIP5wJBuvWPTf5zr0Mrs/vzHHfVQQm7iZwaLUFkWIj+4xxkkN\r\nqFWhi0rUlG82JDG4E+1LCs7KYAthETuJ1HkmUPvZ2003WUJhi1+OE7M3UEbk\r\nebKUzbLfkJEyT6EcaeLqG4ZN2Ow5+5XE1+2gYDDUhHhFRr0DpEOil3ZB3pe+\r\nSQwgb8II1zZBp9EB9RU6lUzI6xLGPYv9k1gIgnmdZd19vZD+R/e9KiS4bu50\r\nNq86LC9yeW/KeD5HAOFDlFBT4LB7j7ABEe/Q2sObTX7V+K7u5ByWEAYPPtOT\r\nbUUcHUK7AOQ9PzWbVFcXpel4OCuXn3Mi2JBPHlm+KSxl9H55nxtQto8zsm5K\r\n7gnM03j3LHJ/IsJ/txTe7JyQloMuJcKtk9my2cs5jiNd/2gPCALCftTeCrMz\r\n3Serzz9eYrMZRWNdAMWgwjw7rAWAJRwxBb66M/GPAL1o5LtuyGum+ru14DWG\r\nuN60npLTPE1xVI+mdj6bGcqYnvyqVmPuWgA=\r\n=CiZK\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715_1664205238573_0.7127359417347083","host":"s3://npm-registry-packages"}},"0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"580796fabc372c64c1f173ce3a362e3365e60bca","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b.tgz","fileCount":10,"integrity":"sha512-1DaCQbYe35amulXCjaTxm9BULFl0B7Y9gVZztNr7akaQUpXlgsJ4z0TVO57kl5cuMNL2UYq5hqt6wNP4uPCEyg==","signatures":[{"sig":"MEUCIQDqGUI2uAc6avuKrq2z9TAVBtSONzwRbDMzZU1F81jZmQIgbexA7wlVPM4DQxMETxeDcJAFoyMjvIpPZ8FI7TegHr4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjMc2TACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoY/A//RE1gMFH2n0UlAWI6+aribmiPP2p3iPnBdK9ydsJsx6IvRG6z\r\nb2XMqS+ysVflmgaNIUxsbP5lqQYaCiFjl+MNFVfIPSlkTvcjZn3h7cYeD8iO\r\niimKW4u8T46705HcYYEFQBr+25G1smVKr214RRXf/cgb6Kpxui9bdyiOSIVq\r\nT7Mg0Gp0CpD6EikctZJYyAtzN6qrs0iy3VMUCR9zxfWPZeyEvo/bJj464qEH\r\nGlVvFvsd3D/qVAssmqWhS5qpSPqYZgogPBO/zjdm6axE/UM883MLppqPIEjg\r\n1VfzieZeOvHUmYhmizTf5ZtpOP2QcfTIObHbkDKepFG1xXBBYhxMXLZnLVk7\r\nZX3OLNvEps7jKQw1lW9KUwEX+mss3sizymQXmhFOOKC4UN8CyxiYCMAGu+9I\r\nVim3zViCoInTt71sTnquHxtNKROdQ7s4sy6Rmn7hjEY7jjy+V9UrqeSy4xti\r\nkwrLKu84GjybKD9m0fOHg3CE2zqzqR/1db4Ob/2hndmjwF/dRHutl1t8aY5r\r\njxtpeLZNusqTTyBp4T/iFceDxLK5a7Iij28eXfjAqmG3VYz4xLTaqWiHb1ve\r\njlZEJbfgMwL+UyLv2KeumXpQB91MnoVMC/HlXjLtUKuSlXjWY2ZN8rTuXd6I\r\nogp/TOJLNhs0qtU9OlkaVERANKBcgVaKrYU=\r\n=v13J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b_1664208275624_0.5888794871703045","host":"s3://npm-registry-packages"}},"0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"9f6e9b19f96d6ca853567f10082dc75116d46b8c","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe.tgz","fileCount":10,"integrity":"sha512-7U7Oy2s7c0fZRkKU2SiRct6Z3nrSyqwLGZl9ec+D17jmPCzWk6oIHT2oN2LyN1CzDACdZu9G99eczKQNWGQYeg==","signatures":[{"sig":"MEUCIQDasbOTn01QGSxvSEfz8R3jq6wH8cObeO/JcbBSOt2OyAIgMbWNvM2Q5+VY2AiLCyMHSWoMPsR5RQW4dGemoZuI+GA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjMhZiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrC9A/+NKDdvYxasDG3T/3CVY9K+l41QgNqQNOsIK+hLPRhTNPO7OGJ\r\n6yeOwoO7JY9sdB7/qETpzHdJtPnCpDySMMi3jcAX4cUslGwLetkVazSDQsGI\r\n0NYy7mo4A/l5Pp2qB5Ryr44vSGP2gP/iePKEI4hlcstJUVGa4sRv8uWxuhGY\r\nzKB7eB2rv+F5wTRBqnFjjBAQGgrOZiqqAw7InWq0O1FjyGi+MMCAEZr5bGI0\r\n9Qf4x8mZJtMMgjibnXLf0m1Be1Vc9OAeB1lm1dZ3hZpNXllrm30xuAMIjdSy\r\nJxmTgGQBLC0/y6wWZO6dhveq810KgMAJG/89+ulK4j0FDSDgvbDG+rFRiqP8\r\nx/Yz+n6xZas5iNMjSsQTFZWzyCJIvBcrmF/QAwfFxvsxa3ZDFamVL5nLvvoe\r\nXmTB8uRS6Cd2Tln5EsbPGbGKCYJ6JQ2JS3Q/GGfVq+HyfSL7sFTG22gxfthl\r\nwkKtHg3xx7I1jdQPCByPbdIayFwM+fizysyqR2Q+ExhpEPeVnKbP1yfB7BTg\r\n5IKt/GY/JHO3j/t08jptscgHo7rFHT9uaIvL3gLTvyulqB49VIL2KFTCnAtu\r\ncFVGTngXQAsItsoU3q1naMnVlN/uk7jQrdRrW1fkHDaOcPInnfY0MCHhiNK9\r\n/T1jaf3jMCxsUEdKnr5IRixqaWIARnm7ZM0=\r\n=Tc1H\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe_1664226913957_0.822464522404488","host":"s3://npm-registry-packages"}},"0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"448ed6ed8d4b9c51c3d395a84a8fa9bc92af82e8","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a.tgz","fileCount":10,"integrity":"sha512-K3Y8S1wx2FZmx2hJ0XGg8UXUc88pKzxWSoy5Nx/Gg5+XOjfzNsT5HRvg0KKga8iU0NKqpk9QMEObXC57CjmdiA==","signatures":[{"sig":"MEUCIBvEcgCB/O3LBqk4IGZUUiWqDdzZk0FUiot2d6EHS7u1AiEAkPaks0ITFB0XfrpY7KuoYCCrMm4R9cTmOU6GTg4X3Ek=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjM2ziACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpBYRAAkVaCnu1HDZU6EnynXQOmOoa4TCFkivSQ8gXpNssWMlVqVKFr\r\nLAyoerv/VfKuDzHdkGwU8SkDuV68S/x/slUCY82mZa6cV8oSpTQc8d6Py+CM\r\nm7AX5RFfyg6JAEEE8ZWFmnEi0Y0PTuLXC5/shbElrJttkXy2oz1ZQAktHEBd\r\n+c8pHo6OmzEZJDzO4nnjWkc6ly6dAqwWRIT/IZzw1ggYLhgYdrSktuNZZ/ha\r\n65sCA530P2EAKQAQjTcezAI5lS6h8NDO93nFNBiEGPJYaAb31FTShadlJ8pi\r\nLKG2lfk3CV9/uNIc0SNquXx6gvQls+LcGhA5xu3L4lng3EnPkCUISwOVuwEv\r\nRmSAywJbrn6M375zlT3L2sMoX2ITSCn31+at56qFncN7iRqvJQbJ1ro4Tdhz\r\nmLhye6oyoDLu4XYx2+GglrFlUUujrnxl09b+XJsAUh2YJOtkvHVvkntjBb/W\r\nx7XzOh9pD4wsr3SxXe+dG/8TJtySyKs3A/qGQl6HDLpdnsXdErVkR0rCHuZ9\r\nqTB3WOcnlpnCe2Snd/hxz2L2MXJ5Ij9WztgrZMx25tZ8ALdGMgjLAcnpcKtP\r\nCST2ng2iG3HpkTEW+TKtdSNH4alsGwjWkWOXdaTSNwrX0B+v/b0eCwUBiX47\r\njrql+RDZxFxpMVNvtklYbGDngAmXcW2omvI=\r\n=8uBR\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a_1664314594131_0.2766555048216146","host":"s3://npm-registry-packages"}},"0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"b74611b5a7f7a453f36637c6ed9b0fc23c0ee12f","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40.tgz","fileCount":10,"integrity":"sha512-xHhp4EgZINayWc4zyiLdzMadVviTLAVOq0PNrY+c4+AkaaI5io9l6/lnhYIkaMBGxY8kVfbNww1uhjr+/3gBlw==","signatures":[{"sig":"MEUCIGZEOvEJkvRE8waI8vhh8tUYhsK5zCOuAraboClB0adMAiEA3R9HpHqL5DceLY4K9+xPer0HGiHOjZRnse6R+MXcKfs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjParnACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZdw//V/q2fyRty0RSuHhN5DqMQ1VHcJKV5ZBFv2xqM8sdavXrnr+d\r\nWf7rWTSB+J5HX8FzMOSnNTilEWlQ0XvR0hecJ6XqEeG1Rgogur+M46MLoVtm\r\nRiwmSTfexfJkU5tIndgpoSYY6VWeHqpr1+Y8hF0+HCkByRCv96O1kileJLrr\r\n6D/2CjCXMuY8Esh8w3ZzHMNS8dr3E2liDrUHMuHIxZuwBLruvPpRxF5tv78R\r\n4+yCmmYJQam15HUgxEFK07ybUlkBqmAyoaKCmYoBMIRH++PkygOX2pyq49hq\r\n9nAnE5gD8JVn2HMBBBpsywnKkfPtXQC52b7ViEFt4OHD1ng3NqQyb4Qb11La\r\niD2pFMs876h4V1cIe+K2bhaSBIMyNfZ3jtU0W3ePyQK2k1086hpdKs1W+A01\r\n+BFChNM8gityt4aGt1iHZymC6H81MIBdt3kWnqwpMYqzOiBfxmqhuUuyw1W3\r\nr0mRltLDXXf1KBQegk5TKvm4b1CTjxpeuZLlrjjgwPCGuhXjYcPp6txV8kpg\r\nyuADw8QsU8racQXtGbsFy8u0JF4u8p9ExZTwvLDhoL8hO5KeRFMKnU3wgIuE\r\nD3pam6GScwGFIYNO+jJw9jTYO1D28TwfeOoDw9fxOBfJqMAnXzSed9szOenh\r\n1zo1I/dWx/8YZjcWOv3AuzXE/xeuzAwjEdQ=\r\n=ksLy\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40_1664985831558_0.9871183444587697","host":"s3://npm-registry-packages"}},"0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"d0dd4af6301898bde1bda0e4fefec2bbc6aa88aa","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa.tgz","fileCount":10,"integrity":"sha512-2HMwJbdL+4uHndARv7BX/1P9YZKCWOkQMvcPlDVDAmaJqaS5pKBqFwSW7BSDk3wH6OqZNcwLfFOgmDuOOQPZ5Q==","signatures":[{"sig":"MEUCIFn/3rCsmXcwc9e+gQUAM74qgcWbXs4l/EA566/nAWg1AiEAxIBhWHe7ahNM1hqdyt9ggBUfe5gZnwZ4ZXRkZx8MErM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjRZVHACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqgPw/+JnrDceefGWuu53v70Gn39fydxscffMNDyn8dNKvQRtZ4jD6n\r\nEJBykssuKNGOX+1flCJO7RK/RQidvsAC2/V2hqrazZo/YlM8nMIBPZKkK+o0\r\nQiAAkrnX8psjfzmrvyPgYYDtM+jMEUYDNieJtAMu70nzj9pxwqvCH1WKgrtn\r\nMpmPB0oaE40w3Le6Ef0fsYnNZkJwjg4RWlYZPJzl6hsESeASV4wmU3DTSNAp\r\nGjyrwLmSFxAdXtZqLDXy7TwOyPLIOULHLDRyL4GLexkIhfKFbMC7h8dwQX4d\r\n4g7/XE5kLKXo4bJ3jKFaOcFwYFOl/shVZmNPfQMbaS/79z0drxCRu8PA/8sz\r\np86W1X1lNeVmn4aBrzz2WIepEPwvxHcahu0wZS+eqtfROyuiFAOSYhCkq3S4\r\ncDweb5aI9By3c+yibTjkIB9/Lw37nH6St0R3aEng0AsjWWfBQYV+GIpy+uob\r\nQEzYE70Ops+KUyzBJLIdK7KhuqIvd9xZYJ4rAqvrpTE725e2J55KhmRh1AQS\r\nHWzALinTRfhHDlR6b0jerDEZZ4BFzoPqkPUn9PFfSg7C+wjwSHE1eaKllQKt\r\nmE/MKr5zIlhiqQJQhCUn4WC8bvXS3ZKJ7qK3i7740widITVFJZw/6HwCTEMy\r\ntyb6Mz+rQjU9l/CiK4rcWfoJOXzLceWpgPQ=\r\n=afWj\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa_1665504583268_0.5127402641147536","host":"s3://npm-registry-packages"}},"0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"b7f6cdf879e97c4b8d8e97dc17d33a4cbec40958","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa.tgz","fileCount":10,"integrity":"sha512-hydrjAPxePq0khsoaa4VLUTR7MMbAsF+eOpMxhvBLxn+TNE6pEgVsC7NChiPllGhd5LrUxyIrEyPNlfADaOwOw==","signatures":[{"sig":"MEUCIQDrc4uc7fbo/m8HJRidscXvma+92Ey0uAu9KJSRmjS/kwIgYyY5RIscWM+dnabjSMPCGM+8Z1Q2gJYvuAUbFDiYyGg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjRcyNACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpqiA//R/issj90r4mtUtrDhrHBBF6GuYuddvBvq2aj0RbwFRORvWKc\r\nw4youK6wq8zU3AgGg0bbljXDORbzceM9a1XNSnAUW//oHBM6eg9/MLtPLb2l\r\n49OiQ4bD45o5GQbE+A0p0VIwDB3alWyvx1KRh7hZxZPfdQo9xim7m1pe/xd4\r\nN96hQ1bGYO/JNgY01cch+AAay5qk20EHklQXPwJWwr3KfMs+JM5vMkZcl49g\r\nJs57szdpjSRLd+qMnNMuTyDDcRhLaX68tXkYIL8WUrIZvvyO29sI3RmuNZqU\r\n6G2MS5Zr5ku7jiCOdcAcSl3KFUfcXsNKQPaUA8lUHPKF+ZDYLZV0EULChN1V\r\nCqCmCih+ZqdWpXiZHW8p6suFtnj0j+pgWYo0cOiwNoT9pAysmcYcAvSxP2cw\r\nPwyphIP8ER6zzgf637DmBMfmfVX4mgsykQaD6loTt459V7mtfmUgcTzg3sm1\r\nIckcx/3+7A/3/di/n/YrOLiMgI4i13toMGJv78EscKezCNgexb73sXGofJ4g\r\nqhH2ppzasyWkwtqco9LxizARD3Rz608z3uLodmrME7+LduDLPWQM/tv3UvN7\r\nVtTZ0tmo7azulF8DpnooeqCDckiE7K2pDueuR1eLsVJvSQRlJ2DQfGCDNyKZ\r\nC/0+gQIC/jUl835NQRLvOO88D0Vjf38oigo=\r\n=Jr3v\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa_1665518733489_0.24128070441140337","host":"s3://npm-registry-packages"}},"0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"a2a113fd210fef616f448098284c245d68e62101","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419.tgz","fileCount":10,"integrity":"sha512-OHvnx83EA0m1QNY2vxNsnyF6qHUrPe6BFGghmlA5K1ebWaQzUBsgs+0hmCel9temrYJfzxFObSFQu44YNDMziA==","signatures":[{"sig":"MEQCIBu6n3aR2aj+S/FPLDxJ1giJkP0cn4CfPSz7Z8Hkp10HAiAbqI6NYeC3qHb/Zwmurg8XFPbKFdLEraOqbq4+aoAasQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118797,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjRtDRACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrW6BAAiRu1YrxIbMNg0A9e3hwl+I0MpcwUePbx5ZdirDH6xRdbMX6T\r\nNGre9P/H4Ua/VkSrmABgZiqgz52gM0Fpx/GVwxcBHh6zOVLTIPvr7tlPoBHI\r\nhnR4A1hlssfnHBFr0Ygnm9+OK2dfEZ8zLMi39KuiB6CejYSv+QU+GmC84B/W\r\nDR/DffX8aCJGGE8pBsgw5jGJtWvIefx/7IXT0VcvRUu26weSJDla7YaWAEaa\r\nsZSHDWsgWoIwvEBZJkwcE1HL0yOWDNcK2jxWUgWyYIfj2HiwV+wH5G2SS3Oo\r\nEsLGiVsSQPI78WUyC4hRguGmLLVfsM9NTpfP2w/p9SHZIWC9GnktFb7+ipgm\r\nCxs4tHcLVbJiWRIbvGg1Lt6DWwgSJ9LdRHs22ioDLQL7k013HPT57Qi6tJpU\r\n/7/Qu9YZBHl73l7hK/sLJoTOlpuwkcTv9vGgnS3hkAA/VoKcXVcIzws+aGWV\r\nILhlA3mZ83ylE0/Q3tt+OziHKqbIfbZjKKnc7CB7+rjVdhM0Lscqq1PcXIqO\r\nFbIPvfo8GNwTJIXUYJSDExzwa6l3qOSVkz9+EMUWAmI8uwSfK5Q7C+UpdGCD\r\nM3PuZ51Xxp3rdSg92mM/iHGpWgFTYc7JKp6Iu53X8xV4vPw3RgNunSg6WG+P\r\n4PCECCT+1ME7job0StV2JTg+3s0He+oO3WY=\r\n=6h7r\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.abandonCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.abandonCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.abandonCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419_1665585360951_0.6617277092811853","host":"s3://npm-registry-packages"}},"0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"98f68e021a10f6f07839f54cd90ce46b2d2b3bc3","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1.tgz","fileCount":10,"integrity":"sha512-GfMv1Ln+A8pWHkD+1thwuTSQwA5dDfxVXdhuH6mVe/ByAifqlhoJm/7x9IazdK3g+5x+RVWrBh6cB7A16RPhXQ==","signatures":[{"sig":"MEQCIGCGH8CNZcT1IaqNahiHk80B47DukwGbZVH4gMb9VSSjAiA2X+5fUdDfihln4T41lq0KK7SW+lSTNKLBsoXg+ATq+w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTrknACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpq6A//WhEqMayPtvVo5I3E+6B9yLMo/zhIm1DyzoeOWBW9sfMP39hP\r\nu4Ph9nGJ7YHRYBDT5IdqCrTInOGxhwvp0qHln/VWlF2pnz8MwvfZ6kIxvYgp\r\nT0Z1h9+gsQ5f2Ug45FStH+C+AFdVeSxY6SKq2NNsk3WZ8ya+a/up+gB96kbA\r\nzcI1HUcpuKwCmeZqxCQRPIHP04jggsYfnfxVZsPU0zNw4sUxfiKwlpfnFsC9\r\nYOhOBZSvzex3QNuaSjO80845rihUEyshMi7MlMWEQBAmB+zyuKQsGjn8SnMi\r\nlmiVMxVoHTBli8Pu4dzB+V3Bj91iKS/I7IpvHaR0qlwLiLFYPtnDh0QQtReY\r\nptUJs23Fy3YT5hoVMItTf0X0SliQW0rDrAjy4Hte3Z+t3ooKqOh3hROa5/Aw\r\nUJS4dWytsSy4oHaMCv0gZhsqtLcgroODs1/MyAvA1WCYhHR7OB7cuCh7uuH4\r\nD1A/9UmkuD6LznRK94WYhFiR0snGCP7SpQTzdpdhFyHfj4l4XSd8toFajgRQ\r\nywTbf3vJ6MP2ZEiQw/hITDTGeDObI/HFRFhIKGaYlcyIr7nXIFehqjk4HSzy\r\ng/IpWGgrPJg3TS+OiVPdOyxaJfhkSVZOJaR8OI6p0zZpmcJEApPRbC4jW+Jw\r\nR0+EvYvcopKJBj5V2XXBL8EQWWY7EZo2Sks=\r\n=1bKZ\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1_1666103591475_0.873264079467809","host":"s3://npm-registry-packages"}},"0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"4021632ce75a1d8452fc0d2c26d9d94114bfe6ab","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf.tgz","fileCount":10,"integrity":"sha512-yFZp2ELgV4qtybBsjCds97wccLQPuoYXKFY4+ruu7qmKJ1//vRbwnOpcyXCjpM07XOW7NaRGCqhjmUyB/dWKzQ==","signatures":[{"sig":"MEUCIQCxEfRkMjBxTFJai0ea4Q/hqTBtu6TY4oZSGH9XlInAmwIgSORPCVf56P9Dg4mLyh2OfHm7G7BW1E54A1EXDOjyYzU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjUBGZACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoZVg/9Gl8nl/90VDpa5SqZnJqi7qzllZMqo7opCBVn+8VQcGE0zzby\r\ngD/2RQ6nLle1cOUB546kNsGOWuiQQmYF2XkN0dWLh3T8Q5pbC+V/l6NzA02n\r\nprdyUKU1JlXYdcDeprJXMeg7x4DVTdtjOU0iTygrCFYmaxmF68HtyVjnVKwu\r\nFbo+kVt75/1+stBIBGvjUu/a3W2ZBngDgjSfsBCdSddV2tubp72YGItaPvm2\r\nkCTVLrs5OP+m1ULHpTEkBza+BxPg8L2oJiGwMCZnh30qa3cR8SpZNN3DD57O\r\nSGvA9eBchf87QDOxJBtITq11cIKJiTo+W2umKxS5rt6mj82Ze1KTTX5vxyya\r\nJ3ZmK/mp6OxqSTkVi7DmM7zwOTNalocSFIjyLA7U93bUW0VGUTMneHL6Fcb1\r\n0NC8mftQFaXjFLfFmrC2OCspeqBHwi0yFvhGaSwkFTaOfF6FPwMOINwN0Cn6\r\nXNyG+aH/InH5Eut9f0Wq9NNYqBTMHSK2IBNaIbnHnoA0vSCgSGLKulJENtbP\r\nE/NuUKfjwxYhgIsN4AmJ3p7s8ULVrHK1y14+B/ZwjR3t7jD+roPUldzELhsw\r\ntkqXxCWI0z484h/4lVutBeRSWcdzf68hb2t+ZCyWFck3pgsITSFW6xXLSuC6\r\nYdFS0uKcQyq6elxTbaBW2MaJn6eh2br+y7o=\r\n=yqwa\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf_1666191769418_0.2573870881937701","host":"s3://npm-registry-packages"}},"0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"290f82648ee3d5c17611e4439584d2af72173ba8","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc.tgz","fileCount":10,"integrity":"sha512-DXyNS1bk+q2YUuuV1WHl7unRv4uqQuSQRy+mfubjfOnhTIQfS666uOazmTNwyvCRpL/GWf3ag19fjkvbzCfq4w==","signatures":[{"sig":"MEQCICL0LH+5g8TZ+2MhuimVW6xu7ABr61omCB3iYnEpVYy/AiAQeihkFeCL7TKxuvHJYyOUs1I+PxUds7/N5x9EU6s0vA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118540,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtZMPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpEpg/9HonxkqSqz3RlB0LPMUKbyMTqI3CoUriL6dp7NKxHMArshjqG\r\nJLKmnPyYeDGN6xrhUICWOL873bFMLP7jzj13rMb9iaRHGJ/Nmt9H9y0szoLd\r\nRl+4ZOonM+cmJfkMNe3qge44ECrH6L9kliJZ4lDIgfBK6CIr5wGqVrPhH3rQ\r\nCPwlH2GfDtBdJveDoMjFePR/QKPemywDkFtYvmZ2RnrNJj2WrHdBaduPxr6F\r\n2Kqouftshwj09LaOi1YBmIzKri9sTrkppst9SMOHjiAaeZSYC6EwEJgVbH6b\r\nrcOIGQ0nHTCh8nJ242uTAaHUtYCGZJDpGGKTtw3Ev5XmsQQe6/byy7G1si8o\r\nNUDIzwmtJK3kdarNzFgdeNv+Eq6q3iQaUHU+CNZ+GkS4dylL6CIERDUz4kg4\r\nE4TTvHmc8Gqb2k7gcTzMCVagrmiwgcG3vuS1UaC61agqTJ5B8ChnWkavXcWq\r\n90JoWI8TVN/d5rkOEMMv3uT4qZ6CaER2xS82ujgEb6LtfJqwHxnzwuq1Ci9m\r\n51DYK/aOsiazBhgK7MmzcvUhghnf/Cqv15gICL/fUd1PgzqY35nV9wwIppg4\r\nz1NUaU77pti9N0JeIpuqBLOuy8MVh42JhDOHsjkYTgiQ/hnJdOroYjP8LC2F\r\nXJ9EqiRGuZQGXsQvnK+n/8xGc80kDGE3ZOo=\r\n=KYUm\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc_1672844047017_0.1952795211992977","host":"s3://npm-registry-packages"}},"0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"1e0d7b61e1505c91cab100cfe136f34d66ec16ec","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35.tgz","fileCount":10,"integrity":"sha512-9BzqisTwigT+Q7XKsKp0DiFOeCRHwaKu4wyT6xLnWd2jzcusHntIqefDHKN0tw8cw8p/nte4GlXCnA6iB1u5AQ==","signatures":[{"sig":"MEUCIEcy/tbi2Bb8rz/3AXdZMnN0rFxT9jFjIns6yUVVV/QNAiEA/mElcZreesR9p/YIZF8+fsPZ51ECSDg0+tGztkhrjsI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118539,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj/7QIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpqqw/7B3HBv79TaUDnQJf/URxpeF99TZ4cAhqGYA3LGE0l0Ki5m828\r\nKCqpExUZs1RfL3YrxrxkZL67XZTVyy4SRf5aBU/xm8Cu6YRxjx7gLyJSYFTY\r\nwpf8KibWZ/r+GWTur+lSgUFs4+R0a4nYwHPYQAHbK7WvEcYgOZql0TOHOh0+\r\n461qgPRTFwfq8snHw+j1y/bTSNzCJqFuBx5icYb14I9vumrug9z3wYQgTchI\r\n1V2uYJEi+feER488JT5gRbCcRxrADuFZVBNBoL0DeZjY4gORuDa4gqaBiKtS\r\nNwnfiUXjSId4mfWpJnKUV5wRMdhtfpQLKrDFXlSAIeOACOk59zURKUaIUM6A\r\n7RQZ4ywlBimo9sRAe0+xbOBQb2BudBKhk9aHUEMo9Yz2ha90IT2k1BcDcPQ5\r\ne1GTmYPklHDvrgiFVEnQvOsRy4IUIPGxKFGo7NqYkxHIn5WuTfiVagIG3CVS\r\nZjzyASH1942/1Oz0s2q+zIyB9Ar/5t+49G8ZA93OGDY1a7GbDBNherKW2dNc\r\n1w9uyj41g8cbv2pgxlvzrdeT+GZa1xT5OaHro1aZHGqyVNduiQ3K2YlG4o8u\r\ni9UsyZ+QwINxhxMp7eT2wWFJeCg3WTlwdMTKshARK6HTGN0vuZjQDBQVuFNW\r\nI2Ty3fBXXD9jSSOgvh1gVxTxMKv94rzV//I=\r\n=Vhd9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35_1677702152487_0.6996409628367646","host":"s3://npm-registry-packages"}},"0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"f1a7a4b0e647cc072e3585eadc4947cb867df94d","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a.tgz","fileCount":10,"integrity":"sha512-ccsjt0oE2jk72gR9jUZJIPVifN0r7HistDQVh2/rRL9KFHWarQhhQGZiDaOgVCIxjQ0h4FLKmcv7uPm4M3wkvA==","signatures":[{"sig":"MEYCIQCRw3oCdZ+NaJ9Ji7+6zweSUIk16qye9YL1mzwmOvyKLwIhAIpBu93UsZZEtdp8Stll22jpMKaA7a1O6+eIcXnAgs1z","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118539,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkEPKiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpxSg//XTb1j/ytEEAYX3rsqKGMXVC3Ri2fvvhZePzpYp0BvB7BD6C7\r\ni7LCQRTIr6zbiOZ3S64+hh/IwtF7S7bwQxF0l5SsnhMrcBPoMOuxIpP03Pza\r\nANcrjnZS2wCgwHpSzoYCJI9osRzrcw7uXKSJiYHDu/B+f+5B66bVnKS4xpV0\r\nMhfLtfI1OS+VoZIJYwyGW6xVAqERWEzPSaf7P/qJw9VvhvjLIn2yNfyAjoCX\r\nQ8VmUKgzEEX4dR8MrtR4JDgY2KiMAmOwq8BK2ZBjLbOkA6hlYo4SOMgVB0Q0\r\n2DOo2ZmVUjYUHBd44D8JA4dcZ55AI/eExr3w537HT6KlyzxLZsiM/3lVP1cG\r\ngzzXoIWKx04PU+O26wORhQiIOsNzr+CvGnQ+7RZncBuvI9Rz3j/8bAtEyLKz\r\nJcs0vvHmn5od98irKdU5gdT7r44uU/TEcmM5yOJ7ksFsyNVAnFPSMgtm/CYN\r\n51rEd7qVxKYxNFF7kIoBOcua2LEzqs/x0F8alSO8IzVnBJFFMLKqVOiWIBtT\r\nhirspeCV2pLrH1FhodXJ7qnLRRZSnvgF/IhVZSS/pYSm5jD3Pom44MOanesG\r\nZK5hesGC50trpiiUEATeeBFOgpdPO6OS/Uo6N7Qvd7RaZxNV5KtxUfe2BDkD\r\nWjGuat99IKntHiEV2SqsXWzXNHKHeshpDQk=\r\n=yBtp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a_1678832290680_0.9407923563192957","host":"s3://npm-registry-packages"}},"0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"86a72eafd850dfebfa424478e9e4412e2d2db208","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751.tgz","fileCount":10,"integrity":"sha512-8txhzzxTUnoT+YJDV4JLFHD8tIqKJk6DurU/qWdrLJAc6qrXh6R76k5J3w3Gq72cwV5s6GbkuUEeL7CgCRD7RA==","signatures":[{"sig":"MEYCIQC1oenZCKWZ9jtnmzqxU8QAt67GxvoYr/CjHU9U28MJoQIhAMi5KxS4rJVHu/Mkvbg0irGnohTxubA+OohvHDDO8XF6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118539,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkK2SeACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoLyw/+Puh5q9LvD5lh/fWmecII2361BAt3HAmdARneu6HtLEj3jC+t\r\nbsxhxolwChwJ0sRuMsTiH3vL64tu3RL/tUv070HxfpmVkmTH45I/MlOABdJC\r\nve9Auxk1m75udaoF03qBBRKweSdyEtyrWEQ4r1Xsb8Fk+dK5gHt4vlFNNTI3\r\nXmb2GCKSsE9NBbu5BdNUAvRKdYyZKPSIHn8bZ69OsqnsQl0ihhLaTA26zYzS\r\nMB+Q4kk9Cirif40rldXf7QK+STOktCN5lMoqLZl/EinvB8IWK8B9GaRpRmHb\r\nSoMON1D3UL+Gt2wefxpvVqyif/mg+MoSvNesZtotlWPUjMy69BdnDR5qv5wp\r\nC4qunbkteMiJmSoqOvfVKn+pIEU/f/oPaZHhbLtTxzBKPik+yn56WhdgqJO7\r\nX5egidJ/S8OVRfhK6TlTZtVHiGrd63ezY9XD0noLV61JocikyEF+hoIyjez6\r\ntu6gx981RK+H+8e2dhGiN3CzE18kVlLoWryQD1uH7UlU2nKUBcUxJPIZp5us\r\n5861jdcnPADRDr9dp4peSoUMwh6MIAcp/hNUldugLBSLAaMXx6Ugr9X7pA/I\r\ndTC7SoSHYLKKTHo6MYCsrvBYzhk/bk0mC8w5DKLx0vwvDCDTZ1KnLfKfSgTA\r\nckSqUG5pS1MbdRtdp6WIw6lo3b1lw/TMwNA=\r\n=UCgB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751_1680565405970_0.14911622332689456","host":"s3://npm-registry-packages"}},"0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c":{"name":"@adobe/commerce-events-sdk","version":"0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c","keywords":[],"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","_id":"@adobe/commerce-events-sdk@0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c","maintainers":[{"name":"adobehalls","email":"halls@adobe.com"},{"name":"fullcolorcoder","email":"bradjohn@adobe.com"},{"name":"marbec","email":"mabecker@adobe.com"},{"name":"tripod","email":"tripod@bocanegra.ch"},{"name":"garthdb","email":"garthdb@gmail.com"},{"name":"lazd","email":"lazdnet@gmail.com"},{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},{"name":"patrickfulton","email":"patrickfulton@gmail.com"},{"name":"trieloff","email":"lars@trieloff.net"},{"name":"shazron","email":"shazron@gmail.com"},{"name":"krisnye","email":"krisnye@gmail.com"},{"name":"dcpfsdk","email":"dcpfsdk@adobe.com"},{"name":"natebaldwin","email":"natebaldwindesign@gmail.com"},{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"aspro83","email":"danniintheus@gmail.com"},{"name":"symanovi","email":"symanovi@adobe.com"},{"name":"dpfister","email":"dominique.pfister@gmail.com"},{"name":"stefan-guggisberg","email":"sg@adobe.com"},{"name":"korra","email":"npmjs.karo@cupdev.net"},{"name":"rofe","email":"npm@rofe.com"},{"name":"kptdobe","email":"kptdobe@gmail.com"}],"homepage":"https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk#readme","bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"dist":{"shasum":"f480dd272da1a7a753b5411dfc3c6ea54075ef82","tarball":"https://registry.npmjs.org/@adobe/commerce-events-sdk/-/commerce-events-sdk-0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c.tgz","fileCount":10,"integrity":"sha512-OtiVkmg0PFU1y4MeQXSifXvKuJRkgy1SrW+QGqr/bzzgbai3drHMaoxZ0pgqGHhCaHMFbBcT6cJA1yNTbHo3yA==","signatures":[{"sig":"MEQCIAwTf8IGrlbybyoz8dyvpzrxmT8ppE1pf1QkRK4rJBjmAiAMGVx4Rg6S+Z3zp8dIQodMJuBpeRINvk7gQqQL/d/d1w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":118539},"main":"dist/umd.index.js","types":"dist/index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"readme":"# Adobe Commerce Events SDK\n\n[![version][version-badge]][npm]\n[![downloads][downloads-badge]][npm]\n[![size][size-badge]][bundlephobia]\n[![build][build-badge]][actions]\n[![typescript][typescript-badge]][typescript]\n[![contributing][contributing-badge]][contributing]\n\n## Overview\n\nThis package serves as the foundation for eventing on an [Adobe Commerce][commerce] storefront. It provides access to a common data layer, and an event publishing and subscription service.\n\nYou can handle the events in a custom implementation, or use the [Adobe Commerce Events Collectors][collectors] package that listens for events and sends them to Adobe Commerce edges for processing.\n\n**Note:** When an event is published through the SDK, all subscribers to that event get notified. Defining a custom listener shouldn't preclude you from also running the Adobe Commerce Events Collectors.\n\nOur context schemas are designed to simplify forwarding to two edges:\n\n-   Adobe Commerce Data Services (maintained by Adobe Engineering and used to power merchant performance dashboards)\n-   [Adobe Experience Platform](https://business.adobe.com/products/experience-platform/adobe-experience-platform.html) (requires a subscription and additional merchant [setup](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en); data can be used by merchants inside the Adobe Experience Platform for detailed analytics, targeted merchandising, real time customer data profiles, and more)\n\n## Installation\n\nThis SDK can be used as a hosted script, or bundled in a JavaScript application. The script version is hosted on [unpkg][unpkg], and the bundled version is hosted on [npm][npm].\n\nTo load the SDK as a script, use the following snippet.\n\n```html\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\"></script>\n```\n\nTo install the script as a dependency, run this command.\n\n```shell\nnpm install @adobe/commerce-events-sdk\n```\n\n### Custom Data Layer name\n\nWhen you are using a customDataLayer name for the Adobe Client Data Layer package, you can pass in the name to the script using the data attribute `data-layer-name`:\n\n```html\n<script>\n    window.myDataLayer = window.adobeDataLayer || [];\n</script>\n<script src=\"https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\" data-layer-name=\"myDataLayer\"></script>\n```\n\n## Quick start\n\nOnce imported, you have access to the four main functions of the Events SDK.\n\n-   [Context][context] - set context data\n-   [Publish][publish] - publish events\n-   [Subscribe][subscribe] - subscribe to events\n-   [Unsubscribe][unsubscribe] - unsubscribe from events\n\nBelow is a code example of how to get started.\n\n> _IMPORTANT: Relevant context data must be populated before publishing events that require it._\n\n```javascript\nimport mse from \"@adobe/commerce-events-sdk\";\n// handler - can go in a different module\nfunction addToCartHandler(event) {\n    // do something with the event\n}\n// subscribe to events\nmse.subscribe.addToCart(addToCartHandler);\n\n// set context data\nconst shoppingCartContext = {\n    id: \"1\",\n    items: [\n        {\n            id: \"shoppingCart\",\n            product: {\n                productId: 111111,\n                sku: \"ts001\",\n                pricing: {\n                    regularPrice: 20.0,\n                    currencyCode: \"USD\",\n                },\n            },\n            quantity: 1,\n        },\n    ],\n};\nmse.context.setShoppingCart(shoppingCartContext);\n\n// publish events\nmse.publish.addToCart();\n\n// unsubscribe from events\nmse.unsubscribe.addToCart(addToCartHandler);\n```\n\n## Schemas and supported events\n\nThe below methods allow you to set specific contexts based on the SDK schema and to publish a set of events supported by this API.\n\nAddiontally, you can publish custom events or add a custom context to a supported event.\n\n## API reference\n\nThe SDK is broken down into four major parts: [Context][context], [Publish][publish], [Subscribe][subscribe], [Unsubscribe][unsubscribe].\n\n### Context\n\nThese setters can be used to specify context in the `mse`:\n\n#### `setAEP`\n\n```javascript\nmse.context.setAEP(aepCtx);\n```\n\nSets the `AEP` context which can be used by event handlers to forward events to the Adobe Experience Platform. A client must have an AEP subscription and provide a valid [IMS Org Id and Datastream Id](https://experienceleague.adobe.com/docs/experience-platform/edge/fundamentals/datastreams.html?lang=en).\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/aep.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L25)\n\n#### `setAccount`\n\n```javascript\nmse.context.setAccount(accountCtx);\n```\n\nSets the `Account` context.\n\n#### `setCategory`\n\n```javascript\nmse.context.setCategory(categoryCtx);\n```\n\nSets the `Category` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/category.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L31)\n\n#### `setChangedProducts`\n\n```javascript\nmse.context.setChangedProducts(changedProductsCtx);\n```\n\nSets the `ChangedProducts` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/src/types/schemas/changedProducts.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-collector/tests/utils/mocks/dataLayer.ts#L31)\n\n#### `setCustomUrl`\n\n```javascript\nmse.context.setCustomUrl(customUrlCtx);\n```\n\nSets the `CustomUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/customUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L40)\n\n#### `setEventForwarding`\n\n```javascript\nmse.context.setEventForwarding(eventForwardingCtx);\n```\n\nSets the `EventForwarding` context. Tells a handler if it should forward events to Adobe Commerce DataSolutions (`commerce: true`), Adobe Experience Platform (`aep: true`), or both.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/eventForwarding.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L47)\n\n#### `setMagentoExtension` @deprecated\n\n```javascript\nmse.context.setMagentoExtension(magentoExtensionCtx);\n```\n\nSets the `MagentoExtension` context. Includes Data Services extension version.\n\nThis field is deprecated. `setDataServicesExtension` should be used instead.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/magentoExtension.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L55)\n\n#### `setDataServicesExtension`\n\n```javascript\nmse.context.setDataServicesExtension(dataServicesExtensionCtx);\n```\n\nSets the `DataServicesExtension` context. Includes Data Services extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/dataServicesExtension.ts)\n\n#### `setExperiencePlatformConnectorExtension`\n\n```javascript\nmse.context.setExperiencePlatformConnectorExtension(experiencePlatformConnectorExtensionCtx);\n```\n\nSets the `ExperiencePlatformConnectorExtension` context. Includes Experience Platform Connector extension version.\n\n#### `setOrder`\n\n```javascript\nmse.context.setOrder(orderCtx);\n```\n\nSets the `Order` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/order.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L62)\n\n#### `setPage`\n\n```javascript\nmse.context.setPage(pageCtx);\n```\n\nSets the `Page` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/page.ts)\n-   [context example](<(https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L76)>)\n\n#### `setProduct`\n\n```javascript\nmse.context.setProduct(productCtx);\n```\n\nSets the `Product` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/product.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L88)\n\n#### `setRecommendations`\n\n```javascript\nmse.context.setRecommendations(recommendationsCtx);\n```\n\nSets the `Recommendations` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendations.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L105)\n\n#### `setRecommendationsExtension`\n\n```javascript\nmse.context.setRecommendationsExtension(recommendationsExtensionCtx);\n```\n\nSets the `RecommendationsExtension` context. Includes Recommendations extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/recommendationsExtension.ts)\n\n#### `setReferrerUrl`\n\n```javascript\nmse.context.setReferrerUrl(referrerUrlCtx);\n```\n\nSets the `ReferrerUrl` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/referrerUrl.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L230)\n\n#### `setSearchExtension`\n\n```javascript\nmse.context.setSearchExtension(searchExtensionCtx);\n```\n\nSets the `SearchExtension` context. Includes Live Search extension version.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchExtension.ts)\n\n#### `setSearchInput`\n\n```javascript\nmse.context.setSearchInput(searchInputCtx);\n```\n\nSets the `SearchInput` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchInput.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L237)\n\n#### `setSearchResults`\n\n```javascript\nmse.context.setSearchResults(searchResultsCtx);\n```\n\nSets the `SearchResults` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/searchResults.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L255)\n\n#### `setShopper`\n\n```javascript\nmse.context.setShopper(shopperCtx);\n```\n\nSets the `Shopper` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shopper.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L294)\n\n#### `setShoppingCart`\n\n```javascript\nmse.context.setShoppingCart(shoppingCartCtx);\n```\n\nSets the `ShoppingCart` context.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/shoppingCart.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L298)\n\n#### `setStorefrontInstance`\n\n```javascript\nmse.context.setStorefrontInstance(storefrontCtx);\n```\n\nSets the `StorefrontInstance` context. This context is used when forwarding data to Adobe Commerce Data Services to identify the Adobe Commerce instance associated with the data.\n\n-   [context schema definition](https://github.com/adobe/commerce-events/tree/main/packages/commerce-events-sdk/src/types/schemas/storefrontInstance.ts)\n-   [context example](https://github.com/adobe/commerce-events/blob/main/packages/commerce-events-sdk/tests/mocks.ts#L345)\n\n#### `setContext`\n\n```javascript\nmse.context.setContext(name, ctx);\n```\n\nSets a custom `Context`.\n\nThese getters are available for accessing context data:\n\n```javascript\nmse.context.getAEP();\nmse.context.getCategory();\nmse.context.getChangedProducts();\nmse.context.getContext(name);\nmse.context.getCustomUrl();\nmse.context.getEventForwarding();\nmse.context.getMagentoExtension();\nmse.context.getDataServicesExtension();\nmse.context.getOrder();\nmse.context.getPage();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getReferrerUrl();\nmse.context.getProduct();\nmse.context.getRecommendations();\nmse.context.getRecommendationsExtension();\nmse.context.getSearchExtension();\nmse.context.getSearchInput();\nmse.context.getSearchResults();\nmse.context.getShopper();\nmse.context.getShoppingCart();\n```\n\n### Publish\n\nThese functions publish events which notify all subscribers:\n\n```javascript\nmse.publish.addToCart();\n```\n\n```javascript\nmse.publish.createAccount(ctx);\n```\n\n```javascript\n// write a `commerce-custom` event to the adobeDataLayer\n// any object passed in will be set under `customContext` for this event\nmse.publish.custom({\n    /*...*/\n});\n```\n\n```javascript\nmse.publish.customUrl(ctx);\n```\n\n```javascript\nmse.publish.editAccount(ctx);\n```\n\n```javascript\nmse.publish.initiateCheckout(ctx);\n```\n\n```javascript\nmse.publish.openCart(ctx);\n```\n\n```javascript\nmse.publish.pageActivitySummary(ctx);\n```\n\n```javascript\nmse.publish.pageView(ctx);\n```\n\n```javascript\nmse.publish.placeOrder(ctx);\n```\n\n```javascript\nmse.publish.productPageView(ctx);\n```\n\n```javascript\nmse.publish.recsItemAddToCartClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsItemClick(unitId, productId, ctx);\n```\n\n```javascript\nmse.publish.recsRequestSent(ctx);\n```\n\n```javascript\nmse.publish.recsResponseReceived(ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitRender(unitId, ctx);\n```\n\n```javascript\n// requires recommendationsContext to be set\nmse.publish.recsUnitView(unitId, ctx);\n```\n\n```javascript\nmse.publish.referrerUrl(ctx);\n```\n\n```javascript\nmse.publish.removeFromCart(ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchCategoryClick(searchUnitId, name, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchProductClick(searchUnitId, sku, ctx);\n```\n\n```javascript\n// requires searchInputContext to be set\nmse.publish.searchRequestSent(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResponseReceived(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchResultsView(searchUnitId, ctx);\n```\n\n```javascript\n// requires searchResultsContext to be set\nmse.publish.searchSuggestionClick(searchUnitId, suggestion, ctx);\n```\n\n```javascript\n// requires shoppingCartContext to be set\nmse.publish.shoppingCartView(ctx);\n```\n\n```javascript\nmse.publish.signIn(ctx);\n```\n\n```javascript\nmse.publish.signOut(ctx);\n```\n\n```javascript\nmse.publish.updateCart(ctx);\n```\n\n### Subscribe\n\nThese functions subscribe to events:\n\n```javascript\nmse.subscribe.addToCart(handler, options);\nmse.subscribe.createAccount(handler, options);\nmse.subscribe.custom(handler, options);\nmse.subscribe.customUrl(handler, options);\nmse.subscribe.editAccount(handler, options);\nmse.subscribe.dataLayerChange(handler, options);\nmse.subscribe.dataLayerEvent(handler, options);\nmse.subscribe.initiateCheckout(handler, options);\nmse.subscribe.openCart(handler, options);\nmse.subscribe.pageActivitySummary(handler, options);\nmse.subscribe.pageView(handler, options);\nmse.subscribe.placeOrder(handler, options);\nmse.subscribe.productPageView(handler, options);\nmse.subscribe.recsItemAddToCartClick(handler, options);\nmse.subscribe.recsItemClick(handler, options);\nmse.subscribe.recsRequestSent(handler, options);\nmse.subscribe.recsResponseReceived(handler, options);\nmse.subscribe.recsUnitRender(handler, options);\nmse.subscribe.recsUnitView(handler, options);\nmse.subscribe.referrerUrl(handler, options);\nmse.subscribe.removeFromCart(handler, options);\nmse.subscribe.searchCategoryClick(handler, options);\nmse.subscribe.searchProductClick(handler, options);\nmse.subscribe.searchRequestSent(handler, options);\nmse.subscribe.searchResponseReceived(handler, options);\nmse.subscribe.searchResultsView(handler, options);\nmse.subscribe.searchSuggestionClick(handler, options);\nmse.subscribe.shoppingCartView(handler, options);\nmse.subscribe.signIn(handler, options);\nmse.subscribe.signOut(handler, options);\nmse.subscribe.updateCart(handler, options);\n```\n\n### Unsubscribe\n\nThese functions unsubscribe from events:\n\n```javascript\nmse.unsubscribe.addToCart(handler);\nmse.unsubscribe.createAccount(handler);\nmse.unsubscribe.custom(handler);\nmse.unsubscribe.customUrl(handler);\nmse.unsubscribe.editAccount(handler);\nmse.unsubscribe.dataLayerChange(handler);\nmse.unsubscribe.dataLayerEvent(handler);\nmse.unsubscribe.initiateCheckout(handler);\nmse.unsubscribe.openCart(handler);\nmse.unsubscribe.pageActivitySummary(handler);\nmse.unsubscribe.pageView(handler);\nmse.unsubscribe.placeOrder(handler);\nmse.unsubscribe.productPageView(handler);\nmse.unsubscribe.recsItemAddToCartClick(handler);\nmse.unsubscribe.recsItemClick(handler);\nmse.unsubscribe.recsRequestSent(handler);\nmse.unsubscribe.recsResponseReceived(handler);\nmse.unsubscribe.recsUnitRender(handler);\nmse.unsubscribe.recsUnitView(handler);\nmse.unsubscribe.referrerUrl(handler);\nmse.unsubscribe.removeFromCart(handler);\nmse.unsubscribe.searchCategoryClick(handler);\nmse.unsubscribe.searchProductClick(handler);\nmse.unsubscribe.searchRequestSent(handler);\nmse.unsubscribe.searchResponseReceived(handler);\nmse.unsubscribe.searchResultsView(handler);\nmse.unsubscribe.searchSuggestionClick(handler);\nmse.unsubscribe.shoppingCartView(handler);\nmse.unsubscribe.signIn(handler);\nmse.unsubscribe.signOut(handler);\nmse.unsubscribe.updateCart(handler);\n```\n\n## Support\n\nIf you have any questions or encounter any issues, please reach out on [GitHub][issues].\n\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[version-badge]: https://img.shields.io/npm/v/@adobe/commerce-events-sdk.svg?style=flat-square\n[downloads-badge]: https://img.shields.io/npm/dt/@adobe/commerce-events-sdk?style=flat-square\n[bundlephobia]: https://bundlephobia.com/result?p=@adobe/commerce-events-sdk\n[size-badge]: https://img.shields.io/bundlephobia/minzip/@adobe/commerce-events-sdk?style=flat-square\n[actions]: https://github.com/adobe/commerce-events/actions\n[build-badge]: https://img.shields.io/github/workflow/status/adobe/commerce-events/publish-latest?style=flat-square\n[typescript]: https://typescriptlang.org/dt/search?search=%40adobe%2Fcommerce-events-sdk\n[typescript-badge]: https://img.shields.io/npm/types/@adobe/commerce-events-sdk?style=flat-square\n[contributing]: https://github.com/adobe/commerce-events/blob/main/.github/CONTRIBUTING.md\n[contributing-badge]: https://img.shields.io/badge/PRs-welcome-success?style=flat-square\n[commerce]: https://business.adobe.com/products/magento/magento-commerce.html\n[collectors]: https://github.com/adobe/commerce-events-collectors\n[unpkg]: https://unpkg.com/@adobe/commerce-events-sdk/dist/index.js\n[npm]: https://npmjs.com/package/@adobe/commerce-events-sdk\n[context]: #context\n[publish]: #publish\n[subscribe]: #subscribe\n[unsubscribe]: #unsubscribe\n[issues]: https://github.com/adobe/commerce-events/issues\n","scripts":{"ace":"NODE_ENV=development rollup -c --watch","dev":"NODE_ENV=development rollup -c --watch","lint":"eslint .","test":"jest --coverage","build":"NODE_ENV=production rollup -c","start":"NODE_ENV=development rollup -c","release":"cross-env HUSKY_SKIP_HOOKS=1 standard-version","test:ci":"jest --ci","build:qa":"NODE_ENV=testing rollup -c","lint:fix":"eslint --fix .","build:dev":"NODE_ENV=development rollup -c","build:prod":"NODE_ENV=production rollup -c","test:watch":"jest --watch"},"_npmUser":{"name":"adobe-admin","email":"grp-opensourceoffice@adobe.com"},"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","directories":{},"dependencies":{"@adobe/adobe-client-data-layer":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"jest":"^26.6.3","eslint":"^7.32.0","rollup":"^2.78.0","esbuild":"^0.15.5","ts-jest":"^26.5.6","tsconfig":"*","cross-env":"^7.0.3","typescript":"^4.7.2","@types/jest":"^26.0.24","standard-version":"^9.5.0","rollup-plugin-dts":"^4.2.2","@rollup/plugin-json":"^4.1.0","rollup-plugin-serve":"^2.0.1","@testing-library/dom":"^7.31.2","eslint-config-custom":"*","rollup-plugin-esbuild":"^4.9.3","rollup-plugin-license":"^2.8.1","@rollup/plugin-commonjs":"^22.0.2","rollup-plugin-sourcemaps":"^0.6.3","cz-conventional-changelog":"^3.0.1","@rollup/plugin-node-resolve":"^13.3.0"},"_npmOperationalInternal":{"tmp":"tmp/commerce-events-sdk_0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c_1691509809756_0.5849240332361572","host":"s3://npm-registry-packages"}}},"time":{"created":"2022-06-28T15:23:45.107Z","modified":"2026-07-08T08:10:52.104Z","0.0.0-bfa1926089508e4a3c2a5b117be30ffeab793f19":"2022-06-28T15:23:45.397Z","0.0.0-b0e9ee788f86104fc458c6cba356cb515c3f1ba6":"2022-06-28T15:52:22.804Z","0.0.0-5b542c476741f10746bc22a62549fbae5a51a1fb":"2022-06-28T16:13:19.388Z","0.0.0-a7a94d6fd08468c128f1887ecd8e2157eaaf4856":"2022-06-28T21:34:16.560Z","0.0.0-b272aaffa8d0351753f4f37470429258d96ef46e":"2022-06-29T18:03:57.870Z","0.0.0-445610123d377edb9fe3238feea8b8effbd1dc2e":"2022-06-29T18:13:16.647Z","0.0.0-8fb54ed8430bedfed83efab09762c83d3d23b5bc":"2022-07-12T19:17:04.858Z","0.0.0-d974b558b86db36db72fcb7a172019b9eeac770e":"2022-07-14T17:25:20.184Z","0.0.0-d8fba47d8e642308cc4ffe5f7c0f5191d1f300c7":"2022-07-15T02:42:58.727Z","0.0.0-32ddd83b7b870ad17a3965f8cc6fc6bd46145d64":"2022-07-15T20:18:37.479Z","0.0.0-27995b9ed59f8a6940dd3ede9b88aa7a7b16e617":"2022-07-21T18:40:33.795Z","0.0.0-2eeca011f4ab84122d117ca5210506dc804d116d":"2022-07-27T19:39:09.374Z","0.0.0-9d20d0266cc42933fb7e3ecc99480ebe64561d29":"2022-07-27T19:45:16.751Z","0.0.0-9eae7f0e6cd9737faa74a7d7cfede697ae883ca3":"2022-07-28T14:47:42.738Z","0.0.0-5b88c2dbc8584f8671c1eb255f964ec5822a0467":"2022-07-28T17:31:27.582Z","0.0.0-7bc250ab7c83c211c4266221e95622ce73ec94e3":"2022-08-02T16:10:04.994Z","0.0.0-610bf9b098c89b94c07da8c09e202743c5583f5a":"2022-08-02T17:39:06.281Z","0.0.0-99b7ec612d5657080719687f50b4f2e49cc84e8f":"2022-08-02T19:18:10.526Z","0.0.0-3416a6d5e4f1564f74d81bfc21c503b0835c3186":"2022-08-02T19:44:43.165Z","0.0.0-38a9ed06514792a2be772ca91abb5f4b78174b62":"2022-08-03T15:00:35.688Z","0.0.0-0ea143fcc77f1966f2dc7cb31fc896aaf0a98aca":"2022-08-03T15:33:10.358Z","0.0.0-212c0d5bd4f63ca6bbfb51bb3029310fcd8993d2":"2022-08-03T15:46:44.504Z","0.0.0-735b4f789b74db78538d9965ff7af2da2c0a5e92":"2022-08-03T16:25:14.957Z","0.0.0-9a94583c87fc38d6750b5fbff3326f6c1a25e498":"2022-08-11T16:05:29.889Z","0.0.0-01fb35b52a036c00ce1c608125b568942dc67560":"2022-08-18T14:27:42.700Z","0.0.0-adb46651b1bb7b4611e62674f2755c312830d65d":"2022-08-18T14:27:50.588Z","0.0.0-67c0d298a5826e4b23837ebec8f5a1ed13d3b505":"2022-09-08T20:18:46.689Z","0.0.0-c9c1b4b52207f89bf0efa271582b5f488cf3d266":"2022-09-12T06:34:03.295Z","0.0.0-398d305da8d81f96f245689e93cfa53a6563b0a6":"2022-09-13T16:00:39.524Z","0.0.0-f0c05a055d83389581b5aa12e5217df4f3d0a057":"2022-09-19T19:25:28.071Z","0.0.0-6704b8e6445473ccf046eef692069c849bf4c564":"2022-09-19T20:01:28.623Z","0.0.0-9c2b80889a9b80940cdc2b6c1cac500374c953e9":"2022-09-20T19:03:44.860Z","0.0.0-bc9cf92ff5f90ad304cd227eb9d58274e3b9d86f":"2022-09-21T14:11:29.685Z","0.0.0-2df0c4614bf7bf739cac8d273d5959548198c715":"2022-09-26T15:13:58.776Z","0.0.0-0532edbccbf6127c783e80f3dce0585187546f7b":"2022-09-26T16:04:35.815Z","0.0.0-85bd07962a44a05f6f44988f4dbcc79b6517bcfe":"2022-09-26T21:15:14.229Z","0.0.0-6702428c4696ac1a2b6c2a40a49725c43767b68a":"2022-09-27T21:36:34.301Z","0.0.0-99cbc4e0583a69944fcf3d8abfce41b27b44cb40":"2022-10-05T16:03:51.729Z","0.0.0-9bc3d2d7ee1b3ba7b27e195b5513c4a6587dbeaa":"2022-10-11T16:09:43.464Z","0.0.0-38fa293d4e508b66e14f79c18ce8126b5eef17aa":"2022-10-11T20:05:33.702Z","0.0.0-05de9ab2cc7559530e4d60779ae766ffad15f419":"2022-10-12T14:36:01.127Z","0.0.0-0d8a0ae7bb8aac6ce5509dd4185a971cdb3ebab1":"2022-10-18T14:33:11.727Z","0.0.0-3df58da9a48ddbc777a227ebc026cd87ea6f1bcf":"2022-10-19T15:02:49.681Z","0.0.0-287d65ef03f46abcc395a0ca9bfce606ef5d7fdc":"2023-01-04T14:54:07.155Z","0.0.0-0a1eafe77160f498ebf36cd41d6dc0dfddcacc35":"2023-03-01T20:22:32.686Z","0.0.0-5f544538cd1e6239aded804f5230a0011c8bf48a":"2023-03-14T22:18:10.875Z","0.0.0-1ca7412c31f009cc1474136e18c3507a7e66b751":"2023-04-03T23:43:26.109Z","0.0.0-da39dfc5be75add99d570ea82dda8bd294301f8c":"2023-08-08T15:50:09.919Z"},"bugs":{"url":"https://github.com/adobe/commerce-events/issues"},"author":{"url":"https://www.adobe.com/","name":"Adobe"},"license":"MIT","homepage":"https://github.com/adobe/commerce-events/packages/commerce-events-sdk#readme","keywords":[],"repository":{"url":"git+https://github.com/adobe/commerce-events","type":"git"},"description":"SDK for working with events on an Adobe Commerce storefront","maintainers":[{"email":"mabecker@adobe.com","name":"marbec"},{"email":"tripod@bocanegra.ch","name":"tripod"},{"email":"garthdb@gmail.com","name":"garthdb"},{"email":"lazdnet@gmail.com","name":"lazd"},{"email":"grp-opensourceoffice@adobe.com","name":"adobe-admin"},{"email":"patrickfulton@gmail.com","name":"patrickfulton"},{"email":"lars@trieloff.net","name":"trieloff"},{"email":"krisnye@gmail.com","name":"krisnye"},{"email":"dcpfsdk@adobe.com","name":"dcpfsdk"},{"email":"natebaldwindesign@gmail.com","name":"natebaldwin"},{"email":"devongovett@gmail.com","name":"devongovett"},{"email":"danniintheus@gmail.com","name":"aspro83"},{"email":"symanovi@adobe.com","name":"symanovi"},{"email":"dominique.pfister@gmail.com","name":"dpfister"},{"email":"sg@adobe.com","name":"stefan-guggisberg"},{"email":"npm@rofe.com","name":"rofe"},{"email":"kptdobe@gmail.com","name":"kptdobe"},{"email":"halls@adobe.com","name":"adobehalls"},{"email":"bradjohn@adobe.com","name":"fullcolorcoder"},{"email":"djaeggi@adobe.com","name":"djaeggi"},{"email":"dylandepass@gmail.com","name":"dylandepass"},{"email":"mhaack@adobe.com","name":"mhaack"},{"email":"amol@adobe.com","name":"amol-anand"},{"email":"stopp@adobe.com","name":"stopp-adobe"},{"email":"namarora@adobe.com","name":"namarora"},{"email":"doten@adobe.com","name":"doten"},{"email":"schmidt@adobe.com","name":"duh_schmidt"},{"email":"astha.bhargava23@gmail.com","name":"asthabh23"},{"email":"zouhir.dahbi@outlook.com","name":"zdahbi"},{"email":"tuicu@adobe.com","name":"tuicu"},{"email":"fmeschbe@adobe.com","name":"fmeschbe"}],"readme":"","readmeFilename":""}