fix(metrics): add workaround for uid check in fxa-settings

Because:
 - the uid getter in fxa-settings could cause an error to be thrown (at
   least when the user has not signed in yet)

This commit:
 - adds a workaround to ignore the error for now
This commit is contained in:
Barry Chen 2023-09-25 16:32:32 -05:00
Родитель 229c5077c3
Коммит f9d8c28ef9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 228DB2785954A0D0
2 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -297,7 +297,9 @@ describe('lib/glean', () => {
// the ping submissions are await'd internally in GleanMetrics... // the ping submissions are await'd internally in GleanMetrics...
await new Promise((resovle) => await new Promise((resovle) =>
setTimeout(() => { setTimeout(() => {
sinon.assert.calledOnce(setuserIdSha256Stub); sinon.assert.calledTwice(setuserIdSha256Stub);
// it sets a default of '' first
sinon.assert.calledWith(setuserIdSha256Stub, '');
sinon.assert.calledWith( sinon.assert.calledWith(
setuserIdSha256Stub, setuserIdSha256Stub,
'7ca0172850c53065046beeac3cdec3fe921532dbfebdf7efeb5c33d019cd7798' '7ca0172850c53065046beeac3cdec3fe921532dbfebdf7efeb5c33d019cd7798'

Просмотреть файл

@ -109,11 +109,14 @@ const populateMetrics = async (properties: EventProperties) => {
event[n].set(properties[n] || ''); event[n].set(properties[n] || '');
} }
if (metricsContext.account?.uid) { userIdSha256.set('');
const hashedUid = await hashUid(metricsContext.account.uid); try {
userIdSha256.set(hashedUid); if (metricsContext.account?.uid) {
} else { const hashedUid = await hashUid(metricsContext.account.uid);
userIdSha256.set(''); userIdSha256.set(hashedUid);
}
} catch (e) {
// noop
} }
oauthClientId.set(metricsContext.integration.data.clientId || ''); oauthClientId.set(metricsContext.integration.data.clientId || '');