Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-gtag

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-gtag - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

dist/vue-gtag.esm.js

463

dist/vue-gtag.js

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

!function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["vue-gtag"]=e():n["vue-gtag"]=e()}("undefined"!=typeof self?self:this,(function(){return function(n){var e={};function t(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)t.d(o,r,function(e){return n[e]}.bind(null,r));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){"use strict";function o(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}t.r(e);var a=function(){};function i(n,e){console.warn("[vue-gtag] "+n),e&&e.stack&&console.warn(e.stack)}function c(n){return n&&"object"===r(n)&&!Array.isArray(n)}var u,f,p=function(){var n,e=_(),t=e.globalObjectName;"undefined"!=typeof window&&(n=window)[t].apply(n,arguments)},d=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var o=_(),r=o.config,a=o.includes;p.apply(void 0,["config",r.id].concat(e)),Array.isArray(a)&&a.forEach((function(n){p.apply(void 0,["config",n.id].concat(e))}))},l=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=_(),o=t.defaultGroupName,r=t.includes,a=e;r&&null==a.send_to&&(a.send_to=r.map((function(n){return n.id})).concat(o)),p("event",n,a)},s=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["page_view"].concat(e))},g=function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["screen_view"].concat(e))},y=function(){var n=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],e=_(),t=e.config;window["ga-disable-".concat(t.id)]=n},v=function(){y(!0)},w={query:p,config:d,event:l,pageview:s,screenview:g,customMap:function(n){d({custom_map:n})},time:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["timing_complete"].concat(e))},exception:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["exception"].concat(e))},linker:function(n){d("linker",n)},purchase:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];l.apply(void 0,["purchase"].concat(e))},set:function(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];p.apply(void 0,["set"].concat(e))},optIn:function(){y(!1)},optOut:v},m=function(){var n=k();n.$gtag=n.prototype.$gtag=w},b=function(n){var e=_(),t=e.onBeforeTrack,o=e.onAfterTrack;n.onReady((function(){n.afterEach((function(n,e){t(n,e),function(n,e){if(n.path!==e.path){var t,o=_(),r=o.pageTrackerTemplate,a=o.pageTrackerScreenviewEnabled,c=o.appName,u=r(n,e);t=u||(a?{app_name:c,screen_name:n.name}:{page_title:n.name,page_path:n.path,page_location:window.location.href}),!a||t.app_name?!a||t.screen_name?a?g(t):s(t):i("To use the screenview, name your routes"):i("To use the screenview, add the appName to the plugin options")}}(n,e),o(n,e)}))}))},h=function(){if("undefined"!=typeof document&&"undefined"!=typeof window){var n,e=_(),t=e.enabled,o=e.globalObjectName,r=e.config,a=r.id,c=r.params,u=e.includes,f=e.pageTrackerEnabled,p=e.onReady,d=e.disableScriptLoad;if(t||v(),null==window[o]&&(window.dataLayer=window.dataLayer||[],window[o]=function(){window.dataLayer.push(arguments)}),window[o]("js",new Date),c?window[o]("config",a,c):window[o]("config",a),Array.isArray(u)&&u.forEach((function(n){n.params?window[o]("config",n.id,n.params):window[o]("config",n.id)})),f&&(n=T())&&b(n),!d){var l="https://www.googletagmanager.com";return function(n,e){return new Promise((function(t,o){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("script");if(a.async=!0,a.src=n,a.charset="utf-8",e){var i=document.createElement("link");i.href=e,i.rel="preconnect",r.appendChild(i)}r.appendChild(a),a.onload=t,a.onerror=o}))}("".concat(l,"/gtag/js?id=").concat(a),l).then((function(){var n=window[o];return"function"==typeof p&&p(n),n})).catch((function(n){return i("Ops! Something happened and gtag.js couldn't be loaded",n),n}))}}},j={pageTrackerTemplate:a,onBeforeTrack:a,onAfterTrack:a,onReady:a,enabled:!0,disableScriptLoad:!1,bootstrap:!0,globalObjectName:"gtag",pageTrackerEnabled:!0,pageTrackerScreenviewEnabled:!1,defaultGroupName:"default",includes:null,config:null},_=function(){return j},O=function(n){return function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),a=1;a<t;a++)r[a-1]=arguments[a];if(!r.length)return e;var i=r.shift();if(c(e)&&c(i)){for(var u in i)c(i[u])?(e[u]||Object.assign(e,o({},u,{})),n(e[u],i[u])):Object.assign(e,o({},u,i[u]));return n.apply(void 0,[e].concat(r))}}(j,n)},k=function(){return u},T=function(){return f};t.d(e,"bootstrap",(function(){return A})),t.d(e,"setOptions",(function(){return S})),t.d(e,"query",(function(){return x})),t.d(e,"config",(function(){return E})),t.d(e,"event",(function(){return N})),t.d(e,"pageview",(function(){return M})),t.d(e,"screenview",(function(){return P})),t.d(e,"customMap",(function(){return L})),t.d(e,"time",(function(){return q})),t.d(e,"exception",(function(){return B})),t.d(e,"linker",(function(){return I})),t.d(e,"purchase",(function(){return R})),t.d(e,"set",(function(){return C})),t.d(e,"optIn",(function(){return G})),t.d(e,"optOut",(function(){return $}));e.default=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2?arguments[2]:void 0;u=n,f=t,O(e),m(),j.bootstrap&&h()};var A=h,S=O,x=w.query,E=w.config,N=w.event,M=w.pageview,P=w.screenview,L=w.customMap,q=w.time,B=w.exception,I=w.linker,R=w.purchase,C=w.set,G=w.optIn,$=w.optOut}])}));
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var noop = function noop() {};
function loadScript(url, domain) {
return new Promise(function (resolve, reject) {
var head = document.head || document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.async = true;
script.src = url;
script.charset = "utf-8";
if (domain) {
var link = document.createElement("link");
link.href = domain;
link.rel = "preconnect";
head.appendChild(link);
}
head.appendChild(script);
script.onload = resolve;
script.onerror = reject;
});
}
function warn(msg, err) {
console.warn("[vue-gtag] " + msg);
if (err && err.stack) {
console.warn(err.stack);
}
}
function isFn(item) {
return typeof item === "function";
}
function isObject(item) {
return item && _typeof(item) === "object" && !Array.isArray(item);
}
function mergeDeep(target) {
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) {
return target;
}
var source = sources.shift();
if (!isObject(target) || !isObject(source)) {
return;
}
for (var key in source) {
if (isObject(source[key])) {
if (!target[key]) {
Object.assign(target, _defineProperty({}, key, {}));
}
mergeDeep(target[key], source[key]);
} else {
Object.assign(target, _defineProperty({}, key, source[key]));
}
}
return mergeDeep.apply(void 0, [target].concat(sources));
}
function query () {
var _window;
var _getOptions = getOptions(),
globalObjectName = _getOptions.globalObjectName;
if (typeof window === "undefined") {
return;
}
(_window = window)[globalObjectName].apply(_window, arguments);
}
var config = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _getOptions = getOptions(),
config = _getOptions.config,
includes = _getOptions.includes;
query.apply(void 0, ["config", config.id].concat(args));
if (Array.isArray(includes)) {
includes.forEach(function (domain) {
query.apply(void 0, ["config", domain.id].concat(args));
});
}
});
var event = (function (name) {
var _params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _getOptions = getOptions(),
defaultGroupName = _getOptions.defaultGroupName,
includes = _getOptions.includes;
var params = _params;
if (includes && params.send_to == null) {
params.send_to = includes.map(function (include) {
return include.id;
}).concat(defaultGroupName);
}
query("event", name, params);
});
var pageview = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
event.apply(void 0, ["page_view"].concat(args));
});
var screenview = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
event.apply(void 0, ["screen_view"].concat(args));
});
var customMap = (function (map) {
config({
custom_map: map
});
});
var time = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
event.apply(void 0, ["timing_complete"].concat(args));
});
var exception = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
event.apply(void 0, ["exception"].concat(args));
});
var linker = (function (params) {
config("linker", params);
});
var purchase = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
event.apply(void 0, ["purchase"].concat(args));
});
var set = (function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
query.apply(void 0, ["set"].concat(args));
});
var disable = (function () {
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var _getOptions = getOptions(),
config = _getOptions.config;
window["ga-disable-".concat(config.id)] = value;
});
var optIn = (function () {
disable(false);
});
var optOut = (function () {
disable(true);
});
var api = {
query: query,
config: config,
event: event,
pageview: pageview,
screenview: screenview,
customMap: customMap,
time: time,
exception: exception,
linker: linker,
purchase: purchase,
set: set,
optIn: optIn,
optOut: optOut
};
var extend = (function () {
var Vue = getVue();
Vue.$gtag = Vue.prototype.$gtag = api;
});
var trackPage = function trackPage(to, from) {
if (to.path === from.path) {
return;
}
var _getOptions = getOptions(),
pageTrackerTemplate = _getOptions.pageTrackerTemplate,
pageTrackerScreenviewEnabled = _getOptions.pageTrackerScreenviewEnabled,
appName = _getOptions.appName;
var template;
var customTemplate = pageTrackerTemplate(to, from);
if (customTemplate) {
template = customTemplate;
} else if (pageTrackerScreenviewEnabled) {
template = {
app_name: appName,
screen_name: to.name
};
} else {
template = {
page_title: to.name,
page_path: to.path,
page_location: window.location.href
};
}
if (pageTrackerScreenviewEnabled && !template.app_name) {
warn("To use the screenview, add the appName to the plugin options");
return;
}
if (pageTrackerScreenviewEnabled && !template.screen_name) {
warn("To use the screenview, name your routes");
return;
}
if (pageTrackerScreenviewEnabled) {
screenview(template);
return;
}
pageview(template);
};
var init = function init(Router) {
var _getOptions2 = getOptions(),
onBeforeTrack = _getOptions2.onBeforeTrack,
onAfterTrack = _getOptions2.onAfterTrack;
/* istanbul ignore next */
Router.onReady(function () {
Router.afterEach(function (to, from) {
onBeforeTrack(to, from);
trackPage(to, from);
onAfterTrack(to, from);
});
});
};
var pageTracker = (function () {
var Router = getRouter();
if (!Router) {
return;
}
init(Router);
});
function _bootstrap () {
if (typeof document === "undefined" || typeof window === "undefined") {
return;
}
var _getOptions = getOptions(),
enabled = _getOptions.enabled,
globalObjectName = _getOptions.globalObjectName,
_getOptions$config = _getOptions.config,
id = _getOptions$config.id,
params = _getOptions$config.params,
includes = _getOptions.includes,
pageTrackerEnabled = _getOptions.pageTrackerEnabled,
onReady = _getOptions.onReady,
disableScriptLoad = _getOptions.disableScriptLoad;
if (!enabled) {
optOut();
}
if (window[globalObjectName] == null) {
window.dataLayer = window.dataLayer || [];
window[globalObjectName] = function () {
window.dataLayer.push(arguments);
};
}
window[globalObjectName]("js", new Date());
if (params) {
window[globalObjectName]("config", id, params);
} else {
window[globalObjectName]("config", id);
}
if (Array.isArray(includes)) {
includes.forEach(function (domain) {
if (domain.params) {
window[globalObjectName]("config", domain.id, domain.params);
} else {
window[globalObjectName]("config", domain.id);
}
});
}
if (pageTrackerEnabled) {
pageTracker();
}
if (disableScriptLoad) {
return;
}
var domain = "https://www.googletagmanager.com";
var resource = "".concat(domain, "/gtag/js?id=").concat(id);
return loadScript(resource, domain).then(function () {
var library = window[globalObjectName];
if (isFn(onReady)) {
onReady(library);
}
return library;
}).catch(function (error) {
warn("Ops! Something happened and gtag.js couldn't be loaded", error);
return error;
});
}
var Vue;
var Router;
var options = {
pageTrackerTemplate: noop,
onBeforeTrack: noop,
onAfterTrack: noop,
onReady: noop,
enabled: true,
disableScriptLoad: false,
bootstrap: true,
globalObjectName: "gtag",
pageTrackerEnabled: true,
pageTrackerScreenviewEnabled: false,
defaultGroupName: "default",
includes: null,
config: null
};
var getOptions = function getOptions() {
return options;
};
var setOptions = function setOptions(_options) {
return mergeDeep(options, _options);
};
var getVue = function getVue() {
return Vue;
};
var getRouter = function getRouter() {
return Router;
};
function install(_Vue) {
var _options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var _Router = arguments.length > 2 ? arguments[2] : undefined;
Vue = _Vue;
Router = _Router;
setOptions(_options);
extend();
if (!options.bootstrap) {
return;
}
_bootstrap();
}
var bootstrap = _bootstrap;
var setOptions$1 = setOptions; // export api for usages outside Vuejs context
var query$1 = api.query;
var config$1 = api.config;
var event$1 = api.event;
var pageview$1 = api.pageview;
var screenview$1 = api.screenview;
var customMap$1 = api.customMap;
var time$1 = api.time;
var exception$1 = api.exception;
var linker$1 = api.linker;
var purchase$1 = api.purchase;
var set$1 = api.set;
var optIn$1 = api.optIn;
var optOut$1 = api.optOut;
exports.bootstrap = bootstrap;
exports.config = config$1;
exports.customMap = customMap$1;
exports.default = install;
exports.event = event$1;
exports.exception = exception$1;
exports.install = install;
exports.linker = linker$1;
exports.optIn = optIn$1;
exports.optOut = optOut$1;
exports.pageview = pageview$1;
exports.purchase = purchase$1;
exports.query = query$1;
exports.screenview = screenview$1;
exports.set = set$1;
exports.setOptions = setOptions$1;
exports.time = time$1;

