oliverdavies.uk-drupal-old/tools/patches/plausible/return-if-authenticated.patch
Oliver Davies dcf180a651 Fix Plausible loading for authenticated users
Return early within the Plausible if the user is authenticated so that
it doesn't pick up when I'm adding or editing content on the site.

Though the role is configured in the Plausible module's admin form, the
conditions in the code don't exclude it. I'll look into this further and
submit a patch upstream along with some tests.

References #350
2021-01-30 17:22:28 +00:00

21 lines
621 B
Diff

diff --git a/plausible.module b/plausible.module
index ce5a826..aa78dc5 100644
--- a/plausible.module
+++ b/plausible.module
@@ -16,9 +16,14 @@ use Drupal\plausible\Component\Render\PlausibleJavaScriptSnippet;
function plausible_page_attachments(array &$attachments) {
$account = \Drupal::currentUser();
- if (! (_plausible_visibility_pages() && _plausible_visibility_roles($account))) {
+ if (!_plausible_visibility_pages()) {
return;
}
+
+ if ($account->isAuthenticated()) {
+ return;
+ }
+
$config = \Drupal::config('plausible.settings');
$attachments['#attached']['html_head'][] = [
[