From 88913c5d727b23c1c334017a1360c178ed2ed811 Mon Sep 17 00:00:00 2001 From: AntoineYANG Date: Mon, 19 Jun 2023 17:15:06 +0800 Subject: [PATCH] fix #375 : remove outdated log service Co-Authored-By: kyusho --- .../rath-client/src/loggers/dataImport.ts | 33 ------------------- .../pages/dataConnection/airtable/index.tsx | 7 ---- .../pages/dataConnection/database/index.tsx | 8 ----- .../src/pages/dataConnection/demo.tsx | 8 ----- .../src/pages/dataConnection/file/index.tsx | 8 +---- .../pages/dataConnection/jsonAPI/index.tsx | 8 ----- .../src/pages/dataConnection/olap.tsx | 7 ---- .../src/pages/dataConnection/restful.tsx | 8 ----- .../dataSource/selection/airtable/index.tsx | 7 ---- .../dataSource/selection/database/index.tsx | 8 ----- .../src/pages/dataSource/selection/demo.tsx | 8 ----- .../pages/dataSource/selection/file/index.tsx | 8 +---- .../dataSource/selection/jsonAPI/index.tsx | 8 ----- .../src/pages/dataSource/selection/olap.tsx | 7 ---- .../pages/dataSource/selection/restful.tsx | 8 ----- 15 files changed, 2 insertions(+), 139 deletions(-) diff --git a/packages/rath-client/src/loggers/dataImport.ts b/packages/rath-client/src/loggers/dataImport.ts index b3510c163..c6bfcc536 100644 --- a/packages/rath-client/src/loggers/dataImport.ts +++ b/packages/rath-client/src/loggers/dataImport.ts @@ -1,36 +1,3 @@ -import { IMuteFieldBase, IRow } from "../interfaces" - -const DATA_SOURCE_LOGGER_URL = - 'https://1423108296428281.cn-hangzhou.fc.aliyuncs.com/2016-08-15/proxy/Rath/dataSourceLogger/' - -interface IDataImportInfo { - dataType: string; - fields: IMuteFieldBase[]; - dataSource: IRow[]; - name?: string; - info?: any; - size: number; -} -export async function logDataImport (props: IDataImportInfo) { - if (process.env.NODE_ENV === 'production') { - try { - const res = await fetch(DATA_SOURCE_LOGGER_URL, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(props), - }) - await res.json() - } catch (error) { - console.error(error) - } - } else { - // eslint-disable-next-line no-console - console.log(`Current Env: ${process.env.NODE_ENV}.`, props); - } -} - export async function dataBackup (file: File) { if (process.env.NODE_ENV === 'production') { const data = new FormData(); diff --git a/packages/rath-client/src/pages/dataConnection/airtable/index.tsx b/packages/rath-client/src/pages/dataConnection/airtable/index.tsx index 372f8c8e5..501cf5e83 100644 --- a/packages/rath-client/src/pages/dataConnection/airtable/index.tsx +++ b/packages/rath-client/src/pages/dataConnection/airtable/index.tsx @@ -1,7 +1,6 @@ import { DefaultButton, PrimaryButton, Stack, TextField } from '@fluentui/react'; import React, { useCallback, useState } from 'react'; import intl from 'react-intl-universal' -import { logDataImport } from '../../../loggers/dataImport'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../interfaces'; import { rawData2DataWithBaseMetas } from '../../dataSource/utils'; import { DataSourceTag, IDBMeta } from '../../../utils/storage'; @@ -38,12 +37,6 @@ const AirTableSource: React.FC = (props) => { .then((ds) => { const name = `airtable-${tableName}-${viewName}`; onDataLoaded(ds.fields, ds.dataSource, name, DataSourceTag.AIR_TABLE); - logDataImport({ - dataType: 'AirTable', - fields: ds.fields, - dataSource: ds.dataSource.slice(0, 10), - size: ds.dataSource.length - }); userStore.saveDataSourceOnCloudOnlineMode({ name, datasourceType: DataSourceType.AirTable, diff --git a/packages/rath-client/src/pages/dataConnection/database/index.tsx b/packages/rath-client/src/pages/dataConnection/database/index.tsx index 5a5c449f0..5f16ea7ef 100644 --- a/packages/rath-client/src/pages/dataConnection/database/index.tsx +++ b/packages/rath-client/src/pages/dataConnection/database/index.tsx @@ -3,7 +3,6 @@ import { observer } from 'mobx-react-lite'; import intl from 'react-intl-universal'; import { IDropdownOption, Stack, registerIcons, PrimaryButton } from '@fluentui/react'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../interfaces'; -import { logDataImport } from '../../../loggers/dataImport'; import prefetch from '../../../utils/prefetch'; import { notify } from '../../../components/error'; import { DataSourceTag } from '../../../utils/storage'; @@ -177,13 +176,6 @@ const DatabaseData: React.FC = ({ onClose, onDataLoaded, setL const { dataSource, fields } = data; const name = [database.value, schema.value].filter(Boolean).join('.'); - logDataImport({ - dataType: `Database/${databaseType}`, - name, - fields, - dataSource: dataSource.slice(0, 10), - size: dataSource.length, - }); userStore.saveDataSourceOnCloudOnlineMode({ name, datasourceType: DataSourceType.Database, diff --git a/packages/rath-client/src/pages/dataConnection/demo.tsx b/packages/rath-client/src/pages/dataConnection/demo.tsx index 510face40..09f053242 100644 --- a/packages/rath-client/src/pages/dataConnection/demo.tsx +++ b/packages/rath-client/src/pages/dataConnection/demo.tsx @@ -19,7 +19,6 @@ import { useId } from "@fluentui/react-hooks"; import intl from 'react-intl-universal'; import styled from 'styled-components'; import { Caption1, Card, CardHeader, Text } from '@fluentui/react-components'; -import { logDataImport } from '../../loggers/dataImport'; import { IDatasetBase, IMuteFieldBase, IRow } from '../../interfaces'; import { DEMO_DATA_REQUEST_TIMEOUT } from '../../constants'; import { DataSourceTag, IDBMeta } from '../../utils/storage'; @@ -104,13 +103,6 @@ const DemoData: FC = props => { requestDemoData(demo.key).then(data => { const { dataSource, fields } = data; onDataLoaded(fields, dataSource, `${demo.text}.${RathDemoVirtualExt}`, DataSourceTag.DEMO); - logDataImport({ - dataType: "Demo", - name: demo.key, - fields, - dataSource: [], - size: dataSource.length, - }); }).catch((err) => { onLoadingFailed(err); }) diff --git a/packages/rath-client/src/pages/dataConnection/file/index.tsx b/packages/rath-client/src/pages/dataConnection/file/index.tsx index 2ec42d253..992bac3b0 100644 --- a/packages/rath-client/src/pages/dataConnection/file/index.tsx +++ b/packages/rath-client/src/pages/dataConnection/file/index.tsx @@ -20,7 +20,7 @@ import { observer } from "mobx-react-lite"; import * as xlsx from 'xlsx'; import intl from "react-intl-universal"; import { isExcelFile, loadDataFile, loadExcelFile, loadExcelRaw, parseExcelFile, readRaw, SampleKey } from "../../dataSource/utils" -import { dataBackup, logDataImport } from "../../../loggers/dataImport"; +import { dataBackup } from "../../../loggers/dataImport"; import { DataSourceType, IMuteFieldBase, IRow } from "../../../interfaces"; import { DataSourceTag, IDBMeta } from "../../../utils/storage" import { useGlobalStore } from "../../../store"; @@ -238,12 +238,6 @@ const FileData: FC = (props) => { fileType: preview.type, }, }, preview); - logDataImport({ - dataType: 'File', - fields, - dataSource: dataSource.slice(0, 10), - size: dataSource.length - }); dataBackup(preview); onDataLoaded(fields, dataSource, preview.name, DataSourceTag.FILE); onClose(); diff --git a/packages/rath-client/src/pages/dataConnection/jsonAPI/index.tsx b/packages/rath-client/src/pages/dataConnection/jsonAPI/index.tsx index 00a170e02..c26db8810 100644 --- a/packages/rath-client/src/pages/dataConnection/jsonAPI/index.tsx +++ b/packages/rath-client/src/pages/dataConnection/jsonAPI/index.tsx @@ -20,7 +20,6 @@ import intl from 'react-intl-universal'; import MonacoEditor from 'react-monaco-editor'; import { unstable_batchedUpdates } from 'react-dom'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../interfaces'; -import { logDataImport } from '../../../loggers/dataImport'; import { DataSourceTag } from '../../../utils/storage'; import { useGlobalStore } from '../../../store'; import { IJSONAPIFormat, getFullData, getPreviewData, jsonDataFormatChecker, requestJSONAPIData } from './utils'; @@ -82,13 +81,6 @@ const JSONAPI: React.FC = (props) => { datasourceType: DataSourceType.Restful, linkInfo: { api, detectedDataStruct }, }); - logDataImport({ - dataType: 'JSON API', - name: api, - fields, - dataSource: dataSource.slice(0, 20), - size: dataSource.length, - }); } onClose(); } diff --git a/packages/rath-client/src/pages/dataConnection/olap.tsx b/packages/rath-client/src/pages/dataConnection/olap.tsx index f91eea4ed..934f276bf 100644 --- a/packages/rath-client/src/pages/dataConnection/olap.tsx +++ b/packages/rath-client/src/pages/dataConnection/olap.tsx @@ -19,7 +19,6 @@ import { DefaultButton, Dropdown, IDropdownOption, PrimaryButton, ProgressIndica import ConnectionStatus from '../../components/connectionStatus'; import { DataSourceType, IMuteFieldBase, IRow } from '../../interfaces'; import { useGlobalStore } from '../../store'; -import { logDataImport } from '../../loggers/dataImport'; import { notify } from '../../components/error'; import { DataSourceTag } from '../../utils/storage'; @@ -61,12 +60,6 @@ const OLAPData: React.FC = (props) => { clickHouseStore .loadSampleData() .then(({ fieldMetas, data }) => { - logDataImport({ - dataType: 'OLAP', - fields: fieldMetas, - dataSource: data.slice(0, 10), - size: data.length, - }); userStore.saveDataSourceOnCloudOnlineMode({ name: '', datasourceType: DataSourceType.Restful, diff --git a/packages/rath-client/src/pages/dataConnection/restful.tsx b/packages/rath-client/src/pages/dataConnection/restful.tsx index 6bd47be03..6218cbbac 100644 --- a/packages/rath-client/src/pages/dataConnection/restful.tsx +++ b/packages/rath-client/src/pages/dataConnection/restful.tsx @@ -20,7 +20,6 @@ import intl from 'react-intl-universal'; import MonacoEditor from 'react-monaco-editor'; import { DEMO_DATA_REQUEST_TIMEOUT } from '../../constants'; import { DataSourceType, IDatasetBase, IMuteFieldBase, IRow } from '../../interfaces'; -import { logDataImport } from '../../loggers/dataImport'; import { DataSourceTag } from '../../utils/storage'; import { useGlobalStore } from '../../store'; @@ -82,13 +81,6 @@ const RestFul: React.FC = (props) => { datasourceType: DataSourceType.Restful, linkInfo: { api }, }); - logDataImport({ - dataType: 'Restful API', - name: api, - fields, - dataSource: [], - size: dataSource.length, - }); }) .catch((err) => { onLoadingFailed(err); diff --git a/packages/rath-client/src/pages/dataSource/selection/airtable/index.tsx b/packages/rath-client/src/pages/dataSource/selection/airtable/index.tsx index c953a9fa7..9e7c2100d 100644 --- a/packages/rath-client/src/pages/dataSource/selection/airtable/index.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/airtable/index.tsx @@ -1,7 +1,6 @@ import { DefaultButton, PrimaryButton, Stack, TextField } from '@fluentui/react'; import React, { useCallback, useState } from 'react'; import intl from 'react-intl-universal' -import { logDataImport } from '../../../../loggers/dataImport'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../../interfaces'; import { rawData2DataWithBaseMetas } from '../../utils'; import { DataSourceTag, IDBMeta } from '../../../../utils/storage'; @@ -38,12 +37,6 @@ const AirTableSource: React.FC = (props) => { .then((ds) => { const name = `airtable-${tableName}-${viewName}`; onDataLoaded(ds.fields, ds.dataSource, name, DataSourceTag.AIR_TABLE); - logDataImport({ - dataType: 'AirTable', - fields: ds.fields, - dataSource: ds.dataSource.slice(0, 10), - size: ds.dataSource.length - }); userStore.saveDataSourceOnCloudOnlineMode({ name, datasourceType: DataSourceType.AirTable, diff --git a/packages/rath-client/src/pages/dataSource/selection/database/index.tsx b/packages/rath-client/src/pages/dataSource/selection/database/index.tsx index 2dc198447..964a14d3b 100644 --- a/packages/rath-client/src/pages/dataSource/selection/database/index.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/database/index.tsx @@ -9,7 +9,6 @@ import useAsyncState from '../../../../hooks/use-async-state'; import useCachedState from '../../../../hooks/use-cached-state'; import { notify } from '../../../../components/error'; import { useGlobalStore } from '../../../../store'; -import { logDataImport } from '../../../../loggers/dataImport'; import { rawData2DataWithBaseMetas } from '../../utils'; import databaseOptions from './config'; import type { SupportedDatabaseType } from './type'; @@ -148,13 +147,6 @@ const DatabaseConnector: FC = ({ onClose, onDataLoaded }) => credentials, }, }); - logDataImport({ - dataType: `Database/${sourceType}`, - name, - fields, - dataSource: dataSource.slice(0, 10), - size: dataSource.length, - }); onDataLoaded(fields, dataSource, name, DataSourceTag.DATABASE); onClose(); diff --git a/packages/rath-client/src/pages/dataSource/selection/demo.tsx b/packages/rath-client/src/pages/dataSource/selection/demo.tsx index 3b2f65f9c..c231be004 100644 --- a/packages/rath-client/src/pages/dataSource/selection/demo.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/demo.tsx @@ -4,7 +4,6 @@ import { useId } from "@fluentui/react-hooks"; import intl from 'react-intl-universal'; import styled from 'styled-components'; import { DemoDataAssets, IDemoDataKey, useDemoDataOptions } from '../config'; -import { logDataImport } from '../../../loggers/dataImport'; import { IDatasetBase, IMuteFieldBase, IRow } from '../../../interfaces'; import { DEMO_DATA_REQUEST_TIMEOUT } from '../../../constants'; import { DataSourceTag, IDBMeta } from '../../../utils/storage'; @@ -138,13 +137,6 @@ const DemoData: FC = props => { requestDemoData(demo.key).then(data => { const { dataSource, fields } = data; onDataLoaded(fields, dataSource, `${demo.text}.${RathDemoVirtualExt}`, DataSourceTag.DEMO); - logDataImport({ - dataType: "Demo", - name: demo.key, - fields, - dataSource: [], - size: dataSource.length, - }); }).catch((err) => { onLoadingFailed(err); }) diff --git a/packages/rath-client/src/pages/dataSource/selection/file/index.tsx b/packages/rath-client/src/pages/dataSource/selection/file/index.tsx index c9ad03331..c1c076e3c 100644 --- a/packages/rath-client/src/pages/dataSource/selection/file/index.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/file/index.tsx @@ -5,7 +5,7 @@ import { observer } from "mobx-react-lite"; import * as xlsx from 'xlsx'; import intl from "react-intl-universal"; import { isExcelFile, loadDataFile, loadExcelFile, loadExcelRaw, parseExcelFile, readRaw, SampleKey } from "../../utils"; -import { dataBackup, logDataImport } from "../../../../loggers/dataImport"; +import { dataBackup } from "../../../../loggers/dataImport"; import { DataSourceType, IMuteFieldBase, IRow } from "../../../../interfaces"; import { DataSourceTag, IDBMeta } from "../../../../utils/storage"; import { useGlobalStore } from "../../../../store"; @@ -224,12 +224,6 @@ const FileData: FC = (props) => { fileType: preview.type, }, }, preview); - logDataImport({ - dataType: 'File', - fields, - dataSource: dataSource.slice(0, 10), - size: dataSource.length - }); dataBackup(preview); onDataLoaded(fields, dataSource, preview.name, DataSourceTag.FILE); onClose(); diff --git a/packages/rath-client/src/pages/dataSource/selection/jsonAPI/index.tsx b/packages/rath-client/src/pages/dataSource/selection/jsonAPI/index.tsx index e2a19492a..d55c504b3 100644 --- a/packages/rath-client/src/pages/dataSource/selection/jsonAPI/index.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/jsonAPI/index.tsx @@ -20,7 +20,6 @@ import intl from 'react-intl-universal'; import MonacoEditor from 'react-monaco-editor'; import { unstable_batchedUpdates } from 'react-dom'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../../interfaces'; -import { logDataImport } from '../../../../loggers/dataImport'; import { DataSourceTag } from '../../../../utils/storage'; import { useGlobalStore } from '../../../../store'; import { IJSONAPIFormat, getFullData, getPreviewData, jsonDataFormatChecker, requestJSONAPIData } from './utils'; @@ -82,13 +81,6 @@ const JSONAPI: React.FC = (props) => { datasourceType: DataSourceType.Restful, linkInfo: { api, detectedDataStruct }, }); - logDataImport({ - dataType: 'JSON API', - name: api, - fields, - dataSource: dataSource.slice(0, 20), - size: dataSource.length, - }); } onClose(); } diff --git a/packages/rath-client/src/pages/dataSource/selection/olap.tsx b/packages/rath-client/src/pages/dataSource/selection/olap.tsx index 02b15ec9f..062cdab63 100644 --- a/packages/rath-client/src/pages/dataSource/selection/olap.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/olap.tsx @@ -4,7 +4,6 @@ import { DefaultButton, Dropdown, IDropdownOption, PrimaryButton, ProgressIndica import ConnectionStatus from '../../../components/connectionStatus'; import { DataSourceType, IMuteFieldBase, IRow } from '../../../interfaces'; import { useGlobalStore } from '../../../store'; -import { logDataImport } from '../../../loggers/dataImport'; import { notify } from '../../../components/error'; import { DataSourceTag } from '../../../utils/storage'; @@ -45,12 +44,6 @@ const OLAPData: React.FC = props => { const loadData = useCallback(() => { clickHouseStore.loadSampleData() .then(({ fieldMetas, data}) => { - logDataImport({ - dataType: 'OLAP', - fields: fieldMetas, - dataSource: data.slice(0, 10), - size: data.length - }); userStore.saveDataSourceOnCloudOnlineMode({ name: '', datasourceType: DataSourceType.Restful, diff --git a/packages/rath-client/src/pages/dataSource/selection/restful.tsx b/packages/rath-client/src/pages/dataSource/selection/restful.tsx index fd53b8aec..7fac74795 100644 --- a/packages/rath-client/src/pages/dataSource/selection/restful.tsx +++ b/packages/rath-client/src/pages/dataSource/selection/restful.tsx @@ -5,7 +5,6 @@ import intl from 'react-intl-universal' import MonacoEditor from 'react-monaco-editor'; import { DEMO_DATA_REQUEST_TIMEOUT } from '../../../constants'; import { DataSourceType, IDatasetBase, IMuteFieldBase, IRow } from '../../../interfaces'; -import { logDataImport } from '../../../loggers/dataImport'; import { DataSourceTag } from '../../../utils/storage'; import { useGlobalStore } from '../../../store'; @@ -65,13 +64,6 @@ const RestFul: React.FC = props => { datasourceType: DataSourceType.Restful, linkInfo: { api }, }); - logDataImport({ - dataType: "Restful API", - name: api, - fields, - dataSource: [], - size: dataSource.length, - }); }).catch((err) => { onLoadingFailed(err); })