Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
giammariam
Super User
Super User

Console is clearing after update

I have a custom visual where the console clears after update. This makes troubleshooting difficult. Is there a way to turn this off? I know that I can persist the log in dev tools, but I can't expand any objects written to the console. 

It appears to be specific to this visual. I checked another visual and the console persists as expected. I searched all of my files and did not find an instance of console.clear().

 

---------

Update 1

I've narrowed it down to the clear method for my ISelectionManager object. When I comment out the following line, the console no longer tries to clear. This did not used to happen, so I'm not sure what has changed.

this.selectionManager.clear();

---------

 

 

 

Below is what comes up when I click the debugger next to the message indicating that the console was cleared. 

MicrosoftTeams-image.png

 

 @v-viig 

 

 

 

 var l = function() {
            function t(n) {
                ! function(t, n) {
                    if (!(t instanceof n)) throw new TypeError("Cannot call a class as a function")
                }(this, t), this._host = n.host;
                var e = n.element.offsetWidth,
                    i = n.element.offsetHeight;
                this._tooltipServiceWrapper = r.a(this._host.tooltipService, Object(a.a)("body").node()), this._rootElement = Object(a.a)(n.element).append("svg").attr("width", e).attr("height", i), this._updateOptions = null
            }
            var n, e, l;
            return n = t, (e = [{
                key: "update",
                value: function(t) {
                    try {
                        if (console.clear(), this._updateOptions = t, this._rootElement.attr("width", t.viewport.width).attr("height", t.viewport.height).selectAll("*").remove(), this._viewModel = u.a.visualTransform(t, this._host), !this._viewModel || 0 != this._viewModel.dataConformanceType) return void(this._viewModel.settings.dataRules.suppress || this.showDataNonConformanceMessage(this._rootElement, i.a[this._viewModel.dataConformanceType]));
                        new o.a({
                            host: this._host,
                            viewModel: this._viewModel,
                            parent: this._rootElement,
                            width: t.viewport.width,
                            height: t.viewport.height,
                            tooltipService: this._host.tooltipService
                        })
                    } catch (t) {
                        console.error(t)
                    }
                }
            },

 

 

 

 

 

 

 

 

 

 

 

 

 

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!
1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @giammariam 

Console.Clear Method can be used to clear the console buffer and corresponding console window of display information.

For reference: Console.Clear Method

Please try ways as below to solve your problem.

First, you can write a extension which executes a javascript on page load and assigns empty function to console.clear. So, it doesn't throw any error if its called.

console.clear = () => {}

References for building extension to run on page load Chrome Extension: Make it run every page load https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page

Secondly, you can load the page once and open devtools and goto sources and search for console.clear and add breakpoints every where its called and reload the page. The code execution will stop when the console.clear is called for the first time and again you can goto console and assign console.clear with empty function and override.

Reference for Using BreakPoints in Firefox https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @giammariam 

Console.Clear Method can be used to clear the console buffer and corresponding console window of display information.

For reference: Console.Clear Method

Please try ways as below to solve your problem.

First, you can write a extension which executes a javascript on page load and assigns empty function to console.clear. So, it doesn't throw any error if its called.

console.clear = () => {}

References for building extension to run on page load Chrome Extension: Make it run every page load https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page

Secondly, you can load the page once and open devtools and goto sources and search for console.clear and add breakpoints every where its called and reload the page. The code execution will stop when the console.clear is called for the first time and again you can goto console and assign console.clear with empty function and override.

Reference for Using BreakPoints in Firefox https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_to/Set_a_breakpoint

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.