Skip to content

Commit 8f04188

Browse files
authored
Merge pull request #2927 from input-output-hk/feat/ddw-1025-matomo-poc
[DDW-809] Analytics - part 1 - analytics opt-in, settings and unique user ID generation
2 parents 2b0e8d1 + 5da90e4 commit 8f04188

File tree

64 files changed

+1365
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1365
-434
lines changed

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,12 @@
103103
"@types/node": "14.18.1",
104104
"@types/qrcode.react": "1.0.2",
105105
"@types/react": "16.9.56",
106+
"@types/react-router": "5.1.18",
107+
"@types/react-router-dom": "5.3.3",
106108
"@types/react-svg-inline": "2.1.3",
107109
"@types/react-table": "^7.7.9",
108110
"@types/trezor-connect": "8.1.18",
111+
"@types/uuid": "8.3.4",
109112
"@typescript-eslint/eslint-plugin": "5.20.0",
110113
"@typescript-eslint/parser": "5.20.0",
111114
"@xarc/run": "1.1.1",
@@ -291,6 +294,7 @@
291294
"url": "0.11.0",
292295
"usb-detection": "4.13.0",
293296
"util": "0.12.4",
297+
"uuid": "8.3.2",
294298
"validator": "13.7.0"
295299
},
296300
"devEngines": {

source/common/config/electron-store.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export const STORAGE_KEYS: Record<string, StorageKey> = {
2323
STAKE_POOLS_LIST_VIEW_TOOLTIP: 'STAKE-POOLS-LIST-VIEW-TOOLTIP',
2424
STAKING_INFO_WAS_OPEN: 'ALONZO-INFO-WAS-OPEN',
2525
TERMS_OF_USE_ACCEPTANCE: 'TERMS-OF-USE-ACCEPTANCE',
26+
ANALYTICS_ACCEPTANCE: 'ANALYTICS-ACCEPTANCE',
27+
USER_ID: 'USER-ID',
2628
THEME: 'THEME',
2729
TOKEN_FAVORITES: 'TOKEN-FAVORITES',
2830
USER_DATE_FORMAT_ENGLISH: 'USER-DATE-FORMAT-ENGLISH',

source/common/ipc/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const DIALOGS = {
1+
import { ApplicationDialog } from '../../renderer/app/types/applicationDialogTypes';
2+
3+
export const DIALOGS: Record<string, ApplicationDialog> = {
24
ABOUT: 'ABOUT_DIALOG',
35
DAEDALUS_DIAGNOSTICS: 'DAEDALUS_DIAGNOSTICS_DIALOG',
46
ITN_REWARDS_REDEMPTION: 'ITN_REWARDS_REDEMPTION_DIALOG',

source/common/ipc/lib/IpcConversation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { isString } from 'lodash';
2-
import uuid from 'uuid';
2+
import { v4 as uuidv4 } from 'uuid';
33

44
export type IpcSender = {
55
send: (channel: string, conversationId: string, ...args: Array<any>) => void;
@@ -68,7 +68,7 @@ export class IpcConversation<Incoming, Outgoing> {
6868
receiver: IpcReceiver
6969
): Promise<Incoming> {
7070
return new Promise((resolve, reject) => {
71-
const conversationId = uuid();
71+
const conversationId = uuidv4();
7272

7373
const handler = (
7474
event,

source/common/types/electron-store.types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export type StorageKey =
2626
| 'USER-TIME-FORMAT'
2727
| 'WALLET-MIGRATION-STATUS'
2828
| 'WALLETS'
29+
| 'ANALYTICS-ACCEPTANCE'
30+
| 'USER-ID'
2931
| 'WINDOW-BOUNDS';
3032
export type StoreMessage = {
3133
type: StorageType;

source/common/types/environment.types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export type Environment = {
2323
mainProcessID: string;
2424
rendererProcessID: string;
2525
os: string;
26-
cpu: string;
26+
system: string;
27+
cpu: Cpu;
2728
ram: number;
2829
hasMetHardwareRequirements: boolean;
2930
installerVersion: string;
@@ -33,6 +34,7 @@ export type Environment = {
3334
isLinux: boolean;
3435
isBlankScreenFixActive: boolean;
3536
keepLocalClusterRunning: boolean;
37+
analyticsFeatureEnabled: boolean;
3638
};
3739
// constants
3840
export const PRODUCTION = 'production';

source/main/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const isPreview = checkIsPreview(NETWORK);
5050
const isShelleyQA = checkIsShelleyQA(NETWORK);
5151
const isSelfnode = checkIsSelfnode(NETWORK);
5252
const isDevelopment = checkIsDevelopment(NETWORK);
53+
const analyticsFeatureEnabled = isMainnet || isStaging || isTestnet;
5354
const keepLocalClusterRunning = process.env.KEEP_LOCAL_CLUSTER_RUNNING;
5455
const API_VERSION = process.env.API_VERSION || 'dev';
5556
const NODE_VERSION = '1.35.3'; // TODO: pick up this value from process.env
@@ -111,6 +112,7 @@ export const environment: Environment = Object.assign(
111112
isBlankScreenFixActive,
112113
keepLocalClusterRunning,
113114
hasMetHardwareRequirements,
115+
analyticsFeatureEnabled,
114116
},
115117
process.env
116118
);

source/renderer/app/Routes.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import WalletSettingsPage from './containers/wallet/WalletSettingsPage';
3434
import WalletUtxoPage from './containers/wallet/WalletUtxoPage';
3535
import VotingRegistrationPage from './containers/voting/VotingRegistrationPage';
3636
import { IS_STAKING_INFO_PAGE_AVAILABLE } from './config/stakingConfig';
37+
import AnalyticsConsentPage from './containers/profile/AnalyticsConsentPage';
3738

3839
export const Routes = withRouter(() => (
3940
<Route path={ROUTES.ROOT}>
@@ -49,6 +50,10 @@ export const Routes = withRouter(() => (
4950
component={InitialSettingsPage}
5051
/>
5152
<Route path={ROUTES.PROFILE.TERMS_OF_USE} component={TermsOfUsePage} />
53+
<Route
54+
path={ROUTES.PROFILE.ANALYTICS}
55+
component={AnalyticsConsentPage}
56+
/>
5257
<Route
5358
path={ROUTES.PROFILE.DATA_LAYER_MIGRATION}
5459
component={DataLayerMigrationPage}

source/renderer/app/actions/lib/Action.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bindAll } from 'lodash';
33
/**
44
* Listener type as Function that takes specific params <P>
55
*/
6-
export type Listener<P> = (params: P) => any;
6+
export type Listener<P> = (params: P) => void;
77
/**
88
* Action class with typed params
99
*/
@@ -30,8 +30,8 @@ export default class Action<Params> {
3030
this.listeners.push(listener);
3131
}
3232

33-
trigger(params?: Params) {
34-
this.listeners.forEach((listener) => listener(params));
33+
async trigger(params?: Params): Promise<void> {
34+
await Promise.all(this.listeners.map((listener) => listener(params)));
3535
}
3636

3737
remove(listener: Listener<Params>) {

source/renderer/app/actions/profile-actions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import Action from './lib/Action'; // ======= PROFILE ACTIONS =======
1+
import Action from './lib/Action';
2+
import { AnalyticsAcceptanceStatus } from '../analytics/types';
23

34
export default class ProfileActions {
5+
acceptAnalytics: Action<AnalyticsAcceptanceStatus> = new Action();
46
acceptTermsOfUse: Action<any> = new Action();
57
acceptDataLayerMigration: Action<any> = new Action();
68
getLogs: Action<any> = new Action();

0 commit comments

Comments
 (0)