Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused cookies in Umbraco 10 #10

Closed
ANT-GBR opened this issue Aug 3, 2023 · 6 comments
Closed

Remove unused cookies in Umbraco 10 #10

ANT-GBR opened this issue Aug 3, 2023 · 6 comments

Comments

@ANT-GBR
Copy link

ANT-GBR commented Aug 3, 2023

Hi Andy,

I want to remove all the cookies that I don't require so I am using the configuration:

    "PersonalisationGroups": {
      "ExcludeCriteria": "pagesViewed,numberOfVisits"
    }

but this isn't working. I am still seeing personalisationGroupsNumberOfVisitsSessionStarted, personalisationGroupsNumberOfVisits, personalisationGroupsPagesViewed.
The only criteria I need are country and querystring but the below doesn't work either:

    "PersonalisationGroups": {
      "IncludeCriteria": "country,querystring"
    }

This is in UmbracoPersonalisationGroups 3.2.7

Thanks
Tony

@AndyButland
Copy link
Owner

Hi - yes, it might make sense if we disabled the cookie based tracking if you don't have the criteria that make use of them enabled. But in the meantime, or perhaps anyway to give most flexibility, you could remove this yourself. It's implemented as a middleware. So I believe if you add this to your startup's ConfigureServices method, or by using an Umbraco composer, you could call this code:

var trackUserActivityMiddlewareDescriptor = services
    .FirstOrDefault(descriptor => descriptor.ImplementationType == typeof(TrackUserActivityMiddleware));
if (trackUserActivityMiddlewareDescriptor != null)
{
    services.Remove(trackUserActivityMiddlewareDescriptor);
}

And that should remove it.

Please let me know how it goes and at very least I'll make sure to add this to the documentation.

@ANT-GBR
Copy link
Author

ANT-GBR commented Aug 4, 2023

I've added that to ConfigureServices and I'm getting 'Our.Umbraco.PersonalisationGroups.Core.Middleware.TrackUserActivityMiddleware is inaccessible due to its protection level.'

Thanks
Tony

@AndyButland
Copy link
Owner

Ah, of course. So unless you resort to reflection hacks, this will need a release. Probably best to add a configuration options that allows you disable the user activity tracking if you aren't using it - I'll look at adding that.

@ANT-GBR
Copy link
Author

ANT-GBR commented Aug 4, 2023

Nice one, thanks Andy

@AndyButland
Copy link
Owner

I've just pushed 3.2.8 which includes a new configuration value. Setting DisableUserActivityTracking to true will disable the middleware that does the tracking of user sessions and pages viewed to a cookie.

i.e.:

  "Umbraco": {
    "PersonalisationGroups": {
      "DisableUserActivityTracking": true
    }
  }

@ANT-GBR
Copy link
Author

ANT-GBR commented Aug 7, 2023

That's awesome, cheers Andy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants