From 245a1eceb0d4f1af1f828ca2aaeb528d1545da1d Mon Sep 17 00:00:00 2001 From: Grace Guo Date: Mon, 26 Nov 2018 11:51:25 -0800 Subject: [PATCH 1/2] [logging] Add render failure error into log (#6422) (cherry picked from commit 2489876) --- superset/assets/src/chart/Chart.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/superset/assets/src/chart/Chart.jsx b/superset/assets/src/chart/Chart.jsx index 1431c55abf7c2..92eecc2de2c47 100644 --- a/superset/assets/src/chart/Chart.jsx +++ b/superset/assets/src/chart/Chart.jsx @@ -139,6 +139,14 @@ class Chart extends React.PureComponent { console.warn(error); // eslint-disable-line this.props.actions.chartRenderingFailed(error, this.props.chartId); }); + + Logger.append(LOG_ACTIONS_RENDER_CHART, { + slice_id: chartId, + has_err: true, + error_details: error.toString(), + start_offset: this.renderStartTime, + duration: Logger.getTimestamp() - this.renderStartTime, + }); } addFilter(col, vals, merge = true, refresh = true) { From de17642b1623a7803d6bfaa4c9475690ba9ee588 Mon Sep 17 00:00:00 2001 From: Grace Guo Date: Tue, 27 Nov 2018 10:36:56 -0800 Subject: [PATCH 2/2] [fix] edit chart title cause JS error (#6438) (cherry picked from commit 3e4742f) --- superset/assets/src/chart/Chart.jsx | 29 +++++++++---------- .../src/dashboard/actions/datasources.js | 2 +- .../explore/components/ExploreChartHeader.jsx | 3 +- .../components/ExploreViewContainer.jsx | 3 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/superset/assets/src/chart/Chart.jsx b/superset/assets/src/chart/Chart.jsx index 92eecc2de2c47..e653c2dc96ea6 100644 --- a/superset/assets/src/chart/Chart.jsx +++ b/superset/assets/src/chart/Chart.jsx @@ -136,17 +136,8 @@ class Chart extends React.PureComponent { } }) .catch((error) => { - console.warn(error); // eslint-disable-line - this.props.actions.chartRenderingFailed(error, this.props.chartId); + this.error(error); }); - - Logger.append(LOG_ACTIONS_RENDER_CHART, { - slice_id: chartId, - has_err: true, - error_details: error.toString(), - start_offset: this.renderStartTime, - duration: Logger.getTimestamp() - this.renderStartTime, - }); } addFilter(col, vals, merge = true, refresh = true) { @@ -170,6 +161,15 @@ class Chart extends React.PureComponent { } error(e) { + Logger.append(LOG_ACTIONS_RENDER_CHART, { + slice_id: this.props.chartId, + has_err: true, + error_details: e.toString(), + start_offset: this.renderStartTime, + duration: Logger.getTimestamp() - this.renderStartTime, + }); + + console.warn(e); // eslint-disable-line this.props.actions.chartRenderingFailed(e, this.props.chartId); } @@ -203,7 +203,7 @@ class Chart extends React.PureComponent { // check that we have the render function and data if (hasVisPromise && ['success', 'rendered'].indexOf(chartStatus) > -1) { const { vizType, formData, queryResponse, setControlValue, chartId } = this.props; - const renderStart = Logger.getTimestamp(); + this.renderStartTime = Logger.getTimestamp(); try { // Executing user-defined data mutator function @@ -220,12 +220,11 @@ class Chart extends React.PureComponent { Logger.append(LOG_ACTIONS_RENDER_CHART, { slice_id: chartId, viz_type: vizType, - start_offset: renderStart, - duration: Logger.getTimestamp() - renderStart, + start_offset: this.renderStartTime, + duration: Logger.getTimestamp() - this.renderStartTime, }); } catch (e) { - console.warn(e); // eslint-disable-line - this.props.actions.chartRenderingFailed(e, chartId); + this.error(e); } } } diff --git a/superset/assets/src/dashboard/actions/datasources.js b/superset/assets/src/dashboard/actions/datasources.js index 85d91bdafde06..24def587b5dee 100644 --- a/superset/assets/src/dashboard/actions/datasources.js +++ b/superset/assets/src/dashboard/actions/datasources.js @@ -28,7 +28,7 @@ export function fetchDatasourceMetadata(key) { return SupersetClient.get({ endpoint: `/superset/fetch_datasource_metadata?datasourceKey=${key}`, }) - .then(data => dispatch(data, key)) + .then(data => dispatch(setDatasource(data, key))) .catch(response => getClientErrorObject(response).then(({ error }) => dispatch(fetchDatasourceFailed(error, key)), diff --git a/superset/assets/src/explore/components/ExploreChartHeader.jsx b/superset/assets/src/explore/components/ExploreChartHeader.jsx index 8c9ea91f2a590..9ef79ff805497 100644 --- a/superset/assets/src/explore/components/ExploreChartHeader.jsx +++ b/superset/assets/src/explore/components/ExploreChartHeader.jsx @@ -44,7 +44,8 @@ class ExploreChartHeader extends React.PureComponent { action: isNewSlice ? 'saveas' : 'overwrite', }; this.props.actions.saveSlice(this.props.form_data, params) - .then((data) => { + .then((json) => { + const { data } = json; if (isNewSlice) { this.props.actions.createNewSlice( data.can_add, data.can_download, data.can_overwrite, diff --git a/superset/assets/src/explore/components/ExploreViewContainer.jsx b/superset/assets/src/explore/components/ExploreViewContainer.jsx index fc95cef750072..f33934c8b8af6 100644 --- a/superset/assets/src/explore/components/ExploreViewContainer.jsx +++ b/superset/assets/src/explore/components/ExploreViewContainer.jsx @@ -16,6 +16,7 @@ import * as exploreActions from '../actions/exploreActions'; import * as saveModalActions from '../actions/saveModalActions'; import * as chartActions from '../../chart/chartAction'; import { isFeatureEnabledCreator } from '../../featureFlags'; +import { fetchDatasourceMetadata } from '../../dashboard/actions/datasources'; import { Logger, ActionLog, EXPLORE_EVENT_NAMES, LOG_ACTIONS_MOUNT_EXPLORER } from '../../logger'; const propTypes = { @@ -82,7 +83,7 @@ class ExploreViewContainer extends React.Component { (this.props.controls.datasource == null || nextProps.controls.datasource.value !== this.props.controls.datasource.value) ) { - this.props.actions.fetchDatasourceMetadata(nextProps.form_data.datasource, true); + fetchDatasourceMetadata(nextProps.form_data.datasource, true); } const changedControlKeys = this.findChangedControlKeys(this.props.controls, nextProps.controls);