wiris / html-integrations

The official JavaScript library for MathType, the leading formula editor and equation writer for the web by Wiris
https://wiris.com/solutions/integrations/html-editors/
MIT License
76 stars 53 forks source link

KB-45700: Update Telemeter Tracking to Utilize Promises #954

Closed usantos-at-wiris closed 5 months ago

usantos-at-wiris commented 6 months ago

Changes

feat: update telemeter tracking to utilize promises. #KB-45700

Description

This PR introduces a significant enhancement to our telemeter tracking functionality by transitioning all tracking actions to utilize promises. The motivation behind this change stems from a recent integration issue encountered with OnlyOffice.

Steps to Reproduce:

  1. Pull the wiris/telemeter repo.
  2. Initiate the telemeter server by executing cargo run and ensure it's operational.
  3. Navigate to packages/devkit/src/Integrationmodel on this branch.
  4. Amend the code from debug: false to debug: true.
  5. Execute yarn && nx build generic && nx start html-generic to build the generic editor.
  6. Verify the connection of the generic editor to the telemeter server.
  7. Interact with the generic editor by inserting formulas, closing, and reopening it.
  8. Observe the telemetry actions being accurately tracked on the telemeter server.

Commands to test generic telemetry

WirisPlugin.GenericIntegration.telemeter.wrsOpenedEditorModal('button','chemistry')

WirisPlugin.GenericIntegration.telemeter.wrsClosedEditorModal('mtct_close','chemistry')

WirisPlugin.GenericIntegration.telemeter.wrsInsertedFormula('«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«msqrt»«mi»x«/mi»«/msqrt»«/math»','«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»«msqrt»«mi»x«/mi»«/msqrt»«/math»',Date.now(),'chemistry')

Link to Task: #45700

carla-at-wiris commented 6 months ago

To make sure the applied changes really have effect, we´d have to await all the methods we appended the async keyword to... In other words, for example, now that we made insertFormula an async method, we need to check all places where that method is used and await its execution... This could bring us to an infinity spiral of async/await methods, let's check it at least!

The code is thought to run in serial mode, so it may not be an issue to add the async/await where needed. However, take into consideration that there are cyclic methods.

usantos-at-wiris commented 6 months ago

Sorry for the length of this PR. Fixed a bunch of typos and added a more considerate way to track the closing telemetry.