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';
32
32
import { Deferred } from '@firebase/util' ;
33
33
import { ConsentSettings } from './public-types' ;
34
34
import { removeGtagScripts } from '../testing/gtag-script-util' ;
35
+ import { logger } from './logger' ;
36
+ import { AnalyticsError , ERROR_FACTORY } from './errors' ;
35
37
36
38
const fakeMeasurementId = 'abcd-efgh-ijkl' ;
37
39
const fakeAppId = 'my-test-app-1234' ;
@@ -84,13 +86,16 @@ describe('Trusted Types policies and functions', () => {
84
86
85
87
it ( 'createGtagTrustedTypesScriptURL rejects URLs with non-gtag base' , ( ) => {
86
88
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 ;
88
96
89
97
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 ) ;
94
99
} ) ;
95
100
} ) ;
96
101
Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ type GtagConfigOrEventParams = ControlParams & EventParams & CustomParams;
34
34
*/
35
35
export function createGtagTrustedTypesScriptURL ( url : string ) : string {
36
36
if ( ! url . startsWith ( GTAG_URL ) ) {
37
- console . error ( 'Unknown gtag resource!' , url ) ;
38
37
const err = ERROR_FACTORY . create ( AnalyticsError . INVALID_GTAG_RESOURCE , {
39
38
gtagURL : url
40
39
} ) ;
You can’t perform that action at this time.
0 commit comments