Giter Club home page Giter Club logo

bytexdigital / bytexdigital.blazor.components.cookieconsent Goto Github PK

View Code? Open in Web Editor NEW
31.0 5.0 12.0 916 KB

Components for handling GDPR cookie consent

Home Page: https://www.nuget.org/packages/BytexDigital.Blazor.Components.CookieConsent/

License: Apache License 2.0

HTML 16.99% C# 63.00% JavaScript 9.52% CSS 10.49%
blazor blazor-webassembly blazor-wasm blazor-ui blazor-ui-library blazor-ui-components blazor-cookies blazor-gdpr blazor-cookies-consent

bytexdigital.blazor.components.cookieconsent's People

Contributors

emorell96 avatar maatj05 avatar ryantt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bytexdigital.blazor.components.cookieconsent's Issues

Showing sites privacy policy when clicked

How can i show my privacy policy page when clicked ?
currently i have the privacypolicy.razor page so hopping to navigate to it using Navmanager.NavigateTo('')
In case the privacy policy page is inside www root as .html, also support navigating to that html page as well as you are doing in google-maps privacy policy.

Also can i also add another link to display terms and condition ?

image

Revoke consent manually seems not to disable services

When a user manually revoke given consent via the preferences modal dialog (e.g. the google analytics service), the service seems not to be disabled.
The type of the script remains "text/javascript instead of changing back to "text/plain"
So I guess the consent remains until the user reloads the page.
Is this the expected behaviour or is this some kind of bug?

Support Blazor-Web-App .NET 8

Hey!

I am testing out the .NET 8 preview 6 for Blazor Web App at the moment and i wanted to test your cookie consent nuget.

Sadly it does not seem to work out of the box and no cookie consent will open. Neither automaticly nor via the CookieConsentService.
The only differece between Blazor Server and Blazor Web App i could spot is that in the Blazor Server project the cookieconsent.js file gets loaded while the Blazor Web App does not seem to load the js file.

But i cant seem to find any error in the console etc. it just does not show up.

Also just a side note:
It seems like if a package.json file already exists in a project your nuget will not add code to it.

Maybe you can have a look so we can enjoy your nuget in the upcoming release of .NET 8

Thanks!

Issues with Blazor Web App setup

When configuring the .Net 8 blazor web app, following the instructions, I face two issues:

<BytexDigital.Blazor.Components.CookieConsent.CookieConsentInitializer @rendermode="@RenderMode.Server" />

is not found. and, when adding

builder.Services.AddCookieConsent(o =>
{
    // The same configuration as on the server! Best to put this lambda in a shared project to reuse to reduce duplication.
}, withUserInterface: false);

no AddCookieConsent which takes two inputs is found.

Component crashes if cookieconsent.js is blocked

We have just deployed the (otherwise excellent) Cookie Consent on our site and one of our developers noticed the site crashes for him when he clicks on one of the cookie consent dialog buttons. It tries to call some javascript function and crashes. In this specific case it is due to the user having cookie script blocking turned on. Javascript is not blocked but some scripts are blocked.

Screenshot:

image

Stacktrace:

blazor.server.js:1 [2022-07-06T15:38:41.900Z] Error: Microsoft.JSInterop.JSException: Failed to fetch dynamically imported module: http://localhost:8000/_content/BytexDigital.Blazor.Components.CookieConsent/cookieconsent.js
TypeError: Failed to fetch dynamically imported module: http://localhost:8000/_content/BytexDigital.Blazor.Components.CookieConsent/cookieconsent.js
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at BytexDigital.Blazor.Components.CookieConsent.CookieConsentService.SavePreferencesAsync(CookiePreferences cookiePreferences)
   at BytexDigital.Blazor.Components.CookieConsent.CookieConsentService.SavePreferencesNecessaryOnlyAsync()
   at BytexDigital.Blazor.Components.CookieConsent.CookieConsentHandler.AcceptAsync(Boolean all)
   at BytexDigital.Blazor.Components.CookieConsent.CookieConsentHandler.<BuildRenderTree>b__38_1()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.Render

So perhaps the component could use error handling in the case a javascript is not available and respond gracefully (for example ignore it).

As a workaround I have created an <ErrorBoundary> around the CookieConsent-based CookieConsentHandler in App.razor.

Cookie not set in docker

Hello,

this is a fantastic cookie consent banner!
But I encountered two issues I do not know how to fix myself maybe anyone here has an idea.
When using the cookie banner in debug within Visual Studio (Edge browser) everything works as expected, the cookie is set inside the browser on my machine. On another MacOS based machine using Safari no cookie is set, while in chrome it worked.
My main problem is that when running my project inside docker, the cookie banner cookie is never set inside Edge (potentially others too).

Script does not execute in Firefox upon consent

I have integrated your component and tested it in our solution. I quickly ran into the script tag should have the defer attribute set, otherwise Blazor seems to strip out the script tag from head of the server rendered HTML (.NET Core 6 Blazor - server rendered); I am writing this this since it is not clear from your otherwise excellent documentation (but maybe there is another way to handle this I am not aware of).

Once that was done I tested in Microsoft Edge and it seems to work well. I can see the script tag is changed to text/javascript and there is network traffic accessing a Google analytics resource.

However, the same is not true in Firefox (only have 1 add-on installed and it is disabled; also with all blocking turned off in settings). I can observe the cookie is created in Firefox and the script tag is changed when I consent - but the Javascript for the Google analytics tag does not seem to do anything - i.e. no network traffic.

You can check this yourself by just adding this code to the head of the page:

