function hotjar_page_attachments in Hotjar 8
Same name and namespace in other branches
- 8.2 hotjar.module \hotjar_page_attachments()
Implements hook_page_attachments().
Insert JavaScript to the <head> tag of the page.
File
- ./hotjar.module, line 88 
- Drupal Module: Hotjar.
Code
function hotjar_page_attachments(array &$attachments) {
  /** @var \Drupal\hotjar\SnippetAccessInterface $access */
  $access = \Drupal::service('hotjar.access');
  if (!$access
    ->check()) {
    return;
  }
  /** @var \Drupal\hotjar\SnippetBuilderInterface $snippet */
  $snippet = \Drupal::service('hotjar.snippet');
  $snippet
    ->pageAttachment($attachments);
}