Skip to content

Commit d154f40

Browse files
authored
Merge pull request #221 from vbihun/audit-logs-and-add-debugLog
Audit logs and add debugLog
2 parents 69d27cd + c520372 commit d154f40

33 files changed

+122
-16
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = {
5353
'react/jsx-filename-extension': 'off',
5454
'react/require-default-props': 'off',
5555
'import/prefer-default-export': 'off',
56-
'no-console': 'off',
56+
'no-console': ['error', { allow: ['warn', 'error'] }],
5757
'prettier/prettier': [
5858
'error',
5959
{

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ app:
7575

7676
Documentation for the Compass GitLab integration can be found [here](https://developer.atlassian.com/cloud/compass/integrations/integrate-Compass-with-Gitlab/). For more information about building integrations on Compass, see [here](https://developer.atlassian.com/cloud/compass/integrations/get-started-integrating-with-Compass/).
7777

78+
### Debugging
79+
80+
To use console.log locally, you should use the debugLog method from the ./src/utils/debugLog.ts and set the forge variable APP_ENV to development
7881

7982
## Tests
8083

src/client/agg.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AggOperation } from '../types';
55
export const aggQuery = async (request: AggOperation) => {
66
const response = await api.asApp().requestGraph(request.query, request.variables);
77
const responseBody = await response.json();
8+
// eslint-disable-next-line no-console
89
console.log({
910
message: 'AGG request',
1011
requestName: request.name,

src/client/compass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function deleteExternalAlias(input: DeleteCompassComponentExternalA
113113
const { errors } = await graphqlGateway.compass.asApp().deleteExternalAlias(input);
114114

115115
if (errors.length === 1 && errors[0].message === UNKNOWN_EXTERNAL_ALIAS_ERROR_MESSAGE) {
116-
console.log('Could not find external alias to delete.');
116+
console.warn('Could not find external alias to delete.');
117117
return;
118118
}
119119

src/client/gitlab.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const callGitlab = async (
7979
const startTime = performance.now();
8080

8181
try {
82+
// eslint-disable-next-line no-console
8283
console.log(`Calling gitlab to ${apiOperation}`);
8384
const resp = await fetch(`${BASE_URL}${path}`, {
8485
method: config?.method || HttpMethod.GET,
@@ -90,6 +91,7 @@ export const callGitlab = async (
9091
body,
9192
});
9293

94+
// eslint-disable-next-line no-console
9395
console.log(`Gitlab response status: ${resp.status}`);
9496

9597
if (resp.status === 204) {
@@ -111,6 +113,7 @@ export const callGitlab = async (
111113
} finally {
112114
const endTime = performance.now();
113115
const duration = endTime - startTime;
116+
// eslint-disable-next-line no-console
114117
console.log(`GitLab API call to ${apiOperation} took ${duration.toFixed(2)} ms`);
115118
}
116119
};
@@ -133,6 +136,7 @@ export const getGroupsData = async (
133136

134137
const { data } = await callGitlab(`getGroupsData`, `/api/v4/groups?${queryParams}`, groupAccessToken);
135138

139+
// eslint-disable-next-line no-console
136140
console.log('Number of groups fetched:', data.length);
137141

138142
return data;
@@ -208,6 +212,7 @@ export const getGroupAccessTokens = async (
208212
groupToken,
209213
);
210214

215+
// eslint-disable-next-line no-console
211216
console.log('Number of active access tokens fetched:', groupAccessTokenList.length);
212217

213218
return groupAccessTokenList;
@@ -475,6 +480,7 @@ export const getEnvironments = async (
475480
groupToken,
476481
);
477482

483+
// eslint-disable-next-line no-console
478484
console.log('Number of environments fetched:', data.length);
479485

480486
return data;

src/entry/data-provider/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const dataProvider = async (
6868
backfillData.metrics.mrCycleTime = mrCycleTime;
6969
backfillData.metrics.openMergeRequestsCount = openMergeRequestsCount;
7070
} catch (err) {
71-
console.log(`data provider error: ${err.message}`);
71+
console.error(`data provider error: ${err.message}`);
7272
const invocationErrorOptions = { backoffTimeInSeconds: 3600 };
7373

7474
if (err instanceof GitlabHttpMethodError) {

src/entry/extension-points/pre-uninstall.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type PreUninstallPayload = {
1212
export default async function preUninstall(payload: PreUninstallPayload): Promise<void> {
1313
const { cloudId } = payload.context;
1414

15+
// eslint-disable-next-line no-console
1516
console.log(`Performing preUninstall for site ${cloudId}`);
1617

1718
const forgeAppId = getForgeAppId();

src/entry/find-matching-files/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,20 @@ export const findMatchingFiles = async (payload: FindMatchingFilesPayload): Prom
8787
payload.fileName.equalsOneOf,
8888
);
8989
if (matchingTopLevelFiles.length > 0) {
90+
// eslint-disable-next-line no-console
9091
console.log(`Found ${matchingTopLevelFiles.length} matching files in depth level 0`);
9192
foundMatchingFiles = [...foundMatchingFiles, ...matchingTopLevelFiles];
9293
}
9394

9495
nextLevelDirectoriesToCheck = getDirectories(allTopLevelFiles);
9596
for (let i = 0; i < LEVELS_TO_SEARCH - 1; i += 1) {
9697
let tempNextLevelDirectoriesToCheck: ProjectFile[] = [];
98+
// eslint-disable-next-line no-console
9799
console.log(`Searching ${nextLevelDirectoriesToCheck.length} directories in depth level ${i + 1}`);
98100

99101
for (const directory of nextLevelDirectoriesToCheck) {
100102
const allProjectFiles = await callListFiles(groupToken, project.id, directory.path);
103+
// eslint-disable-next-line no-console
101104
console.log(`Found ${allProjectFiles.length} project files in depth level ${i + 1}`);
102105

103106
const matchingFiles = getMatchingFiles(
@@ -106,6 +109,7 @@ export const findMatchingFiles = async (payload: FindMatchingFilesPayload): Prom
106109
payload.fileName.equalsOneOf,
107110
);
108111
if (matchingFiles.length > 0) {
112+
// eslint-disable-next-line no-console
109113
console.log(`Found ${matchingFiles.length} matching files in depth level ${i + 1}`);
110114
foundMatchingFiles = [...foundMatchingFiles, ...matchingFiles];
111115
}
@@ -126,7 +130,7 @@ export const findMatchingFiles = async (payload: FindMatchingFilesPayload): Prom
126130
statusCode: 200,
127131
};
128132
} catch (e) {
129-
console.log('Failed to find matching files', e.message);
133+
console.error('Failed to find matching files', e.message);
130134
return {
131135
success: false,
132136
errorMessage: e.message,

src/entry/import-recent-repos/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ export const importRecentRepos = async ({
147147
const checkedDataWithExistingComponents = await checkForExistingImports(cloudId, groupToken, recentProjects.data);
148148
const projectsToImport = filterExistingProjects(recentProjects.data, checkedDataWithExistingComponents);
149149

150+
// eslint-disable-next-line no-console
150151
console.log(`Importing ${projectsToImport.length} recent repos that have not been imported yet`);
151152

152153
const importResults = await importReposToCompass(cloudId, projectsToImport, groupToken);

src/entry/scheduled-triggers/data-provider-backfill.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ export default async function dataProviderBackfill(req: WebtriggerRequest): Prom
1414
const queue = new Queue({ key: 'data-provider-backfill' });
1515

1616
if (!isCompassPushEventEnabled()) {
17-
console.log('Compass push event is not enabled');
17+
console.warn('Compass push event is not enabled');
1818
return;
1919
}
2020

2121
const backfillVersion = await getBackfillVersion();
2222
if (backfillVersion >= CURRENT_BACKFILL_VERSION) {
23+
// eslint-disable-next-line no-console
2324
console.log(`Skipping backfill as it already has the latest version (v${backfillVersion})`);
2425
return;
2526
}

0 commit comments

Comments
 (0)