Skip to content

Commit

Permalink
v8.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Jan 23, 2023
1 parent eb976bc commit 221c6ea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Gleap = window.Gleap;

//Gleap.setFrameUrl("http://0.0.0.0:3001");
//Gleap.setApiUrl("http://0.0.0.0:9000");
Gleap.setFrameUrl("http://0.0.0.0:3001");
Gleap.setApiUrl("http://0.0.0.0:9000");
Gleap.initialize("DUPaIr7s689BBblcFI4pc5aBgYJTm7Sc");
//Gleap.setEnvironment("dev");

Expand Down
3 changes: 1 addition & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export namespace Gleap {
): void;
function showSurvey(
actionType: string,
outboundId: string,
format: string
format?: string
): void;
function on(event: string, callback: (data?: any) => void): void;
function getIdentity(): any;
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.8",
"version": "8.5.9",
"main": "build/index.js",
"scripts": {
"start": "webpack serve",
Expand Down
1 change: 1 addition & 0 deletions published/8.5.9/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.

35 changes: 28 additions & 7 deletions src/Gleap.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class Gleap {

// Inject the notification container
GleapNotificationManager.getInstance().injectNotificationUI();

// Check for URL params.
Gleap.checkForUrlParams();
})
.catch(function (err) {
console.warn("Failed to initialize Gleap.");
Expand All @@ -162,6 +165,27 @@ class Gleap {
sessionInstance.startSession();
}

static checkForUrlParams() {
if (typeof window === "undefined" || !window.location.search) {
return;
}

try {
const urlParams = new URLSearchParams(window.location.search);
const feedbackFlow = urlParams.get('gleap_feedback');
if (feedbackFlow && feedbackFlow.length > 0) {
Gleap.startFeedbackFlow(feedbackFlow);
}
const surveyFlow = urlParams.get('gleap_survey');
const surveyFlowFormat = urlParams.get('gleap_survey_format');
if (surveyFlow && surveyFlow.length > 0) {
Gleap.showSurvey(surveyFlow, surveyFlowFormat === "survey_full" ? "survey_full" : "survey");
}
} catch (exp) {
console.log(exp);
}
}

/**
* Destroy
* @returns
Expand Down Expand Up @@ -524,14 +548,12 @@ class Gleap {
/**
* Shows a survey manually.
* @param {*} actionType
* @param {*} outboundId
* @param {*} format
*/
static showSurvey(actionType, outboundId, format) {
static showSurvey(actionType, format = "survey") {
Gleap.startFeedbackFlowWithOptions(
actionType,
{
actionOutboundId: outboundId,
hideBackButton: true,
format,
},
Expand All @@ -556,7 +578,7 @@ class Gleap {
options = {},
isSurvey = false
) {
const { actionOutboundId, autostartDrawing, hideBackButton, format } =
const { autostartDrawing, hideBackButton, format } =
options;
const sessionInstance = GleapSession.getInstance();
if (!sessionInstance.ready) {
Expand All @@ -581,7 +603,6 @@ class Gleap {
name: action,
data: {
flow: feedbackFlow,
actionOutboundId: actionOutboundId,
hideBackButton: hideBackButton,
format,
},
Expand Down Expand Up @@ -832,11 +853,11 @@ class Gleap {
performActions(actions) {
for (let i = 0; i < actions.length; i++) {
const action = actions[i];
if (action && action.outbound && action.actionType) {
if (action && action.actionType) {
if (action.actionType === "notification") {
Gleap.showNotification(action);
} else {
Gleap.showSurvey(action.actionType, action.outbound, action.format);
Gleap.showSurvey(action.actionType, action.format);
}
}
}
Expand Down

0 comments on commit 221c6ea

Please sign in to comment.