1 /* Copyright 2013 Mozilla Foundation
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 export class PdfJsTelemetryContent {
17 static onViewerIsUsed() {
18 Glean.pdfjs.used.add(1);
22 export class PdfJsTelemetry {
23 static report(aData) {
24 const { type } = aData;
27 this.onTimeToView(aData.timestamp);
30 this.onEditing(aData);
35 const id = aData.data.id.replace(
37 c => `_${c.toLowerCase()}`
39 if (type === "buttons") {
49 static onTimeToView(ms) {
50 Glean.pdfjs.timeToView.accumulateSingleSample(ms);
53 static onEditing({ type, data }) {
54 if (type !== "editing" || !data) {
58 if (!data.type && data.action?.startsWith("pdfjs.image")) {
66 Glean.pdfjs.editing[data.type].add(1);
70 Glean.pdfjs.editing[data.type].add(1);
71 const { stats } = data;
75 if (data.type === "highlight") {
76 const numbers = ["one", "two", "three", "four", "five"];
77 Glean.pdfjsEditingHighlight[data.type].add(1);
78 Glean.pdfjsEditingHighlight.numberOfColors[
79 numbers[stats.highlight.numberOfColors - 1]
85 action: "pdfjs.image.added",
92 if (data.action.startsWith("pdfjs.image.")) {
97 if (data.action === "added") {
98 Glean.pdfjs.editing.stamp.add(1);
101 Glean.pdfjs.stamp[data.action].add(1);
104 "alt_text_decorative",
105 "alt_text_description",
109 Glean.pdfjs.stamp[key].add(1);
114 case "free_highlight":
115 switch (data.action) {
117 Glean.pdfjsEditingHighlight.kind[data.type].add(1);
118 Glean.pdfjsEditingHighlight.method[data.methodOfCreation].add(1);
119 Glean.pdfjsEditingHighlight.color[data.color].add(1);
120 if (data.type === "free_highlight") {
121 Glean.pdfjsEditingHighlight.thickness.accumulateSingleSample(
126 case "color_changed":
127 Glean.pdfjsEditingHighlight.color[data.color].add(1);
128 Glean.pdfjsEditingHighlight.colorChanged.add(1);
130 case "thickness_changed":
131 Glean.pdfjsEditingHighlight.thickness.accumulateSingleSample(
134 Glean.pdfjsEditingHighlight.thicknessChanged.add(1);
137 Glean.pdfjsEditingHighlight.deleted.add(1);
140 Glean.pdfjsEditingHighlight.edited.add(1);
142 case "toggle_visibility":
143 Glean.pdfjsEditingHighlight.toggleVisibility.add(1);
150 static onImage({ action, data = {} }) {
151 action = action.split(".").pop();
154 // New alt text telemetry.
156 Glean.pdfjsImageAltText.info.record(data);
158 case "ai_generation_check":
159 Glean.pdfjsImageAltText.aiGenerationCheck.record(data);
161 case "settings_displayed":
162 Glean.pdfjsImageAltText.settingsDisplayed.record(data);
164 case "settings_ai_generation_check":
165 Glean.pdfjsImageAltText.settingsAiGenerationCheck.record(data);
167 case "settings_edit_alt_text_check":
168 Glean.pdfjsImageAltText.settingsEditAltTextCheck.record(data);
171 Glean.pdfjsImageAltText.save.record(data);
174 Glean.pdfjsImageAltText.dismiss.record(data);
176 case "model_download_start":
177 Glean.pdfjsImageAltText.modelDownloadStart.record(data);
179 case "model_download_complete":
180 Glean.pdfjsImageAltText.modelDownloadComplete.record(data);
182 case "model_download_error":
183 Glean.pdfjsImageAltText.modelDownloadError.record(data);
185 case "model_deleted":
186 Glean.pdfjsImageAltText.modelDeleted.record(data);
189 Glean.pdfjsImageAltText.modelResult.record(data);
192 Glean.pdfjsImageAltText.userEdit.record(data);
194 case "image_status_label_displayed":
195 Glean.pdfjsImageAltText.imageStatusLabelDisplayed.record(data);
197 case "image_status_label_clicked":
198 Glean.pdfjsImageAltText.imageStatusLabelClicked.record(data);
202 Glean.pdfjsImage.iconClick.record(data);
204 case "add_image_click":
205 Glean.pdfjsImage.addImageClick.record(data);
207 case "image_selected":
208 Glean.pdfjsImage.imageSelected.record(data);
211 Glean.pdfjsImage.imageAdded.record(data);
214 const { hasAltText, hasNoAltText } = data;
215 Glean.pdfjsImage.added.with_alt_text.add(hasAltText);
216 Glean.pdfjsImage.added.with_no_alt_text.add(hasNoAltText);
219 case "alt_text_edit":
220 Glean.pdfjsImage.altTextEdit.ask_to_edit.set(data.ask_to_edit);
221 Glean.pdfjsImage.altTextEdit.ai_generation.set(data.ai_generation);
226 static onButtons(id) {
227 Glean.pdfjs.buttons[id].add(1);
230 static onGeckoview(id) {
231 Glean.pdfjs.geckoview[id].add(1);