Appropriate Placement of the DAP Script Tag

Created on 23 June 2020, over 4 years ago
Updated 21 February 2023, about 2 years ago

According to the documentation the JS should not be injected on admin pages, log in, log out, password reset, or for administrators.

While this module is installed and enabled I tested the site with the Google Chrome Google Analytics Debugger and found that the javascript seems to be injected on every page in conflict with the requirements.

πŸ› Bug report
Status

Fixed

Version

1.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States MattDeckerIO

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States jrglasgow Idaho

    In looking into this I have removed the old Google Analytics module config portion and added a few check to match with the specified placement

    Specifically I have ensures that the script tag doesn't appear for logged in users:

    // don't show for logged in users
      $user = \Drupal::currentUser();
      if ($user->isAuthenticated()) {
        return;
      }
    

    doesn't appear on password reset/log in/log out pages

      // don't show for password reset/login/logout pages
      $routeMatch = \Drupal::routeMatch();
      $route = $routeMatch->getRouteObject();
      if (str_starts_with($route->getPath(), '/user/')) {
        return;
      }
    

    // doesn't appear on admin page (in case for some reason the previous two tests don't return)

    // don't show on admin pages
      if (\Drupal::service('router.admin_context')->isAdminRoute()) {
        return;
      }
    
  • πŸ‡ΊπŸ‡ΈUnited States jrglasgow Idaho
    • jrglasgow β†’ authored 78fe3525 on 8.x-1.x
      Issue #3154284 by jrglasgow: Appropriate Placement of the DAP Script Tag
      
  • Status changed to Fixed about 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States jrglasgow Idaho
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024