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

workbox-google-analytics

Package Overview
Dependencies
Maintainers
4
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-google-analytics - npm Package Compare versions

Comparing version 4.0.0-beta.2 to 4.0.0-rc.0

29

build/workbox-offline-ga.dev.js

@@ -6,3 +6,3 @@ this.workbox = this.workbox || {};

try {
self['workbox:google-analytics:4.0.0-beta.2'] && _();
self['workbox:google-analytics:4.0.0-rc.0'] && _();
} catch (e) {} // eslint-disable-line

@@ -24,2 +24,3 @@

const GTAG_JS_PATH = '/gtag/js';
const GTM_JS_PATH = '/gtm.js';
// endpoints. Most of the time the default path (/collect) is used, but

@@ -66,3 +67,3 @@ // occasionally an experimental endpoint is used when testing new features,

// either the URL query string (for GET requests) or the POST body.
const params = request.method === 'POST' ? new URLSearchParams((await request.text())) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
const params = request.method === 'POST' ? new URLSearchParams((await request.clone().text())) : url.searchParams; // Calculate the qt param, accounting for the fact that an existing
// qt param may be present and should be updated rather than replaced.

@@ -85,3 +86,3 @@

config.hitFilter.call(null, params);
} // Retry the fetch. Ignore URL search params form the URL as they're
} // Retry the fetch. Ignore URL search params from the URL as they're
// now in the post body.

@@ -180,2 +181,22 @@

/**
* Creates a route with a network first strategy for the gtm.js script.
*
* @param {string} cacheName
* @return {Route} The created route.
*
* @private
*/
const createGtmJsRoute = cacheName => {
const match = ({
url
}) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH;
const handler = new NetworkFirst_mjs.NetworkFirst({
cacheName
});
return new Route_mjs.Route(match, handler, 'GET');
};
/**
* @param {Object=} [options]

@@ -204,3 +225,3 @@ * @param {Object} [options.cacheName] The cache name to store and retrieve

});
const routes = [createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(queuePlugin)];
const routes = [createGtmJsRoute(cacheName), createAnalyticsJsRoute(cacheName), createGtagJsRoute(cacheName), ...createCollectRoutes(queuePlugin)];
const router = new Router_mjs.Router();

@@ -207,0 +228,0 @@

2

build/workbox-offline-ga.prod.js

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

this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(t,e,o,n,c,a,r){"use strict";try{self["workbox:google-analytics:4.0.0-beta.2"]&&_()}catch(t){}const w=/^\/(\w+\/)?collect/;return t.initialize=((t={})=>{const s=o.cacheNames.getGoogleAnalyticsName(t.cacheName),i=new e.Plugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:(t=>async({queue:e})=>{let o;for(;o=await e.shiftRequest();){const{request:n,timestamp:c}=o,a=new URL(n.url);try{const r="POST"===n.method?new URLSearchParams(await n.text()):a.searchParams,w=c-(Number(r.get("qt"))||0),s=Date.now()-w;if(r.set("qt",s),t.parameterOverrides)for(const e of Object.keys(t.parameterOverrides)){const o=t.parameterOverrides[e];r.set(e,o)}"function"==typeof t.hitFilter&&t.hitFilter.call(null,r),await fetch(new Request(a.origin+a.pathname,{body:r.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(t){return void await e.unshiftRequest(o)}}})(t)}),l=[(t=>{const e=new a.NetworkFirst({cacheName:t});return new n.Route(({url:t})=>"www.google-analytics.com"===t.hostname&&"/analytics.js"===t.pathname,e,"GET")})(s),(t=>{const e=new a.NetworkFirst({cacheName:t});return new n.Route(({url:t})=>"www.googletagmanager.com"===t.hostname&&"/gtag/js"===t.pathname,e,"GET")})(s),...(t=>{const e=({url:t})=>"www.google-analytics.com"===t.hostname&&w.test(t.pathname),o=new r.NetworkOnly({plugins:[t]});return[new n.Route(e,o,"GET"),new n.Route(e,o,"POST")]})(i)],u=new c.Router;for(const t of l)u.registerRoute(t);u.addFetchListener()}),t}({},workbox.backgroundSync,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies);
this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(e,t,o,n,a,c,r){"use strict";try{self["workbox:google-analytics:4.0.0-rc.0"]&&_()}catch(e){}const w=/^\/(\w+\/)?collect/;return e.initialize=((e={})=>{const s=o.cacheNames.getGoogleAnalyticsName(e.cacheName),i=new t.Plugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:(e=>async({queue:t})=>{let o;for(;o=await t.shiftRequest();){const{request:n,timestamp:a}=o,c=new URL(n.url);try{const r="POST"===n.method?new URLSearchParams(await n.clone().text()):c.searchParams,w=a-(Number(r.get("qt"))||0),s=Date.now()-w;if(r.set("qt",s),e.parameterOverrides)for(const t of Object.keys(e.parameterOverrides)){const o=e.parameterOverrides[t];r.set(t,o)}"function"==typeof e.hitFilter&&e.hitFilter.call(null,r),await fetch(new Request(c.origin+c.pathname,{body:r.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(e){return void await t.unshiftRequest(o)}}})(e)}),l=[(e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtm.js"===e.pathname,t,"GET")})(s),(e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.google-analytics.com"===e.hostname&&"/analytics.js"===e.pathname,t,"GET")})(s),(e=>{const t=new c.NetworkFirst({cacheName:e});return new n.Route(({url:e})=>"www.googletagmanager.com"===e.hostname&&"/gtag/js"===e.pathname,t,"GET")})(s),...(e=>{const t=({url:e})=>"www.google-analytics.com"===e.hostname&&w.test(e.pathname),o=new r.NetworkOnly({plugins:[e]});return[new n.Route(t,o,"GET"),new n.Route(t,o,"POST")]})(i)],u=new a.Router;for(const e of l)u.registerRoute(e);u.addFetchListener()}),e}({},workbox.backgroundSync,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies);
//# sourceMappingURL=workbox-offline-ga.prod.js.map
{
"name": "workbox-google-analytics",
"version": "4.0.0-beta.2",
"version": "4.0.0-rc.0",
"license": "MIT",

@@ -32,8 +32,8 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-background-sync": "^4.0.0-beta.2",
"workbox-core": "^4.0.0-beta.2",
"workbox-routing": "^4.0.0-beta.2",
"workbox-strategies": "^4.0.0-beta.2"
"workbox-background-sync": "^4.0.0-rc.0",
"workbox-core": "^4.0.0-rc.0",
"workbox-routing": "^4.0.0-rc.0",
"workbox-strategies": "^4.0.0-rc.0"
},
"gitHead": "a0baa6ac838e1bff9a140ccbe2e78551d9605466"
"gitHead": "895940b985bea024e086713c319af216f7c5ee95"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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