Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client data to synchronizer instances #81

Merged
merged 4 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 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 @@ -173,7 +173,7 @@
},
"dependencies": {
"@monokle/parser": "^0.3.2",
"@monokle/synchronizer": "^0.12.5",
"@monokle/synchronizer": "^0.13.0",
"@monokle/validation": "^0.32.0",
"@segment/analytics-node": "^1.1.0",
"normalize-url": "^4.5.1",
Expand Down
18 changes: 18 additions & 0 deletions src/client-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type, release } from 'os';
import { readFileSync } from 'fs';
import { env } from 'vscode';

const CLIENT_NAME = 'Monokle VSCode';

export function getClientConfig() {
const pkg = JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8'));

return {
name: CLIENT_NAME,
version: pkg.version,
os: `${type()} ${release()}`,
additionalData: {
machineId: env.machineId,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For privacy concerns, maybe we should only add this when analytics are enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, especially that without telemetry we won't get any other data to connect with this one by machineId.

}
};
}
4 changes: 3 additions & 1 deletion src/utils/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getClientConfig } from '../client-config';

export type Authenticator = Awaited<ReturnType<typeof getAuthenticator>>;

export const AUTH_CLIENT_ID = 'mc-cli';
Expand All @@ -17,7 +19,7 @@ export async function getAuthenticator(origin?: string) {
const {createMonokleAuthenticatorFromOrigin} = await import('@monokle/synchronizer');

try {
const authenticator = await createMonokleAuthenticatorFromOrigin(AUTH_CLIENT_ID, origin);
const authenticator = await createMonokleAuthenticatorFromOrigin(AUTH_CLIENT_ID, getClientConfig(), origin);
return authenticator;
} catch (err: any) {
// Without this entire extension can run only in local mode. Needs to be obvious to users what went wrong and how to fix.
Expand Down
4 changes: 3 additions & 1 deletion src/utils/synchronization.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getClientConfig } from '../client-config';

export type Synchronizer = Awaited<ReturnType<typeof getSynchronizer>>;

export async function getSynchronizer(origin?: string) {
Expand Down Expand Up @@ -26,7 +28,7 @@ export async function getSynchronizer(origin?: string) {
const {createMonokleSynchronizerFromOrigin} = await import('@monokle/synchronizer');

try {
const synchronizer = await createMonokleSynchronizerFromOrigin(origin);
const synchronizer = await createMonokleSynchronizerFromOrigin(getClientConfig(), origin);
return synchronizer;
} catch (err: any) {
// Without this entire extension can run only in local mode. Needs to be obvious to users what went wrong and how to fix.
Expand Down