obi-sdk 0.6.5 → 0.6.6
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/dist/core/types.d.ts +2 -2
- package/dist/modular/chunks/index-d7a5d2f6.js +6 -0
- package/dist/modular/chunks/index-d7a5d2f6.js.map +1 -0
- package/dist/modular/chunks/{obi-widget-9e8ccac7.js → obi-widget-94e8c026.js} +267 -216
- package/dist/modular/chunks/obi-widget-94e8c026.js.map +1 -0
- package/dist/modular/index.js +1 -1
- package/dist/modular/ui.js +10 -10
- package/dist/obi-sdk.standalone.iife.js +5 -5
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/react.es.js +637 -586
- package/dist/react.es.js.map +1 -1
- package/dist/react.umd.js +13 -13
- package/dist/react.umd.js.map +1 -1
- package/package.json +3 -3
- package/dist/modular/chunks/index-8d3d1cc8.js +0 -6
- package/dist/modular/chunks/index-8d3d1cc8.js.map +0 -1
- package/dist/modular/chunks/obi-widget-9e8ccac7.js.map +0 -1
package/dist/core/types.d.ts
CHANGED
|
@@ -18,9 +18,9 @@ export declare const ObiSDKConfigSchema: z.ZodObject<{
|
|
|
18
18
|
metadata?: any;
|
|
19
19
|
}>>;
|
|
20
20
|
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
debug: boolean;
|
|
21
22
|
enableVoice: boolean;
|
|
22
23
|
enableScreenCapture: boolean;
|
|
23
|
-
debug: boolean;
|
|
24
24
|
apiKey?: string | undefined;
|
|
25
25
|
user?: {
|
|
26
26
|
id: string;
|
|
@@ -29,9 +29,9 @@ export declare const ObiSDKConfigSchema: z.ZodObject<{
|
|
|
29
29
|
} | undefined;
|
|
30
30
|
}, {
|
|
31
31
|
apiKey?: string | undefined;
|
|
32
|
+
debug?: boolean | undefined;
|
|
32
33
|
enableVoice?: boolean | undefined;
|
|
33
34
|
enableScreenCapture?: boolean | undefined;
|
|
34
|
-
debug?: boolean | undefined;
|
|
35
35
|
user?: {
|
|
36
36
|
id: string;
|
|
37
37
|
email?: string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-d7a5d2f6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -497,6 +497,11 @@ class ObiClient {
|
|
|
497
497
|
params: { path: { id } }
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
|
+
async startSession(id, token) {
|
|
501
|
+
return await this.client.GET("/sessions/{id}/start-session", {
|
|
502
|
+
params: { path: { id }, query: token ? { token } : {} }
|
|
503
|
+
});
|
|
504
|
+
}
|
|
500
505
|
async getSessionRecording(id) {
|
|
501
506
|
return await this.client.GET("/sessions/{id}/recording", {
|
|
502
507
|
params: { path: { id } }
|
|
@@ -10108,53 +10113,6 @@ function n$2(t2) {
|
|
|
10108
10113
|
function r$1(r2) {
|
|
10109
10114
|
return n$2({ ...r2, state: true, attribute: false });
|
|
10110
10115
|
}
|
|
10111
|
-
class StorageManager {
|
|
10112
|
-
/**
|
|
10113
|
-
* Create a new StorageManager with a specific namespace
|
|
10114
|
-
* @param namespace The namespace to prefix all keys with
|
|
10115
|
-
*/
|
|
10116
|
-
constructor(namespace) {
|
|
10117
|
-
this.namespace = namespace;
|
|
10118
|
-
}
|
|
10119
|
-
/**
|
|
10120
|
-
* Get a value from localStorage with the namespace prefix
|
|
10121
|
-
* @param key The key to retrieve
|
|
10122
|
-
* @returns The stored value or null if not found
|
|
10123
|
-
*/
|
|
10124
|
-
getItem(key) {
|
|
10125
|
-
return localStorage.getItem(`${this.namespace}.${key}`);
|
|
10126
|
-
}
|
|
10127
|
-
/**
|
|
10128
|
-
* Set a value in localStorage with the namespace prefix
|
|
10129
|
-
* @param key The key to set
|
|
10130
|
-
* @param value The value to store
|
|
10131
|
-
*/
|
|
10132
|
-
setItem(key, value) {
|
|
10133
|
-
localStorage.setItem(`${this.namespace}.${key}`, value);
|
|
10134
|
-
}
|
|
10135
|
-
/**
|
|
10136
|
-
* Remove a value from localStorage with the namespace prefix
|
|
10137
|
-
* @param key The key to remove
|
|
10138
|
-
*/
|
|
10139
|
-
removeItem(key) {
|
|
10140
|
-
localStorage.removeItem(`${this.namespace}.${key}`);
|
|
10141
|
-
}
|
|
10142
|
-
/**
|
|
10143
|
-
* Clear all keys that belong to this namespace
|
|
10144
|
-
*/
|
|
10145
|
-
clear() {
|
|
10146
|
-
for (let i3 = 0; i3 < localStorage.length; i3++) {
|
|
10147
|
-
const key = localStorage.key(i3);
|
|
10148
|
-
if (key && key.startsWith(`${this.namespace}.`)) {
|
|
10149
|
-
localStorage.removeItem(key);
|
|
10150
|
-
}
|
|
10151
|
-
}
|
|
10152
|
-
}
|
|
10153
|
-
}
|
|
10154
|
-
const STORAGE_KEYS = {
|
|
10155
|
-
SESSION_DATA: "session_data"
|
|
10156
|
-
};
|
|
10157
|
-
const storage = new StorageManager("io.obi.widget");
|
|
10158
10116
|
const DEBUG_BUILD$2 = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
10159
10117
|
const SDK_VERSION = "9.23.0";
|
|
10160
10118
|
const GLOBAL_OBJ = globalThis;
|
|
@@ -16016,6 +15974,53 @@ function withComponentErrorTracking(componentName) {
|
|
|
16016
15974
|
}
|
|
16017
15975
|
};
|
|
16018
15976
|
}
|
|
15977
|
+
class StorageManager {
|
|
15978
|
+
/**
|
|
15979
|
+
* Create a new StorageManager with a specific namespace
|
|
15980
|
+
* @param namespace The namespace to prefix all keys with
|
|
15981
|
+
*/
|
|
15982
|
+
constructor(namespace) {
|
|
15983
|
+
this.namespace = namespace;
|
|
15984
|
+
}
|
|
15985
|
+
/**
|
|
15986
|
+
* Get a value from localStorage with the namespace prefix
|
|
15987
|
+
* @param key The key to retrieve
|
|
15988
|
+
* @returns The stored value or null if not found
|
|
15989
|
+
*/
|
|
15990
|
+
getItem(key) {
|
|
15991
|
+
return localStorage.getItem(`${this.namespace}.${key}`);
|
|
15992
|
+
}
|
|
15993
|
+
/**
|
|
15994
|
+
* Set a value in localStorage with the namespace prefix
|
|
15995
|
+
* @param key The key to set
|
|
15996
|
+
* @param value The value to store
|
|
15997
|
+
*/
|
|
15998
|
+
setItem(key, value) {
|
|
15999
|
+
localStorage.setItem(`${this.namespace}.${key}`, value);
|
|
16000
|
+
}
|
|
16001
|
+
/**
|
|
16002
|
+
* Remove a value from localStorage with the namespace prefix
|
|
16003
|
+
* @param key The key to remove
|
|
16004
|
+
*/
|
|
16005
|
+
removeItem(key) {
|
|
16006
|
+
localStorage.removeItem(`${this.namespace}.${key}`);
|
|
16007
|
+
}
|
|
16008
|
+
/**
|
|
16009
|
+
* Clear all keys that belong to this namespace
|
|
16010
|
+
*/
|
|
16011
|
+
clear() {
|
|
16012
|
+
for (let i3 = 0; i3 < localStorage.length; i3++) {
|
|
16013
|
+
const key = localStorage.key(i3);
|
|
16014
|
+
if (key && key.startsWith(`${this.namespace}.`)) {
|
|
16015
|
+
localStorage.removeItem(key);
|
|
16016
|
+
}
|
|
16017
|
+
}
|
|
16018
|
+
}
|
|
16019
|
+
}
|
|
16020
|
+
const STORAGE_KEYS = {
|
|
16021
|
+
SESSION_DATA: "session_data"
|
|
16022
|
+
};
|
|
16023
|
+
const storage = new StorageManager("io.obi.widget");
|
|
16019
16024
|
var __defProp$7 = Object.defineProperty;
|
|
16020
16025
|
var __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor;
|
|
16021
16026
|
var __decorateClass$7 = (decorators, target, key, kind) => {
|
|
@@ -17601,199 +17606,245 @@ class ObiWidget extends i$1 {
|
|
|
17601
17606
|
this.obiClient = null;
|
|
17602
17607
|
this.closeNavTimeoutRef = null;
|
|
17603
17608
|
this.researchingTimeoutRef = null;
|
|
17604
|
-
this.connectObi = withSentryAsyncHandler(
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
}
|
|
17610
|
-
trackEvent("session_connection_started", { sessionToken }, "ObiWidget");
|
|
17611
|
-
setGlobalContext({ sessionId: sessionToken });
|
|
17612
|
-
try {
|
|
17613
|
-
const session = this.createSession(sessionToken);
|
|
17614
|
-
if (!session) {
|
|
17615
|
-
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17609
|
+
this.connectObi = withSentryAsyncHandler(
|
|
17610
|
+
async (sessionToken) => {
|
|
17611
|
+
if (this.activeSession) {
|
|
17612
|
+
trackEvent("connection_already_exists", { sessionToken }, "ObiWidget");
|
|
17613
|
+
console.log("Connection already exists");
|
|
17616
17614
|
return;
|
|
17617
17615
|
}
|
|
17618
|
-
|
|
17619
|
-
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17616
|
+
trackEvent("session_connection_started", { sessionToken }, "ObiWidget");
|
|
17617
|
+
setGlobalContext({ sessionId: sessionToken });
|
|
17618
|
+
try {
|
|
17619
|
+
const session = this.createSession(sessionToken);
|
|
17620
|
+
if (!session) {
|
|
17621
|
+
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17622
|
+
return;
|
|
17623
|
+
}
|
|
17624
|
+
this.setupSessionEventListeners(session, () => this.removeSessionUrlParams());
|
|
17625
|
+
session.on(
|
|
17626
|
+
"screenCaptureRequested",
|
|
17627
|
+
withSentryAsyncHandler(
|
|
17628
|
+
async () => {
|
|
17629
|
+
trackEvent("screen_capture_requested", {}, "ObiWidget");
|
|
17630
|
+
try {
|
|
17631
|
+
const canvas = await html2canvas(document.documentElement, {
|
|
17632
|
+
useCORS: true,
|
|
17633
|
+
allowTaint: true,
|
|
17634
|
+
foreignObjectRendering: true
|
|
17635
|
+
});
|
|
17636
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
17637
|
+
this.activeSession.emit("screenCaptureComplete", dataUrl);
|
|
17638
|
+
trackEvent("screen_capture_completed", {}, "ObiWidget");
|
|
17639
|
+
} catch (e2) {
|
|
17640
|
+
captureException(e2, {
|
|
17641
|
+
componentName: "ObiWidget",
|
|
17642
|
+
handlerName: "screenCaptureRequested",
|
|
17643
|
+
sessionToken
|
|
17644
|
+
});
|
|
17645
|
+
console.error("[obi] error capturing screen:", e2);
|
|
17646
|
+
this.activeSession.emit("screenCaptureComplete", "error");
|
|
17647
|
+
trackEvent(
|
|
17648
|
+
"screen_capture_failed",
|
|
17649
|
+
{
|
|
17650
|
+
error: e2 instanceof Error ? e2.message : String(e2)
|
|
17651
|
+
},
|
|
17652
|
+
"ObiWidget"
|
|
17653
|
+
);
|
|
17654
|
+
}
|
|
17655
|
+
},
|
|
17656
|
+
"screenCaptureRequested",
|
|
17657
|
+
"ObiWidget"
|
|
17658
|
+
)
|
|
17659
|
+
);
|
|
17660
|
+
const connectionInfo = await session.connect();
|
|
17661
|
+
if (connectionInfo) {
|
|
17662
|
+
this.sessionToken = sessionToken;
|
|
17663
|
+
this.roomToken = connectionInfo.token;
|
|
17664
|
+
this.roomUrl = connectionInfo.url;
|
|
17665
|
+
setGlobalContext({
|
|
17666
|
+
sessionId: sessionToken,
|
|
17667
|
+
widgetState: this.state.toString()
|
|
17635
17668
|
});
|
|
17636
|
-
|
|
17637
|
-
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17669
|
+
this.removeSessionUrlParams();
|
|
17670
|
+
trackEvent(
|
|
17671
|
+
"session_connection_established",
|
|
17672
|
+
{
|
|
17673
|
+
sessionToken,
|
|
17674
|
+
hasRoomToken: !!connectionInfo.token
|
|
17675
|
+
},
|
|
17676
|
+
"ObiWidget"
|
|
17677
|
+
);
|
|
17641
17678
|
}
|
|
17642
|
-
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
sessionId: sessionToken,
|
|
17650
|
-
widgetState: this.state.toString()
|
|
17679
|
+
this.activeSession = session;
|
|
17680
|
+
} catch (error) {
|
|
17681
|
+
console.error("Failed to start session:", error);
|
|
17682
|
+
captureException(error, {
|
|
17683
|
+
componentName: "ObiWidget",
|
|
17684
|
+
handlerName: "connectObi",
|
|
17685
|
+
sessionToken
|
|
17651
17686
|
});
|
|
17652
|
-
this.removeSessionUrlParams();
|
|
17653
|
-
trackEvent("session_connection_established", {
|
|
17654
|
-
sessionToken,
|
|
17655
|
-
hasRoomToken: !!connectionInfo.token
|
|
17656
|
-
}, "ObiWidget");
|
|
17687
|
+
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17657
17688
|
}
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
componentName: "ObiWidget",
|
|
17663
|
-
handlerName: "connectObi",
|
|
17664
|
-
sessionToken
|
|
17665
|
-
});
|
|
17666
|
-
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17667
|
-
}
|
|
17668
|
-
}, "connectObi", "ObiWidget");
|
|
17689
|
+
},
|
|
17690
|
+
"connectObi",
|
|
17691
|
+
"ObiWidget"
|
|
17692
|
+
);
|
|
17669
17693
|
this.handleCourseSelectEvent = (event) => {
|
|
17670
17694
|
const customEvent = event;
|
|
17671
17695
|
this.selectedCourse = customEvent.detail;
|
|
17672
17696
|
this.showCourseModal = false;
|
|
17673
17697
|
this.showSessionStartModal = true;
|
|
17674
17698
|
};
|
|
17675
|
-
this.handleUrlSessionEvent = withSentryAsyncHandler(
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17699
|
+
this.handleUrlSessionEvent = withSentryAsyncHandler(
|
|
17700
|
+
async (sessionToken) => {
|
|
17701
|
+
trackEvent("url_session_event", { sessionToken }, "ObiWidget");
|
|
17702
|
+
try {
|
|
17703
|
+
if (!this.obiClient) {
|
|
17704
|
+
const error = new Error("ObiClient not initialized");
|
|
17705
|
+
captureException(error, {
|
|
17706
|
+
componentName: "ObiWidget",
|
|
17707
|
+
handlerName: "handleUrlSessionEvent",
|
|
17708
|
+
sessionToken
|
|
17709
|
+
});
|
|
17710
|
+
console.error("ObiClient not initialized");
|
|
17711
|
+
return;
|
|
17712
|
+
}
|
|
17713
|
+
const sessionsResponse = await this.obiClient.startSession(sessionToken, this.apiKey);
|
|
17714
|
+
if (sessionsResponse.data) {
|
|
17715
|
+
const { session } = sessionsResponse.data;
|
|
17716
|
+
console.log("[obi-sdk] session:", session);
|
|
17717
|
+
trackEvent(
|
|
17718
|
+
"session_started",
|
|
17719
|
+
{
|
|
17720
|
+
sessionId: session?.id,
|
|
17721
|
+
sessionToken
|
|
17722
|
+
},
|
|
17723
|
+
"ObiWidget"
|
|
17724
|
+
);
|
|
17725
|
+
if (session) {
|
|
17726
|
+
const sessionWithPlan = session;
|
|
17727
|
+
this.selectedCourse = {
|
|
17728
|
+
id: sessionToken,
|
|
17729
|
+
name: sessionWithPlan.onboarding_plan?.name || "",
|
|
17730
|
+
description: sessionWithPlan.onboarding_plan?.description || ""
|
|
17731
|
+
};
|
|
17732
|
+
this.state = SDKState.LOADING;
|
|
17733
|
+
this.showSessionStartModal = true;
|
|
17734
|
+
trackEvent(
|
|
17735
|
+
"matching_session_found",
|
|
17736
|
+
{
|
|
17737
|
+
sessionToken,
|
|
17738
|
+
hasOnboardingPlan: !!sessionWithPlan.onboarding_plan
|
|
17739
|
+
},
|
|
17740
|
+
"ObiWidget"
|
|
17741
|
+
);
|
|
17742
|
+
} else {
|
|
17743
|
+
console.log("[obi-sdk] no session found with token:", sessionToken);
|
|
17744
|
+
trackEvent("no_matching_session", { sessionToken }, "ObiWidget");
|
|
17745
|
+
}
|
|
17746
|
+
}
|
|
17747
|
+
} catch (error) {
|
|
17748
|
+
console.error("Failed to fetch session details:", error);
|
|
17680
17749
|
captureException(error, {
|
|
17681
17750
|
componentName: "ObiWidget",
|
|
17682
17751
|
handlerName: "handleUrlSessionEvent",
|
|
17683
17752
|
sessionToken
|
|
17684
17753
|
});
|
|
17685
|
-
|
|
17754
|
+
}
|
|
17755
|
+
},
|
|
17756
|
+
"handleUrlSessionEvent",
|
|
17757
|
+
"ObiWidget"
|
|
17758
|
+
);
|
|
17759
|
+
this.handleSessionStart = withSentryAsyncHandler(
|
|
17760
|
+
async (sessionToken) => {
|
|
17761
|
+
trackEvent("session_start_requested", { sessionToken }, "ObiWidget");
|
|
17762
|
+
if (this.activeSession) {
|
|
17763
|
+
trackEvent("session_start_blocked", { sessionToken }, "ObiWidget");
|
|
17764
|
+
console.log("Connection already in progress or active session exists");
|
|
17686
17765
|
return;
|
|
17687
17766
|
}
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17767
|
+
this.showSessionStartModal = false;
|
|
17768
|
+
this.state = SDKState.LOADING;
|
|
17769
|
+
setGlobalContext({ widgetState: this.state.toString() });
|
|
17770
|
+
await this.connectObi(sessionToken);
|
|
17771
|
+
},
|
|
17772
|
+
"handleSessionStart",
|
|
17773
|
+
"ObiWidget"
|
|
17774
|
+
);
|
|
17775
|
+
this.checkExistingSession = withSentryAsyncHandler(
|
|
17776
|
+
async () => {
|
|
17777
|
+
trackEvent("checking_existing_session", {}, "ObiWidget");
|
|
17778
|
+
try {
|
|
17779
|
+
const sessionData = JSON.parse(
|
|
17780
|
+
storage.getItem(STORAGE_KEYS.SESSION_DATA) || "{}"
|
|
17781
|
+
);
|
|
17782
|
+
const { sessionToken, roomToken, roomUrl, sessionExpiry, obiState } = sessionData;
|
|
17783
|
+
if (!sessionToken || !roomToken || !roomUrl) {
|
|
17784
|
+
trackEvent("no_existing_session_data", {}, "ObiWidget");
|
|
17785
|
+
return;
|
|
17786
|
+
}
|
|
17787
|
+
console.log("[obi-sdk] using existing session");
|
|
17788
|
+
trackEvent(
|
|
17789
|
+
"existing_session_data_found",
|
|
17790
|
+
{
|
|
17707
17791
|
sessionToken,
|
|
17708
|
-
|
|
17709
|
-
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17792
|
+
hasExpiry: !!sessionExpiry,
|
|
17793
|
+
obiState
|
|
17794
|
+
},
|
|
17795
|
+
"ObiWidget"
|
|
17796
|
+
);
|
|
17797
|
+
if (sessionExpiry) {
|
|
17798
|
+
const expiryDate = new Date(sessionExpiry);
|
|
17799
|
+
if (expiryDate < /* @__PURE__ */ new Date()) {
|
|
17800
|
+
this.clearSessionStorage();
|
|
17801
|
+
trackEvent("session_expired", { sessionToken }, "ObiWidget");
|
|
17802
|
+
return;
|
|
17803
|
+
}
|
|
17713
17804
|
}
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
}
|
|
17723
|
-
}, "handleUrlSessionEvent", "ObiWidget");
|
|
17724
|
-
this.handleSessionStart = withSentryAsyncHandler(async (sessionToken) => {
|
|
17725
|
-
trackEvent("session_start_requested", { sessionToken }, "ObiWidget");
|
|
17726
|
-
if (this.activeSession) {
|
|
17727
|
-
trackEvent("session_start_blocked", { sessionToken }, "ObiWidget");
|
|
17728
|
-
console.log("Connection already in progress or active session exists");
|
|
17729
|
-
return;
|
|
17730
|
-
}
|
|
17731
|
-
this.showSessionStartModal = false;
|
|
17732
|
-
this.state = SDKState.LOADING;
|
|
17733
|
-
setGlobalContext({ widgetState: this.state.toString() });
|
|
17734
|
-
await this.connectObi(sessionToken);
|
|
17735
|
-
}, "handleSessionStart", "ObiWidget");
|
|
17736
|
-
this.checkExistingSession = withSentryAsyncHandler(async () => {
|
|
17737
|
-
trackEvent("checking_existing_session", {}, "ObiWidget");
|
|
17738
|
-
try {
|
|
17739
|
-
const sessionData = JSON.parse(
|
|
17740
|
-
storage.getItem(STORAGE_KEYS.SESSION_DATA) || "{}"
|
|
17741
|
-
);
|
|
17742
|
-
const { sessionToken, roomToken, roomUrl, sessionExpiry, obiState } = sessionData;
|
|
17743
|
-
if (!sessionToken || !roomToken || !roomUrl) {
|
|
17744
|
-
trackEvent("no_existing_session_data", {}, "ObiWidget");
|
|
17745
|
-
return;
|
|
17746
|
-
}
|
|
17747
|
-
console.log("[obi-sdk] using existing session");
|
|
17748
|
-
trackEvent("existing_session_data_found", {
|
|
17749
|
-
sessionToken,
|
|
17750
|
-
hasExpiry: !!sessionExpiry,
|
|
17751
|
-
obiState
|
|
17752
|
-
}, "ObiWidget");
|
|
17753
|
-
if (sessionExpiry) {
|
|
17754
|
-
const expiryDate = new Date(sessionExpiry);
|
|
17755
|
-
if (expiryDate < /* @__PURE__ */ new Date()) {
|
|
17756
|
-
this.clearSessionStorage();
|
|
17757
|
-
trackEvent("session_expired", { sessionToken }, "ObiWidget");
|
|
17805
|
+
this.state = SDKState.LOADING;
|
|
17806
|
+
setGlobalContext({
|
|
17807
|
+
sessionId: sessionToken,
|
|
17808
|
+
widgetState: this.state.toString()
|
|
17809
|
+
});
|
|
17810
|
+
const session = this.createSession(sessionToken);
|
|
17811
|
+
if (!session) {
|
|
17812
|
+
this.handleSessionCreationFailure(() => this.clearSessionStorage());
|
|
17758
17813
|
return;
|
|
17759
17814
|
}
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17815
|
+
this.setupSessionEventListeners(session, () => this.clearSessionStorage());
|
|
17816
|
+
const reconnected = await session.reconnect(roomUrl, roomToken, obiState);
|
|
17817
|
+
if (reconnected) {
|
|
17818
|
+
this.activeSession = session;
|
|
17819
|
+
this.sessionToken = sessionToken;
|
|
17820
|
+
this.roomToken = roomToken;
|
|
17821
|
+
this.roomUrl = roomUrl;
|
|
17822
|
+
this.state = obiState;
|
|
17823
|
+
this.storedActiveState = obiState;
|
|
17824
|
+
trackEvent(
|
|
17825
|
+
"session_reconnected",
|
|
17826
|
+
{
|
|
17827
|
+
sessionToken,
|
|
17828
|
+
obiState
|
|
17829
|
+
},
|
|
17830
|
+
"ObiWidget"
|
|
17831
|
+
);
|
|
17832
|
+
} else {
|
|
17833
|
+
this.clearSessionStorage();
|
|
17834
|
+
trackEvent("session_reconnection_failed", { sessionToken }, "ObiWidget");
|
|
17835
|
+
}
|
|
17836
|
+
} catch (error) {
|
|
17837
|
+
console.error("Error reconnecting to session:", error);
|
|
17838
|
+
captureException(error, {
|
|
17839
|
+
componentName: "ObiWidget",
|
|
17840
|
+
handlerName: "checkExistingSession"
|
|
17841
|
+
});
|
|
17768
17842
|
this.handleSessionCreationFailure(() => this.clearSessionStorage());
|
|
17769
|
-
return;
|
|
17770
|
-
}
|
|
17771
|
-
this.setupSessionEventListeners(session, () => this.clearSessionStorage());
|
|
17772
|
-
const reconnected = await session.reconnect(roomUrl, roomToken, obiState);
|
|
17773
|
-
if (reconnected) {
|
|
17774
|
-
this.activeSession = session;
|
|
17775
|
-
this.sessionToken = sessionToken;
|
|
17776
|
-
this.roomToken = roomToken;
|
|
17777
|
-
this.roomUrl = roomUrl;
|
|
17778
|
-
this.state = obiState;
|
|
17779
|
-
this.storedActiveState = obiState;
|
|
17780
|
-
trackEvent("session_reconnected", {
|
|
17781
|
-
sessionToken,
|
|
17782
|
-
obiState
|
|
17783
|
-
}, "ObiWidget");
|
|
17784
|
-
} else {
|
|
17785
|
-
this.clearSessionStorage();
|
|
17786
|
-
trackEvent("session_reconnection_failed", { sessionToken }, "ObiWidget");
|
|
17787
17843
|
}
|
|
17788
|
-
}
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17792
|
-
handlerName: "checkExistingSession"
|
|
17793
|
-
});
|
|
17794
|
-
this.handleSessionCreationFailure(() => this.clearSessionStorage());
|
|
17795
|
-
}
|
|
17796
|
-
}, "checkExistingSession", "ObiWidget");
|
|
17844
|
+
},
|
|
17845
|
+
"checkExistingSession",
|
|
17846
|
+
"ObiWidget"
|
|
17847
|
+
);
|
|
17797
17848
|
try {
|
|
17798
17849
|
const errorTracker = withComponentErrorTracking("ObiWidget");
|
|
17799
17850
|
errorTracker.setContext();
|
|
@@ -18355,4 +18406,4 @@ export {
|
|
|
18355
18406
|
withSentryAsyncHandler as w,
|
|
18356
18407
|
x
|
|
18357
18408
|
};
|
|
18358
|
-
//# sourceMappingURL=obi-widget-
|
|
18409
|
+
//# sourceMappingURL=obi-widget-94e8c026.js.map
|