Skip to content

Commit da13a4d

Browse files
Merge remote-tracking branch 'origin/main' into beta-releases
2 parents 928feed + a9f4f5b commit da13a4d

File tree

52 files changed

+1438
-1138
lines changed

Some content is hidden

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

52 files changed

+1438
-1138
lines changed

THIRD-PARTY-NOTICES.md

Lines changed: 70 additions & 283 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1053 additions & 768 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/atlas-service/src/main.spec.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Sinon from 'sinon';
22
import { expect } from 'chai';
3-
import { AtlasService, getTrackingUserInfo, throwIfNotOk } from './main';
3+
import { AtlasService, throwIfNotOk } from './main';
4+
import * as util from './util';
45
import { EventEmitter } from 'events';
56
import { createSandboxFromDefaultPreferences } from 'compass-preferences-model';
67
import type { PreferencesAccess } from 'compass-preferences-model';
78
import type { AtlasUserConfigStore } from './user-config-store';
8-
import type { AtlasUserInfo } from './util';
99

1010
function getListenerCount(emitter: EventEmitter) {
1111
return emitter.eventNames().reduce((acc, name) => {
@@ -74,6 +74,14 @@ describe('AtlasServiceMain', function () {
7474

7575
let preferences: PreferencesAccess;
7676

77+
let getTrackingUserInfoStub: Sinon.SinonStubbedMember<
78+
typeof util.getTrackingUserInfo
79+
>;
80+
81+
before(function () {
82+
getTrackingUserInfoStub = sandbox.stub(util, 'getTrackingUserInfo');
83+
});
84+
7785
beforeEach(async function () {
7886
AtlasService['ipcMain'] = {
7987
handle: sandbox.stub(),
@@ -114,8 +122,15 @@ describe('AtlasServiceMain', function () {
114122
sandbox.resetHistory();
115123
});
116124

125+
after(function () {
126+
sandbox.restore();
127+
});
128+
117129
describe('signIn', function () {
118130
it('should sign in using oidc plugin', async function () {
131+
const atlasUid = 'abcdefgh';
132+
getTrackingUserInfoStub.returns({ auid: atlasUid });
133+
119134
const userInfo = await AtlasService.signIn();
120135
expect(
121136
mockOidcPlugin.mongoClientOptions.authMechanismProperties
@@ -124,6 +139,9 @@ describe('AtlasServiceMain', function () {
124139
// proper error message from oidc plugin in case of failed sign in
125140
).to.have.been.calledTwice;
126141
expect(userInfo).to.have.property('sub', '1234');
142+
expect(preferences.getPreferences().telemetryAtlasUserId).to.equal(
143+
atlasUid
144+
);
127145
});
128146

129147
it('should debounce inflight sign in requests', async function () {
@@ -522,19 +540,6 @@ describe('AtlasServiceMain', function () {
522540
});
523541
});
524542

525-
describe('getTrackingUserInfo', function () {
526-
it('should return required tracking info from user info', function () {
527-
expect(
528-
getTrackingUserInfo({
529-
sub: '1234',
530-
primaryEmail: '[email protected]',
531-
} as AtlasUserInfo)
532-
).to.deep.eq({
533-
auid: '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4',
534-
});
535-
});
536-
});
537-
538543
describe('setupAIAccess', function () {
539544
beforeEach(async function () {
540545
await preferences.savePreferences({

packages/atlas-service/src/main.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { shell, app } from 'electron';
22
import { URL, URLSearchParams } from 'url';
3-
import { createHash } from 'crypto';
43
import type { AuthFlowType, MongoDBOIDCPlugin } from '@mongodb-js/oidc-plugin';
5-
import { AtlasServiceError } from './util';
4+
import { AtlasServiceError, getTrackingUserInfo } from './util';
65
import {
76
createMongoDBOIDCPlugin,
87
hookLoggerToMongoLogWriter as oidcPluginHookLoggerToMongoLogWriter,
@@ -114,14 +113,6 @@ const TOKEN_TYPE_TO_HINT = {
114113
refreshToken: 'refresh_token',
115114
} as const;
116115

117-
export function getTrackingUserInfo(userInfo: AtlasUserInfo) {
118-
return {
119-
// AUID is shared Cloud user identificator that can be tracked through
120-
// various MongoDB properties
121-
auid: createHash('sha256').update(userInfo.sub, 'utf8').digest('hex'),
122-
};
123-
}
124-
125116
export type AtlasServiceConfig = {
126117
atlasApiBaseUrl: string;
127118
atlasApiUnauthBaseUrl: string;
@@ -374,7 +365,11 @@ export class AtlasService {
374365
'AtlasService',
375366
'Signed in successfully'
376367
);
377-
track('Atlas Sign In Success', getTrackingUserInfo(userInfo));
368+
const { auid } = getTrackingUserInfo(userInfo);
369+
track('Atlas Sign In Success', { auid });
370+
await this.preferences.savePreferences({
371+
telemetryAtlasUserId: auid,
372+
});
378373
return userInfo;
379374
} catch (err) {
380375
track('Atlas Sign In Error', {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { getTrackingUserInfo } from './util';
2+
import type { AtlasUserInfo } from './util';
3+
import { expect } from 'chai';
4+
5+
describe('getTrackingUserInfo', function () {
6+
it('should return required tracking info from user info', function () {
7+
expect(
8+
getTrackingUserInfo({
9+
sub: '1234',
10+
primaryEmail: '[email protected]',
11+
} as AtlasUserInfo)
12+
).to.deep.eq({
13+
auid: '03ac674216f3e15c761ee1a5e255f067953623c8b388b4459e13f978d7c846f4',
14+
});
15+
});
16+
});

packages/atlas-service/src/util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type * as plugin from '@mongodb-js/oidc-plugin';
22
import util from 'util';
33
import type { AtlasUserConfig } from './user-config-store';
4+
import { createHash } from 'crypto';
45

56
export type AtlasUserInfo = {
67
sub: string;
@@ -160,3 +161,11 @@ export class AtlasServiceError extends Error {
160161
this.detail = detail;
161162
}
162163
}
164+
165+
export function getTrackingUserInfo(userInfo: AtlasUserInfo) {
166+
return {
167+
// AUID is shared Cloud user identificator that can be tracked through
168+
// various MongoDB properties
169+
auid: createHash('sha256').update(userInfo.sub, 'utf8').digest('hex'),
170+
};
171+
}

packages/compass-aggregations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"mongodb-database-model": "^2.17.4",
9090
"mongodb-instance-model": "^12.17.4",
9191
"mongodb-ns": "^2.4.0",
92-
"mongodb-query-parser": "^4.0.2",
92+
"mongodb-query-parser": "^4.1.0",
9393
"mongodb-schema": "^12.1.0",
9494
"nyc": "^15.1.0",
9595
"prettier": "^2.7.1",

packages/compass-aggregations/src/components/aggregation-side-panel/stage-wizard-use-cases/match/match.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ describe('match', function () {
593593
const onChangeSpy = Sinon.spy();
594594
render(<MatchForm fields={SAMPLE_FIELDS} onChange={onChangeSpy} />);
595595
setComboboxValue(new RegExp(SINGLE_SELECT_LABEL, 'i'), 'name');
596-
expect(onChangeSpy.lastCall.args).deep.equal(["{\n name: ''\n}", null]);
596+
expect(onChangeSpy.lastCall.args).deep.equal(["{\n name: ''\n}", null]);
597597
});
598598

599599
it('should call onChange with an error if there was an error during the conversion to stage', function () {

packages/compass-crud/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"mocha": "^10.2.0",
101101
"mongodb-instance-model": "^12.17.4",
102102
"mongodb-ns": "^2.4.0",
103-
"mongodb-query-parser": "^4.0.2",
103+
"mongodb-query-parser": "^4.1.0",
104104
"nyc": "^15.1.0",
105105
"prop-types": "^15.7.2",
106106
"react": "^17.0.2",

packages/compass-crud/src/components/bulk-delete-modal.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('BulkDeleteModal Component', function () {
7070
it('shows the provided query', function () {
7171
renderBulkDeleteModal({ filter: { a: 1 } });
7272
expect(screen.getByTestId('readonly-filter').textContent).to.equal(
73-
'{\n a: 1\n}'
73+
'{\n a: 1\n}'
7474
);
7575
});
7676

0 commit comments

Comments
 (0)