-
Notifications
You must be signed in to change notification settings - Fork 1
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
User agent client hints support #18
base: main
Are you sure you want to change the base?
Conversation
src/extra/AddonInfo.ts
Outdated
} | ||
|
||
export class AddonInfo implements WebTelemetryAddon<AddonInfoData & AddonInfoMetadata, {}> { | ||
data(): AddonInfoData & AddonInfoMetadata { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Паша data
синхронный метод.
А getHighEntropyValues
это ассинхронная операция.
Т.е. у тебя возможен вариант когда не будет нужных данных при чтении из объекта который вернул data() .
Тут по хорошему у тебя должны были сломаться какие-то тесты. Глянь есть ли такие тесты, если нет напиши.
src/extra/AddonInfo.ts
Outdated
|
||
return highEntropyValues; | ||
} | ||
|
||
metadata() { | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Новые данные должный сюда идти, а не в data.
Все что приходит в данные ложится в именные столбцы в таблицу.
Все, что приходит в metadata ложиться в поле metadata в виде json.
Т.е. новые поля без миграции таблиц мы добавляем в metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pamellix Паша, у нас телеметрия не умеет работать с асинхронными аддонами.
Попробуй доработать, чтобы могла.
Но для начала нужно написать тесты, которые бы падали при добавлении асинхронности в аддоны.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Паша, просто завернуть всё в await — не вариант.
Во-первых, могут возникнуть ситуации, когда код вместо параллельного выполнения будет выполняться последовательно.
Во-вторых, теперь придётся писать await везде, включая сторонние аддоны.
Мы с тобой обсуждали другой подход.
Давай еще раз обсудим голосом.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/WebTelemetryBase.spec.ts
Outdated
@@ -3,21 +3,21 @@ import { WebTelemetryBase } from './WebTelemetryBase'; | |||
|
|||
class Addon1 implements WebTelemetryAddon<{ addon1Data: string }, { addon1Metadata: string }> { | |||
data() { | |||
return { addon1Data: 'addon1Data' }; | |||
return Promise.resolve({ addon1Data: 'addon1Data' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно. Обарачиваем в Promise.resolve на староне WebTemetryBase.
src/WebTelemetryBase.spec.ts
Outdated
} | ||
} | ||
|
||
class Addon2 implements WebTelemetryAddon<{ addon2Data: string }, { addon2Metadata: string }> { | ||
data() { | ||
return { addon2Data: 'addon2Data' }; | ||
return Promise.resolve({ addon2Data: 'addon2Data' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно
src/WebTelemetryBase.spec.ts
Outdated
} | ||
|
||
metadata() { | ||
return { addon2Metadata: 'addon2Metadata' }; | ||
return Promise.resolve({ addon2Metadata: 'addon2Metadata' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно Promise.resolve . Просто оборачивай вызов metadata в Promise.resolve
, а не даныне в metadata
.
src/WebTelemetryBase.spec.ts
Outdated
@@ -26,12 +26,12 @@ class WebTelemetry<T> extends WebTelemetryBase<T, T> { | |||
return payload; | |||
} | |||
|
|||
protected scheduleSend() { | |||
protected async scheduleSend() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно async.
@@ -62,7 +62,8 @@ describe('WebTelemetryBase', () => { | |||
addon2Metadata: 'addon2Metadata', | |||
}; | |||
|
|||
instance.push({ data: 'data' }, { metadata: 'metadata' }); | |||
await instance.push({ data: 'data' }, { metadata: 'metadata' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
push у нас не ассинхронный.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
если убрать await, то этот тест не сможет правильно отработать, так как getEvents()[0] вернёт undefined. Такой же тест находится на webtelemetrykv.spec.ts, на 16й строке, старался на него ориентироваться
src/extra/KVDataFrameTime.spec.ts
Outdated
@@ -18,7 +18,7 @@ const fakeTransport = new (class implements WebTelemetryTransport { | |||
} | |||
|
|||
async subscribe() { | |||
return this.subscriber; | |||
return await this.subscriber; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно await
src/extra/AddonNavigationPerf.ts
Outdated
@@ -71,11 +71,11 @@ export class AddonNavigationPerf implements WebTelemetryAddon<AddonNavigationPer | |||
} | |||
} | |||
|
|||
data() { | |||
async data() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно async
src/extra/AddonNavigationPerf.ts
Outdated
return { ...this.value }; | ||
} | ||
|
||
metadata() { | ||
async metadata() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно async
} | ||
|
||
metadata() { | ||
return {}; | ||
private async getHighEntropyValues(): Promise<UserAgentDataValues | null> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это потом гляну. )
src/extra/AddonFCP.ts
Outdated
return { | ||
FCP: Math.round(this.value), | ||
}; | ||
} | ||
|
||
metadata() { | ||
async metadata() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не нужно async.
📦 Published PR as canary version:
2.0.3--canary.18.12864022629.0
✨ Test out this PR locally via: