Skip to content

Commit 9351afa

Browse files
committed
fix(quality-insights): added improved event display
1 parent 62517e7 commit 9351afa

File tree

6 files changed

+75
-26
lines changed

6 files changed

+75
-26
lines changed

src/abstract/managers/TelemetryManager.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ export class TelemetryManager {
9595
EventType.FILE_UPLOAD_PROGRESS,
9696
EventType.FILE_UPLOAD_SUCCESS,
9797
EventType.FILE_UPLOAD_FAILED,
98-
EventType.FILE_URL_CHANGED,
99-
EventType.GROUP_CREATED,
10098
].includes(type)
10199
) {
102100
return true;
@@ -146,14 +144,12 @@ export class TelemetryManager {
146144
* Method to send telemetry event for Cloud Image Editor.
147145
*/
148146
sendEventCloudImageEditor(e: MouseEvent, tabId: string, options: Record<string, unknown> = {}): void {
149-
this.sendEvent({
150-
payload: {
151-
metadata: {
152-
tabId,
153-
node: (e.currentTarget as HTMLElement | null)?.tagName,
154-
event: e.type,
155-
...options,
156-
},
147+
this._block.emit(EventType.ACTION_EVENT, {
148+
metadata: {
149+
tabId,
150+
node: (e.currentTarget as HTMLElement | null)?.tagName,
151+
event: e.type,
152+
...options,
157153
},
158154
});
159155
}

src/blocks/CameraSource/CameraSource.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { deserializeCsv } from '../../utils/comma-separated';
55
import { debounce } from '../../utils/debounce';
66
import { stringToArray } from '../../utils/stringToArray';
77
import { UploadSource } from '../../utils/UploadSource';
8+
import { EventType } from '../UploadCtxProvider/EventEmitter';
89
import './camera-source.css';
910
import { CameraSourceEvents, CameraSourceTypes } from './constants';
1011

@@ -174,12 +175,28 @@ export class CameraSource extends UploaderBlock {
174175
this.historyBack();
175176
},
176177

177-
onShot: () => this._shot(),
178+
onShot: () => {
179+
this.emit(EventType.ACTION_EVENT, {
180+
metadata: {
181+
event: 'shot-camera',
182+
node: this.tagName,
183+
},
184+
});
185+
this._shot();
186+
},
178187

179188
onRequestPermissions: () => this._capture(),
180189

181190
/** General method for photo and video capture */
182-
onStartCamera: () => this._chooseActionWithCamera(),
191+
onStartCamera: () => {
192+
this.emit(EventType.ACTION_EVENT, {
193+
metadata: {
194+
event: 'start-camera',
195+
node: this.tagName,
196+
},
197+
});
198+
this._chooseActionWithCamera();
199+
},
183200

184201
onStartRecording: () => this._startRecording(),
185202

@@ -189,9 +206,25 @@ export class CameraSource extends UploaderBlock {
189206

190207
onToggleAudio: () => this._toggleEnableAudio(),
191208

192-
onRetake: () => this._retake(),
209+
onRetake: () => {
210+
this.emit(EventType.ACTION_EVENT, {
211+
metadata: {
212+
event: 'retake-camera',
213+
node: this.tagName,
214+
},
215+
});
216+
this._retake();
217+
},
193218

194-
onAccept: () => this._accept(),
219+
onAccept: () => {
220+
this.emit(EventType.ACTION_EVENT, {
221+
metadata: {
222+
event: 'accept-camera',
223+
node: this.tagName,
224+
},
225+
});
226+
this._accept();
227+
},
195228

196229
onClickTab: (event: MouseEvent) => {
197230
const target = event.currentTarget as HTMLElement | null;

src/blocks/FileItem/FileItem.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { parseShrink } from '../../utils/parseShrink';
1313
import { throttle } from '../../utils/throttle';
1414
import { ExternalUploadSource } from '../../utils/UploadSource';
1515
import './file-item.css';
16+
import { EventType } from '../UploadCtxProvider/EventEmitter';
1617
import { FileItemConfig } from './FileItemConfig';
1718

1819
const FileItemState = Object.freeze({
@@ -84,12 +85,10 @@ export class FileItem extends FileItemConfig {
8485
state: FileItemState.IDLE,
8586
ariaLabelStatusFile: '',
8687
onEdit: this._withEntry((entry) => {
87-
this.telemetryManager.sendEvent({
88-
payload: {
89-
metadata: {
90-
event: 'edit-file',
91-
node: this.tagName,
92-
},
88+
this.emit(EventType.ACTION_EVENT, {
89+
metadata: {
90+
event: 'edit-file',
91+
node: this.tagName,
9392
},
9493
});
9594
this.$['*currentActivityParams'] = {
@@ -99,12 +98,10 @@ export class FileItem extends FileItemConfig {
9998
this.$['*currentActivity'] = ActivityBlock.activities.CLOUD_IMG_EDIT;
10099
}),
101100
onRemove: () => {
102-
this.telemetryManager.sendEvent({
103-
payload: {
104-
metadata: {
105-
event: 'remove-file',
106-
node: this.tagName,
107-
},
101+
this.emit(EventType.ACTION_EVENT, {
102+
metadata: {
103+
event: 'remove-file',
104+
node: this.tagName,
108105
},
109106
});
110107
this.uploadCollection.remove(this.$.uid);

src/blocks/UploadCtxProvider/EventEmitter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const DEFAULT_DEBOUNCE_TIMEOUT = 20;
88
export const InternalEventType = Object.freeze({
99
INIT_SOLUTION: 'init-solution',
1010
CHANGE_CONFIG: 'change-config',
11+
ACTION_EVENT: 'action-event',
1112
} as const);
1213

1314
export const EventType = Object.freeze({
@@ -64,6 +65,9 @@ export type EventPayload = {
6465
[EventType.GROUP_CREATED]: OutputCollectionState<'success', 'has-group'>;
6566
[EventType.INIT_SOLUTION]: void;
6667
[EventType.CHANGE_CONFIG]: void;
68+
[EventType.ACTION_EVENT]: {
69+
metadata: Record<string, unknown>;
70+
};
6771
};
6872

6973
export class EventEmitter {

src/blocks/UploadList/UploadList.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export class UploadList extends UploaderBlock {
3838

3939
hasFiles: false,
4040
onAdd: () => {
41+
this.emit(EventType.ACTION_EVENT, {
42+
metadata: {
43+
event: 'add-more',
44+
node: this.tagName,
45+
},
46+
});
4147
this.api.initFlow(true);
4248
},
4349
onUpload: () => {
@@ -50,6 +56,12 @@ export class UploadList extends UploaderBlock {
5056
this.api.doneFlow();
5157
},
5258
onCancel: () => {
59+
this.emit(EventType.ACTION_EVENT, {
60+
metadata: {
61+
event: 'clear-all',
62+
node: this.tagName,
63+
},
64+
});
5365
this.uploadCollection.clearAll();
5466
},
5567
} as any;

src/blocks/UrlSource/UrlSource.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ActivityType } from '../../abstract/ActivityBlock';
22
import { ActivityBlock } from '../../abstract/ActivityBlock';
33
import { UploaderBlock } from '../../abstract/UploaderBlock';
44
import { UploadSource } from '../../utils/UploadSource';
5+
import { EventType } from '../UploadCtxProvider/EventEmitter';
56
import './url-source.css';
67

78
type BaseInitState = InstanceType<typeof UploaderBlock>['init$'];
@@ -25,6 +26,12 @@ export class UrlSource extends UploaderBlock {
2526
importDisabled: true,
2627
onUpload: (event: Event) => {
2728
event.preventDefault();
29+
this.emit(EventType.ACTION_EVENT, {
30+
metadata: {
31+
event: 'upload-from-url',
32+
node: this.tagName,
33+
},
34+
});
2835

2936
const url = this.ref.input['value'] as string;
3037
this.api.addFileFromUrl(url, { source: UploadSource.URL });

0 commit comments

Comments
 (0)