graceguo-supercat commented on a change in pull request #9733:
URL: 
https://github.com/apache/incubator-superset/pull/9733#discussion_r419794871



##########
File path: superset-frontend/src/dashboard/components/Dashboard.jsx
##########
@@ -158,6 +173,27 @@ class Dashboard extends React.PureComponent {
     }
   }
 
+  componentWillUnmount() {
+    window.removeEventListener('visibilitychange', this.onVisibilityChange);
+  }
+
+  onVisibilityChange() {
+    if (document.visibilityState === 'hidden') {
+      // from visible to hidden
+      this.visibilityEventData = {
+        start_offset: Logger.getTimestamp(),
+        ts: new Date().getTime(),
+      };
+    } else {
+      // from hidden to visible
+      const logStart = this.visibilityEventData.start_offset;
+      this.props.actions.logEvent(LOG_ACTIONS_HIDDEN_BROWSER_TAB, {
+        ...this.visibilityEventData.start_offset,

Review comment:
       correct. fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to