File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
packages/analytics-nextjs/src Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ export function AnalyticsProvider({
7373 const {
7474 tracking_policy : trackingPolicy = TrackingPolicy . DEFAULT as TrackingPolicy ,
7575 segment_analytics_id : segmentWriteKey = customSegmentWriteKey ,
76+ google_analytics_id : googleAnalyticsId ,
7677 uuid,
7778 } = newsroom || { } ;
7879
@@ -90,6 +91,14 @@ export function AnalyticsProvider({
9091 ) ;
9192 } , [ isEnabled , trackingPolicy ] ) ;
9293
94+ useEffect ( ( ) => {
95+ if ( ! googleAnalyticsId ) {
96+ return ;
97+ }
98+
99+ window [ `ga-disable-${ googleAnalyticsId } ` ] = ! isTrackingCookieAllowed ;
100+ } , [ isTrackingCookieAllowed , googleAnalyticsId ] ) ;
101+
93102 useEffect ( ( ) => {
94103 async function loadAnalytics ( writeKey : string ) {
95104 try {
Original file line number Diff line number Diff line change 1- declare interface Window { }
1+ type GoogleAnalyticsId = string ;
2+
3+ interface Window {
4+ [ key : `ga-disable-${string } `] : boolean | undefined ;
5+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ export interface RecipientInfo {
1313
1414// Pulled from `@prezly/sdk` to get rid of direct dependency requirement
1515export enum TrackingPolicy {
16+ STRICT = 'strict' ,
1617 DEFAULT = 'default' ,
18+ WILD_WEST = 'wild-west' ,
1719 DISABLED = 'disabled' ,
1820 CONSENT_TO_IDENTIFY = 'consent-to-identify' ,
1921}
You can’t perform that action at this time.
0 commit comments