obi-sdk 0.6.4 → 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-c52bfca4.js → obi-widget-94e8c026.js} +269 -220
- 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 +6 -6
- package/dist/obi-sdk.standalone.iife.js.map +1 -1
- package/dist/react.es.js +638 -593
- package/dist/react.es.js.map +1 -1
- package/dist/react.umd.js +14 -14
- package/dist/react.umd.js.map +1 -1
- package/package.json +3 -3
- package/dist/modular/chunks/index-d50e99a5.js +0 -6
- package/dist/modular/chunks/index-d50e99a5.js.map +0 -1
- package/dist/modular/chunks/obi-widget-c52bfca4.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) => {
|
|
@@ -17137,11 +17142,9 @@ class AudioEqualizer extends i$1 {
|
|
|
17137
17142
|
for (let i3 = 0; i3 < this.barCount; i3++) {
|
|
17138
17143
|
const spectrumValue = processedSpectrum.length > 0 ? processedSpectrum[i3] !== void 0 ? processedSpectrum[i3] : currentVolume : currentVolume;
|
|
17139
17144
|
if (this.volume.speaker === "USER") {
|
|
17140
|
-
|
|
17141
|
-
ctx.fillStyle = `${this.primaryColor}${opacity2}`;
|
|
17145
|
+
ctx.fillStyle = `${this.primaryColor}`;
|
|
17142
17146
|
} else {
|
|
17143
|
-
|
|
17144
|
-
ctx.fillStyle = `#FFFFFF${opacity2}`;
|
|
17147
|
+
ctx.fillStyle = "#FFFFFF";
|
|
17145
17148
|
}
|
|
17146
17149
|
const barHeight = Math.max(2, spectrumValue * 0.8 * barMaxHeight);
|
|
17147
17150
|
const x2 = displayWidth - (this.barCount - i3) * (barWidth + gap);
|
|
@@ -17603,199 +17606,245 @@ class ObiWidget extends i$1 {
|
|
|
17603
17606
|
this.obiClient = null;
|
|
17604
17607
|
this.closeNavTimeoutRef = null;
|
|
17605
17608
|
this.researchingTimeoutRef = null;
|
|
17606
|
-
this.connectObi = withSentryAsyncHandler(
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
17610
|
-
|
|
17611
|
-
}
|
|
17612
|
-
trackEvent("session_connection_started", { sessionToken }, "ObiWidget");
|
|
17613
|
-
setGlobalContext({ sessionId: sessionToken });
|
|
17614
|
-
try {
|
|
17615
|
-
const session = this.createSession(sessionToken);
|
|
17616
|
-
if (!session) {
|
|
17617
|
-
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");
|
|
17618
17614
|
return;
|
|
17619
17615
|
}
|
|
17620
|
-
|
|
17621
|
-
|
|
17622
|
-
|
|
17623
|
-
|
|
17624
|
-
|
|
17625
|
-
|
|
17626
|
-
|
|
17627
|
-
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
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()
|
|
17637
17668
|
});
|
|
17638
|
-
|
|
17639
|
-
|
|
17640
|
-
|
|
17641
|
-
|
|
17642
|
-
|
|
17669
|
+
this.removeSessionUrlParams();
|
|
17670
|
+
trackEvent(
|
|
17671
|
+
"session_connection_established",
|
|
17672
|
+
{
|
|
17673
|
+
sessionToken,
|
|
17674
|
+
hasRoomToken: !!connectionInfo.token
|
|
17675
|
+
},
|
|
17676
|
+
"ObiWidget"
|
|
17677
|
+
);
|
|
17643
17678
|
}
|
|
17644
|
-
|
|
17645
|
-
|
|
17646
|
-
|
|
17647
|
-
|
|
17648
|
-
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
sessionId: sessionToken,
|
|
17652
|
-
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
|
|
17653
17686
|
});
|
|
17654
|
-
this.removeSessionUrlParams();
|
|
17655
|
-
trackEvent("session_connection_established", {
|
|
17656
|
-
sessionToken,
|
|
17657
|
-
hasRoomToken: !!connectionInfo.token
|
|
17658
|
-
}, "ObiWidget");
|
|
17687
|
+
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17659
17688
|
}
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
componentName: "ObiWidget",
|
|
17665
|
-
handlerName: "connectObi",
|
|
17666
|
-
sessionToken
|
|
17667
|
-
});
|
|
17668
|
-
this.handleSessionCreationFailure(() => this.removeSessionUrlParams());
|
|
17669
|
-
}
|
|
17670
|
-
}, "connectObi", "ObiWidget");
|
|
17689
|
+
},
|
|
17690
|
+
"connectObi",
|
|
17691
|
+
"ObiWidget"
|
|
17692
|
+
);
|
|
17671
17693
|
this.handleCourseSelectEvent = (event) => {
|
|
17672
17694
|
const customEvent = event;
|
|
17673
17695
|
this.selectedCourse = customEvent.detail;
|
|
17674
17696
|
this.showCourseModal = false;
|
|
17675
17697
|
this.showSessionStartModal = true;
|
|
17676
17698
|
};
|
|
17677
|
-
this.handleUrlSessionEvent = withSentryAsyncHandler(
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
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);
|
|
17682
17749
|
captureException(error, {
|
|
17683
17750
|
componentName: "ObiWidget",
|
|
17684
17751
|
handlerName: "handleUrlSessionEvent",
|
|
17685
17752
|
sessionToken
|
|
17686
17753
|
});
|
|
17687
|
-
|
|
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");
|
|
17688
17765
|
return;
|
|
17689
17766
|
}
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
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
|
+
{
|
|
17709
17791
|
sessionToken,
|
|
17710
|
-
|
|
17711
|
-
|
|
17712
|
-
|
|
17713
|
-
|
|
17714
|
-
|
|
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
|
+
}
|
|
17715
17804
|
}
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17720
|
-
|
|
17721
|
-
|
|
17722
|
-
|
|
17723
|
-
|
|
17724
|
-
}
|
|
17725
|
-
}, "handleUrlSessionEvent", "ObiWidget");
|
|
17726
|
-
this.handleSessionStart = withSentryAsyncHandler(async (sessionToken) => {
|
|
17727
|
-
trackEvent("session_start_requested", { sessionToken }, "ObiWidget");
|
|
17728
|
-
if (this.activeSession) {
|
|
17729
|
-
trackEvent("session_start_blocked", { sessionToken }, "ObiWidget");
|
|
17730
|
-
console.log("Connection already in progress or active session exists");
|
|
17731
|
-
return;
|
|
17732
|
-
}
|
|
17733
|
-
this.showSessionStartModal = false;
|
|
17734
|
-
this.state = SDKState.LOADING;
|
|
17735
|
-
setGlobalContext({ widgetState: this.state.toString() });
|
|
17736
|
-
await this.connectObi(sessionToken);
|
|
17737
|
-
}, "handleSessionStart", "ObiWidget");
|
|
17738
|
-
this.checkExistingSession = withSentryAsyncHandler(async () => {
|
|
17739
|
-
trackEvent("checking_existing_session", {}, "ObiWidget");
|
|
17740
|
-
try {
|
|
17741
|
-
const sessionData = JSON.parse(
|
|
17742
|
-
storage.getItem(STORAGE_KEYS.SESSION_DATA) || "{}"
|
|
17743
|
-
);
|
|
17744
|
-
const { sessionToken, roomToken, roomUrl, sessionExpiry, obiState } = sessionData;
|
|
17745
|
-
if (!sessionToken || !roomToken || !roomUrl) {
|
|
17746
|
-
trackEvent("no_existing_session_data", {}, "ObiWidget");
|
|
17747
|
-
return;
|
|
17748
|
-
}
|
|
17749
|
-
console.log("[obi-sdk] using existing session");
|
|
17750
|
-
trackEvent("existing_session_data_found", {
|
|
17751
|
-
sessionToken,
|
|
17752
|
-
hasExpiry: !!sessionExpiry,
|
|
17753
|
-
obiState
|
|
17754
|
-
}, "ObiWidget");
|
|
17755
|
-
if (sessionExpiry) {
|
|
17756
|
-
const expiryDate = new Date(sessionExpiry);
|
|
17757
|
-
if (expiryDate < /* @__PURE__ */ new Date()) {
|
|
17758
|
-
this.clearSessionStorage();
|
|
17759
|
-
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());
|
|
17760
17813
|
return;
|
|
17761
17814
|
}
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
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
|
+
});
|
|
17770
17842
|
this.handleSessionCreationFailure(() => this.clearSessionStorage());
|
|
17771
|
-
return;
|
|
17772
|
-
}
|
|
17773
|
-
this.setupSessionEventListeners(session, () => this.clearSessionStorage());
|
|
17774
|
-
const reconnected = await session.reconnect(roomUrl, roomToken, obiState);
|
|
17775
|
-
if (reconnected) {
|
|
17776
|
-
this.activeSession = session;
|
|
17777
|
-
this.sessionToken = sessionToken;
|
|
17778
|
-
this.roomToken = roomToken;
|
|
17779
|
-
this.roomUrl = roomUrl;
|
|
17780
|
-
this.state = obiState;
|
|
17781
|
-
this.storedActiveState = obiState;
|
|
17782
|
-
trackEvent("session_reconnected", {
|
|
17783
|
-
sessionToken,
|
|
17784
|
-
obiState
|
|
17785
|
-
}, "ObiWidget");
|
|
17786
|
-
} else {
|
|
17787
|
-
this.clearSessionStorage();
|
|
17788
|
-
trackEvent("session_reconnection_failed", { sessionToken }, "ObiWidget");
|
|
17789
17843
|
}
|
|
17790
|
-
}
|
|
17791
|
-
|
|
17792
|
-
|
|
17793
|
-
|
|
17794
|
-
handlerName: "checkExistingSession"
|
|
17795
|
-
});
|
|
17796
|
-
this.handleSessionCreationFailure(() => this.clearSessionStorage());
|
|
17797
|
-
}
|
|
17798
|
-
}, "checkExistingSession", "ObiWidget");
|
|
17844
|
+
},
|
|
17845
|
+
"checkExistingSession",
|
|
17846
|
+
"ObiWidget"
|
|
17847
|
+
);
|
|
17799
17848
|
try {
|
|
17800
17849
|
const errorTracker = withComponentErrorTracking("ObiWidget");
|
|
17801
17850
|
errorTracker.setContext();
|
|
@@ -18357,4 +18406,4 @@ export {
|
|
|
18357
18406
|
withSentryAsyncHandler as w,
|
|
18358
18407
|
x
|
|
18359
18408
|
};
|
|
18360
|
-
//# sourceMappingURL=obi-widget-
|
|
18409
|
+
//# sourceMappingURL=obi-widget-94e8c026.js.map
|