Problem/Motivation

Currently, we are using a not so nice workaround to set the `cookieless_mode` for when klaro is installed:

  if (\Drupal::moduleHandler()->moduleExists('klaro') && !isset($initConfigJson['cookieless_mode'])) {
    $initConfigJson['cookieless_mode'] = 'on_reject';
  }

This is ok, but an alter hook, to alter the initConfigJson + a dedicated "posthog_klaro" submodule, which automatically enables the klaro "posthog" config on install (if it exists and is not already enabled) and contains a dependency on klaro in the info.yml would be nicer.

Steps to reproduce

Proposed resolution

Create an init config alter hook and a new klaro submodule to set klaro specific init settings

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#3 screenshot-2026-04-16 14_19_15.png23.93 KBgrevil

Issue fork posthog-3585191

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

grevil created an issue. See original summary.

grevil’s picture

Status: Active » Needs review
StatusFileSize
new23.93 KB

All done, please review!

I tested it and it works as expected. Note that currently if the klaro cookies are not accepted, no "cookieless_" user is tracked, but I guess that is because the default cookieless behavior is not properly set on posthogs site and they are working on it right now?

For some reason, I could not test if the install message is shown, when installing the module via console, since for some reason drupal doesn't allow me to delete the klaro posthog config:
screenshot

But the message should be shown. Even on console. Please review!

anybody’s picture

Assigned: Unassigned » grevil
Status: Needs review » Needs work

GREAT! Left some final comments.

grevil’s picture

Assigned: grevil » anybody
Status: Needs work » Needs review

Adjusted accordingly and testet the update hook! Final review please!

anybody’s picture

Assigned: anybody » Unassigned
Status: Needs review » Reviewed & tested by the community

RTBC after condition cleanup! Nice work!!

  • grevil committed 98599faa on 2.x
    feat: #3585191 Create an init config alter hook and a new klaro...
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.