<script type="text/plain" data-consent-category="google" defer="defer">
      alert("google consent detected - but not in Firefox");
</script>

In Edge the alert will show; in Firefox it will not.

How to read the consent level ?

How do i know if user has denied the consent in my Razor Page ?
Is there a way to track via code in .razor page as to what has been accepted and what has been denied ?

ConsentDescriptionText appears twice

I am using the "Latest prerelease 1.0.17-preview.1673483543" version:

In my .NET 7 Blazor WASM app, the ConsentDescriptionText appears twice:
image

I also tried adding o.ConsentDescriptionText = new Dictionary<string, string> { { "ConsentDescription", "Blah blah." } }; but then it shows "Blah blah. Blah blah."

My Program.cs file:

builder.Services.AddCookieConsent(o =>
{
    o.Revision = 1;
    o.PolicyUrl = "/cookie-policy";
    o.ConsentModalPosition = ConsentModalPosition.BottomRight;
    o.ConsentModalLayout = ConsentModalLayout.Cloud;
    o.ConsentSecondaryActionOpensSettings = true;
    o.Categories.Add(new CookieCategory
    {
        TitleText = new()
        {
            ["en"] = "Google Services",
            ["de"] = "Google Dienste"
        },
        DescriptionText = new()
        {
            ["en"] = "Allows the integration and usage of Google services.",
            ["de"] = "Erlaubt die Verwendung von Google Diensten."
        },
        Identifier = "google",
        IsPreselected = true,

        Services = new()
        {
            new CookieCategoryService
            {
                Identifier = "google-maps",
                PolicyUrl = "https://policies.google.com/privacy",
                TitleText = new()
                {
                    ["en"] = "Google Maps",
                    ["de"] = "Google Maps"
                },
                ShowPolicyText = new()
                {
                    ["en"] = "Display policies",
                    ["de"] = "Richtlinien anzeigen"
                }
            },
            new CookieCategoryService
            {
                Identifier = "google-places",
                PolicyUrl = "https://policies.google.com/privacy",
                TitleText = new()
                {
                    ["en"] = "Google Places",
                    ["de"] = "Google Places"
                },
                ShowPolicyText = new()
                {
                    ["en"] = "Display policies",
                    ["de"] = "Richtlinien anzeigen"
                }
            },
            new CookieCategoryService
            {
                Identifier = "google-analytics",
                PolicyUrl = "https://policies.google.com/privacy",
                TitleText = new()
                {
                    ["en"] = "Google Analytics",
                    ["de"] = "Google Analytics"
                },
                ShowPolicyText = new()
                {
                    ["en"] = "Display policies",
                    ["de"] = "Richtlinien anzeigen"
                }
            }
        }
    });
});

french translation incorrect

Here are the correct translations. Otherwise there are very big mistakes.

    o.ConsentDescriptionText["fr"] = "Ce site web utilise des cookies pour améliorer votre visite.";
    o.ConsentAcknowledgeText["fr"] = "Je comprends.";
    o.ConsentTitleText["fr"] = "Utilisation des cookies";
    o.OpenPreferencesText["fr"] = "Préférences";
    o.ConsentAcceptAllText["fr"] = "Tout Accepter";

Redirect if declined

Hi is it possible to redirect user to his homepage if he declined the cookie consent?

UseDefaultConsentPrompt not found?

I have a Blazor server-side app with NET7.

I added the following to my Startup.cs:

services.AddCookieConsent(options =>
{
	options.Revision = 1;
	options.PolicyUrl = "/cookie-policy";

	options.UseDefaultConsentPrompt(prompt =>
	{
		prompt.Position = ConsentModalPosition.BottomRight;
		prompt.Layout = ConsentModalLayout.Bar;
		prompt.SecondaryActionOpensSettings = false;
		prompt.AcceptAllButtonDisplaysFirst = false;
	});
});

UseDefaultConsentPrompt is not found in any namespace. Where is actually located?

CookiePolicyOptions and AddCookieConsent

Just before adding services.AddCookieConsent(...) I am doing:

services.Configure<CookiePolicyOptions>(options =>
{
	options.CheckConsentNeeded = context => true;
	options.MinimumSameSitePolicy = SameSiteMode.None;
	options.Secure = CookieSecurePolicy.Always;
});

Do I still need options.CheckConsentNeeded = context => true; ?

Cookie not saving on production

Hi!

The Consent is working perfectly on localhost, but when I publish and use it live it doest not save the user selection at all, and keeps poping up everytime.

Am I missing any configuration required to publish? I've followed the step by step exactly as instructed.

Manually open the preferences modal

Hi,

Thank you for this library, it's amazing! I just have a question regarding the manually opening of the preferences modal. It requires a "CookieConsentService" object, which can be declared with a new statement. This new statement requires IJSRuntime which can be injected, but I don't seem to be able to figure out how I should declare the options tag. Could you add an examle of this to the readme please?

Thanks!

Feature Request: Reject all Button

The tendency of cookie banners in the EU and by the GDPR is more and more in the direction that the user must be given the possibility to reject all non-essential cookies.

Please add an option for a "reject all" button that rejects all cookies. Maybe just in the style of the "change preference" button or even without background. Then you could reduce the height of the other two buttons a bit and it should fit from the design point of view.

So far everything runs fine in .NET 8 RC2

customize order of OpenPreferences and AcceptAll buttons

Would you be able to introduce a way to customize the order of the OpenPreferences and AcceptAll buttons? I would like to display the "AcceptAll" button to be above the "OpenPreferences" button.

I am using version 1.0.17-preview.1673626511

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.