From 569287035d2558521bd7b696c61d561e9e1f6c1b Mon Sep 17 00:00:00 2001 From: Lone Iversen <108085781+loivsen@users.noreply.github.com> Date: Wed, 21 Sep 2022 13:49:29 +0200 Subject: [PATCH 01/28] init --- src/Umbraco.Web.UI.Client/schemas/api/api.yml | 59 ++++++++++ .../schemas/generated-schema.ts | 60 +++++++++++ .../telemetry/dashboard-telemetry.element.ts | 102 +++++++++++++++++- .../src/core/api/fetcher.ts | 3 + .../src/core/models/index.ts | 1 + .../src/mocks/browser-handlers.ts | 2 + .../src/mocks/domains/telemetry.handlers.ts | 33 ++++++ .../src/mocks/e2e-handlers.ts | 2 + .../src/temp-internal-manifests.ts | 13 +++ .../temp-schema-generator/api.ts | 1 + .../temp-schema-generator/telemetry.ts | 46 ++++++++ 11 files changed, 319 insertions(+), 3 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/mocks/domains/telemetry.handlers.ts create mode 100644 src/Umbraco.Web.UI.Client/temp-schema-generator/telemetry.ts diff --git a/src/Umbraco.Web.UI.Client/schemas/api/api.yml b/src/Umbraco.Web.UI.Client/schemas/api/api.yml index 3c4e98e020..bd68978972 100644 --- a/src/Umbraco.Web.UI.Client/schemas/api/api.yml +++ b/src/Umbraco.Web.UI.Client/schemas/api/api.yml @@ -229,6 +229,58 @@ paths: application/json: schema: $ref: '#/components/schemas/ProblemDetails' + /telemetry/ConsentLevel: + get: + operationId: GetConsentLevel + responses: + '200': + description: 200 response + content: + application/json: + schema: + $ref: '#/components/schemas/ConsentLevelSettings' + default: + description: default response + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + post: + operationId: PostConsentLevel + parameters: [] + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ConsentLevelSettings' + required: true + responses: + '201': + description: 201 response + '400': + description: 400 response + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' + /telemetry/ConsentLevels: + get: + operationId: ConsentLevels + responses: + '200': + description: 200 response + content: + application/json: + schema: + type: array + items: + type: string + default: + description: default response + content: + application/json: + schema: + $ref: '#/components/schemas/ProblemDetails' components: schemas: ConsentLevel: @@ -903,3 +955,10 @@ components: type: string required: - sections + ConsentLevelSettings: + type: object + properties: + telemetryLevel: + type: string + required: + - telemetryLevel diff --git a/src/Umbraco.Web.UI.Client/schemas/generated-schema.ts b/src/Umbraco.Web.UI.Client/schemas/generated-schema.ts index fdc1e66117..685d8676ec 100644 --- a/src/Umbraco.Web.UI.Client/schemas/generated-schema.ts +++ b/src/Umbraco.Web.UI.Client/schemas/generated-schema.ts @@ -46,6 +46,13 @@ export interface paths { "/user/sections": { get: operations["GetAllowedSections"]; }; + "/telemetry/ConsentLevel": { + get: operations["GetConsentLevel"]; + post: operations["PostConsentLevel"]; + }; + "/telemetry/ConsentLevels": { + get: operations["ConsentLevels"]; + }; } export interface components { @@ -314,6 +321,9 @@ export interface components { AllowedSectionsResponse: { sections: string[]; }; + ConsentLevelSettings: { + telemetryLevel: string; + }; }; } @@ -541,6 +551,56 @@ export interface operations { }; }; }; + GetConsentLevel: { + responses: { + /** 200 response */ + 200: { + content: { + "application/json": components["schemas"]["ConsentLevelSettings"]; + }; + }; + /** default response */ + default: { + content: { + "application/json": components["schemas"]["ProblemDetails"]; + }; + }; + }; + }; + PostConsentLevel: { + parameters: {}; + responses: { + /** 201 response */ + 201: unknown; + /** 400 response */ + 400: { + content: { + "application/json": components["schemas"]["ProblemDetails"]; + }; + }; + }; + requestBody: { + content: { + "application/json": components["schemas"]["ConsentLevelSettings"]; + }; + }; + }; + ConsentLevels: { + responses: { + /** 200 response */ + 200: { + content: { + "application/json": string[]; + }; + }; + /** default response */ + default: { + content: { + "application/json": components["schemas"]["ProblemDetails"]; + }; + }; + }; + }; } export interface external {} diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/dashboards/telemetry/dashboard-telemetry.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/dashboards/telemetry/dashboard-telemetry.element.ts index ef57dea972..6903c3f625 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/dashboards/telemetry/dashboard-telemetry.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/dashboards/telemetry/dashboard-telemetry.element.ts @@ -1,15 +1,111 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import { unsafeHTML } from 'lit/directives/unsafe-html.js'; + +import { customElement, property, state } from 'lit/decorators.js'; + +import type { TelemetryModel } from '../../../core/models'; +import { getConsentLevel, getConsentLevels } from '../../../core/api/fetcher'; + +export type SettingOption = 'Minimal' | 'Basic' | 'Detailed'; @customElement('umb-dashboard-telemetry') export class UmbDashboardTelemetryElement extends LitElement { - static styles = [UUITextStyles, css``]; + static styles = [ + UUITextStyles, + css` + .italic { + font-style: italic; + } + `, + ]; + + @state() + private _telemetryLevels: TelemetryModel[] = [ + { level: 'Minimal', description: 'We will only send an anonymized site ID to let us know that the site exists.' }, + { level: 'Basic', description: 'We will send an anonymized site ID, Umbraco version, and packages installed.' }, + { + level: 'Detailed', + description: `We will send:
${unsafeHTML(this._selectedTelemetry.description)}
+ `; + } render() { return html`
+ In order to improve Umbraco and add new functionality based on as relevant information as possible, we would
+ like to collect system- and usage information from your installation. Aggregate data will be shared on a
+ regular basis as well as learnings from these metrics. Hopefully, you will help us collect some valuable
+ data.
+
+ We WILL NOT collect any personal data such as content, code, user information, and all data
+ will be fully anonymized.
+
${unsafeHTML(this._selectedTelemetry.description)}
+${unsafeHTML(this._selectedTelemetryDescription)}
`; } @@ -104,7 +149,9 @@ export class UmbDashboardTelemetryElement extends LitElement { will be fully anonymized. ${this._renderSettingSlider()} -