@@ -22,6 +22,7 @@ import {
2222 collectAttribution ,
2323 getOrCreateSession ,
2424 createConsentManager ,
25+ canTrack ,
2526 startCmpDetection ,
2627} from '@imtbl/audience-core' ;
2728import { setupAutocapture } from './autocapture' ;
@@ -124,7 +125,7 @@ export class Pixel {
124125 if ( isAutoConsent ) {
125126 // CMP detection will fire the deferred page view when consent upgrades.
126127 this . startCmpDetection ( ) ;
127- } else if ( this . consent . level !== 'none' ) {
128+ } else if ( canTrack ( this . consent . level ) ) {
128129 // Static consent — fire page view immediately.
129130 this . initialPageViewFired = true ;
130131 this . page ( ) ;
@@ -139,7 +140,7 @@ export class Pixel {
139140 }
140141
141142 page ( properties ?: Record < string , unknown > ) : void {
142- if ( ! this . canTrack ( ) ) return ;
143+ if ( ! this . isTrackingAllowed ( ) ) return ;
143144
144145 const { sessionId, isNew } = getOrCreateSession ( this . domain ) ;
145146 this . refreshSession ( sessionId , isNew ) ;
@@ -168,7 +169,7 @@ export class Pixel {
168169 // Fire the deferred page view if consent was upgraded from 'none'
169170 // (covers the case where CMP detection failed and the caller
170171 // manually sets consent as a fallback).
171- if ( level !== 'none' && ! this . initialPageViewFired ) {
172+ if ( canTrack ( level ) && ! this . initialPageViewFired ) {
172173 this . initialPageViewFired = true ;
173174 this . page ( ) ;
174175 }
@@ -200,7 +201,7 @@ export class Pixel {
200201 this . consent ! . setLevel ( level ) ;
201202
202203 // Fire the deferred page view on first consent upgrade from 'none'.
203- if ( level !== 'none' && ! this . initialPageViewFired ) {
204+ if ( canTrack ( level ) && ! this . initialPageViewFired ) {
204205 this . initialPageViewFired = true ;
205206 this . page ( ) ;
206207 }
@@ -210,7 +211,7 @@ export class Pixel {
210211 onCmpUpdate ,
211212 ( detector : CmpDetector ) => {
212213 // CMP found — apply the initial consent level it reported.
213- if ( detector . level !== 'none' ) {
214+ if ( canTrack ( detector . level ) ) {
214215 onCmpUpdate ( detector . level ) ;
215216 }
216217 } ,
@@ -220,7 +221,7 @@ export class Pixel {
220221 // -- Auto-capture helper --------------------------------------------------
221222
222223 private track ( eventName : string , properties : Record < string , unknown > ) : void {
223- if ( ! this . canTrack ( ) ) return ;
224+ if ( ! this . isTrackingAllowed ( ) ) return ;
224225
225226 const { sessionId, isNew } = getOrCreateSession ( this . domain ) ;
226227 this . refreshSession ( sessionId , isNew ) ;
@@ -247,7 +248,7 @@ export class Pixel {
247248 }
248249
249250 private fireSessionStart ( sessionId : string ) : void {
250- if ( ! this . canTrack ( ) ) return ;
251+ if ( ! this . isTrackingAllowed ( ) ) return ;
251252
252253 const message : TrackMessage = {
253254 ...this . buildBase ( ) ,
@@ -261,7 +262,7 @@ export class Pixel {
261262 }
262263
263264 private fireSessionEnd ( ) : void {
264- if ( ! this . canTrack ( ) || ! this . sessionId ) return ;
265+ if ( ! this . isTrackingAllowed ( ) || ! this . sessionId ) return ;
265266
266267 const duration = this . sessionStartTime
267268 ? Math . round ( ( Date . now ( ) - this . sessionStartTime ) / 1000 )
@@ -337,8 +338,8 @@ export class Pixel {
337338
338339 // -- Guards -------------------------------------------------------------
339340
340- private canTrack ( ) : boolean {
341- return this . isReady ( ) && this . consent ! . level !== 'none' ;
341+ private isTrackingAllowed ( ) : boolean {
342+ return this . isReady ( ) && canTrack ( this . consent ! . level ) ;
342343 }
343344
344345 private isReady ( ) : boolean {
0 commit comments