Skip to content

Commit 7bd3ce1

Browse files
committed
v8.1.0
1 parent 27d09e0 commit 7bd3ce1

File tree

8 files changed

+28
-10
lines changed

8 files changed

+28
-10
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/main.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ Gleap.setApiUrl("http://0.0.0.0:9000");
1111
Gleap.initialize("KProDXhMS0V3UUku2iNnrZ4XsBnAYzxt");
1212
//Gleap.setEnvironment("dev");
1313

14-
/*
1514
Gleap.identify("user_1933333283", {
1615
name: "Luki",
1716
email: "lukas@gleap.io",
1817
value: 199
1918
});
20-
*/
21-
//Gleap.clearIdentity();
2219

2320
Gleap.attachCustomData({
2421
mission: "Unicorn",

index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ export namespace Gleap {
8282
function showFeedbackButton(show: boolean): void;
8383
function startFeedbackFlow(feedbackFlow: string, showBackButton?: boolean): void;
8484
function on(event: string, callback: (data?: any) => void): void;
85+
function getIdentity(): any;
86+
function isUserIdentified(): boolean;
8587
}
8688
export default Gleap;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "8.0.22",
3+
"version": "8.1.0",
44
"main": "build/index.js",
55
"scripts": {
66
"start": "webpack serve",

published/8.1.0/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Gleap.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,23 @@ class Gleap {
179179
GleapSession.getInstance().clearSession();
180180
}
181181

182+
/**
183+
* Returns the current user session
184+
*/
185+
static getIdentity() {
186+
GleapSession.getInstance().session;
187+
}
188+
189+
/**
190+
* Returns whether the user is identified or not.
191+
*/
192+
static isUserIdentified() {
193+
const session = GleapSession.getInstance().session;
194+
if (session && session.userId && session.userId.length > 0) {
195+
return true;
196+
}
197+
}
198+
182199
/**
183200
* Widget opened status
184201
* @returns {boolean} isOpened

src/GleapSession.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class GleapSession {
5656
if (this.session && this.session.gleapId) {
5757
return this.session.gleapId;
5858
}
59-
59+
6060
return null;
6161
}
6262

@@ -94,6 +94,7 @@ export default class GleapSession {
9494
saveToGleapCache(`session-${this.sdkKey}`, null);
9595
} catch (exp) { }
9696

97+
this.ready = false;
9798
this.session = {
9899
id: null,
99100
hash: null,
@@ -122,7 +123,7 @@ export default class GleapSession {
122123
};
123124

124125
validateSession = (session) => {
125-
if (!session) {
126+
if (!session || !session.gleapId) {
126127
return;
127128
}
128129

@@ -216,9 +217,9 @@ export default class GleapSession {
216217
// Wait for gleap session to be ready.
217218
this.setOnSessionReady(function () {
218219
if (!self.session.gleapId || !self.session.gleapHash) {
219-
return reject("No session ready to identify. This usually means that you called clearSession() directly before calling this method.");
220+
return reject("Session not ready yet.");
220221
}
221-
222+
222223
const http = new XMLHttpRequest();
223224
http.open("POST", self.apiUrl + "/sessions/identify");
224225
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");

0 commit comments

Comments
 (0)