30

package.json
{
"name": "vue-gtag",
"description": "Global Site Tag (gtag.js) plugin for Vue",
"version": "1.3.1",
"version": "1.4.0",
"author": {

@@ -16,6 +16,8 @@ "name": "Matteo Gabriele",

"commit": "git-cz",
"build": "webpack --mode production",
"dev": "webpack --mode development --watch",
"lint": "eslint src --ext .js",
"lint:fix": "eslint src --ext .js --fix",
"clean": "del-cli dist",
"prebuild": "yarn clean",
"build": "bili",
"dev": "bili --config bili.config.dev.js --watch",
"lint": "eslint --ext .js .",
"lint:fix": "yarn lint --fix",
"test": "jest",

@@ -27,3 +29,3 @@ "test:ci": "jest --coverage --bail --runInBand --verbose=false",

"coverage:lcov": "jest --coverage --coverageReporters=lcov",
"prepublishOnly": "yarn lint && yarn test && webpack --mode production",
"prepublishOnly": "yarn lint && yarn test && yarn build",
"semantic-release": "semantic-release"

@@ -59,3 +61,6 @@ },

],
"main": "dist/vue-gtag.js",
"main": "./dist/vue-gtag.js",
"module": "./dist/vue-gtag.esm.js",
"unpkg": "./dist/vue-gtag.umd.js",
"jsdelivr": "./dist/vue-gtag.umd.js",
"types": "vue-gtag.d.ts",

@@ -75,10 +80,8 @@ "files": [

"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"clean-webpack-plugin": "^3.0.0",
"bili": "^4.8.1",
"commitizen": "^4.0.3",
"compression-webpack-plugin": "^3.0.0",
"cz-conventional-changelog": "^3.0.2",
"del-cli": "^3.0.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.7.0",
"eslint-loader": "^3.0.2",
"eslint-plugin-jest": "^23.0.4",

@@ -91,9 +94,6 @@ "eslint-plugin-prettier": "^3.1.1",

"semantic-release": "^15.13.31",
"terser-webpack-plugin": "^2.2.1",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
"vue-template-compiler": "^2.6.10"
}
}

@@ -13,4 +13,4 @@ <p align="center">

</a>
<a href="https://travis-ci.org/MatteoGabriele/vue-gtag">
<img src="https://badgen.net/travis/MatteoGabriele/vue-gtag/master">
<a href="https://circleci.com/gh/MatteoGabriele/workflows/vue-gtag/tree/master">
<img src="https://badgen.net/circleci/github/MatteoGabriele/vue-gtag/master">
</a>

@@ -17,0 +17,0 @@ <a href="https://codeclimate.com/github/MatteoGabriele/vue-gtag/maintainability">

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc