Skip to content

Commit 018c067

Browse files
committed
chore: move analytics definitions to suite-common
1 parent 28d1609 commit 018c067

File tree

27 files changed

+75
-63
lines changed

27 files changed

+75
-63
lines changed

packages/suite-analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
"type-check": "yarn g:tsc --build"
1111
},
1212
"dependencies": {
13-
"@trezor/analytics": "workspace:*"
13+
"@suite-common/analytics": "workspace:*"
1414
}
1515
}

packages/suite-analytics/src/index.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
import { Analytics, getRandomId } from '@trezor/analytics';
2-
3-
import type { SuiteAnalyticsEvent } from './types/events';
4-
5-
const analytics = new Analytics<SuiteAnalyticsEvent>({
6-
version: process.env.VERSION!,
7-
app: 'suite',
8-
useQueue: true,
9-
});
10-
11-
export { analytics, getRandomId };
12-
export * from './types/definitions';
13-
export * from './types/events';
14-
export * from './constants';
1+
export * from '@suite-common/analytics/src/events/suite';
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": { "outDir": "libDev" },
4-
"references": [{ "path": "../analytics" }]
4+
"references": [
5+
{ "path": "../../suite-common/analytics" }
6+
]
57
}

suite-common/analytics/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
"dependencies": {
1414
"@reduxjs/toolkit": "2.8.2",
1515
"@suite-common/redux-utils": "workspace:*",
16+
"@suite-common/suite-config": "workspace:*",
17+
"@suite-common/suite-constants": "workspace:*",
18+
"@suite-common/trading": "workspace:*",
19+
"@suite-common/wallet-config": "workspace:*",
20+
"@suite-common/wallet-types": "workspace:*",
21+
"@trezor/analytics": "workspace:*",
22+
"@trezor/connect": "workspace:*",
23+
"@trezor/env-utils": "workspace:*",
1624
"react": "18.2.0"
1725
}
1826
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './suite-native';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './suite';
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { isDebugEnv } from '@suite-native/config';
2-
import { Analytics, Event } from '@trezor/analytics';
1+
import { Analytics, Event, getRandomId } from '@trezor/analytics';
32
import { getSuiteVersion } from '@trezor/env-utils';
43

5-
import { SuiteNativeAnalyticsEvent } from './events';
4+
import { SuiteNativeAnalyticsEvent } from './types';
65

7-
export const analytics = new Analytics<SuiteNativeAnalyticsEvent>({
6+
const analytics = new Analytics<SuiteNativeAnalyticsEvent>({
87
version: getSuiteVersion(),
98
app: 'suite',
109
});
1110

11+
// Inlined to avoid native dependency
12+
const isDebugEnv = () => process.env.EXPO_PUBLIC_ENVIRONMENT === 'debug';
13+
1214
if (isDebugEnv()) {
1315
// Do not send analytics in development
1416
analytics.report = (event: Event) => {
@@ -18,3 +20,8 @@ if (isDebugEnv()) {
1820
}
1921
};
2022
}
23+
24+
export { analytics, getRandomId };
25+
export * from './definitions';
26+
export * from './types';
27+
export * from './constants';

suite-native/analytics/src/events.ts renamed to suite-common/analytics/src/events/suite-native/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
FirmwareUpdatePayload,
1414
FirmwareUpdateStartType,
1515
FirmwareUpdateStuckedState,
16-
} from './types';
16+
} from './definitions';
1717

1818
export type SuiteNativeAnalyticsEvent =
1919
| {

packages/suite-analytics/src/types/definitions.ts renamed to suite-common/analytics/src/events/suite/definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppUpdateEventStatus } from '../constants';
1+
import { AppUpdateEventStatus } from './constants';
22

33
export type OnboardingAnalytics = {
44
startTime: number;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Analytics, getRandomId } from '@trezor/analytics';
2+
3+
import type { SuiteAnalyticsEvent } from './types';
4+
5+
const analytics = new Analytics<SuiteAnalyticsEvent>({
6+
version: process.env.VERSION!,
7+
app: 'suite',
8+
useQueue: true,
9+
});
10+
11+
export { analytics, getRandomId };
12+
export * from './definitions';
13+
export * from './types';
14+
export * from './constants';

packages/suite-analytics/src/types/events.ts renamed to suite-common/analytics/src/events/suite/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NetworkSymbol } from '@suite-common/wallet-config';
22

3-
import { EventType } from '../constants';
3+
import { EventType } from './constants';
44
import type { AppUpdateEvent, FirmwareSource, OnboardingAnalytics } from './definitions';
55

66
export type SuiteAnalyticsEventSuiteReady = {

suite-common/analytics/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
export * from './analyticsReducer';
2-
export * from './analyticsActions';
1+
export { analytics, getRandomId } from './events';
2+
3+
export * from './events';
4+
5+
export * from './redux/analyticsReducer';
6+
export * from './redux/analyticsActions';

suite-common/analytics/tsconfig.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": { "outDir": "libDev" },
4-
"references": [{ "path": "../redux-utils" }]
4+
"references": [
5+
{ "path": "../redux-utils" },
6+
{ "path": "../suite-config" },
7+
{ "path": "../suite-constants" },
8+
{ "path": "../trading" },
9+
{ "path": "../wallet-config" },
10+
{ "path": "../wallet-types" },
11+
{ "path": "../../packages/analytics" },
12+
{ "path": "../../packages/connect" },
13+
{ "path": "../../packages/env-utils" }
14+
]
515
}

