senza-sdk 4.2.44 → 4.2.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "senza-sdk",
3
- "version": "4.2.44",
3
+ "version": "4.2.45",
4
4
  "main": "./src/api.js",
5
5
  "description": "API for Senza application",
6
6
  "license": "MIT",
package/src/lifecycle.js CHANGED
@@ -21,6 +21,7 @@ const DEFAULT_AUTO_BACKGROUND_ENABLED = false;
21
21
  * Lifecycle is a singleton class that manages the application lifecycle states.<br>
22
22
  * @fires onstatechange
23
23
  * @fires userinactivity
24
+ * @fires userdisconnected
24
25
  */
25
26
  class Lifecycle extends EventTarget {
26
27
  /**
@@ -60,6 +61,17 @@ class Lifecycle extends EventTarget {
60
61
  * });
61
62
  * @alpha API has not yet been released
62
63
  */
64
+
65
+ /**
66
+ * @event Lifecycle#userdisconnected
67
+ * @description Fired when the user session ends .
68
+ * This event is useful for cleaning up application state or saving data before the application closes.
69
+ * @example
70
+ * lifecycle.addEventListener("userdisconnected", () => {
71
+ * console.log("User session ended, cleaning up application state");
72
+ * // Perform any necessary cleanup here
73
+ * });
74
+ */
63
75
  constructor() {
64
76
  super();
65
77
 
@@ -106,6 +118,11 @@ class Lifecycle extends EventTarget {
106
118
  this.dispatchEvent(event);
107
119
  });
108
120
 
121
+ typeof document !== "undefined" && document.addEventListener("hs/endOfSession", () => {
122
+ const event = new Event("userdisconnected");
123
+ this.dispatchEvent(event);
124
+ });
125
+
109
126
  typeof document !== "undefined" && document.addEventListener("keydown", () => {
110
127
  if (this._autoBackground) {
111
128
  if (this.state === this.UiState.BACKGROUND ||