🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@ecomplus/widget-fb-pixel

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ecomplus/widget-fb-pixel - npm Package Compare versions

Comparing version
1.4.0
to
1.4.1
+11
-0
CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.4.1](https://github.com/ecomplus/storefront/compare/@ecomplus/widget-fb-pixel@1.4.0...@ecomplus/widget-fb-pixel@1.4.1) (2022-02-16)
### Bug Fixes
* **widget-fb-pixel:** get amount for value from order router param ([#630](https://github.com/ecomplus/storefront/issues/630)) ([baf6ed2](https://github.com/ecomplus/storefront/commit/baf6ed2d1de61963dd3a5d645d040ccd5ef1738e))
# [1.4.0](https://github.com/ecomplus/storefront/compare/@ecomplus/widget-fb-pixel@1.3.1...@ecomplus/widget-fb-pixel@1.4.0) (2022-02-06)

@@ -8,0 +19,0 @@

+1
-1

@@ -1,2 +0,2 @@

var widgetFbPixel=function(t){var e={};function o(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=e,o.d=function(t,e,r){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)o.d(r,n,function(e){return t[e]}.bind(null,n));return r},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/assets/vendor/",o(o.s=2)}([function(t,e){t.exports=void 0},function(t,e){t.exports=void 0},function(t,e,o){"use strict";o.r(e);var r=o(1);const n=r.$ecomConfig.get("currency")||"BRL",c=t=>{const e={currency:n,content_ids:[t.sku],content_name:t.name,value:Object(r.price)(t),content_type:"product"};return t.categories&&t.categories.length&&(e.content_category=t.category_tree||t.categories[0].name),e};var a=o(0),u=o.n(a);e.default=(t={})=>{if("function"==typeof window.fbq){const o=(e,o={},r=!1)=>{t.debug&&console.log("fbq",e,o),window.fbq(r?"trackCustom":"track",e,o)};(t=>{const e=window.storefront&&window.storefront.context;e&&"products"===e.resource&&t("ViewContent",c(e.body))})(o),((t,e)=>{const o=window.storefrontApp&&window.storefrontApp.router;if(o){let r,c,a;const i=()=>{const{amount:t}=window.storefrontApp,e={value:t&&t.total||u.a.data&&u.a.data.subtotal||0,currency:n,contents:[],content_type:"product"};return u.a.data&&Array.isArray(u.a.data.items)&&u.a.data.items.forEach(({sku:t,quantity:o})=>{e.contents.push({id:t,quantity:o})}),e},s=(e,o)=>{const n=i(),a={...n,checkout_step:e,checkout_option:o};e<=1||!r?(t("InitiateCheckout",n),t("Checkout",a,!0),r=!0):c||(t("CheckoutOption",a,!0),c=!0)},d=o=>{a||!0===e.disablePurchase||(t("Purchase",{...i(),order_id:o}),a=!0)},f=({name:t,params:e})=>{switch(t){case"cart":s(1,"Review Cart");break;case"checkout":s(2,"Confirm Purchase");break;case"confirmation":d(e.id)}};o.currentRoute&&f(o.currentRoute),o.afterEach(f)}})(o,t),e=o,u.a.on("addItem",({item:t})=>{e("AddToCart",c(t))})}var e}}]).default;
var widgetFbPixel=function(t){var e={};function o(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,o),r.l=!0,r.exports}return o.m=t,o.c=e,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,e){if(1&e&&(t=o(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)o.d(n,r,function(e){return t[e]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="/assets/vendor/",o(o.s=2)}([function(t,e){t.exports=void 0},function(t,e){t.exports=void 0},function(t,e,o){"use strict";o.r(e);var n=o(1);const r=n.$ecomConfig.get("currency")||"BRL",c=t=>{const e={currency:r,content_ids:[t.sku],content_name:t.name,value:Object(n.price)(t),content_type:"product"};return t.categories&&t.categories.length&&(e.content_category=t.category_tree||t.categories[0].name),e};var a=o(0),u=o.n(a);e.default=(t={})=>{if("function"==typeof window.fbq){const o=(e,o={},n=!1)=>{t.debug&&console.log("fbq",e,o),window.fbq(n?"trackCustom":"track",e,o)};(t=>{const e=window.storefront&&window.storefront.context;e&&"products"===e.resource&&t("ViewContent",c(e.body))})(o),((t,e)=>{const o=window.storefrontApp&&window.storefrontApp.router;if(o){let n,c,a,i;const s=decodeURIComponent(params.json);if(s)try{i=JSON.parse(s)}catch(t){}const d=()=>{const{amount:t}=i||window.storefrontApp,e={value:t&&t.total||u.a.data&&u.a.data.subtotal||0,currency:r,contents:[],content_type:"product"};return u.a.data&&Array.isArray(u.a.data.items)&&u.a.data.items.forEach(({sku:t,quantity:o})=>{e.contents.push({id:t,quantity:o})}),e},f=(e,o)=>{const r=d(),a={...r,checkout_step:e,checkout_option:o};e<=1||!n?(t("InitiateCheckout",r),t("Checkout",a,!0),n=!0):c||(t("CheckoutOption",a,!0),c=!0)},p=o=>{a||!0===e.disablePurchase||(t("Purchase",{...d(),order_id:o}),a=!0)},l=({name:t,params:e})=>{switch(t){case"cart":f(1,"Review Cart");break;case"checkout":f(2,"Confirm Purchase");break;case"confirmation":p(e.id)}};o.currentRoute&&l(o.currentRoute),o.afterEach(l)}})(o,t),e=o,u.a.on("addItem",({item:t})=>{e("AddToCart",c(t))})}var e}}]).default;
//# sourceMappingURL=widget-fb-pixel.var.min.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["webpack://widgetFbPixel/webpack/bootstrap","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/shopping-cart\",\"commonjs2\":\"@ecomplus/shopping-cart\",\"root\":\"ecomCart\"}","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/utils\",\"commonjs2\":\"@ecomplus/utils\",\"root\":\"ecomUtils\"}","webpack://widgetFbPixel/./src/lib/common.js","webpack://widgetFbPixel/./src/lib/parse-context.js","webpack://widgetFbPixel/./src/index.js","webpack://widgetFbPixel/./src/lib/watch-app-routes.js","webpack://widgetFbPixel/./src/lib/watch-shopping-cart.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","undefined","currency","$ecomConfig","getProductData","body","data","content_ids","sku","content_name","price","content_type","categories","length","content_category","category_tree","fbq","options","window","track","evName","isCustomEv","debug","console","log","context","storefront","resource","parseContext","router","storefrontApp","isCartSent","isCheckoutSent","isPurchaseSent","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","disablePurchase","order_id","addRouteToData","params","currentRoute","afterEach","watchAppRoutes","on","item"],"mappings":"8BACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,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AAItC,EAAKoC,eAG3BtC,GAGHyC,EAAe,CAACC,EAAMC,KAC1B,MAAMC,EAAehB,IACfiB,EAAa,IACdD,EACHE,cAAeJ,EACfK,gBAAiBJ,GAEfD,GAAQ,IAAMjB,GAChBf,EAAI,mBAAoBkC,GACxBlC,EAAI,WAAYmC,GAAY,GAC5BpB,GAAa,GACHC,IACVhB,EAAI,iBAAkBmC,GAAY,GAClCnB,GAAiB,IAIfsB,EAAeC,IACdtB,IAA8C,IAA5BhB,EAAQuC,kBAC7BxC,EAAI,WAAY,IACXkB,IACHuB,SAAUF,IAEZtB,GAAiB,IAIfyB,EAAiB,EAAGlF,OAAMmF,aAC9B,OAAQnF,GACN,IAAK,OACHuE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAaK,EAAOb,MAKtBjB,EAAO+B,cACTF,EAAe7B,EAAO+B,cAExB/B,EAAOgC,UAAUH,KD1DjBI,CAAe3C,EAAOF,GEXXD,EFYOG,EEXpBkB,IAAS0B,GAAG,UAAW,EAAGC,WACxBhD,EAAI,YAAaZ,EAAe4D,MAFrBhD,U","file":"widget-fb-pixel.var.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/assets/vendor/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = undefined;","module.exports = undefined;","import { $ecomConfig, price } from '@ecomplus/utils'\n\nexport const currency = $ecomConfig.get('currency') || 'BRL'\n\nexport const getProductData = body => {\n const data = {\n currency,\n content_ids: [body.sku],\n content_name: body.name,\n value: price(body),\n content_type: 'product'\n }\n if (body.categories && body.categories.length) {\n data.content_category = body.category_tree || body.categories[0].name\n }\n return data\n}\n","import { getProductData } from './common'\n\nexport default fbq => {\n const context = window.storefront && window.storefront.context\n if (context && context.resource === 'products') {\n fbq('ViewContent', getProductData(context.body))\n }\n}\n","import parseContext from './lib/parse-context'\nimport watchAppRoutes from './lib/watch-app-routes'\nimport watchShoppingCart from './lib/watch-shopping-cart'\n\nexport default (options = {}) => {\n if (typeof window.fbq === 'function') {\n const track = (evName, data = {}, isCustomEv = false) => {\n if (options.debug) {\n console.log('fbq', evName, data)\n }\n window.fbq(isCustomEv ? 'trackCustom' : 'track', evName, data)\n }\n\n parseContext(track)\n watchAppRoutes(track, options)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default (fbq, options) => {\n const router = window.storefrontApp && window.storefrontApp.router\n if (router) {\n let isCartSent, isCheckoutSent, isPurchaseSent\n\n const getPurchaseData = () => {\n const { amount } = window.storefrontApp\n const data = {\n value: (\n (amount && amount.total) ||\n (ecomCart.data && ecomCart.data.subtotal) ||\n 0\n ),\n currency,\n contents: [],\n content_type: 'product'\n }\n if (ecomCart.data && Array.isArray(ecomCart.data.items)) {\n ecomCart.data.items.forEach(({ sku, quantity }) => {\n data.contents.push({ id: sku, quantity })\n })\n }\n return data\n }\n\n const emitCheckout = (step, option) => {\n const purchaseData = getPurchaseData()\n const customData = {\n ...purchaseData,\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\n fbq('InitiateCheckout', purchaseData)\n fbq('Checkout', customData, true)\n isCartSent = true\n } else if (!isCheckoutSent) {\n fbq('CheckoutOption', customData, true)\n isCheckoutSent = true\n }\n }\n\n const emitPurchase = orderId => {\n if (!isPurchaseSent && options.disablePurchase !== true) {\n fbq('Purchase', {\n ...getPurchaseData(),\n order_id: orderId\n })\n isPurchaseSent = true\n }\n }\n\n const addRouteToData = ({ name, params }) => {\n switch (name) {\n case 'cart':\n emitCheckout(1, 'Review Cart')\n break\n case 'checkout':\n emitCheckout(2, 'Confirm Purchase')\n break\n case 'confirmation':\n emitPurchase(params.id)\n break\n }\n }\n\n if (router.currentRoute) {\n addRouteToData(router.currentRoute)\n }\n router.afterEach(addRouteToData)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { getProductData } from './common'\n\nexport default fbq => {\n ecomCart.on('addItem', ({ item }) => {\n fbq('AddToCart', getProductData(item))\n })\n}\n"],"sourceRoot":""}
{"version":3,"sources":["webpack://widgetFbPixel/webpack/bootstrap","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/shopping-cart\",\"commonjs2\":\"@ecomplus/shopping-cart\",\"root\":\"ecomCart\"}","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/utils\",\"commonjs2\":\"@ecomplus/utils\",\"root\":\"ecomUtils\"}","webpack://widgetFbPixel/./src/lib/common.js","webpack://widgetFbPixel/./src/lib/parse-context.js","webpack://widgetFbPixel/./src/index.js","webpack://widgetFbPixel/./src/lib/watch-app-routes.js","webpack://widgetFbPixel/./src/lib/watch-shopping-cart.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","undefined","currency","$ecomConfig","getProductData","body","data","content_ids","sku","content_name","price","content_type","categories","length","content_category","category_tree","fbq","options","window","track","evName","isCustomEv","debug","console","log","context","storefront","resource","parseContext","router","storefrontApp","isCartSent","isCheckoutSent","isPurchaseSent","order","orderJson","decodeURIComponent","params","json","JSON","parse","e","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","disablePurchase","order_id","addRouteToData","currentRoute","afterEach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A,EAAOC,OACjBC,IAASvC,MAAQuC,IAASvC,KAAKwC,UAChC,EAEF5C,WACA6C,SAAU,GACVpC,aAAc,WAOhB,OALIkC,IAASvC,MAAQ0C,MAAMC,QAAQJ,IAASvC,KAAK4C,QAC/CL,IAASvC,KAAK4C,MAAMC,QAAQ,EAAG3C,MAAK4C,eAClC9C,EAAKyC,SAASM,KAAK,CAAEC,GAAI9C,EAAK4C,eAG3B9C,GAGHiD,EAAe,CAACC,EAAMC,KAC1B,MAAMC,EAAehB,IACfiB,EAAa,IACdD,EACHE,cAAeJ,EACfK,gBAAiBJ,GAEfD,GAAQ,IAAMzB,GAChBf,EAAI,mBAAoB0C,GACxB1C,EAAI,WAAY2C,GAAY,GAC5B5B,GAAa,GACHC,IACVhB,EAAI,iBAAkB2C,GAAY,GAClC3B,GAAiB,IAIf8B,EAAeC,IACd9B,IAA8C,IAA5BhB,EAAQ+C,kBAC7BhD,EAAI,WAAY,IACX0B,IACHuB,SAAUF,IAEZ9B,GAAiB,IAIfiC,EAAiB,EAAG1F,OAAM6D,aAC9B,OAAQ7D,GACN,IAAK,OACH+E,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAazB,EAAOiB,MAKtBzB,EAAOsC,cACTD,EAAerC,EAAOsC,cAExBtC,EAAOuC,UAAUF,KDjEjBG,CAAelD,EAAOF,GEXXD,EFYOG,EEXpB0B,IAASyB,GAAG,UAAW,EAAGC,WACxBvD,EAAI,YAAaZ,EAAemE,MAFrBvD,U","file":"widget-fb-pixel.var.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/assets/vendor/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = undefined;","module.exports = undefined;","import { $ecomConfig, price } from '@ecomplus/utils'\n\nexport const currency = $ecomConfig.get('currency') || 'BRL'\n\nexport const getProductData = body => {\n const data = {\n currency,\n content_ids: [body.sku],\n content_name: body.name,\n value: price(body),\n content_type: 'product'\n }\n if (body.categories && body.categories.length) {\n data.content_category = body.category_tree || body.categories[0].name\n }\n return data\n}\n","import { getProductData } from './common'\n\nexport default fbq => {\n const context = window.storefront && window.storefront.context\n if (context && context.resource === 'products') {\n fbq('ViewContent', getProductData(context.body))\n }\n}\n","import parseContext from './lib/parse-context'\nimport watchAppRoutes from './lib/watch-app-routes'\nimport watchShoppingCart from './lib/watch-shopping-cart'\n\nexport default (options = {}) => {\n if (typeof window.fbq === 'function') {\n const track = (evName, data = {}, isCustomEv = false) => {\n if (options.debug) {\n console.log('fbq', evName, data)\n }\n window.fbq(isCustomEv ? 'trackCustom' : 'track', evName, data)\n }\n\n parseContext(track)\n watchAppRoutes(track, options)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default (fbq, options) => {\n const router = window.storefrontApp && window.storefrontApp.router\n if (router) {\n let isCartSent, isCheckoutSent, isPurchaseSent, order\n const orderJson = decodeURIComponent(params.json)\n if (orderJson) {\n try { \n order = JSON.parse(orderJson)\n } catch (e) {\n }\n }\n\n const getPurchaseData = () => {\n const { amount } = order || window.storefrontApp\n const data = {\n value: (\n (amount && amount.total) ||\n (ecomCart.data && ecomCart.data.subtotal) ||\n 0\n ),\n currency,\n contents: [],\n content_type: 'product'\n }\n if (ecomCart.data && Array.isArray(ecomCart.data.items)) {\n ecomCart.data.items.forEach(({ sku, quantity }) => {\n data.contents.push({ id: sku, quantity })\n })\n }\n return data\n }\n\n const emitCheckout = (step, option) => {\n const purchaseData = getPurchaseData()\n const customData = {\n ...purchaseData,\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\n fbq('InitiateCheckout', purchaseData)\n fbq('Checkout', customData, true)\n isCartSent = true\n } else if (!isCheckoutSent) {\n fbq('CheckoutOption', customData, true)\n isCheckoutSent = true\n }\n }\n\n const emitPurchase = orderId => {\n if (!isPurchaseSent && options.disablePurchase !== true) {\n fbq('Purchase', {\n ...getPurchaseData(),\n order_id: orderId\n })\n isPurchaseSent = true\n }\n }\n\n const addRouteToData = ({ name, params }) => {\n switch (name) {\n case 'cart':\n emitCheckout(1, 'Review Cart')\n break\n case 'checkout':\n emitCheckout(2, 'Confirm Purchase')\n break\n case 'confirmation':\n emitPurchase(params.id)\n break\n }\n }\n\n if (router.currentRoute) {\n addRouteToData(router.currentRoute)\n }\n router.afterEach(addRouteToData)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { getProductData } from './common'\n\nexport default fbq => {\n ecomCart.on('addItem', ({ item }) => {\n fbq('AddToCart', getProductData(item))\n })\n}\n"],"sourceRoot":""}

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ecomplus/shopping-cart"),require("@ecomplus/utils")):"function"==typeof define&&define.amd?define([,],t):"object"==typeof exports?exports.widgetFbPixel=t(require("@ecomplus/shopping-cart"),require("@ecomplus/utils")):e.widgetFbPixel=t(e.ecomCart,e.ecomUtils)}(window,(function(e,t){return function(e){var t={};function o(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/assets/vendor/",o(o.s=2)}([function(t,o){t.exports=e},function(e,o){e.exports=t},function(e,t,o){"use strict";o.r(t);var r=o(1);const n=r.$ecomConfig.get("currency")||"BRL",c=e=>{const t={currency:n,content_ids:[e.sku],content_name:e.name,value:Object(r.price)(e),content_type:"product"};return e.categories&&e.categories.length&&(t.content_category=e.category_tree||e.categories[0].name),t};var u=o(0),a=o.n(u);t.default=(e={})=>{if("function"==typeof window.fbq){const o=(t,o={},r=!1)=>{e.debug&&console.log("fbq",t,o),window.fbq(r?"trackCustom":"track",t,o)};(e=>{const t=window.storefront&&window.storefront.context;t&&"products"===t.resource&&e("ViewContent",c(t.body))})(o),((e,t)=>{const o=window.storefrontApp&&window.storefrontApp.router;if(o){let r,c,u;const i=()=>{const{amount:e}=window.storefrontApp,t={value:e&&e.total||a.a.data&&a.a.data.subtotal||0,currency:n,contents:[],content_type:"product"};return a.a.data&&Array.isArray(a.a.data.items)&&a.a.data.items.forEach(({sku:e,quantity:o})=>{t.contents.push({id:e,quantity:o})}),t},s=(t,o)=>{const n=i(),u={...n,checkout_step:t,checkout_option:o};t<=1||!r?(e("InitiateCheckout",n),e("Checkout",u,!0),r=!0):c||(e("CheckoutOption",u,!0),c=!0)},f=o=>{u||!0===t.disablePurchase||(e("Purchase",{...i(),order_id:o}),u=!0)},d=({name:e,params:t})=>{switch(e){case"cart":s(1,"Review Cart");break;case"checkout":s(2,"Confirm Purchase");break;case"confirmation":f(t.id)}};o.currentRoute&&d(o.currentRoute),o.afterEach(d)}})(o,e),t=o,a.a.on("addItem",({item:e})=>{t("AddToCart",c(e))})}var t}}]).default}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ecomplus/shopping-cart"),require("@ecomplus/utils")):"function"==typeof define&&define.amd?define([,],t):"object"==typeof exports?exports.widgetFbPixel=t(require("@ecomplus/shopping-cart"),require("@ecomplus/utils")):e.widgetFbPixel=t(e.ecomCart,e.ecomUtils)}(window,(function(e,t){return function(e){var t={};function o(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/assets/vendor/",o(o.s=2)}([function(t,o){t.exports=e},function(e,o){e.exports=t},function(e,t,o){"use strict";o.r(t);var r=o(1);const n=r.$ecomConfig.get("currency")||"BRL",c=e=>{const t={currency:n,content_ids:[e.sku],content_name:e.name,value:Object(r.price)(e),content_type:"product"};return e.categories&&e.categories.length&&(t.content_category=e.category_tree||e.categories[0].name),t};var u=o(0),a=o.n(u);t.default=(e={})=>{if("function"==typeof window.fbq){const o=(t,o={},r=!1)=>{e.debug&&console.log("fbq",t,o),window.fbq(r?"trackCustom":"track",t,o)};(e=>{const t=window.storefront&&window.storefront.context;t&&"products"===t.resource&&e("ViewContent",c(t.body))})(o),((e,t)=>{const o=window.storefrontApp&&window.storefrontApp.router;if(o){let r,c,u,i;const s=decodeURIComponent(params.json);if(s)try{i=JSON.parse(s)}catch(e){}const f=()=>{const{amount:e}=i||window.storefrontApp,t={value:e&&e.total||a.a.data&&a.a.data.subtotal||0,currency:n,contents:[],content_type:"product"};return a.a.data&&Array.isArray(a.a.data.items)&&a.a.data.items.forEach(({sku:e,quantity:o})=>{t.contents.push({id:e,quantity:o})}),t},d=(t,o)=>{const n=f(),u={...n,checkout_step:t,checkout_option:o};t<=1||!r?(e("InitiateCheckout",n),e("Checkout",u,!0),r=!0):c||(e("CheckoutOption",u,!0),c=!0)},p=o=>{u||!0===t.disablePurchase||(e("Purchase",{...f(),order_id:o}),u=!0)},l=({name:e,params:t})=>{switch(e){case"cart":d(1,"Review Cart");break;case"checkout":d(2,"Confirm Purchase");break;case"confirmation":p(t.id)}};o.currentRoute&&l(o.currentRoute),o.afterEach(l)}})(o,e),t=o,a.a.on("addItem",({item:e})=>{t("AddToCart",c(e))})}var t}}]).default}));
//# sourceMappingURL=widget-fb-pixel.min.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["webpack://widgetFbPixel/webpack/universalModuleDefinition","webpack://widgetFbPixel/webpack/bootstrap","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/shopping-cart\",\"commonjs2\":\"@ecomplus/shopping-cart\",\"root\":\"ecomCart\"}","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/utils\",\"commonjs2\":\"@ecomplus/utils\",\"root\":\"ecomUtils\"}","webpack://widgetFbPixel/./src/lib/common.js","webpack://widgetFbPixel/./src/lib/parse-context.js","webpack://widgetFbPixel/./src/index.js","webpack://widgetFbPixel/./src/lib/watch-app-routes.js","webpack://widgetFbPixel/./src/lib/watch-shopping-cart.js"],"names":["root","factory","exports","module","require","define","amd","window","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","currency","$ecomConfig","getProductData","body","data","content_ids","sku","content_name","price","content_type","categories","length","content_category","category_tree","fbq","options","track","evName","isCustomEv","debug","console","log","context","storefront","resource","parseContext","router","storefrontApp","isCartSent","isCheckoutSent","isPurchaseSent","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","disablePurchase","order_id","addRouteToData","params","currentRoute","afterEach","watchAppRoutes","on","item"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,2BAA4BA,QAAQ,oBAC5C,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,GAAKJ,GACa,iBAAZC,QACdA,QAAuB,cAAID,EAAQG,QAAQ,2BAA4BA,QAAQ,oBAE/EJ,EAAoB,cAAIC,EAAQD,EAAe,SAAGA,EAAgB,WARpE,CASGO,QAAQ,SAASC,EAAgCC,GACpD,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUV,QAGnC,IAAIC,EAASO,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHZ,QAAS,IAUV,OANAa,EAAQH,GAAUI,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASS,GAG/DR,EAAOW,GAAI,EAGJX,EAAOD,QA0Df,OArDAS,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASjB,EAASkB,EAAMC,GAC3CV,EAAoBW,EAAEpB,EAASkB,IAClCG,OAAOC,eAAetB,EAASkB,EAAM,CAAEK,YAAY,EAAMC,IA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WAAY,IACXiB,IACHuB,SAAUF,IAEZtB,GAAiB,IAIfyB,EAAiB,EAAGhF,OAAMiF,aAC9B,OAAQjF,GACN,IAAK,OACHqE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAaK,EAAOb,MAKtBjB,EAAO+B,cACTF,EAAe7B,EAAO+B,cAExB/B,EAAOgC,UAAUH,KD1DjBI,CAAe3C,EAAOD,GEXXD,EFYOE,EEXpBkB,IAAS0B,GAAG,UAAW,EAAGC,WACxB/C,EAAI,YAAaZ,EAAe2D,MAFrB/C,U","file":"widget-fb-pixel.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@ecomplus/shopping-cart\"), require(\"@ecomplus/utils\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([, ], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"widgetFbPixel\"] = factory(require(\"@ecomplus/shopping-cart\"), require(\"@ecomplus/utils\"));\n\telse\n\t\troot[\"widgetFbPixel\"] = factory(root[\"ecomCart\"], root[\"ecomUtils\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__1__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/assets/vendor/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","import { $ecomConfig, price } from '@ecomplus/utils'\n\nexport const currency = $ecomConfig.get('currency') || 'BRL'\n\nexport const getProductData = body => {\n const data = {\n currency,\n content_ids: [body.sku],\n content_name: body.name,\n value: price(body),\n content_type: 'product'\n }\n if (body.categories && body.categories.length) {\n data.content_category = body.category_tree || body.categories[0].name\n }\n return data\n}\n","import { getProductData } from './common'\n\nexport default fbq => {\n const context = window.storefront && window.storefront.context\n if (context && context.resource === 'products') {\n fbq('ViewContent', getProductData(context.body))\n }\n}\n","import parseContext from './lib/parse-context'\nimport watchAppRoutes from './lib/watch-app-routes'\nimport watchShoppingCart from './lib/watch-shopping-cart'\n\nexport default (options = {}) => {\n if (typeof window.fbq === 'function') {\n const track = (evName, data = {}, isCustomEv = false) => {\n if (options.debug) {\n console.log('fbq', evName, data)\n }\n window.fbq(isCustomEv ? 'trackCustom' : 'track', evName, data)\n }\n\n parseContext(track)\n watchAppRoutes(track, options)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default (fbq, options) => {\n const router = window.storefrontApp && window.storefrontApp.router\n if (router) {\n let isCartSent, isCheckoutSent, isPurchaseSent\n\n const getPurchaseData = () => {\n const { amount } = window.storefrontApp\n const data = {\n value: (\n (amount && amount.total) ||\n (ecomCart.data && ecomCart.data.subtotal) ||\n 0\n ),\n currency,\n contents: [],\n content_type: 'product'\n }\n if (ecomCart.data && Array.isArray(ecomCart.data.items)) {\n ecomCart.data.items.forEach(({ sku, quantity }) => {\n data.contents.push({ id: sku, quantity })\n })\n }\n return data\n }\n\n const emitCheckout = (step, option) => {\n const purchaseData = getPurchaseData()\n const customData = {\n ...purchaseData,\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\n fbq('InitiateCheckout', purchaseData)\n fbq('Checkout', customData, true)\n isCartSent = true\n } else if (!isCheckoutSent) {\n fbq('CheckoutOption', customData, true)\n isCheckoutSent = true\n }\n }\n\n const emitPurchase = orderId => {\n if (!isPurchaseSent && options.disablePurchase !== true) {\n fbq('Purchase', {\n ...getPurchaseData(),\n order_id: orderId\n })\n isPurchaseSent = true\n }\n }\n\n const addRouteToData = ({ name, params }) => {\n switch (name) {\n case 'cart':\n emitCheckout(1, 'Review Cart')\n break\n case 'checkout':\n emitCheckout(2, 'Confirm Purchase')\n break\n case 'confirmation':\n emitPurchase(params.id)\n break\n }\n }\n\n if (router.currentRoute) {\n addRouteToData(router.currentRoute)\n }\n router.afterEach(addRouteToData)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { getProductData } from './common'\n\nexport default fbq => {\n ecomCart.on('addItem', ({ item }) => {\n fbq('AddToCart', getProductData(item))\n })\n}\n"],"sourceRoot":""}
{"version":3,"sources":["webpack://widgetFbPixel/webpack/universalModuleDefinition","webpack://widgetFbPixel/webpack/bootstrap","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/shopping-cart\",\"commonjs2\":\"@ecomplus/shopping-cart\",\"root\":\"ecomCart\"}","webpack://widgetFbPixel/external {\"commonjs\":\"@ecomplus/utils\",\"commonjs2\":\"@ecomplus/utils\",\"root\":\"ecomUtils\"}","webpack://widgetFbPixel/./src/lib/common.js","webpack://widgetFbPixel/./src/lib/parse-context.js","webpack://widgetFbPixel/./src/index.js","webpack://widgetFbPixel/./src/lib/watch-app-routes.js","webpack://widgetFbPixel/./src/lib/watch-shopping-cart.js"],"names":["root","factory","exports","module","require","define","amd","window","__WEBPACK_EXTERNAL_MODULE__0__","__WEBPACK_EXTERNAL_MODULE__1__","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","currency","$ecomConfig","getProductData","body","data","content_ids","sku","content_name","price","content_type","categories","length","content_category","category_tree","fbq","options","track","evName","isCustomEv","debug","console","log","context","storefront","resource","parseContext","router","storefrontApp","isCartSent","isCheckoutSent","isPurchaseSent","order","orderJson","decodeURIComponent","params","json","JSON","parse","e","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","disablePurchase","order_id","addRouteToData","currentRoute","afterEach","watchAppRoutes","on","item"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,2BAA4BA,QAAQ,oBAC5C,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,CAAC,GAAKJ,GACa,iBAAZC,QACdA,QAAuB,cAAID,EAAQG,QAAQ,2BAA4BA,QAAQ,oBAE/EJ,EAAoB,cAAIC,EAAQD,EAAe,SAAGA,EAAgB,WARpE,CASGO,QAAQ,SAASC,EAAgCC,GACpD,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUV,QAGnC,IAAIC,EAASO,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHZ,QAAS,IAUV,OANAa,EAAQH,GAAUI,KAAKb,EAAOD,QAASC,EAAQA,EAAOD,QAASS,GAG/DR,EAAOW,GAAI,EAGJX,EAAOD,QA0Df,OArDAS,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASjB,EAASkB,EAAMC,GAC3CV,EAAoBW,EAAEpB,EAASkB,IAClCG,OAAOC,eAAetB,EAASkB,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAASzB,GACX,oBAAX0B,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAetB,EAAS0B,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAetB,EAAS,aAAc,CAAE4B,OAAO,KAQvDnB,EAAoBoB,EAAI,S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,IAAK,OACH6E,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAazB,EAAOiB,MAKtBzB,EAAOsC,cACTD,EAAerC,EAAOsC,cAExBtC,EAAOuC,UAAUF,KDjEjBG,CAAelD,EAAOD,GEXXD,EFYOE,EEXpB0B,IAASyB,GAAG,UAAW,EAAGC,WACxBtD,EAAI,YAAaZ,EAAekE,MAFrBtD,U","file":"widget-fb-pixel.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"@ecomplus/shopping-cart\"), require(\"@ecomplus/utils\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([, ], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"widgetFbPixel\"] = factory(require(\"@ecomplus/shopping-cart\"), require(\"@ecomplus/utils\"));\n\telse\n\t\troot[\"widgetFbPixel\"] = factory(root[\"ecomCart\"], root[\"ecomUtils\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__1__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/assets/vendor/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","module.exports = __WEBPACK_EXTERNAL_MODULE__1__;","import { $ecomConfig, price } from '@ecomplus/utils'\n\nexport const currency = $ecomConfig.get('currency') || 'BRL'\n\nexport const getProductData = body => {\n const data = {\n currency,\n content_ids: [body.sku],\n content_name: body.name,\n value: price(body),\n content_type: 'product'\n }\n if (body.categories && body.categories.length) {\n data.content_category = body.category_tree || body.categories[0].name\n }\n return data\n}\n","import { getProductData } from './common'\n\nexport default fbq => {\n const context = window.storefront && window.storefront.context\n if (context && context.resource === 'products') {\n fbq('ViewContent', getProductData(context.body))\n }\n}\n","import parseContext from './lib/parse-context'\nimport watchAppRoutes from './lib/watch-app-routes'\nimport watchShoppingCart from './lib/watch-shopping-cart'\n\nexport default (options = {}) => {\n if (typeof window.fbq === 'function') {\n const track = (evName, data = {}, isCustomEv = false) => {\n if (options.debug) {\n console.log('fbq', evName, data)\n }\n window.fbq(isCustomEv ? 'trackCustom' : 'track', evName, data)\n }\n\n parseContext(track)\n watchAppRoutes(track, options)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default (fbq, options) => {\n const router = window.storefrontApp && window.storefrontApp.router\n if (router) {\n let isCartSent, isCheckoutSent, isPurchaseSent, order\n const orderJson = decodeURIComponent(params.json)\n if (orderJson) {\n try { \n order = JSON.parse(orderJson)\n } catch (e) {\n }\n }\n\n const getPurchaseData = () => {\n const { amount } = order || window.storefrontApp\n const data = {\n value: (\n (amount && amount.total) ||\n (ecomCart.data && ecomCart.data.subtotal) ||\n 0\n ),\n currency,\n contents: [],\n content_type: 'product'\n }\n if (ecomCart.data && Array.isArray(ecomCart.data.items)) {\n ecomCart.data.items.forEach(({ sku, quantity }) => {\n data.contents.push({ id: sku, quantity })\n })\n }\n return data\n }\n\n const emitCheckout = (step, option) => {\n const purchaseData = getPurchaseData()\n const customData = {\n ...purchaseData,\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\n fbq('InitiateCheckout', purchaseData)\n fbq('Checkout', customData, true)\n isCartSent = true\n } else if (!isCheckoutSent) {\n fbq('CheckoutOption', customData, true)\n isCheckoutSent = true\n }\n }\n\n const emitPurchase = orderId => {\n if (!isPurchaseSent && options.disablePurchase !== true) {\n fbq('Purchase', {\n ...getPurchaseData(),\n order_id: orderId\n })\n isPurchaseSent = true\n }\n }\n\n const addRouteToData = ({ name, params }) => {\n switch (name) {\n case 'cart':\n emitCheckout(1, 'Review Cart')\n break\n case 'checkout':\n emitCheckout(2, 'Confirm Purchase')\n break\n case 'confirmation':\n emitPurchase(params.id)\n break\n }\n }\n\n if (router.currentRoute) {\n addRouteToData(router.currentRoute)\n }\n router.afterEach(addRouteToData)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { getProductData } from './common'\n\nexport default fbq => {\n ecomCart.on('addItem', ({ item }) => {\n fbq('AddToCart', getProductData(item))\n })\n}\n"],"sourceRoot":""}
{
"name": "@ecomplus/widget-fb-pixel",
"version": "1.4.0",
"version": "1.4.1",
"description": "Storefront plugin to handle Facebook Pixel events",

@@ -5,0 +5,0 @@ "main": "dist/widget-fb-pixel.min.js",

@@ -7,6 +7,13 @@ import ecomCart from '@ecomplus/shopping-cart'

if (router) {
let isCartSent, isCheckoutSent, isPurchaseSent
let isCartSent, isCheckoutSent, isPurchaseSent, order
const orderJson = decodeURIComponent(params.json)
if (orderJson) {
try {
order = JSON.parse(orderJson)
} catch (e) {
}
}
const getPurchaseData = () => {
const { amount } = window.storefrontApp
const { amount } = order || window.storefrontApp
const data = {

@@ -13,0 +20,0 @@ value: (