Additional Settings

OnInitialized function

  • The OnInitialized function is used when the SDK has logic that needs to run after Init is complete.

Dfinery.OnInitialized(() => {
  // init Operation logic after
});
  • If there is page transition logic right after calling the event function, the page transition may occur before the function is completed, so the event may not be collected. Since logEvent is an asynchronous function that returns a Promise, it is recommended to proceed with the code as follows.

// init Run the function afterwards
window.Dfinery.onInitialized(() => {
  Promise.race([
    window.Dfinery.logEvent("EVENT_NAME"),
    new Promise((resolve, reject) => {
      setTimeout(() => reject("Timed out"), 2000); // If you don't succeed within 2 seconds, you fail.
    }),
  ])
    .catch((error) => {
      //
    })
    .then(() => {
      // movement
      window.location.href = "https://www.dfinery.io/crm";
    });
});

Adjust the timeout to reduce the impact of SDK errors. Depending on the timeout time and the client's network speed, collection may not be possible.

Last updated