File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ import { GtagCommand, GTAG_URL } from './constants';
3232import { Deferred } from '@firebase/util' ;
3333import { ConsentSettings } from './public-types' ;
3434import { removeGtagScripts } from '../testing/gtag-script-util' ;
35+ import { logger } from './logger' ;
36+ import { AnalyticsError , ERROR_FACTORY } from './errors' ;
3537
3638const fakeMeasurementId = 'abcd-efgh-ijkl' ;
3739const fakeAppId = 'my-test-app-1234' ;
@@ -84,13 +86,16 @@ describe('Trusted Types policies and functions', () => {
8486
8587 it ( 'createGtagTrustedTypesScriptURL rejects URLs with non-gtag base' , ( ) => {
8688 const NON_GTAG_URL = 'http://iamnotgtag.com' ;
87- const consoleErrorStub = stub ( console , 'error' ) ;
89+ const loggerWarnStub = stub ( logger , 'warn' ) ;
90+ const errorMessage = ERROR_FACTORY . create (
91+ AnalyticsError . INVALID_GTAG_RESOURCE ,
92+ {
93+ gtagURL : NON_GTAG_URL
94+ }
95+ ) . message ;
8896
8997 expect ( createGtagTrustedTypesScriptURL ( NON_GTAG_URL ) ) . to . equal ( '' ) ;
90- expect ( consoleErrorStub ) . to . be . calledWith (
91- 'Unknown gtag resource!' ,
92- NON_GTAG_URL
93- ) ;
98+ expect ( loggerWarnStub ) . to . be . calledWith ( errorMessage ) ;
9499 } ) ;
95100 } ) ;
96101
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ type GtagConfigOrEventParams = ControlParams & EventParams & CustomParams;
3434 */
3535export function createGtagTrustedTypesScriptURL ( url : string ) : string {
3636 if ( ! url . startsWith ( GTAG_URL ) ) {
37- console . error ( 'Unknown gtag resource!' , url ) ;
3837 const err = ERROR_FACTORY . create ( AnalyticsError . INVALID_GTAG_RESOURCE , {
3938 gtagURL : url
4039 } ) ;
You can’t perform that action at this time.
0 commit comments