Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/EnvironmentContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {DomUtils, parseDocument} from 'htmlparser2';
import type {ReactElement, ReactNode} from 'react';
import React, {createContext, useCallback, useEffect, useMemo, useState} from 'react';
import type {ValueOf} from 'type-fest';
import {getEnvironment, getEnvironmentURL} from '@libs/Environment/Environment';
import {getEnvironmentURL} from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import CONST from '@src/CONST';

type EnvironmentProviderProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Request} from '@src/types/onyx';
import proxyConfig from '../../config/proxyConfig';
import {getEnvironment} from './Environment/Environment';
import getEnvironment from './Environment/getEnvironment';

// To avoid rebuilding native apps, native apps use production config for both staging and prod
// We use the async environment check because it works on all platforms
Expand Down
3 changes: 2 additions & 1 deletion src/libs/FraudProtection/GroupIBSdkBridge/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {FP, FPAttributeFormat} from 'group-ib-fp';
import {getEnvironment, getOldDotEnvironmentURL} from '@libs/Environment/Environment';
import {getOldDotEnvironmentURL} from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import Log from '@libs/Log';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
Expand Down
3 changes: 2 additions & 1 deletion src/libs/FraudProtection/GroupIBSdkBridge/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {getEnvironment, getOldDotEnvironmentURL} from '@libs/Environment/Environment';
import {getOldDotEnvironmentURL} from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import Log from '@libs/Log';
import CONST from '@src/CONST';
import cidMap from './cidMap';
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Fullstory/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import FullStory, {FSPage} from '@fullstory/react-native';
import {Str} from 'expensify-common';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
import getEnvironment from '@src/libs/Environment/getEnvironment';
import getChatFSClass from './common';
import type {Fullstory} from './types';

Expand Down Expand Up @@ -33,7 +33,7 @@ const FS: Fullstory = {
// We only use FullStory in production environment. We need to check this here
// after the init function since this function is also called on updates for
// UserMetadata onyx key.
Environment.getEnvironment().then((envName: string) => {
getEnvironment().then((envName: string) => {
const isTestEmail = userMetadata.email !== undefined && userMetadata.email.startsWith('fullstory') && userMetadata.email.endsWith(CONST.EMAIL.QA_DOMAIN);
if ((CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) || Str.extractEmailDomain(userMetadata.email ?? '') === CONST.EXPENSIFY_PARTNER_NAME) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Fullstory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {FullStory, init, isInitialized} from '@fullstory/browser';
import {Str} from 'expensify-common';
import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
import getEnvironment from '@src/libs/Environment/getEnvironment';
import getChatFSClass from './common';
import type {FSPageLike, Fullstory} from './types';

Expand Down Expand Up @@ -54,7 +54,7 @@ const FS: Fullstory = {
return;
}
try {
Environment.getEnvironment().then((envName: string) => {
getEnvironment().then((envName: string) => {
const isTestEmail = userMetadata.email !== undefined && userMetadata.email.startsWith('fullstory') && userMetadata.email.endsWith(CONST.EMAIL.QA_DOMAIN);
if (
(CONST.ENVIRONMENT.PRODUCTION !== envName && !isTestEmail) ||
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
import {convertToDisplayString} from './CurrencyUtils';
import DateUtils from './DateUtils';
import {hasValidDraftComment} from './DraftCommentUtils';
import {getEnvironment, getEnvironmentURL} from './Environment/Environment';
import {getEnvironmentURL} from './Environment/Environment';
import getEnvironment from './Environment/getEnvironment';
import type EnvironmentType from './Environment/getEnvironment/types';
import {getMicroSecondOnyxErrorWithTranslationKey, isReceiptError} from './ErrorUtils';
import getAttachmentDetails from './fileDownload/getAttachmentDetails';
Expand Down Expand Up @@ -920,7 +921,7 @@
const parsedReportActionMessageCache: Record<string, string> = {};

let conciergeReportID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 924 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportID = value;
Expand All @@ -928,7 +929,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 932 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -946,7 +947,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 950 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (currentUserAccountID) {
Expand All @@ -958,14 +959,14 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 962 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
});

let allPolicies: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 969 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => (allPolicies = value),
Expand All @@ -973,7 +974,7 @@

let allReports: OnyxCollection<Report>;
let reportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 977 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1014,14 +1015,14 @@
});

let allBetas: OnyxEntry<Beta[]>;
Onyx.connect({

Check warning on line 1018 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETAS,
callback: (value) => (allBetas = value),
});

let allTransactions: OnyxCollection<Transaction> = {};
let reportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1025 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1047,7 +1048,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1051 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand All @@ -1060,7 +1061,7 @@

let allReportMetadata: OnyxCollection<ReportMetadata>;
const allReportMetadataKeyValue: Record<string, ReportMetadata> = {};
Onyx.connect({

Check warning on line 1064 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_METADATA,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/StatsCounter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import * as API from '@libs/API';
import type GraphiteParams from '@libs/API/parameters/GraphiteParams';
import {READ_COMMANDS} from '@libs/API/types';
import * as Environment from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import getPlatform from '@libs/getPlatform';
import pkg from '../../../package.json';

const StatsCounter = (eventName: string, value = 1) => {
Environment.getEnvironment().then((envName) => {
getEnvironment().then((envName) => {
const platform = getPlatform();
const version = pkg.version.replace(/\./g, '-');

Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Timing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as API from '@libs/API';
import type {SendPerformanceTimingParams} from '@libs/API/parameters';
import {READ_COMMANDS} from '@libs/API/types';
import * as Environment from '@libs/Environment/Environment';
import getEnvironment from '@libs/Environment/getEnvironment';
import Firebase from '@libs/Firebase';
import getPlatform from '@libs/getPlatform';
import Log from '@libs/Log';
Expand Down Expand Up @@ -48,7 +49,7 @@ function end(eventName: string, secondaryName = '', maxExecutionTime = 0) {
Firebase.stopTrace(eventName);
}

Environment.getEnvironment().then((envName) => {
getEnvironment().then((envName) => {
const baseEventName = `${envName}.new.expensify.${eventName}`;
const grafanaEventName = secondaryName ? `${baseEventName}.${secondaryName}` : baseEventName;

Expand Down
7 changes: 6 additions & 1 deletion tests/unit/EnvironmentContextTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import CONST from '@src/CONST';
const mockGetEnvironment: jest.MockedFunction<() => Promise<string>> = jest.fn();
const mockGetEnvironmentURL: jest.MockedFunction<() => Promise<string>> = jest.fn();

jest.mock('@libs/Environment/getEnvironment', () => ({
// eslint-disable-next-line @typescript-eslint/naming-convention
__esModule: true,
default: jest.fn(() => mockGetEnvironment()),
}));

jest.mock('@libs/Environment/Environment', () => ({
getEnvironment: jest.fn().mockImplementation(() => mockGetEnvironment()),
getEnvironmentURL: jest.fn().mockImplementation(() => mockGetEnvironmentURL()),
}));

Expand Down
Loading