superset-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-superset] ktmud commented on a change in pull request #10815: chore: type src/logger
Date Wed, 09 Sep 2020 17:47:02 GMT

ktmud commented on a change in pull request #10815:
URL: https://github.com/apache/incubator-superset/pull/10815#discussion_r485803045



##########
File path: superset-frontend/src/logger/actions/index.ts
##########
@@ -16,10 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import { Dispatch } from 'react-redux';
+
 export const LOG_EVENT = 'LOG_EVENT';
 
-export function logEvent(eventName, eventData) {
-  return dispatch =>
+export function logEvent(eventName: string, eventData: Record<string, any>) {

Review comment:
       E.g.
   
   ```diff
   diff --git a/superset-frontend/src/logger/actions/index.js b/superset-frontend/src/logger/actions.ts
   similarity index 79%
   rename from superset-frontend/src/logger/actions/index.js
   rename to superset-frontend/src/logger/actions.ts
   index f319068e6..884a8982f 100644
   --- a/superset-frontend/src/logger/actions/index.js
   +++ b/superset-frontend/src/logger/actions.ts
   @@ -16,10 +16,16 @@
     * specific language governing permissions and limitations
     * under the License.
     */
   +import { Dispatch } from 'react-redux';
   +import { LogEventName, LogEventPayload } from './constants';
   +
    export const LOG_EVENT = 'LOG_EVENT';
    
   -export function logEvent(eventName, eventData) {
   -  return dispatch =>
   +export function logEvent<T extends LogEventName>(
   +  eventName: T,
   +  eventData: LogEventPayload<T>,
   +) {
   +  return (dispatch: Dispatch<never>) =>
        dispatch({
          type: LOG_EVENT,
          payload: {
   diff --git a/superset-frontend/src/logger/constants.ts b/superset-frontend/src/logger/constants.ts
   new file mode 100644
   index 000000000..7180e1a21
   --- /dev/null
   +++ b/superset-frontend/src/logger/constants.ts
   @@ -0,0 +1,39 @@
   +/**
   + * Licensed to the Apache Software Foundation (ASF) under one
   + * or more contributor license agreements.  See the NOTICE file
   + * distributed with this work for additional information
   + * regarding copyright ownership.  The ASF licenses this file
   + * to you under the Apache License, Version 2.0 (the
   + * "License"); you may not use this file except in compliance
   + * with the License.  You may obtain a copy of the License at
   + *
   + *   http://www.apache.org/licenses/LICENSE-2.0
   + *
   + * Unless required by applicable law or agreed to in writing,
   + * software distributed under the License is distributed on an
   + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   + * KIND, either express or implied.  See the License for the
   + * specific language governing permissions and limitations
   + * under the License.
   + */
   +export const LogEvents = {
   +  load_chart: 'load_chart',
   +  render_chart: 'render_chart',
   +  hide_browser_tab: 'hide_browser_tab',
   +  mount_dashboard: 'mount_dashboard',
   +  mount_explorer: 'mount_explorer',
   +  select_dashboard_tab: 'select_dashboard_tab',
   +  force_refresh_chart: 'force_refresh_chart',
   +  change_explore_controls: 'change_explore_controls',
   +  toggle_edit_dashboard: 'toggle_edit_dashboard',
   +  force_refresh_dashboard: 'force_refresh_dashboard',
   +  periodic_render_dashboard: 'periodic_render_dashboard',
   +  explore_dashboard_chart: 'explore_dashboard_chart',
   +  export_csv_dashboard_chart: 'export_csv_dashboard_chart',
   +  change_dashboard_filter: 'change_dashboard_filter',
   +  omnibar_triggered: 'omnibar_triggered',
   +};
   +
   +export type LogEventName = keyof typeof LogEvents;
   +
   +export type LogEventPayload<T> = Record<string, any>;
   diff --git a/superset-frontend/src/logger/index.ts b/superset-frontend/src/logger/index.ts
   new file mode 100644
   index 000000000..d3bd62022
   --- /dev/null
   +++ b/superset-frontend/src/logger/index.ts
   @@ -0,0 +1,20 @@
   +/**
   + * Licensed to the Apache Software Foundation (ASF) under one
   + * or more contributor license agreements.  See the NOTICE file
   + * distributed with this work for additional information
   + * regarding copyright ownership.  The ASF licenses this file
   + * to you under the Apache License, Version 2.0 (the
   + * "License"); you may not use this file except in compliance
   + * with the License.  You may obtain a copy of the License at
   + *
   + *   http://www.apache.org/licenses/LICENSE-2.0
   + *
   + * Unless required by applicable law or agreed to in writing,
   + * software distributed under the License is distributed on an
   + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   + * KIND, either express or implied.  See the License for the
   + * specific language governing permissions and limitations
   + * under the License.
   + */
   +export * from './constants';
   +export * from './actions';
   
   ```




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Mime
View raw message