Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed outdated code related to web analytics #8755

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion Dockerfile.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
COPY cvat-canvas/ /tmp/cvat-canvas/
COPY cvat-ui/ /tmp/cvat-ui/

ARG WA_PAGE_VIEW_HIT
ARG UI_APP_CONFIG
ARG CLIENT_PLUGINS
ARG DISABLE_SOURCE_MAPS
ARG SOURCE_MAPS_TOKEN

Check warning on line 30 in Dockerfile.ui

View workflow job for this annotation

GitHub Actions / build

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "SOURCE_MAPS_TOKEN") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

RUN CLIENT_PLUGINS="${CLIENT_PLUGINS}" \
DISABLE_SOURCE_MAPS="${DISABLE_SOURCE_MAPS}" \
Expand Down
5 changes: 1 addition & 4 deletions cvat-ui/src/components/cvat-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ import { Organization, getCore } from 'cvat-core-wrapper';
import {
ErrorState, NotificationState, NotificationsState, PluginsState,
} from 'reducers';
import { customWaViewHit } from 'utils/environment';
import showPlatformNotification, {
platformInfo,
stopNotifications,
Expand Down Expand Up @@ -142,7 +141,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP

public componentDidMount(): void {
const core = getCore();
const { history, location, onChangeLocation } = this.props;
const { history, onChangeLocation } = this.props;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential bug: Inconsistent prop usage

The location prop is removed from destructuring but is still used elsewhere in the component. This could lead to runtime errors.

Verify all usages of the location prop and ensure consistent handling:

#!/bin/bash
# Search for all usages of 'location' prop in the component
ast-grep --pattern 'location' cvat-ui/src/components/cvat-app.tsx

const {
HEALTH_CHECK_RETRIES, HEALTH_CHECK_PERIOD, HEALTH_CHECK_REQUEST_TIMEOUT,
SERVER_UNAVAILABLE_COMPONENT, RESET_NOTIFICATIONS_PATHS,
Expand Down Expand Up @@ -170,9 +169,7 @@ class CVATApplication extends React.PureComponent<CVATAppProps & RouteComponentP
}
};

customWaViewHit(location.pathname, location.search, location.hash);
history.listen((newLocation) => {
customWaViewHit(newLocation.pathname, newLocation.search, newLocation.hash);
const { location: prevLocation } = this.props;

onChangeLocation(prevLocation.pathname, newLocation.pathname);
Expand Down
22 changes: 1 addition & 21 deletions cvat-ui/src/utils/environment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corp
// Copyright (C) 2024 CVAT.ai Corpopration
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
//
// SPDX-License-Identifier: MIT

Expand All @@ -9,23 +9,3 @@
export function isDev(): boolean {
return process.env.NODE_ENV === 'development';
}

export function customWaViewHit(pageName?: string, queryString?: string, hashInfo?: string): void {
const waHitFunctionName = process.env.WA_PAGE_VIEW_HIT;
if (waHitFunctionName) {
const waHitFunction = new Function(
'pageName',
'queryString',
'hashInfo',
`if (typeof ${waHitFunctionName} === 'function') {
${waHitFunctionName}(pageName, queryString, hashInfo);
}`,
);
try {
waHitFunction(pageName, queryString, hashInfo);
} catch (error: any) {
// eslint-disable-next-line
console.error(`Web analytics hit function has failed. ${error.toString()}`);
}
}
}
Loading