Enhanced browser console debugging with Charles Proxy
This article demonstrates how to use Charles Proxy to obtain more advanced output from utag.DB.
By adding a rewrite setting to Charles Proxy, the regular errors from utag.DB
will be displayed as browser level console warnings. This allows for the Warnings filter in the console to be used when filtering errors, warnings, and info output.
Prerequisites
- Charles Proxy Web Debugging Application installed on your computer.
- utag.DB output is enabled in the browser.
Create rewrite rules from XML file
-
Save the following XML as a file on your computer.
-
Open Charles Rewrite Settings (Tools > Rewrite).
-
Click Import (see image below).
-
Select the file and click Open.
-
Click Apply and OK to complete the import.
-
Refresh the browser window loading your site with Tealium. You should now be able to see the warnings output in the console as shown in the sample below.
Create rewrite rules manually
-
Open Charles Proxy.
-
From the menu, navigate to Tools > Rewrite.
-
In the dialog, click the Add button on the left-hand side to add a new set. Title it
uTag DB Upgrade
. -
Under the Location section, click the Add button to add a location.
-
Copy and paste the below code into the Path text field:
/*/utag.js
-
Leave the rest of the fields blank and click OK.
-
Under the Type/Action section, click the Add button to add the first rewrite rule.
- In the Type dropdown, select Body.
- In the Where section, ensure Response is checked.
- In the Match and Replace sections, copy and paste the below code into the corresponding text fields.
For the Match section, place in the Value field
For the Replace section, place in the Value field:;utag.o['
; utag.ut.typeOf = function(e) {return ({}).toString.call(e).match(/\s([a-zA-Z]+)/)[1].toLowerCase();}; utag.DB = function(a, b) { var t; if (utag.cfg.utagdb === false) { return; } else if (typeof utag.cfg.utagdb == "undefined") { utag.db_log = []; b = document.cookie + ''; utag.cfg.utagdb = ((b.indexOf('utagdb=true') >= 0) ? true : false); } if (utag.cfg.utagdb === true) { var con = window.console; if (utag.ut.typeOf(a) === "error") { utag.db_log.push(a); t = ""; if (a.stack && a.stack.split) { t = a.stack.split("\n")[1].replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '').replace(/^at\s/, ""); } if (con) { t = "utag - Error : " + t + " "+ a.message; if (con.warn) { con.warn(t); } else if (con.log){ con.log(t); } } } else { t = (utag.ut.typeOf(a) == "object") ? utag.handler.C(a) : a; utag.db_log.push(t); if (con && con.log) con.log("utag - ", t); } } };utag.o['
- In the Replace section, ensure the Replace first option is selected.
- Your Rewrite Rule should look something like this:
- Click the OK button to save the rule.
-
Under the Type/Action section, click the Add button to add the second rewrite rule.
- In the Type dropdown, select Body.
- In the Where section, ensure Request is checked.
- In the Match and Replace sections, copy and paste the below code into the corresponding text fields.
For the Match section, place in the Value field
For the Replace section, place in the Value field\}catch\((.*?)\)\{
}catch($1){utag.DB($1);
- In the Match section, ensure the Regex box is checked.
- In the Replace section, ensure the Replace first option is selected.
- Click the OK button to save the rule.
- Your Rewrite Rule should look something like this:
-
The
uTag DB Upgrade
set with the two included rewrites should look like this when complete: -
Click Apply to apply the rewrite and then click OK to close the dialog.
-
Refresh the browser window loading your site with Tealium. You should now be able to see the Warnings output in the console as shown in the sample below.
Output sample
Below is a sample of the enhanced output as shown in Google Chrome DevTools. You can see that instead of just showing as Info output, the error is showing as an expandable warning, which can be filtered by selecting the Warnings option in the dropdown next to the Filter input box.
This page was last updated: September 22, 2023