workbox-google-analytics
Advanced tools
Comparing version 6.3.0 to 6.4.0
"use strict"; | ||
// @ts-ignore | ||
try { | ||
self['workbox:google-analytics:6.2.4'] && _(); | ||
self['workbox:google-analytics:6.3.0'] && _(); | ||
} | ||
catch (e) { } |
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:google-analytics:6.2.4'] && _(); | ||
self['workbox:google-analytics:6.3.0'] && _(); | ||
} catch (e) {} | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(t,e,o,n,r,c,a,w,s){"use strict";try{self["workbox:google-analytics:6.2.4"]&&_()}catch(t){}const i="www.google-analytics.com",l="www.googletagmanager.com",u=/^\/(\w+\/)?collect/,m=t=>{const e=({url:t})=>t.hostname===i&&u.test(t.pathname),o=new s.NetworkOnly({plugins:[t]});return[new c.Route(e,o,"GET"),new c.Route(e,o,"POST")]},g=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===i&&"/analytics.js"===t.pathname),e,"GET")},h=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===l&&"/gtag/js"===t.pathname),e,"GET")},b=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===l&&"/gtm.js"===t.pathname),e,"GET")};return t.initialize=(t={})=>{const n=o.cacheNames.getGoogleAnalyticsName(t.cacheName),r=new e.BackgroundSyncPlugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:(c=t,async({queue:t})=>{let e;for(;e=await t.shiftRequest();){const{request:o,timestamp:n}=e,r=new URL(o.url);try{const t="POST"===o.method?new URLSearchParams(await o.clone().text()):r.searchParams,e=n-(Number(t.get("qt"))||0),a=Date.now()-e;if(t.set("qt",String(a)),c.parameterOverrides)for(const e of Object.keys(c.parameterOverrides)){const o=c.parameterOverrides[e];t.set(e,o)}"function"==typeof c.hitFilter&&c.hitFilter.call(null,t),await fetch(new Request(r.origin+r.pathname,{body:t.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(o){throw await t.unshiftRequest(e),o}}})});var c;const w=[b(n),g(n),h(n),...m(r)],s=new a.Router;for(const t of w)s.registerRoute(t);s.addFetchListener()},t}({},workbox.backgroundSync,workbox.core._private,workbox.core._private,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies); | ||
this.workbox=this.workbox||{},this.workbox.googleAnalytics=function(t,e,o,n,r,c,a,w,s){"use strict";try{self["workbox:google-analytics:6.3.0"]&&_()}catch(t){}const i="www.google-analytics.com",l="www.googletagmanager.com",u=/^\/(\w+\/)?collect/,m=t=>{const e=({url:t})=>t.hostname===i&&u.test(t.pathname),o=new s.NetworkOnly({plugins:[t]});return[new c.Route(e,o,"GET"),new c.Route(e,o,"POST")]},g=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===i&&"/analytics.js"===t.pathname),e,"GET")},h=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===l&&"/gtag/js"===t.pathname),e,"GET")},b=t=>{const e=new w.NetworkFirst({cacheName:t});return new c.Route((({url:t})=>t.hostname===l&&"/gtm.js"===t.pathname),e,"GET")};return t.initialize=(t={})=>{const n=o.cacheNames.getGoogleAnalyticsName(t.cacheName),r=new e.BackgroundSyncPlugin("workbox-google-analytics",{maxRetentionTime:2880,onSync:(c=t,async({queue:t})=>{let e;for(;e=await t.shiftRequest();){const{request:o,timestamp:n}=e,r=new URL(o.url);try{const t="POST"===o.method?new URLSearchParams(await o.clone().text()):r.searchParams,e=n-(Number(t.get("qt"))||0),a=Date.now()-e;if(t.set("qt",String(a)),c.parameterOverrides)for(const e of Object.keys(c.parameterOverrides)){const o=c.parameterOverrides[e];t.set(e,o)}"function"==typeof c.hitFilter&&c.hitFilter.call(null,t),await fetch(new Request(r.origin+r.pathname,{body:t.toString(),method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"text/plain"}}))}catch(o){throw await t.unshiftRequest(e),o}}})});var c;const w=[b(n),g(n),h(n),...m(r)],s=new a.Router;for(const t of w)s.registerRoute(t);s.addFetchListener()},t}({},workbox.backgroundSync,workbox.core._private,workbox.core._private,workbox.core._private,workbox.routing,workbox.routing,workbox.strategies,workbox.strategies); | ||
//# sourceMappingURL=workbox-offline-ga.prod.js.map |
@@ -6,2 +6,2 @@ import { initialize } from './initialize.js'; | ||
*/ | ||
export { initialize, }; | ||
export { initialize }; |
@@ -13,2 +13,2 @@ /* | ||
*/ | ||
export { initialize, }; | ||
export { initialize }; |
@@ -26,2 +26,2 @@ import './_version.js'; | ||
declare const initialize: (options?: GoogleAnalyticsInitializeOptions) => void; | ||
export { initialize, }; | ||
export { initialize }; |
@@ -38,5 +38,5 @@ /* | ||
// either the URL query string (for GET requests) or the POST body. | ||
const params = request.method === 'POST' ? | ||
new URLSearchParams(await request.clone().text()) : | ||
url.searchParams; | ||
const params = request.method === 'POST' | ||
? new URLSearchParams(await request.clone().text()) | ||
: url.searchParams; | ||
// Calculate the qt param, accounting for the fact that an existing | ||
@@ -69,4 +69,3 @@ // qt param may be present and should be updated rather than replaced. | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.log(`Request for '${getFriendlyURL(url.href)}' ` + | ||
`has been replayed`); | ||
logger.log(`Request for '${getFriendlyURL(url.href)}' ` + `has been replayed`); | ||
} | ||
@@ -103,6 +102,3 @@ } | ||
}); | ||
return [ | ||
new Route(match, handler, 'GET'), | ||
new Route(match, handler, 'POST'), | ||
]; | ||
return [new Route(match, handler, 'GET'), new Route(match, handler, 'POST')]; | ||
}; | ||
@@ -132,4 +128,3 @@ /** | ||
const createGtagJsRoute = (cacheName) => { | ||
const match = ({ url }) => url.hostname === GTM_HOST && | ||
url.pathname === GTAG_JS_PATH; | ||
const match = ({ url }) => url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH; | ||
const handler = new NetworkFirst({ cacheName }); | ||
@@ -147,4 +142,3 @@ return new Route(match, handler, 'GET'); | ||
const createGtmJsRoute = (cacheName) => { | ||
const match = ({ url }) => url.hostname === GTM_HOST && | ||
url.pathname === GTM_JS_PATH; | ||
const match = ({ url }) => url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH; | ||
const handler = new NetworkFirst({ cacheName }); | ||
@@ -187,2 +181,2 @@ return new Route(match, handler, 'GET'); | ||
}; | ||
export { initialize, }; | ||
export { initialize }; |
{ | ||
"name": "workbox-google-analytics", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"license": "MIT", | ||
@@ -28,8 +28,8 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-background-sync": "6.3.0", | ||
"workbox-core": "6.3.0", | ||
"workbox-routing": "6.3.0", | ||
"workbox-strategies": "6.3.0" | ||
"workbox-background-sync": "6.4.0", | ||
"workbox-core": "6.4.0", | ||
"workbox-routing": "6.4.0", | ||
"workbox-strategies": "6.4.0" | ||
}, | ||
"gitHead": "03055e64014a46f6cc977a3a50ad814c6409d36a" | ||
"gitHead": "cdad230c678a3626c217615d5792eb0f1c77194c" | ||
} |
// @ts-ignore | ||
try{self['workbox:google-analytics:6.3.0']&&_()}catch(e){} | ||
try{self['workbox:google-analytics:6.4.0']&&_()}catch(e){} |
@@ -12,3 +12,2 @@ /* | ||
/** | ||
@@ -18,4 +17,2 @@ * @module workbox-google-analytics | ||
export { | ||
initialize, | ||
}; | ||
export {initialize}; |
@@ -31,3 +31,2 @@ /* | ||
export interface GoogleAnalyticsInitializeOptions { | ||
@@ -60,5 +59,6 @@ cacheName?: string; | ||
// either the URL query string (for GET requests) or the POST body. | ||
const params = request.method === 'POST' ? | ||
new URLSearchParams(await request.clone().text()) : | ||
url.searchParams; | ||
const params = | ||
request.method === 'POST' | ||
? new URLSearchParams(await request.clone().text()) | ||
: url.searchParams; | ||
@@ -88,14 +88,16 @@ // Calculate the qt param, accounting for the fact that an existing | ||
// now in the post body. | ||
await fetch(new Request(url.origin + url.pathname, { | ||
body: params.toString(), | ||
method: 'POST', | ||
mode: 'cors', | ||
credentials: 'omit', | ||
headers: {'Content-Type': 'text/plain'}, | ||
})); | ||
await fetch( | ||
new Request(url.origin + url.pathname, { | ||
body: params.toString(), | ||
method: 'POST', | ||
mode: 'cors', | ||
credentials: 'omit', | ||
headers: {'Content-Type': 'text/plain'}, | ||
}), | ||
); | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.log(`Request for '${getFriendlyURL(url.href)}' ` + | ||
`has been replayed`); | ||
logger.log( | ||
`Request for '${getFriendlyURL(url.href)}' ` + `has been replayed`, | ||
); | ||
} | ||
@@ -106,4 +108,6 @@ } catch (err) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.log(`Request for '${getFriendlyURL(url.href)}' ` + | ||
`failed to replay, putting it back in the queue.`); | ||
logger.log( | ||
`Request for '${getFriendlyURL(url.href)}' ` + | ||
`failed to replay, putting it back in the queue.`, | ||
); | ||
} | ||
@@ -114,4 +118,6 @@ throw err; | ||
if (process.env.NODE_ENV !== 'production') { | ||
logger.log(`All Google Analytics request successfully replayed; ` + | ||
`the queue is now empty!`); | ||
logger.log( | ||
`All Google Analytics request successfully replayed; ` + | ||
`the queue is now empty!`, | ||
); | ||
} | ||
@@ -131,4 +137,4 @@ }; | ||
const match = ({url}: RouteMatchCallbackOptions) => | ||
url.hostname === GOOGLE_ANALYTICS_HOST && | ||
COLLECT_PATHS_REGEX.test(url.pathname); | ||
url.hostname === GOOGLE_ANALYTICS_HOST && | ||
COLLECT_PATHS_REGEX.test(url.pathname); | ||
@@ -139,6 +145,3 @@ const handler = new NetworkOnly({ | ||
return [ | ||
new Route(match, handler, 'GET'), | ||
new Route(match, handler, 'POST'), | ||
]; | ||
return [new Route(match, handler, 'GET'), new Route(match, handler, 'POST')]; | ||
}; | ||
@@ -156,4 +159,4 @@ | ||
const match = ({url}: RouteMatchCallbackOptions) => | ||
url.hostname === GOOGLE_ANALYTICS_HOST && | ||
url.pathname === ANALYTICS_JS_PATH; | ||
url.hostname === GOOGLE_ANALYTICS_HOST && | ||
url.pathname === ANALYTICS_JS_PATH; | ||
@@ -175,4 +178,3 @@ const handler = new NetworkFirst({cacheName}); | ||
const match = ({url}: RouteMatchCallbackOptions) => | ||
url.hostname === GTM_HOST && | ||
url.pathname === GTAG_JS_PATH; | ||
url.hostname === GTM_HOST && url.pathname === GTAG_JS_PATH; | ||
@@ -194,4 +196,3 @@ const handler = new NetworkFirst({cacheName}); | ||
const match = ({url}: RouteMatchCallbackOptions) => | ||
url.hostname === GTM_HOST && | ||
url.pathname === GTM_JS_PATH; | ||
url.hostname === GTM_HOST && url.pathname === GTM_JS_PATH; | ||
@@ -242,4 +243,2 @@ const handler = new NetworkFirst({cacheName}); | ||
export { | ||
initialize, | ||
}; | ||
export {initialize}; |
@@ -8,11 +8,9 @@ { | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
], | ||
"include": ["src/**/*.ts"], | ||
"references": [ | ||
{ "path": "../workbox-background-sync/" }, | ||
{ "path": "../workbox-core/" }, | ||
{ "path": "../workbox-routing/" }, | ||
{ "path": "../workbox-strategies/" } | ||
{"path": "../workbox-background-sync/"}, | ||
{"path": "../workbox-core/"}, | ||
{"path": "../workbox-routing/"}, | ||
{"path": "../workbox-strategies/"} | ||
] | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81094
3
80
710
+ Addedworkbox-background-sync@6.4.0(transitive)
+ Addedworkbox-core@6.4.0(transitive)
+ Addedworkbox-routing@6.4.0(transitive)
+ Addedworkbox-strategies@6.4.0(transitive)
- Removedworkbox-background-sync@6.3.0(transitive)
- Removedworkbox-core@6.3.0(transitive)
- Removedworkbox-routing@6.3.0(transitive)
- Removedworkbox-strategies@6.3.0(transitive)
Updatedworkbox-core@6.4.0
Updatedworkbox-routing@6.4.0
Updatedworkbox-strategies@6.4.0