Properly set WebZ version in production

This commit is contained in:
Alexander Zinchuk 2021-06-12 04:24:46 +03:00
parent f5086002bb
commit 1bda49acc9
5 changed files with 13 additions and 7 deletions

View File

@ -7,7 +7,7 @@
"dev": "cross-env APP_ENV=development webpack-dev-server -d",
"build": "webpack -p",
"build:staging": "rm -rf dist/ && APP_ENV=staging npm run build && ./deploy/copy_to_dist.sh",
"build:production": "npm i && rm -rf dist/ && APP_INFO=\"Telegram WebZ alpha $(git rev-parse --short HEAD)\" APP_ENV=production npm run build && ./deploy/copy_to_dist.sh",
"build:production": "npm i && rm -rf dist/ && APP_VERSION=$(git rev-parse --short HEAD) APP_ENV=production npm run build && ./deploy/copy_to_dist.sh",
"deploy:production": "npm run build:production && git add -A && git commit -a -m '[Build]' && git push",
"perf:serve": "APP_ENV=perf parcel src/index-perf.html",
"lint": "eslint . --ext .ts,.tsx",

View File

@ -7,7 +7,7 @@ import { TwoFaParams } from '../../../lib/gramjs/client/2fa';
import { ApiMediaFormat, ApiOnProgress, OnApiUpdate } from '../../types';
import {
DEBUG, DEBUG_GRAMJS, UPLOAD_WORKERS, IS_TEST,
DEBUG, DEBUG_GRAMJS, UPLOAD_WORKERS, IS_TEST, APP_VERSION,
} from '../../../config';
import {
onRequestPhoneNumber, onRequestCode, onRequestPassword, onRequestRegistration,
@ -19,6 +19,9 @@ import downloadMediaWithClient from './media';
import { buildApiUserFromFull } from '../apiBuilders/users';
import localDb from '../localDb';
const DEFAULT_USER_AGENT = 'Unknown UserAgent';
const APP_CODE_NAME = 'Z';
GramJsLogger.setLevel(DEBUG_GRAMJS ? 'debug' : 'warn');
const gramJsUpdateEventBuilder = { build: (update: object) => update };
@ -44,6 +47,8 @@ export async function init(sessionInfo: string, _onUpdate: OnApiUpdate) {
process.env.TELEGRAM_T_API_ID,
process.env.TELEGRAM_T_API_HASH,
{
deviceModel: navigator.userAgent || DEFAULT_USER_AGENT,
appVersion: `${APP_VERSION} ${APP_CODE_NAME}`,
useWSS: true,
additionalDcsDisabled: IS_TEST,
} as any,

View File

@ -7,7 +7,7 @@ import { GlobalActions } from '../../../global/types';
import { LeftColumnContent, ISettings } from '../../../types';
import { ApiChat } from '../../../api/types';
import { APP_INFO, FEEDBACK_URL } from '../../../config';
import { APP_NAME, APP_VERSION, FEEDBACK_URL } from '../../../config';
import { IS_MOBILE_SCREEN } from '../../../util/environment';
import buildClassName from '../../../util/buildClassName';
import { pick } from '../../../util/iteratees';
@ -160,7 +160,7 @@ const LeftMainHeader: FC<OwnProps & StateProps & DispatchProps> = ({
<div id="LeftMainHeader" className="left-header">
<DropdownMenu
trigger={MainButton}
footer={APP_INFO}
footer={`${APP_NAME} ${APP_VERSION}`}
>
<MenuItem
icon="saved-messages"

View File

@ -1,7 +1,8 @@
export const PAGE_TITLE = 'Telegram';
export const INACTIVE_MARKER = ' [Inactive]';
export const APP_INFO = process.env.APP_INFO || 'Telegram T';
export const APP_NAME = 'Telegram WebZ';
export const APP_VERSION = process.env.APP_VERSION || 'dev';
export const DEBUG = (
process.env.APP_ENV !== 'production' && process.env.APP_ENV !== 'perf' && process.env.APP_ENV !== 'test'

View File

@ -1,4 +1,4 @@
import { DEBUG } from '../config';
import { APP_NAME, DEBUG } from '../config';
declare const self: ServiceWorkerGlobalScope;
@ -68,7 +68,7 @@ function getNotificationData(data: PushData): NotificationData {
return {
chatId: getChatId(data),
messageId: getMessageId(data),
title: data.title || process.env.APP_INFO!,
title: data.title || APP_NAME,
body: data.description,
};
}