Update GDPR typings to allow for top level metadata. (#146943)

* Update gdpr typings

* Try out new typing
This commit is contained in:
Logan Ramos 2022-04-07 14:23:27 -04:00 committed by GitHub
parent e2b873e1af
commit f1e2e9990b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View file

@ -13,11 +13,16 @@ export interface IPropertyData {
}
export interface IGDPRProperty {
readonly [name: string]: IPropertyData | undefined | IGDPRProperty;
owner?: string;
comment?: string;
expiration?: string;
readonly [name: string]: IPropertyData | undefined | IGDPRProperty | string;
}
export type IGDPRPropertyWithoutMetadata<T> = Omit<T, 'owner' | 'comment' | 'expiration'>;
export type ClassifiedEvent<T extends IGDPRProperty> = {
[k in keyof T]: any
[k in keyof IGDPRPropertyWithoutMetadata<T>]: any
};
export type StrictPropertyChecker<TEvent, TClassifiedEvent, TError> = keyof TEvent extends keyof TClassifiedEvent ? keyof TClassifiedEvent extends keyof TEvent ? TEvent : TError : TError;
@ -26,4 +31,4 @@ export type StrictPropertyCheckError = 'Type of classified event does not match
export type StrictPropertyCheck<T extends IGDPRProperty, E> = StrictPropertyChecker<E, ClassifiedEvent<T>, StrictPropertyCheckError>;
export type GDPRClassification<T> = { [_ in keyof T]: IPropertyData | IGDPRProperty | undefined };
export type GDPRClassification<T> = { [_ in keyof T]: IPropertyData | IGDPRProperty | undefined | string };

View file

@ -55,7 +55,7 @@ export class MainThreadTelemetry extends Disposable implements MainThreadTelemet
this._telemetryService.publicLog(eventName, data);
}
$publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data: StrictPropertyCheck<T, E>): void {
$publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>): void {
this.$publicLog(eventName, data as any);
}
}

View file

@ -746,7 +746,9 @@ export class EditorResolverService extends Disposable implements IEditorResolver
private sendEditorResolutionTelemetry(chosenInput: EditorInput): void {
type editorResolutionClassification = {
viewType: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; owner: 'lramos15'; comment: 'The id of the editor opened. Used to gain an undertsanding of what editors are most popular' };
viewType: { classification: 'PublicNonPersonalData'; purpose: 'FeatureInsight'; comment: 'The id of the editor opened. Used to gain an undertsanding of what editors are most popular' };
owner: 'lramos15';
comment: 'Event sent when an editor type is determined.';
};
type editorResolutionEvent = {
viewType: string;