suite-common/test-utils/src/mocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@ const getWalletTransaction = (t?: Partial<WalletAccountTransaction>): WalletAcco
304304
...t,
305305
});
306306

307-
// Mocked @trezor/suite-analytics package used in various tests
307+
// Mocked @suite-common/analytics package used in various tests
308308
const getAnalytics = () => {
309-
const originalModule = jest.requireActual('@trezor/suite-analytics');
309+
const originalModule = jest.requireActual('@suite-common/analytics');
310310

311311
return {
312312
__esModule: true, // this property makes it work

suite-common/wallet-core/tests/settings/walletSettingsActions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const initStore = (state: any) =>
1717
preloadedState: { wallet: { settings: state } },
1818
});
1919

20-
jest.doMock('@trezor/suite-analytics', () => testMocks.getAnalytics());
20+
jest.doMock('@suite-common/analytics', () => testMocks.getAnalytics());
2121

2222
describe('walletSettings Actions', () => {
2323
walletSettingsFixtures.forEach(f => {

suite-native/analytics/package.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,8 @@
1212
"dependencies": {
1313
"@suite-common/analytics": "workspace:*",
1414
"@suite-common/redux-utils": "workspace:*",
15-
"@suite-common/suite-config": "workspace:*",
16-
"@suite-common/suite-constants": "workspace:*",
17-
"@suite-common/trading": "workspace:*",
18-
"@suite-common/wallet-config": "workspace:*",
19-
"@suite-common/wallet-types": "workspace:*",
2015
"@suite-native/config": "workspace:*",
2116
"@trezor/analytics": "workspace:*",
22-
"@trezor/connect": "workspace:*",
2317
"@trezor/env-utils": "workspace:*"
2418
}
2519
}

suite-native/analytics/src/analyticsThunks.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import {
55
selectIsAnalyticsConfirmed,
66
selectIsAnalyticsEnabled,
77
} from '@suite-common/analytics';
8+
import { EventType, analytics } from '@suite-common/analytics/src/events/suite-native';
89
import { createThunk } from '@suite-common/redux-utils';
910
import { isDevelopEnv } from '@suite-native/config';
1011
import { allowSentryReport, setSentryUser } from '@suite-native/sentry';
1112
import { getTrackingRandomId } from '@trezor/analytics';
1213
import { getCommitHash } from '@trezor/env-utils';
1314

14-
import { analytics } from './analytics';
15-
import { EventType } from './constants';
16-
1715
const ACTION_PREFIX = '@suite-native/analytics';
1816

1917
export const enableAnalyticsThunk = createThunk(

suite-native/analytics/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
export * from './analytics';
21
export * from './analyticsThunks';
3-
export * from './constants';
4-
export * from './types';
2+
export * from '@suite-common/analytics/src/events/suite-native';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jest.mock('./analytics');
1+
jest.mock('@trezor/analytics');

suite-native/analytics/tsconfig.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,8 @@
88
{
99
"path": "../../suite-common/redux-utils"
1010
},
11-
{
12-
"path": "../../suite-common/suite-config"
13-
},
14-
{
15-
"path": "../../suite-common/suite-constants"
16-
},
17-
{ "path": "../../suite-common/trading" },
18-
{
19-
"path": "../../suite-common/wallet-config"
20-
},
21-
{
22-
"path": "../../suite-common/wallet-types"
23-
},
2411
{ "path": "../config" },
2512
{ "path": "../../packages/analytics" },
26-
{ "path": "../../packages/connect" },
2713
{ "path": "../../packages/env-utils" }
2814
]
2915
}

yarn.lock

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9202,6 +9202,14 @@ __metadata:
92029202
dependencies:
92039203
"@reduxjs/toolkit": "npm:2.8.2"
92049204
"@suite-common/redux-utils": "workspace:*"
9205+
"@suite-common/suite-config": "workspace:*"
9206+
"@suite-common/suite-constants": "workspace:*"
9207+
"@suite-common/trading": "workspace:*"
9208+
"@suite-common/wallet-config": "workspace:*"
9209+
"@suite-common/wallet-types": "workspace:*"
9210+
"@trezor/analytics": "workspace:*"
9211+
"@trezor/connect": "workspace:*"
9212+
"@trezor/env-utils": "workspace:*"
92059213
react: "npm:18.2.0"
92069214
languageName: unknown
92079215
linkType: soft
@@ -9773,14 +9781,8 @@ __metadata:
97739781
dependencies:
97749782
"@suite-common/analytics": "workspace:*"
97759783
"@suite-common/redux-utils": "workspace:*"
9776-
"@suite-common/suite-config": "workspace:*"
9777-
"@suite-common/suite-constants": "workspace:*"
9778-
"@suite-common/trading": "workspace:*"
9779-
"@suite-common/wallet-config": "workspace:*"
9780-
"@suite-common/wallet-types": "workspace:*"
97819784
"@suite-native/config": "workspace:*"
97829785
"@trezor/analytics": "workspace:*"
9783-
"@trezor/connect": "workspace:*"
97849786
"@trezor/env-utils": "workspace:*"
97859787
languageName: unknown
97869788
linkType: soft
@@ -12246,7 +12248,7 @@ __metadata:
1224612248
version: 0.0.0-use.local
1224712249
resolution: "@trezor/suite-analytics@workspace:packages/suite-analytics"
1224812250
dependencies:
12249-
"@trezor/analytics": "workspace:*"
12251+
"@suite-common/analytics": "workspace:*"
1225012252
languageName: unknown
1225112253
linkType: soft
1225212254

0 commit comments

Comments
 (0)