remove a log message about fetching URLs (#643)

Every fetch made from the client is logged to the console.
But this isn't really necessary, and is particularly confusing
in grist-static, where those fetches are virtualized.

Tests in grist-saas may need adjusting to remove the logger.
This commit is contained in:
Paul Fitzpatrick 2023-08-29 08:49:25 -04:00 committed by GitHub
parent ce02fb94a8
commit 8d687a7651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 3 additions and 16 deletions

View File

@ -1,6 +1,5 @@
import {parsePermissions, permissionSetToText, splitSchemaEditPermissionSet} from 'app/common/ACLPermissions'; import {parsePermissions, permissionSetToText, splitSchemaEditPermissionSet} from 'app/common/ACLPermissions';
import {AclRuleProblem} from 'app/common/ActiveDocAPI'; import {AclRuleProblem} from 'app/common/ActiveDocAPI';
import {ILogger} from 'app/common/BaseAPI';
import {DocData} from 'app/common/DocData'; import {DocData} from 'app/common/DocData';
import {AclMatchFunc, ParsedAclFormula, RulePart, RuleSet, UserAttributeRule} from 'app/common/GranularAccessClause'; import {AclMatchFunc, ParsedAclFormula, RulePart, RuleSet, UserAttributeRule} from 'app/common/GranularAccessClause';
import {getSetMapValue, isNonNullish} from 'app/common/gutil'; import {getSetMapValue, isNonNullish} from 'app/common/gutil';
@ -8,6 +7,8 @@ import {MetaRowRecord} from 'app/common/TableData';
import {decodeObject} from 'app/plugin/objtypes'; import {decodeObject} from 'app/plugin/objtypes';
import sortBy = require('lodash/sortBy'); import sortBy = require('lodash/sortBy');
export type ILogger = Pick<Console, 'log'|'debug'|'info'|'warn'|'error'>;
const defaultMatchFunc: AclMatchFunc = () => true; const defaultMatchFunc: AclMatchFunc = () => true;
export const SPECIAL_RULES_TABLE_ID = '*SPECIAL'; export const SPECIAL_RULES_TABLE_ID = '*SPECIAL';

View File

@ -2,13 +2,10 @@ import {ApiError, ApiErrorDetails} from 'app/common/ApiError';
import axios, {AxiosRequestConfig, AxiosResponse} from 'axios'; import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
import {tbind} from './tbind'; import {tbind} from './tbind';
export type ILogger = Pick<Console, 'log'|'debug'|'info'|'warn'|'error'>;
export interface IOptions { export interface IOptions {
headers?: Record<string, string>; headers?: Record<string, string>;
fetch?: typeof fetch; fetch?: typeof fetch;
newFormData?: () => FormData; // constructor for FormData depends on platform. newFormData?: () => FormData; // constructor for FormData depends on platform.
logger?: ILogger;
extraParameters?: Map<string, string>; // if set, add query parameters to requests. extraParameters?: Map<string, string>; // if set, add query parameters to requests.
} }
@ -54,13 +51,11 @@ export class BaseAPI {
protected fetch: typeof fetch; protected fetch: typeof fetch;
protected newFormData: () => FormData; protected newFormData: () => FormData;
private _headers: Record<string, string>; private _headers: Record<string, string>;
private _logger: ILogger;
private _extraParameters?: Map<string, string>; private _extraParameters?: Map<string, string>;
constructor(options: IOptions = {}) { constructor(options: IOptions = {}) {
this.fetch = options.fetch || tbind(window.fetch, window); this.fetch = options.fetch || tbind(window.fetch, window);
this.newFormData = options.newFormData || (() => new FormData()); this.newFormData = options.newFormData || (() => new FormData());
this._logger = options.logger || console;
this._headers = { this._headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest', 'X-Requested-With': 'XMLHttpRequest',
@ -116,7 +111,6 @@ export class BaseAPI {
} }
} }
const resp = await this.fetch(input, init); const resp = await this.fetch(input, init);
this._logger.log("Fetched", input);
if (resp.status !== 200) { if (resp.status !== 200) {
const body = await resp.json().catch(() => ({})); const body = await resp.json().catch(() => ({}));
throwApiError(input, resp, body); throwApiError(input, resp, body);

View File

@ -14,7 +14,6 @@ import {getDocWorkerMap} from 'app/gen-server/lib/DocWorkerMap';
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager'; import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
import * as docUtils from 'app/server/lib/docUtils'; import * as docUtils from 'app/server/lib/docUtils';
import {FlexServer, FlexServerOptions} from 'app/server/lib/FlexServer'; import {FlexServer, FlexServerOptions} from 'app/server/lib/FlexServer';
import log from 'app/server/lib/log';
import {main as mergedServerMain, ServerType} from 'app/server/mergedServerMain'; import {main as mergedServerMain, ServerType} from 'app/server/mergedServerMain';
import axios from 'axios'; import axios from 'axios';
import FormData from 'form-data'; import FormData from 'form-data';
@ -287,7 +286,6 @@ export class TestSession {
fetch: fetch as any, fetch: fetch as any,
headers, headers,
newFormData: () => new FormData() as any, newFormData: () => new FormData() as any,
logger: log,
}); });
// Make sure api is functioning, and create user if this is their first time to hit API. // Make sure api is functioning, and create user if this is their first time to hit API.
if (checkAccess) { await api.getOrg('current'); } if (checkAccess) { await api.getOrg('current'); }

View File

@ -13,7 +13,6 @@ import {UserProfile} from 'app/common/LoginSessionAPI';
import {BehavioralPrompt, UserPrefs, WelcomePopup} from 'app/common/Prefs'; import {BehavioralPrompt, UserPrefs, WelcomePopup} from 'app/common/Prefs';
import {DocWorkerAPI, UserAPI, UserAPIImpl} from 'app/common/UserAPI'; import {DocWorkerAPI, UserAPI, UserAPIImpl} from 'app/common/UserAPI';
import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager'; import {HomeDBManager} from 'app/gen-server/lib/HomeDBManager';
import log from 'app/server/lib/log';
import {TestingHooksClient} from 'app/server/lib/TestingHooks'; import {TestingHooksClient} from 'app/server/lib/TestingHooks';
import EventEmitter = require('events'); import EventEmitter = require('events');
@ -445,7 +444,7 @@ export class HomeUtil {
headers, headers,
fetch: fetch as any, fetch: fetch as any,
newFormData: () => new FormData() as any, // form-data isn't quite type compatible newFormData: () => new FormData() as any, // form-data isn't quite type compatible
logger: log}); });
} }
private async _toggleTips(enabled: boolean, email: string) { private async _toggleTips(enabled: boolean, email: string) {

View File

@ -14,7 +14,6 @@ import {
getDocApiUsageKeysToIncr, getDocApiUsageKeysToIncr,
WebhookSubscription WebhookSubscription
} from 'app/server/lib/DocApi'; } from 'app/server/lib/DocApi';
import log from 'app/server/lib/log';
import {delayAbort} from 'app/server/lib/serverUtils'; import {delayAbort} from 'app/server/lib/serverUtils';
import axios, {AxiosRequestConfig, AxiosResponse} from 'axios'; import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
import {delay} from 'bluebird'; import {delay} from 'bluebird';
@ -2485,7 +2484,6 @@ function testDocApi() {
headers: {Authorization: 'Bearer api_key_for_kiwi'}, headers: {Authorization: 'Bearer api_key_for_kiwi'},
fetch: fetch as any, fetch: fetch as any,
newFormData: () => new FormData() as any, newFormData: () => new FormData() as any,
logger: log
}); });
// upload something for Chimpy and something else for Kiwi. // upload something for Chimpy and something else for Kiwi.
const worker1 = await userApi.getWorkerAPI('import'); const worker1 = await userApi.getWorkerAPI('import');
@ -2593,7 +2591,6 @@ function testDocApi() {
headers: {Authorization: 'Bearer api_key_for_chimpy'}, headers: {Authorization: 'Bearer api_key_for_chimpy'},
fetch: fetch as any, fetch: fetch as any,
newFormData: () => new FormData() as any, newFormData: () => new FormData() as any,
logger: log
}); });
const ws2 = (await nasaApi.getOrgWorkspaces('current'))[0].id; const ws2 = (await nasaApi.getOrgWorkspaces('current'))[0].id;
const doc2 = await nasaApi.newDoc({name: 'testdoc2', urlId: 'urlid'}, ws2); const doc2 = await nasaApi.newDoc({name: 'testdoc2', urlId: 'urlid'}, ws2);
@ -2625,7 +2622,6 @@ function testDocApi() {
headers: {Authorization: 'Bearer api_key_for_chimpy'}, headers: {Authorization: 'Bearer api_key_for_chimpy'},
fetch: fetch as any, fetch: fetch as any,
newFormData: () => new FormData() as any, newFormData: () => new FormData() as any,
logger: log
}); });
const ws2 = (await nasaApi.getOrgWorkspaces('current'))[0].id; const ws2 = (await nasaApi.getOrgWorkspaces('current'))[0].id;
const doc2 = await nasaApi.newDoc({name: 'testdoc2'}, ws2); const doc2 = await nasaApi.newDoc({name: 'testdoc2'}, ws2);

View File

@ -137,7 +137,6 @@ export class TestServer {
headers: {Authorization: `Bearer api_key_for_${user}`}, headers: {Authorization: `Bearer api_key_for_${user}`},
fetch: fetch as unknown as typeof globalThis.fetch, fetch: fetch as unknown as typeof globalThis.fetch,
newFormData: () => new FormData() as any, newFormData: () => new FormData() as any,
logger: log
}); });
} }