-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[Telemetry] Prepare for versioned HTTP APIs #152111
Merged
jloleysens
merged 7 commits into
elastic:main
from
jloleysens:telemetry-remove-so-attribs-from-endpoints
Mar 1, 2023
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
798cf89
updated server routes to use new versioned common types
jloleysens 6d5c33a
added new common types
jloleysens 4983cc3
update imports
jloleysens 71d6df3
fix TS issue
jloleysens 44b82e0
Merge branch 'main' into telemetry-remove-so-attribs-from-endpoints
jloleysens c2731bf
Merge branch 'main' into telemetry-remove-so-attribs-from-endpoints
jloleysens 5660d9d
Merge branch 'main' into telemetry-remove-so-attribs-from-endpoints
jloleysens File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export * from './v2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export interface Telemetry { | ||
/** Whether telemetry is enabled */ | ||
enabled?: boolean | null; | ||
lastVersionChecked?: string; | ||
/** Whether to send usage from the server or browser. */ | ||
sendUsageFrom?: 'browser' | 'server'; | ||
lastReported?: number; | ||
allowChangingOptInStatus?: boolean; | ||
userHasSeenNotice?: boolean; | ||
reportFailureCount?: number; | ||
reportFailureVersion?: string; | ||
} | ||
|
||
export interface FetchTelemetryConfigResponse { | ||
allowChangingOptInStatus: boolean; | ||
optIn: boolean | null; | ||
sendUsageFrom: 'server' | 'browser'; | ||
telemetryNotifyUserAboutOptInDefault: boolean; | ||
} | ||
|
||
export interface FetchLastReportedResponse { | ||
lastReported: undefined | number; | ||
} | ||
|
||
export type UpdateLastReportedResponse = undefined; | ||
|
||
export interface OptInStatsBody { | ||
enabled: boolean; | ||
/** @default true */ | ||
unencrypted?: boolean; | ||
} | ||
|
||
export interface StatsPayload { | ||
cluster_uuid: string; | ||
opt_in_status: boolean; | ||
} | ||
|
||
export type OptInStatsResponse = Array<{ | ||
clusterUuid: string; | ||
stats: StatsPayload; | ||
}>; | ||
|
||
export interface OptInBody { | ||
enabled: boolean; | ||
} | ||
|
||
export type OptInResponse = Array<{ | ||
clusterUuid: string; | ||
stats: string; | ||
}>; | ||
|
||
export interface UsageStatsBody { | ||
/** @default false */ | ||
unencrypted: boolean; | ||
/** @default false */ | ||
refreshCache: boolean; | ||
} | ||
|
||
export type UseHasSeenNoticeResponse = Telemetry; | ||
|
||
export type EncryptedTelemetryPayload = Array<{ clusterUuid: string; stats: string }>; | ||
|
||
export type UnencryptedTelemetryPayload = Array<{ clusterUuid: string; stats: object }>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
import type { IRouter } from '@kbn/core/server'; | ||
import { TELEMETRY_SAVED_OBJECT_TYPE } from '../saved_objects'; | ||
import { v2 } from '../../common/types'; | ||
import { | ||
type TelemetrySavedObjectAttributes, | ||
getTelemetrySavedObject, | ||
|
@@ -33,7 +34,17 @@ export function registerTelemetryUserHasSeenNotice(router: IRouter) { | |
}; | ||
await updateTelemetrySavedObject(soClient, updatedAttributes); | ||
|
||
return res.ok({ body: updatedAttributes }); | ||
const body: v2.Telemetry = { | ||
allowChangingOptInStatus: updatedAttributes.allowChangingOptInStatus, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicitly map our SO attributes to the response |
||
enabled: updatedAttributes.enabled, | ||
lastReported: updatedAttributes.lastReported, | ||
lastVersionChecked: updatedAttributes.lastVersionChecked, | ||
reportFailureCount: updatedAttributes.reportFailureCount, | ||
reportFailureVersion: updatedAttributes.reportFailureVersion, | ||
sendUsageFrom: updatedAttributes.sendUsageFrom, | ||
userHasSeenNotice: updatedAttributes.userHasSeenNotice, | ||
}; | ||
return res.ok({ body }); | ||
} | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is kind of an interesting one... I am deferring changing this path as I am not familiar with the original context for introducing
v2
in it, but I am guessing once an actual versioning mechanism is available we can come back to it? Let me know what y'all think.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.
That is a very good question!! I need to rely on @Bamieh because the
/v2/
part of the telemetry APIs predates me 🤷FWIW, our telemetry APIs should be considered internal (we probably should name them as such, TBH)... Having said that, we are aware that some external products already use them, so I don't think we can introduce a breaking change without notifying them (or providing a sensible deprecation period).
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.
From what I can recall, 'v2' deals with encryption
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.
The versioning is introduced for external consumers to check for and detect how to handle incoming requests (our telemetry endpoint for example).
v1 -> v2 was for encryption. This way the telemetry cluster endpoint will check the request URL and will handle the request differently based on the version.