Skip to content
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

[Editor] Add some telemetry to know how often the editing features are used (bug 1782254) #15264

Merged
merged 1 commit into from
Aug 3, 2022

Conversation

calixteman
Copy link
Contributor

No description provided.

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't help but wonder if we could perhaps reduce the amount of code needed, primarily in the src/display/editor/-folder, in order pass the necessary editor-type onto the viewer?

More specifically, in addition to the code that you're adding to handle saving/printing, we might be able to use the AnnotationStorage along these lines:

diff --git a/src/display/annotation_storage.js b/src/display/annotation_storage.js
index 6b558f8f0..eb52a4823 100644
--- a/src/display/annotation_storage.js
+++ b/src/display/annotation_storage.js
@@ -31,6 +31,8 @@ class AnnotationStorage {
     // can have undesirable effects.
     this.onSetModified = null;
     this.onResetModified = null;
+
+    this.onAnnotationEditor = null;
   }
 
   /**
@@ -100,6 +102,13 @@ class AnnotationStorage {
     if (modified) {
       this.#setModified();
     }
+
+    if (
+      value instanceof AnnotationEditor &&
+      typeof this.onAnnotationEditor === "function"
+    ) {
+      this.onAnnotationEditor(value.constructor._type);
+    }
   }
 
   /**
diff --git a/web/app.js b/web/app.js
index 8b4e6265e..fd05a99aa 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1734,6 +1734,12 @@ const PDFViewerApplication = {
         delete this._annotationStorageModified;
       }
     };
+    annotationStorage.onAnnotationEditor = typeStr => {
+      this.externalServices.reportTelemetry({
+        type: "editing",
+        data: { type: typeStr },
+      })
+    };
   },
 
   setInitialView(

@calixteman
Copy link
Contributor Author

I can't help but wonder if we could perhaps reduce the amount of code needed, primarily in the src/display/editor/-folder, in order pass the necessary editor-type onto the viewer?

More specifically, in addition to the code that you're adding to handle saving/printing, we might be able to use the AnnotationStorage along these lines:

diff --git a/src/display/annotation_storage.js b/src/display/annotation_storage.js
index 6b558f8f0..eb52a4823 100644
--- a/src/display/annotation_storage.js
+++ b/src/display/annotation_storage.js
@@ -31,6 +31,8 @@ class AnnotationStorage {
     // can have undesirable effects.
     this.onSetModified = null;
     this.onResetModified = null;
+
+    this.onAnnotationEditor = null;
   }
 
   /**
@@ -100,6 +102,13 @@ class AnnotationStorage {
     if (modified) {
       this.#setModified();
     }
+
+    if (
+      value instanceof AnnotationEditor &&
+      typeof this.onAnnotationEditor === "function"
+    ) {
+      this.onAnnotationEditor(value.constructor._type);
+    }
   }
 
   /**
diff --git a/web/app.js b/web/app.js
index 8b4e6265e..fd05a99aa 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1734,6 +1734,12 @@ const PDFViewerApplication = {
         delete this._annotationStorageModified;
       }
     };
+    annotationStorage.onAnnotationEditor = typeStr => {
+      this.externalServices.reportTelemetry({
+        type: "editing",
+        data: { type: typeStr },
+      })
+    };
   },
 
   setInitialView(

It's definitely more clever than my solution but it adds a kind of invisible dependency between annotationStorage and externalServices, is it really something we want ?

@Snuffleupagus
Copy link
Collaborator

but it adds a kind of invisible dependency between annotationStorage and externalServices,

To me it's not that much different from the pre-existing callback-functions available in the AnnotationStorage class, and in a way the new hasAnnotationEditors method (which we still need of course) also introduces a kind-of dependency here.
The advantage of the suggested approach, at least in my opinion, is that it's smaller and easier to overview which hopefully means that it's less likely to break with any future changes to the Editing-functionality.

@Snuffleupagus
Copy link
Collaborator

/botio integrationtest

@pdfjsbot
Copy link

pdfjsbot commented Aug 3, 2022

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/f665a041f21edaf/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 3, 2022

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/73c591736ec6dde/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 3, 2022

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/f665a041f21edaf/output.txt

Total script time: 4.67 mins

  • Integration Tests: Passed

@pdfjsbot
Copy link

pdfjsbot commented Aug 3, 2022

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/73c591736ec6dde/output.txt

Total script time: 10.09 mins

  • Integration Tests: FAILED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants