🚀 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.1.3
to
1.2.0
+11
-0
CHANGELOG.md

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

# [1.2.0](https://github.com/ecomplus/storefront/compare/@ecomplus/widget-fb-pixel@1.1.3...@ecomplus/widget-fb-pixel@1.2.0) (2020-08-07)
### Features
* **fb-pixel:** track default event 'InitiateCheckout' ([f0d4540](https://github.com/ecomplus/storefront/commit/f0d45408c8d3e1530a80eed1f9fb60e34fdf7ad6))
## [1.1.3](https://github.com/ecomplus/storefront/compare/@ecomplus/widget-fb-pixel@1.1.2...@ecomplus/widget-fb-pixel@1.1.3) (2020-06-30)

@@ -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=>{const e=window.storefrontApp&&window.storefrontApp.router;if(e){let o,r,c;const a=()=>{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},i=(e,n)=>{const c={...a(),checkout_step:e,checkout_option:n};e<=1||!o?(t("Checkout",c,!0),o=!0):r||(t("CheckoutOption",c,!0),r=!0)},s=e=>{c||(t("Purchase",{...a(),order_id:e}),c=!0)},d=({name:t,params:e})=>{switch(t){case"cart":i(1,"Review Cart");break;case"checkout":i(2,"Confirm Purchase");break;case"confirmation":s(e.id)}};e.currentRoute&&d(e.currentRoute),e.afterEach(d)}})(o),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=>{const e=window.storefrontApp&&window.storefrontApp.router;if(e){let o,n,c;const a=()=>{const{amount:t}=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},i=(e,r)=>{const c=a(),u={...c,checkout_step:e,checkout_option:r};e<=1||!o?(t("InitiateCheckout",c),t("Checkout",u,!0),o=!0):n||(t("CheckoutOption",u,!0),n=!0)},s=e=>{c||(t("Purchase",{...a(),order_id:e}),c=!0)},d=({name:t,params:e})=>{switch(t){case"cart":i(1,"Review Cart");break;case"checkout":i(2,"Confirm Purchase");break;case"confirmation":s(e.id)}};e.currentRoute&&d(e.currentRoute),e.afterEach(d)}})(o),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","customData","checkout_step","checkout_option","emitPurchase","orderId","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,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,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HC,IACVhB,EAAI,iBAAkBkC,GAAY,GAClClB,GAAiB,IAIfqB,EAAeC,IACdrB,IACHjB,EAAI,WAAY,IACXkB,IACHqB,SAAUD,IAEZrB,GAAiB,IAIfuB,EAAiB,EAAGhF,OAAMiF,aAC9B,OAAQjF,GACN,IAAK,OACHuE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHM,EAAaI,EAAOX,MAKtBjB,EAAO6B,cACTF,EAAe3B,EAAO6B,cAExB7B,EAAO8B,UAAUH,KDxDjBI,CAAezC,GEXJH,EFYOG,EEXpBkB,IAASwB,GAAG,UAAW,EAAGC,WACxB9C,EAAI,YAAaZ,EAAe0D,MAFrB9C,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)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default fbq => {\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 customData = {\n ...getPurchaseData(),\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\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) {\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","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","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,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,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iBAAkBmC,GAAY,GAClCnB,GAAiB,IAIfsB,EAAeC,IACdtB,IACHjB,EAAI,WAAY,IACXkB,IACHsB,SAAUD,IAEZtB,GAAiB,IAIfwB,EAAiB,EAAGjF,OAAMkF,aAC9B,OAAQlF,GACN,IAAK,OACHuE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAaI,EAAOZ,MAKtBjB,EAAO8B,cACTF,EAAe5B,EAAO8B,cAExB9B,EAAO+B,UAAUH,KD1DjBI,CAAe1C,GEXJH,EFYOG,EEXpBkB,IAASyB,GAAG,UAAW,EAAGC,WACxB/C,EAAI,YAAaZ,EAAe2D,MAFrB/C,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)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default fbq => {\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) {\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=>{const t=window.storefrontApp&&window.storefrontApp.router;if(t){let o,r,c;const u=()=>{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},i=(t,n)=>{const c={...u(),checkout_step:t,checkout_option:n};t<=1||!o?(e("Checkout",c,!0),o=!0):r||(e("CheckoutOption",c,!0),r=!0)},s=t=>{c||(e("Purchase",{...u(),order_id:t}),c=!0)},f=({name:e,params:t})=>{switch(e){case"cart":i(1,"Review Cart");break;case"checkout":i(2,"Confirm Purchase");break;case"confirmation":s(t.id)}};t.currentRoute&&f(t.currentRoute),t.afterEach(f)}})(o),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),i=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=>{const t=window.storefrontApp&&window.storefrontApp.router;if(t){let o,r,c;const u=()=>{const{amount:e}=window.storefrontApp,t={value:e&&e.total||i.a.data&&i.a.data.subtotal||0,currency:n,contents:[],content_type:"product"};return i.a.data&&Array.isArray(i.a.data.items)&&i.a.data.items.forEach(({sku:e,quantity:o})=>{t.contents.push({id:e,quantity:o})}),t},a=(t,n)=>{const c=u(),i={...c,checkout_step:t,checkout_option:n};t<=1||!o?(e("InitiateCheckout",c),e("Checkout",i,!0),o=!0):r||(e("CheckoutOption",i,!0),r=!0)},s=t=>{c||(e("Purchase",{...u(),order_id:t}),c=!0)},f=({name:e,params:t})=>{switch(e){case"cart":a(1,"Review Cart");break;case"checkout":a(2,"Confirm Purchase");break;case"confirmation":s(t.id)}};t.currentRoute&&f(t.currentRoute),t.afterEach(f)}})(o),t=o,i.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","customData","checkout_step","checkout_option","emitPurchase","orderId","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,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MAAQiC,MAAMC,QAAQJ,IAAS9B,KAAKmC,QAC/CL,IAAS9B,KAAKmC,MAAMC,QAAQ,EAAGlC,MAAKmC,eAClCrC,EAAKgC,SAASM,KAAK,CAAEC,GAAIrC,EAAKmC,eAG3BrC,GAGHwC,EAAe,CAACC,EAAMC,KAC1B,MAAMC,EAAa,IACdhB,IACHiB,cAAeH,EACfI,gBAAiBH,GAEfD,GAAQ,IAAMjB,GAChBd,EAAI,WAAYiC,GAAY,GAC5BnB,GAAa,GACHC,IACVf,EAAI,iBAAkBiC,GAAY,GAClClB,GAAiB,IAIfqB,EAAeC,IACdrB,IACHhB,EAAI,WAAY,IACXiB,IACHqB,SAAUD,IAEZrB,GAAiB,IAIfuB,EAAiB,EAAG9E,OAAM+E,aAC9B,OAAQ/E,GACN,IAAK,OACHqE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHM,EAAaI,EAAOX,MAKtBjB,EAAO6B,cACTF,EAAe3B,EAAO6B,cAExB7B,EAAO8B,UAAUH,KDxDjBI,CAAezC,GEXJF,EFYOE,EEXpBkB,IAASwB,GAAG,UAAW,EAAGC,WACxB7C,EAAI,YAAaZ,EAAeyD,MAFrB7C,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)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default fbq => {\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 customData = {\n ...getPurchaseData(),\n checkout_step: step,\n checkout_option: option\n }\n if (step <= 1 || !isCartSent) {\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) {\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","getPurchaseData","amount","total","ecomCart","subtotal","contents","Array","isArray","items","forEach","quantity","push","id","emitCheckout","step","option","purchaseData","customData","checkout_step","checkout_option","emitPurchase","orderId","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,GAC3C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AAiB,IAIfsB,EAAeC,IACdtB,IACHhB,EAAI,WAAY,IACXiB,IACHsB,SAAUD,IAEZtB,GAAiB,IAIfwB,EAAiB,EAAG/E,OAAMgF,aAC9B,OAAQhF,GACN,IAAK,OACHqE,EAAa,EAAG,eAChB,MACF,IAAK,WACHA,EAAa,EAAG,oBAChB,MACF,IAAK,eACHO,EAAaI,EAAOZ,MAKtBjB,EAAO8B,cACTF,EAAe5B,EAAO8B,cAExB9B,EAAO+B,UAAUH,KD1DjBI,CAAe1C,GEXJF,EFYOE,EEXpBkB,IAASyB,GAAG,UAAW,EAAGC,WACxB9C,EAAI,YAAaZ,EAAe0D,MAFrB9C,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)\n watchShoppingCart(track)\n }\n}\n","import ecomCart from '@ecomplus/shopping-cart'\nimport { currency } from './common'\n\nexport default fbq => {\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) {\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.1.3",
"version": "1.2.0",
"description": "Storefront plugin to handle Facebook Pixel events",

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

@@ -30,4 +30,5 @@ import ecomCart from '@ecomplus/shopping-cart'

const emitCheckout = (step, option) => {
const purchaseData = getPurchaseData()
const customData = {
...getPurchaseData(),
...purchaseData,
checkout_step: step,

@@ -37,2 +38,3 @@ checkout_option: option

if (step <= 1 || !isCartSent) {
fbq('InitiateCheckout', purchaseData)
fbq('Checkout', customData, true)

@@ -39,0 +41,0 @@ isCartSent = true