segmentio / consent-manager

Drop-in consent management plugin for analytics.js
https://segmentio.github.io/consent-manager/
MIT License
341 stars 142 forks source link

Compatibility issues with segment snippet package #264

Closed joelpierre closed 2 years ago

joelpierre commented 2 years ago

"@segment/consent-manager" + "@segment/snippet"

Current Stack

Node env: 16.15.1 NextJS ver: 12.2.2 Consent Manager: 5.6.0

Trying to use this package in a nextJS app with one of your other packages "@segment/snippet" and they are simply fighting each other. Considering for the most part the "internet" requires consent of some form these days why doesn't Segment/snippet allow for an opt in for the consent manager so you don't have two configs for the two apps.

I would prefer this package JUST handle the consent manager UI and nothing to do with loading window.analytics as right now I get the Segment snippet included twice. Which IMO shouldn't be an error. If segment is loaded just use that one.

chrisradek commented 2 years ago

@joelpierre Thanks for opening this issue. Are you setting the load field in @segment/snippet to false to disable automatically loading analytics.js?

The consent manager needs to be the one to call load so that it can tell analytics which destinations to enable/disable, but that's why there's a setting on snippet to exclude the load() call from the snippet itself.

joelpierre commented 2 years ago

We feature flag our services but yes we only load if the consent manager isn't enabled, satisfying the consent managers requirement to be the thing that manages this process.

I do have it working now but it would be great if these options were a bit more intuitive for people working with both packages. e.g the plugin handling this under the hood if you are using the consent manager.