mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-21 22:57:17 +01:00
chore(suite): add suite version and commit hash to env utils
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
"prepublish": "yarn tsx ../../scripts/prepublish.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"react-native-config": "^1.5.0",
|
||||
"ua-parser-js": "^1.0.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies -- react-native and expo-localization have been excluded from the package.json file as a workaround, ensuring that they are not bundled with the suite-desktop app */
|
||||
|
||||
import { Dimensions, Platform } from 'react-native';
|
||||
import Config from 'react-native-config';
|
||||
|
||||
import { getLocales } from 'expo-localization';
|
||||
|
||||
@@ -24,6 +25,10 @@ const getDeviceType = () => '';
|
||||
|
||||
const getOsVersion = () => `${Platform.Version}`;
|
||||
|
||||
const getSuiteVersion = () => Config.VERSION || '';
|
||||
|
||||
const getCommitHash = () => Config.COMMIT_HASH || '';
|
||||
|
||||
const isFirefox = () => false;
|
||||
|
||||
const getPlatform = () => Platform.OS;
|
||||
@@ -77,8 +82,10 @@ export const envUtils: EnvUtils = {
|
||||
isChromeOs,
|
||||
getBrowserName,
|
||||
getBrowserVersion,
|
||||
getCommitHash,
|
||||
getDeviceType,
|
||||
getOsVersion,
|
||||
getSuiteVersion,
|
||||
isFirefox,
|
||||
getPlatform,
|
||||
getPlatformLanguages,
|
||||
|
||||
@@ -30,9 +30,13 @@ const isChromeOs = () => /CrOS/.test(getUserAgent());
|
||||
|
||||
const getBrowserVersion = () => getUserAgentParser().getBrowser().version || '';
|
||||
|
||||
const getCommitHash = () => process.env.COMMITHASH || '';
|
||||
|
||||
/* Not correct for Linux as there is many different distributions in different versions */
|
||||
const getOsVersion = () => getUserAgentParser().getOS().version || '';
|
||||
|
||||
const getSuiteVersion = () => process.env.VERSION || '';
|
||||
|
||||
const getBrowserName = () => {
|
||||
const browserName = getUserAgentParser().getBrowser().name;
|
||||
return browserName?.toLowerCase() || '';
|
||||
@@ -122,7 +126,9 @@ export const envUtils: EnvUtils = {
|
||||
getOsVersion,
|
||||
getBrowserName,
|
||||
getBrowserVersion,
|
||||
getCommitHash,
|
||||
getDeviceType,
|
||||
getSuiteVersion,
|
||||
isFirefox,
|
||||
getPlatform,
|
||||
getPlatformLanguages,
|
||||
|
||||
@@ -11,8 +11,10 @@ export const {
|
||||
isChromeOs,
|
||||
getBrowserVersion,
|
||||
getBrowserName,
|
||||
getCommitHash,
|
||||
getDeviceType,
|
||||
getOsVersion,
|
||||
getSuiteVersion,
|
||||
isFirefox,
|
||||
getPlatform,
|
||||
getPlatformLanguages,
|
||||
|
||||
@@ -9,8 +9,10 @@ export interface EnvUtils {
|
||||
isChromeOs: () => boolean;
|
||||
getBrowserName: () => string;
|
||||
getBrowserVersion: () => string;
|
||||
getCommitHash: () => string;
|
||||
getDeviceType: () => string | undefined;
|
||||
getOsVersion: () => string;
|
||||
getSuiteVersion: () => string;
|
||||
isFirefox: () => boolean;
|
||||
getPlatform: () => string;
|
||||
getPlatformLanguages: () => readonly string[];
|
||||
|
||||
@@ -31,6 +31,7 @@ module.exports = {
|
||||
'!node_modules/@babel',
|
||||
'!node_modules/date-fns',
|
||||
'!node_modules/@reduxjs',
|
||||
'!node_modules/react-native-config',
|
||||
'!node_modules/redux',
|
||||
'!node_modules/redux-thunk',
|
||||
'!node_modules/reselect',
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import { allowSentryReport, setSentryUser } from '@suite-utils/sentry';
|
||||
import { getEnvironment } from '@trezor/env-utils';
|
||||
import { getEnvironment, getCommitHash } from '@trezor/env-utils';
|
||||
import type { Dispatch, GetState } from '@suite-types';
|
||||
|
||||
import {
|
||||
@@ -52,7 +52,7 @@ export const init = () => (dispatch: Dispatch, getState: GetState) => {
|
||||
instanceId,
|
||||
sessionId,
|
||||
environment: getEnvironment(),
|
||||
commitId: process.env.COMMITHASH || '',
|
||||
commitId: getCommitHash(),
|
||||
isDev: !process.env.CODESIGN_BUILD,
|
||||
callbacks: {
|
||||
onEnable: () => dispatch(enableAnalyticsThunk()),
|
||||
|
||||
@@ -15,6 +15,8 @@ import {
|
||||
getWindowHeight,
|
||||
getWindowWidth,
|
||||
getOsName,
|
||||
getCommitHash,
|
||||
getSuiteVersion,
|
||||
} from '@trezor/env-utils';
|
||||
|
||||
const Headline = styled.div`
|
||||
@@ -186,8 +188,8 @@ export const Feedback = ({ type }: FeedbackProps) => {
|
||||
platform: getEnvironment(),
|
||||
os: getOsName(),
|
||||
user_agent: getUserAgent(),
|
||||
suite_version: process.env.VERSION || '',
|
||||
suite_revision: process.env.COMMITHASH || '',
|
||||
suite_version: getSuiteVersion(),
|
||||
suite_revision: getCommitHash(),
|
||||
window_dimensions: `${getWindowWidth()}x${getWindowHeight()}`,
|
||||
device_model: getDeviceModel(device),
|
||||
firmware_version: device?.features ? getFirmwareVersion(device) : '',
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { getDeviceModel, getFirmwareType, getFirmwareVersion } from '@trezor/device-utils';
|
||||
|
||||
import { isDesktop, getUserAgent, getScreenWidth, getScreenHeight } from '@trezor/env-utils';
|
||||
import {
|
||||
getCommitHash,
|
||||
getScreenHeight,
|
||||
getScreenWidth,
|
||||
getSuiteVersion,
|
||||
getUserAgent,
|
||||
isDesktop,
|
||||
} from '@trezor/env-utils';
|
||||
import type { TrezorDevice } from '@suite-types';
|
||||
import type { TransportInfo } from '@trezor/connect';
|
||||
import { GITHUB_REPO_URL } from '@trezor/urls';
|
||||
@@ -20,7 +27,7 @@ const getDeviceInfo = (device?: TrezorDevice) => {
|
||||
};
|
||||
|
||||
const getSuiteInfo = () =>
|
||||
`${isDesktop() ? 'desktop' : 'web'} ${process.env.VERSION} (${process.env.COMMITHASH})`;
|
||||
`${isDesktop() ? 'desktop' : 'web'} ${getSuiteVersion()} (${getCommitHash()})`;
|
||||
|
||||
const getTransportInfo = (transport?: Partial<TransportInfo>) => {
|
||||
if (!transport?.type) {
|
||||
|
||||
@@ -6,11 +6,13 @@ import {
|
||||
getEnvironment,
|
||||
getBrowserName,
|
||||
getBrowserVersion,
|
||||
getCommitHash,
|
||||
getOsName,
|
||||
getOsVersion,
|
||||
getPlatformLanguages,
|
||||
getScreenHeight,
|
||||
getScreenWidth,
|
||||
getSuiteVersion,
|
||||
getWindowHeight,
|
||||
getWindowWidth,
|
||||
} from '@trezor/env-utils';
|
||||
@@ -168,8 +170,8 @@ export const getApplicationLog = (log: LogEntry[], redactSensitiveData = false)
|
||||
|
||||
export const getApplicationInfo = (state: AppState, hideSensitiveInfo: boolean) => ({
|
||||
environment: getEnvironment(),
|
||||
suiteVersion: process.env.VERSION || '',
|
||||
commitHash: process.env.COMMITHASH || '',
|
||||
suiteVersion: getSuiteVersion(),
|
||||
commitHash: getCommitHash(),
|
||||
startTime,
|
||||
isDev: !process.env.CODESIGN_BUILD,
|
||||
debugMenu: state.suite.settings.debug.showDebugMenu,
|
||||
|
||||
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Link, H2, P } from '@trezor/components';
|
||||
import { Modal } from '@suite-components';
|
||||
import { getCommitHash, getSuiteVersion } from '@trezor/env-utils';
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: flex;
|
||||
@@ -19,16 +20,16 @@ export const Version = () => (
|
||||
<P size="small" weight="bold">
|
||||
APPLICATION VERSION
|
||||
</P>
|
||||
<H2 data-test="@version/number">{process.env.VERSION}</H2>
|
||||
<H2 data-test="@version/number">{getSuiteVersion()}</H2>
|
||||
<Line />
|
||||
<P size="small" weight="bold">
|
||||
LAST COMMIT HASH
|
||||
</P>
|
||||
<Link
|
||||
href={`https://github.com/trezor/trezor-suite/commits/${process.env.COMMITHASH}`}
|
||||
href={`https://github.com/trezor/trezor-suite/commits/${getCommitHash()}`}
|
||||
data-test="@version/commit-hash-link"
|
||||
>
|
||||
<H2>{process.env.COMMITHASH}</H2>
|
||||
<H2>{getCommitHash()}</H2>
|
||||
</Link>
|
||||
</Wrapper>
|
||||
</Modal>
|
||||
|
||||
@@ -4,8 +4,10 @@ import {
|
||||
getEnvironment,
|
||||
getBrowserName,
|
||||
getBrowserVersion,
|
||||
getCommitHash,
|
||||
getOsName,
|
||||
getOsVersion,
|
||||
getSuiteVersion,
|
||||
Environment as EnvironmentType,
|
||||
} from '@trezor/env-utils';
|
||||
import type {
|
||||
@@ -230,8 +232,8 @@ export const getValidMessages = (config: MessageSystem | null, options: Options)
|
||||
const currentBrowserVersion = transformVersionToSemverFormat(getBrowserVersion());
|
||||
|
||||
const environment = getEnvironment();
|
||||
const suiteVersion = transformVersionToSemverFormat(process.env.VERSION);
|
||||
const commitHash = process.env.COMMITHASH;
|
||||
const suiteVersion = transformVersionToSemverFormat(getSuiteVersion());
|
||||
const commitHash = getCommitHash();
|
||||
|
||||
return config.actions
|
||||
.filter(
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"@suite-common/wallet-config": "workspace:*",
|
||||
"@suite-common/wallet-types": "workspace:*",
|
||||
"@suite-native/config": "workspace:*",
|
||||
"@trezor/analytics": "workspace:*"
|
||||
"@trezor/analytics": "workspace:*",
|
||||
"@trezor/env-utils": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { getAppVersion, isDebugEnv } from '@suite-native/config';
|
||||
import { isDebugEnv } from '@suite-native/config';
|
||||
import { getSuiteVersion } from '@trezor/env-utils';
|
||||
import { Analytics } from '@trezor/analytics';
|
||||
|
||||
import { SuiteNativeAnalyticsEvent } from './events';
|
||||
|
||||
export const analytics = new Analytics<SuiteNativeAnalyticsEvent>(getAppVersion(), 'suite');
|
||||
export const analytics = new Analytics<SuiteNativeAnalyticsEvent>(getSuiteVersion(), 'suite');
|
||||
|
||||
if (isDebugEnv()) {
|
||||
// Do not send analytics in development
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
} from '@suite-common/analytics';
|
||||
import { createThunk } from '@suite-common/redux-utils';
|
||||
import { getTrackingRandomId } from '@trezor/analytics';
|
||||
import { getCommitHash, isDevelopEnv } from '@suite-native/config';
|
||||
import { isDevelopEnv } from '@suite-native/config';
|
||||
import { getCommitHash } from '@trezor/env-utils';
|
||||
|
||||
import { analytics } from './analytics';
|
||||
import { EventType } from './constants';
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"path": "../../suite-common/wallet-types"
|
||||
},
|
||||
{ "path": "../config" },
|
||||
{ "path": "../../packages/analytics" }
|
||||
{ "path": "../../packages/analytics" },
|
||||
{ "path": "../../packages/env-utils" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import Config from 'react-native-config';
|
||||
|
||||
export const getAppVersion = () => Config.VERSION || '';
|
||||
|
||||
export const getCommitHash = () => Config.COMMIT_HASH || '';
|
||||
|
||||
export const getBuildVersionNumber = () => Config.BUILD_NUMBER || '';
|
||||
|
||||
export const getChangelog = () => Config.CHANGELOG || '';
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"@suite-native/module-settings": "workspace:*",
|
||||
"@suite-native/navigation": "workspace:*",
|
||||
"@suite-native/storage": "workspace:*",
|
||||
"@trezor/env-utils": "workspace:*",
|
||||
"@trezor/styles": "workspace:*",
|
||||
"@trezor/theme": "workspace:*",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
getEnv,
|
||||
getChangelog,
|
||||
getCommitHash,
|
||||
getAppVersion,
|
||||
getBuildVersionNumber,
|
||||
} from '@suite-native/config';
|
||||
import { getEnv, getChangelog, getBuildVersionNumber } from '@suite-native/config';
|
||||
import { getSuiteVersion, getCommitHash } from '@trezor/env-utils';
|
||||
import { ListItem, VStack } from '@suite-native/atoms';
|
||||
|
||||
export const BuildInfo = () => (
|
||||
<VStack spacing="medium">
|
||||
<ListItem
|
||||
subtitle={`${getEnv()}-${getAppVersion()} (${getBuildVersionNumber()}), commit ${getCommitHash()}`}
|
||||
subtitle={`${getEnv()}-${getSuiteVersion()} (${getBuildVersionNumber()}), commit ${getCommitHash()}`}
|
||||
title="Build version"
|
||||
/>
|
||||
<ListItem subtitle={getChangelog()} title="Changelog" />
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
{ "path": "../module-settings" },
|
||||
{ "path": "../navigation" },
|
||||
{ "path": "../storage" },
|
||||
{ "path": "../../packages/env-utils" },
|
||||
{ "path": "../../packages/styles" },
|
||||
{ "path": "../../packages/theme" }
|
||||
]
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"@suite-native/storage": "workspace:*",
|
||||
"@suite-native/theme": "workspace:*",
|
||||
"@trezor/connect": "workspace:*",
|
||||
"@trezor/env-utils": "workspace:*",
|
||||
"@trezor/styles": "workspace:*",
|
||||
"@trezor/theme": "workspace:*",
|
||||
"jotai": "1.9.1",
|
||||
|
||||
@@ -4,7 +4,8 @@ import { S } from '@mobily/ts-belt';
|
||||
|
||||
import { Screen, ScreenHeader } from '@suite-native/navigation';
|
||||
import { VStack, Card, Text, Box, Divider, ListItem } from '@suite-native/atoms';
|
||||
import { getAppVersion, getBuildVersionNumber, getCommitHash } from '@suite-native/config';
|
||||
import { getBuildVersionNumber } from '@suite-native/config';
|
||||
import { getSuiteVersion, getCommitHash } from '@trezor/env-utils';
|
||||
import { useOpenLink } from '@suite-native/link';
|
||||
|
||||
import { AboutUsBanners } from '../components/AboutUsBanners';
|
||||
@@ -21,7 +22,7 @@ const CommitHashWithDevMenu = () => (
|
||||
export const SettingsAboutUsScreen = () => {
|
||||
const openLink = useOpenLink();
|
||||
const hasVersionAndBuildInfo =
|
||||
S.isNotEmpty(getAppVersion()) && S.isNotEmpty(getBuildVersionNumber());
|
||||
S.isNotEmpty(getSuiteVersion()) && S.isNotEmpty(getBuildVersionNumber());
|
||||
const hasCommitHash = S.isNotEmpty(getCommitHash());
|
||||
|
||||
return (
|
||||
@@ -53,7 +54,7 @@ export const SettingsAboutUsScreen = () => {
|
||||
<Box flexDirection="row" justifyContent="space-between">
|
||||
{hasVersionAndBuildInfo && (
|
||||
<Text variant="hint" color="textDisabled">
|
||||
Version: {`${getAppVersion()} (${getBuildVersionNumber()})`}
|
||||
Version: {`${getSuiteVersion()} (${getBuildVersionNumber()})`}
|
||||
</Text>
|
||||
)}
|
||||
{(hasCommitHash || true) && <CommitHashWithDevMenu />}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
{ "path": "../storage" },
|
||||
{ "path": "../theme" },
|
||||
{ "path": "../../packages/connect" },
|
||||
{ "path": "../../packages/env-utils" },
|
||||
{ "path": "../../packages/styles" },
|
||||
{ "path": "../../packages/theme" }
|
||||
]
|
||||
|
||||
@@ -6572,6 +6572,7 @@ __metadata:
|
||||
"@suite-common/wallet-types": "workspace:*"
|
||||
"@suite-native/config": "workspace:*"
|
||||
"@trezor/analytics": "workspace:*"
|
||||
"@trezor/env-utils": "workspace:*"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
@@ -6910,6 +6911,7 @@ __metadata:
|
||||
"@suite-native/module-settings": "workspace:*"
|
||||
"@suite-native/navigation": "workspace:*"
|
||||
"@suite-native/storage": "workspace:*"
|
||||
"@trezor/env-utils": "workspace:*"
|
||||
"@trezor/styles": "workspace:*"
|
||||
"@trezor/theme": "workspace:*"
|
||||
jest: ^26.6.3
|
||||
@@ -7032,6 +7034,7 @@ __metadata:
|
||||
"@suite-native/storage": "workspace:*"
|
||||
"@suite-native/theme": "workspace:*"
|
||||
"@trezor/connect": "workspace:*"
|
||||
"@trezor/env-utils": "workspace:*"
|
||||
"@trezor/styles": "workspace:*"
|
||||
"@trezor/theme": "workspace:*"
|
||||
jotai: 1.9.1
|
||||
@@ -7818,6 +7821,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@trezor/env-utils@workspace:packages/env-utils"
|
||||
dependencies:
|
||||
react-native-config: ^1.5.0
|
||||
rimraf: ^5.0.1
|
||||
tsx: ^3.12.7
|
||||
typescript: 4.9.5
|
||||
|
||||
Reference in New Issue
Block a user