frontend: remove telemetry notification on first load

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8327
GitOrigin-RevId: 7f2e7a2be2d3b74584c407e99f7491db69df661c
This commit is contained in:
Rishichandra Wawhal 2023-04-03 14:39:57 +05:30 committed by hasura-bot
parent 6a75ca1283
commit 80ec1c0684
7 changed files with 3 additions and 128 deletions

View File

@ -205,7 +205,6 @@ const globals = {
: null,
cliUUID: window.__env?.cliUUID || '',
hasuraUUID: '',
telemetryNotificationShown: false,
isProduction,
herokuOAuthClientId: window.__env?.herokuOAuthClientId,
hasuraCloudTenantId: window.__env?.tenantID,

View File

@ -6,11 +6,6 @@ import { hot } from 'react-hot-loader';
import { ThemeProvider } from 'styled-components';
import 'react-loading-skeleton/dist/skeleton.css';
import ErrorBoundary from '../Error/ErrorBoundary';
import {
telemetryNotificationShown,
setTelemetryNotificationShownInDB,
} from '../../telemetry/Actions';
import { showTelemetryNotification } from '../../telemetry/Notifications';
import globals from '../../Globals';
import styles from './App.module.scss';
import { ToastsHub } from '../../new-components/Toasts';
@ -28,7 +23,6 @@ const App = ({
connectionFailed,
dispatch,
metadata,
telemetry,
}) => {
React.useEffect(() => {
const className = document.getElementById('content').className;
@ -46,23 +40,6 @@ const App = ({
object: 'App',
});
}, []);
const telemetryShown = React.useRef(false);
// should be true only in the case of hasura cloud
const isContextCloud = globals.consoleType === 'cloud';
React.useEffect(() => {
if (
telemetry.console_opts &&
!telemetry.console_opts.telemetryNotificationShown &&
!telemetryShown.current &&
!isContextCloud
) {
telemetryShown.current = true;
dispatch(showTelemetryNotification());
dispatch(telemetryNotificationShown());
dispatch(setTelemetryNotificationShownInDB());
}
}, [dispatch, telemetry, isContextCloud]);
let connectionFailMsg = null;
if (connectionFailed) {
@ -123,7 +100,6 @@ const mapStateToProps = state => {
return {
...state.progressBar,
notifications: state.notifications,
telemetry: state.telemetry,
metadata: state.metadata,
};
};

View File

@ -1154,14 +1154,6 @@
}
}
.telemetryNotification {
background-color: red;
padding: 10px;
position: fixed;
bottom: 50px;
right: 0px;
}
.overlappingExclamation {
position: relative;
font-size: 12px;

View File

@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
import { AnyAction, Dispatch } from 'redux';
import { AnyAction } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { getUserType } from '../components/Main/utils';
@ -22,7 +22,6 @@ import { ConsoleState, defaultConsoleState, NotificationsState } from './state';
import { isUpdateIDsEqual } from './utils';
const SET_CONSOLE_OPTS = 'Telemetry/SET_CONSOLE_OPTS';
const SET_NOTIFICATION_SHOWN = 'Telemetry/SET_NOTIFICATION_SHOWN';
const SET_HASURA_UUID = 'Telemetry/SET_HASURA_UUID';
const UPDATE_CONSOLE_NOTIFICATIONS = 'Telemetry/UPDATE_CONSOLE_NOTIFICATIONS';
@ -80,33 +79,6 @@ const setConsoleOptsInDB =
);
};
const telemetryNotificationShown =
() => (dispatch: Dispatch<TelemetryActionTypes>) => {
dispatch({ type: SET_NOTIFICATION_SHOWN });
};
const setTelemetryNotificationShownInDB = () => {
const successCb = (data: Record<string, unknown>) => {
console.log(
`Updated telemetry notification status in db ${JSON.stringify(data)}`
);
};
const errorCb = (error: Error) => {
console.error(
`Failed to update telemetry notification status in db ${JSON.stringify(
error
)}`
);
};
const opts = {
telemetryNotificationShown: true,
};
return setConsoleOptsInDB(opts, successCb, errorCb);
};
const setOnboardingCompletedInDB = (
dispatch: ThunkDispatch<ReduxState, unknown, AnyAction>,
getState: GetReduxState
@ -381,9 +353,6 @@ const loadConsoleOpts =
data: console_state,
});
globals.telemetryNotificationShown =
!!console_state?.telemetryNotificationShown;
if (
!console_state?.console_notifications ||
(console_state.console_notifications &&
@ -417,9 +386,6 @@ interface SetConsoleOptsAction {
type: typeof SET_CONSOLE_OPTS;
data: ConsoleState['console_opts'];
}
interface SetNotificationShowAction {
type: typeof SET_NOTIFICATION_SHOWN;
}
interface SetHasuraUuid {
type: typeof SET_HASURA_UUID;
@ -433,7 +399,6 @@ interface UpdateConsoleNotifications {
type TelemetryActionTypes =
| SetConsoleOptsAction
| SetNotificationShowAction
| SetHasuraUuid
| UpdateConsoleNotifications;
@ -455,14 +420,6 @@ const telemetryReducer = (
...action.data,
},
};
case SET_NOTIFICATION_SHOWN:
return {
...state,
console_opts: {
...state.console_opts,
telemetryNotificationShown: true,
},
};
case SET_HASURA_UUID:
return {
...state,
@ -490,8 +447,6 @@ export {
setConsoleOptsInDB,
setOnboardingCompletedInDB,
setPreReleaseNotificationOptOutInDB,
setTelemetryNotificationShownInDB,
telemetryNotificationShown,
UPDATE_CONSOLE_NOTIFICATIONS,
updateConsoleNotificationsState,
};

View File

@ -1,38 +0,0 @@
import React from 'react';
import { AnyAction } from 'redux';
import { ThunkDispatch } from 'redux-thunk';
import { showNotification } from '../components/Services/Common/Notification';
import { ReduxState } from '../types';
const showTelemetryNotification = () => {
return (dispatch: ThunkDispatch<ReduxState, unknown, AnyAction>) => {
dispatch(
showNotification(
{
position: 'tr',
autoDismiss: 10,
level: 'info',
title: 'Telemetry',
children: (
<div>
Help us improve Hasura! The console collects anonymized usage
stats which allows us to keep improving Hasura at warp speed.
<a
href="https://hasura.io/docs/latest/graphql/core/guides/telemetry.html"
target="_blank"
rel="noopener noreferrer"
>
{' '}
Click here
</a>{' '}
to read more or to opt-out.
</div>
),
},
'info'
)
);
};
};
export { showTelemetryNotification };

View File

@ -7,13 +7,12 @@ export type NotificationsState = {
};
export type UserTypes = 'admin' | string;
export type TelemetryNotificationsState = Record<UserTypes, NotificationsState>;
export type ConsoleNotificationsState = Record<UserTypes, NotificationsState>;
export type ConsoleState = {
console_opts: Nullable<{
telemetryNotificationShown?: boolean;
disablePreReleaseUpdateNotifications?: boolean;
console_notifications?: TelemetryNotificationsState;
console_notifications?: ConsoleNotificationsState;
onboardingShown?: boolean;
}>;
hasura_uuid: string;

View File

@ -1299,14 +1299,6 @@
}
}
.telemetryNotification {
background-color: red;
padding: 10px;
position: fixed;
bottom: 50px;
right: 0px;
}
.overlappingExclamation {
position: relative;
font-size: 12px;