Skip to content

Commit

Permalink
Merge pull request #4206 from kubeshop/f1ames/fix/synchronizer-client-id
Browse files Browse the repository at this point in the history
Add client data to synchronizer instances
  • Loading branch information
WitoDelnat authored Jan 4, 2024
2 parents 29687a8 + 44c35df commit 9aae267
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 47 deletions.
7 changes: 5 additions & 2 deletions electron/app/services/cloud/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import {app} from 'electron';

import {join} from 'path';

import {Authenticator, StorageHandlerAuth, createDefaultMonokleAuthenticator} from '@monokle/synchronizer';
import {Authenticator, StorageHandlerAuth, createMonokleAuthenticatorFromOrigin} from '@monokle/synchronizer';
import {getClientConfig} from './client-config';

export const AUTH_CLIENT_ID = 'mc-cli';

let authenticator: Authenticator | undefined;

const initAuthenticator = async (cloudStorageDir: string) => {
const newAuthenticator = createDefaultMonokleAuthenticator(new StorageHandlerAuth(cloudStorageDir));
const newAuthenticator = await createMonokleAuthenticatorFromOrigin(AUTH_CLIENT_ID, getClientConfig(), undefined, new StorageHandlerAuth(cloudStorageDir));
authenticator = newAuthenticator;
return newAuthenticator;
};
Expand Down
18 changes: 18 additions & 0 deletions electron/app/services/cloud/client-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {type, release} from 'os';
import {machineIdSync} from 'node-machine-id';
import {app} from 'electron';
import electronStore from '@shared/utils/electronStore';

const CLIENT_NAME = 'Monokle Desktop';

export function getClientConfig() {
const isTrackingDisabled = Boolean(electronStore.get('appConfig.disableEventTracking'));
const additionalData = isTrackingDisabled ? undefined : { machineId: machineIdSync() };

return {
name: CLIENT_NAME,
version: app.getVersion(),
os: `${type()} ${release()}`,
additionalData,
};
}
5 changes: 3 additions & 2 deletions electron/app/services/cloud/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {app} from 'electron';

import {join} from 'path';

import {StorageHandlerPolicy, Synchronizer, createDefaultMonokleSynchronizer} from '@monokle/synchronizer';
import {StorageHandlerPolicy, Synchronizer, createMonokleSynchronizerFromOrigin} from '@monokle/synchronizer';
import {getClientConfig} from './client-config';

let synchronizer: Synchronizer | undefined;

const initSynchronizer = async (cloudStorageDir: string) => {
const newSynchronizer = createDefaultMonokleSynchronizer(new StorageHandlerPolicy(cloudStorageDir));
const newSynchronizer = await createMonokleSynchronizerFromOrigin(getClientConfig(), undefined, new StorageHandlerPolicy(cloudStorageDir));
synchronizer = newSynchronizer;
return newSynchronizer;
};
Expand Down
149 changes: 107 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"@dnd-kit/sortable": "7.0.2",
"@kubernetes/client-node": "0.19.0",
"@monokle/components": "1.7.0",
"@monokle/synchronizer": "^0.6.0",
"@monokle/synchronizer": "^0.13.0",
"@monokle/validation": "0.31.5",
"@open-policy-agent/opa-wasm": "1.8.0",
"@reduxjs/toolkit": "1.9.5",
Expand Down

0 comments on commit 9aae267

Please sign in to comment.