How to use the workbox-core/_private/cacheNames.js.cacheNames.getGoogleAnalyticsName function in workbox-core

To help you get started, we’ve selected a few workbox-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GoogleChrome / workbox / packages / workbox-google-analytics / src / initialize.ts View on Github external
const initialize = (options: GoogleAnalyticsInitializeOptions = {}) => {
  const cacheName = cacheNames.getGoogleAnalyticsName(options.cacheName);

  const bgSyncPlugin = new BackgroundSyncPlugin(QUEUE_NAME, {
    maxRetentionTime: MAX_RETENTION_TIME,
    onSync: createOnSyncCallback(options),
  });

  const routes = [
    createGtmJsRoute(cacheName),
    createAnalyticsJsRoute(cacheName),
    createGtagJsRoute(cacheName),
    ...createCollectRoutes(bgSyncPlugin),
  ];

  const router = new Router();
  for (const route of routes) {
    router.registerRoute(route);