Skip to content

Commit

Permalink
v8.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Oct 12, 2022
1 parent 27d09e0 commit 7bd3ce1
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ Gleap.setApiUrl("http://0.0.0.0:9000");
Gleap.initialize("KProDXhMS0V3UUku2iNnrZ4XsBnAYzxt");
//Gleap.setEnvironment("dev");

/*
Gleap.identify("user_1933333283", {
name: "Luki",
email: "[email protected]",
value: 199
});
*/
//Gleap.clearIdentity();

Gleap.attachCustomData({
mission: "Unicorn",
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@ export namespace Gleap {
function showFeedbackButton(show: boolean): void;
function startFeedbackFlow(feedbackFlow: string, showBackButton?: boolean): void;
function on(event: string, callback: (data?: any) => void): void;
function getIdentity(): any;
function isUserIdentified(): boolean;
}
export default Gleap;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gleap",
"version": "8.0.22",
"version": "8.1.0",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
1 change: 1 addition & 0 deletions published/8.1.0/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion published/latest/index.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/Gleap.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,23 @@ class Gleap {
GleapSession.getInstance().clearSession();
}

/**
* Returns the current user session
*/
static getIdentity() {
GleapSession.getInstance().session;
}

/**
* Returns whether the user is identified or not.
*/
static isUserIdentified() {
const session = GleapSession.getInstance().session;
if (session && session.userId && session.userId.length > 0) {
return true;
}
}

/**
* Widget opened status
* @returns {boolean} isOpened
Expand Down
9 changes: 5 additions & 4 deletions src/GleapSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class GleapSession {
if (this.session && this.session.gleapId) {
return this.session.gleapId;
}

return null;
}

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

this.ready = false;
this.session = {
id: null,
hash: null,
Expand Down Expand Up @@ -122,7 +123,7 @@ export default class GleapSession {
};

validateSession = (session) => {
if (!session) {
if (!session || !session.gleapId) {
return;
}

Expand Down Expand Up @@ -216,9 +217,9 @@ export default class GleapSession {
// Wait for gleap session to be ready.
this.setOnSessionReady(function () {
if (!self.session.gleapId || !self.session.gleapHash) {
return reject("No session ready to identify. This usually means that you called clearSession() directly before calling this method.");
return reject("Session not ready yet.");
}

const http = new XMLHttpRequest();
http.open("POST", self.apiUrl + "/sessions/identify");
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
Expand Down

0 comments on commit 7bd3ce1

Please sign in to comment.