Skip to content

Commit

Permalink
v8.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Jan 27, 2023
1 parent 1fc525b commit 6437bcd
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 28 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export namespace Gleap {
primaryColor: string;
headerColor: string;
buttonColor: string;
cornerRadius: string;
backgroundColor: string;
borderRadius?: number;
buttonX?: number;
buttonY?: number;
buttonStyle?: string;
}): void;
function disableConsoleLogOverwrite(): void;
function setLiveSite(isLiveSite: boolean): void;
Expand All @@ -77,18 +81,21 @@ export namespace Gleap {
): void;
function open(): void;
function openNews(showBackButton?: boolean): void;
function openNewsArticle(
id: string,
showBackButton?: boolean
): void;
function openNewsArticle(id: string, showBackButton?: boolean): void;
function openConversations(showBackButton?: boolean): void;
function openConversation(
shareToken?: string,
showBackButton?: boolean
): void;
function openHelpCenter(showBackButton?: boolean): void;
function openHelpCenterCollection(collectionId: string, showBackButton?: boolean): void;
function openHelpCenterArticle(articleId: string, showBackButton?: boolean): void;
function openHelpCenterCollection(
collectionId: string,
showBackButton?: boolean
): void;
function openHelpCenterArticle(
articleId: string,
showBackButton?: boolean
): void;
function searchHelpCenter(term: string, showBackButton?: boolean): void;
function openFeatureRequests(showBackButton?: boolean): void;
function close(): void;
Expand All @@ -100,10 +107,7 @@ export namespace Gleap {
feedbackFlow: string,
showBackButton?: boolean
): void;
function showSurvey(
surveyId: string,
format?: string
): void;
function showSurvey(surveyId: string, format?: string): void;
function on(event: string, callback: (data?: any) => void): void;
function getIdentity(): any;
function isUserIdentified(): boolean;
Expand Down
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.5.10",
"version": "8.6.0",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
2 changes: 1 addition & 1 deletion published/7.0.31/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions published/8.6.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.

6 changes: 4 additions & 2 deletions src/Gleap.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ class Gleap {
backgroundColor = "#ffffff",
borderRadius = 20,
buttonX = 20,
buttonY = 20
buttonY = 20,
buttonStyle = GleapFeedbackButtonManager.FEEDBACK_BUTTON_BOTTOM_LEFT
) {
runFunctionWhenDomIsReady(() => {
injectStyledCSS(
Expand All @@ -468,7 +469,8 @@ class Gleap {
borderRadius,
backgroundColor,
buttonX,
buttonY
buttonY,
buttonStyle
);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/GleapConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class GleapConfigManager {
parseIntWithDefault(flowConfig.borderRadius, 20),
parseIntWithDefault(flowConfig.buttonX, 20),
parseIntWithDefault(flowConfig.buttonY, 20),
flowConfig.feedbackButtonPosition
);
}

Expand Down
7 changes: 5 additions & 2 deletions src/GleapSession.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GleapEventManager, GleapFrameManager, GleapNotificationManager } from "./Gleap";
import { GleapEventManager, GleapFrameManager, GleapNotificationManager, GleapStreamedEvent } from "./Gleap";
import { eraseGleapCookie, getGleapCookie, loadFromGleapCache, saveToGleapCache, setGleapCookie } from "./GleapHelper";

export default class GleapSession {
Expand Down Expand Up @@ -137,7 +137,7 @@ export default class GleapSession {
if (!session || !session.gleapId) {
return;
}

// Unregister previous group.
if (this.session && this.session.gleapHash) {
GleapEventManager.notifyEvent("unregister-pushmessage-group", `gleapuser-${this.session.gleapHash}`);
Expand Down Expand Up @@ -197,6 +197,9 @@ export default class GleapSession {
try {
const sessionData = JSON.parse(http.responseText);
self.validateSession(sessionData);

// Initially track.
GleapStreamedEvent.getInstance().restart();
} catch (exp) { }
} else {
if (http.status !== 429) {
Expand Down
25 changes: 19 additions & 6 deletions src/GleapStreamedEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class GleapStreamedEvent {
streamingEvents = false;
lastUrl = undefined;
stopped = false;
mainLoopTimeout = null;

// GleapStreamedEvent singleton
static instance;
Expand Down Expand Up @@ -38,12 +39,27 @@ export default class GleapStreamedEvent {
}, 60000);
}

restart() {
if (this.mainLoopTimeout) {
clearInterval(this.mainLoopTimeout);
this.mainLoopTimeout = null;
}
this.skippedCount = 1;

this.trackInitialEvents();
this.runEventStreamLoop();
}

start() {
this.startPageListener();
this.runEventStreamLoop();
this.resetErrorCountLoop();
}

trackInitialEvents() {
GleapStreamedEvent.getInstance().logEvent("sessionStarted");
GleapStreamedEvent.getInstance().logCurrentPage();
}

logCurrentPage() {
const currentUrl = window.location.href;
if (currentUrl && currentUrl !== this.lastUrl) {
Expand All @@ -55,9 +71,6 @@ export default class GleapStreamedEvent {
}

startPageListener() {
this.logEvent("sessionStarted");
this.logCurrentPage();

const self = this;
setInterval(function () {
if (self.stopped) {
Expand Down Expand Up @@ -96,8 +109,8 @@ export default class GleapStreamedEvent {

const self = this;
this.streamEvents();

setTimeout(function () {
this.mainLoopTimeout = setTimeout(function () {
self.runEventStreamLoop();
}, 10000);
};
Expand Down
18 changes: 15 additions & 3 deletions src/UI.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import GleapFeedbackButtonManager from "./GleapFeedbackButtonManager";

const calculateShadeColor = function (col, amt) {
col = col.replace(/^#/, "");
if (col.length === 3)
Expand Down Expand Up @@ -38,7 +40,8 @@ export const injectStyledCSS = (
borderRadius,
backgroundColor,
buttonX,
buttonY
buttonY,
buttonStyle,
) => {
const contrastColor = calculateContrast(primaryColor);
const contrastButtonColor = calculateContrast(buttonColor);
Expand All @@ -63,6 +66,15 @@ export const injectStyledCSS = (
const formItemSmallBorderRadius = Math.round(borderRadius * 0.25);
const zIndexBase = 2147483600;

var bottomInfoOffset = 57 + buttonY;
if (buttonStyle === GleapFeedbackButtonManager.FEEDBACK_BUTTON_CLASSIC_BOTTOM) {
bottomInfoOffset = buttonY + 15;
} else if (buttonStyle && buttonStyle.includes("CLASSIC")) {
bottomInfoOffset = buttonY;
} else if (buttonStyle === GleapFeedbackButtonManager.FEEDBACK_BUTTON_NONE) {
bottomInfoOffset = buttonY;
}

const colorStyleSheet = `
.gleap-font, .gleap-font * {
font-style: normal;
Expand Down Expand Up @@ -251,8 +263,8 @@ export const injectStyledCSS = (
.gleap-notification-container {
position: fixed;
bottom: ${62 + buttonY}px;
right: ${4 + buttonX}px;
bottom: ${bottomInfoOffset}px;
right: ${buttonX}px;
z-index: ${zIndexBase + 30};
display: flex;
flex-direction: column;
Expand Down

0 comments on commit 6437bcd

Please sign in to comment.