Skip to content

Commit

Permalink
feature: add support for multi region param
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayElkana committed May 27, 2024
1 parent c8bf7af commit f5bd864
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/consts/urls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AppFeatureType } from 'src/types/services/app-features-service';
import { LogType, LogsFilterCriteriaArguments } from 'types/commands/logs';
import { AppId } from 'types/general';
import { Region } from 'types/general/region';

const BASE_APPS_URL = '/api/apps';
const BASE_APP_VERSIONS_URL = '/api/app-versions';
Expand Down Expand Up @@ -48,13 +49,16 @@ export const getLogsStreamForAppVersionIdUrl = (
appVersionId: number,
logsType: LogType,
logsFilterCriteria?: LogsFilterCriteriaArguments | null,
region?: Region,
): string => {
const logsFilterCriteriaParams = logsFilterCriteria
? `&fromDate=${logsFilterCriteria.fromDate.getTime()}&toDate=${logsFilterCriteria.toDate.getTime()}&text=${encodeURIComponent(
logsFilterCriteria.text || '',
)}`
: '';
return `${appVersionIdBaseUrl(appVersionId)}/logs?type=${logsType}${logsFilterCriteriaParams}`;
return `${appVersionIdBaseUrl(appVersionId)}/logs?type=${logsType}${logsFilterCriteriaParams}${
region ? `&region=${region}` : ''
}`;
};

export const listAppsUrl = (): string => {
Expand Down
5 changes: 1 addition & 4 deletions src/services/notification-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Region } from 'types/general/region';
import { HttpMethodTypes } from 'types/services/api-service';
import { ClientChannel } from 'types/services/notification-service';
import logger from 'utils/logger';
import { addRegionToQuery } from 'utils/region';
import { appsUrlBuilder } from 'utils/urls-builder';

export const logsStream = async (
Expand All @@ -19,13 +18,11 @@ export const logsStream = async (
region?: Region,
): Promise<ClientChannel> => {
try {
const logsStreamForUrl = getLogsStreamForAppVersionIdUrl(appVersionId, logsType, logsFilterCriteria);
const logsStreamForUrl = getLogsStreamForAppVersionIdUrl(appVersionId, logsType, logsFilterCriteria, region);
const url = appsUrlBuilder(logsStreamForUrl);
logger.debug(`fetching logs url: ${url}`);
const query = addRegionToQuery({}, region);
const response = await execute<ClientChannel>(
{
query,
url,
headers: { Accept: 'application/json' },
method: HttpMethodTypes.GET,
Expand Down

0 comments on commit f5bd864

Please sign in to comment.