Skip to content

Commit

Permalink
v13.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Jul 24, 2024
1 parent 4bd7007 commit 5c692a2
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 57 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion build/cjs/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/esm/index.mjs

Large diffs are not rendered by default.

48 changes: 30 additions & 18 deletions demo/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,40 @@ Gleap.setFrameUrl("http://0.0.0.0:3001");
Gleap.setApiUrl("http://0.0.0.0:9000");
Gleap.setWSApiUrl("ws://0.0.0.0:9000");

Gleap.setAiTools([{
name: 'send-money',
description: 'Send money to a given contact.',
executionType: 'button',
parameters: [{
name: 'amount',
description: 'The amount of money to send. Must be positive and provided by the user.',
type: 'number',
required: true
}, {
name: 'contact',
description: 'The contact to send money to.',
type: 'string',
Gleap.setAiTools([
{
name: "send-money",
description: "Send money to a given contact.",
executionType: "button",
parameters: [
{
name: "amount",
description:
"The amount of money to send. Must be positive and provided by the user.",
type: "number",
required: true,
},
{
name: "contact",
description: "The contact to send money to.",
type: "string",
enum: ["Alice", "Bob"],
required: true
}]
}]);
required: true,
},
],
},
]);

Gleap.on("tool-execution", (tool) => {
console.log("Tool execution", JSON.stringify(tool, null, 2));
console.log("Tool execution", JSON.stringify(tool, null, 2));
});

Gleap.setTicketAttribute("notes", "This is a test value.");

Gleap.initialize("itSm7G1k4MMOfIgZuCfOaJGQ08C5U6fK");
Gleap.identify("user1234", {
email: "[email protected]",
name: "Lukas",
sla: 30,
});

Gleap.initialize("xwjGqF5QHMTuQauPoZyMzarGqg7WyTvN");
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": "13.8.0",
"version": "13.8.1",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
1 change: 1 addition & 0 deletions published/13.8.1/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.

83 changes: 48 additions & 35 deletions src/Gleap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import GleapTagManager from "./GleapTagManager";
import GleapAdminManager from "./GleapAdminManager";
import GleapProductTours from "./GleapProductTours";

if (typeof HTMLCanvasElement !== "undefined" && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.__originalGetContext === undefined) {
if (
typeof HTMLCanvasElement !== "undefined" &&
HTMLCanvasElement.prototype &&
HTMLCanvasElement.prototype.__originalGetContext === undefined
) {
HTMLCanvasElement.prototype.__originalGetContext =
HTMLCanvasElement.prototype.getContext;
HTMLCanvasElement.prototype.getContext = function (type, options) {
Expand Down Expand Up @@ -88,15 +92,15 @@ class Gleap {

/**
* Set tags to be submitted with each ticket.
* @param {*} tags
* @param {*} tags
*/
static setTags(tags) {
GleapTagManager.getInstance().setTags(tags);
}

/**
* Sets a custom URL handler.
* @param {*} urlHandler
* @param {*} urlHandler
*/
static setUrlHandler(urlHandler) {
GleapFrameManager.getInstance().setUrlHandler(urlHandler);
Expand All @@ -113,7 +117,7 @@ class Gleap {

/**
* Disable the in-app notifications.
* @param {*} disableInAppNotifications
* @param {*} disableInAppNotifications
*/
static setDisableInAppNotifications(disableInAppNotifications) {
const instance = this.getInstance();
Expand All @@ -122,7 +126,7 @@ class Gleap {

/**
* Disable the default page tracking.
* @param {*} disablePageTracking
* @param {*} disablePageTracking
*/
static setDisablePageTracking(disablePageTracking) {
const instance = this.getInstance();
Expand Down Expand Up @@ -214,18 +218,27 @@ class Gleap {

try {
const urlParams = new URLSearchParams(window.location.search);
const feedbackFlow = urlParams.get('gleap_feedback');

const widget = urlParams.get("gleap_widget");
if (widget && widget.length > 0) {
Gleap.open();
}

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');
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");
Gleap.showSurvey(
surveyFlow,
surveyFlowFormat === "survey_full" ? "survey_full" : "survey"
);
}
const tourId = urlParams.get('gleap_tour');
const tourId = urlParams.get("gleap_tour");
if (tourId && tourId.length > 0) {
var tourDelay = parseInt(urlParams.get('gleap_tour_delay'));
var tourDelay = parseInt(urlParams.get("gleap_tour_delay"));
if (isNaN(tourDelay)) {
tourDelay = 4;
}
Expand All @@ -234,7 +247,7 @@ class Gleap {
Gleap.startProductTour(tourId);
}, tourDelay * 1000);
}
} catch (exp) { }
} catch (exp) {}
}

/**
Expand All @@ -260,7 +273,7 @@ class Gleap {

/**
* Enable or disable Gleap session tracking through cookies.
* @param {*} useCookies
* @param {*} useCookies
*/
static setUseCookies(useCookies) {
GleapSession.getInstance().useCookies = useCookies;
Expand All @@ -284,9 +297,7 @@ class Gleap {
* @param {*} userData
*/
static updateContact(userData) {
return GleapSession.getInstance().updateSession(
gleapDataParser(userData),
);
return GleapSession.getInstance().updateSession(gleapDataParser(userData));
}

/**
Expand Down Expand Up @@ -361,7 +372,7 @@ class Gleap {

/**
* Set custom replay options.
* @param {*} options
* @param {*} options
*/
static setReplayOptions(options) {
GleapReplayRecorder.getInstance().setOptions(options);
Expand Down Expand Up @@ -687,8 +698,8 @@ class Gleap {
);
feedback
.sendFeedback()
.then(() => { })
.catch((error) => { });
.then(() => {})
.catch((error) => {});
}

/**
Expand Down Expand Up @@ -733,8 +744,7 @@ class Gleap {
options = {},
isSurvey = false
) {
const { autostartDrawing, hideBackButton, format } =
options;
const { autostartDrawing, hideBackButton, format } = options;
const sessionInstance = GleapSession.getInstance();
if (!sessionInstance.ready) {
return;
Expand Down Expand Up @@ -1117,9 +1127,12 @@ class Gleap {

static startProductTour(tourId) {
const self = this;
GleapSession.getInstance().startProductTourConfig(tourId).then((config) => {
self.startProductTourWithConfig(tourId, config);
}).catch((error) => { });
GleapSession.getInstance()
.startProductTourConfig(tourId)
.then((config) => {
self.startProductTourWithConfig(tourId, config);
})
.catch((error) => {});
}

static startProductTourWithConfig(tourId, config) {
Expand All @@ -1136,7 +1149,7 @@ class Gleap {
static showBanner(data) {
try {
GleapBannerManager.getInstance().showBanner(data);
} catch (e) { }
} catch (e) {}
}

static showNotification(data) {
Expand Down Expand Up @@ -1185,51 +1198,51 @@ if (typeof window !== "undefined") {

const handleGleapLink = (href) => {
try {
const urlParts = href.split('/');
const urlParts = href.split("/");
const type = urlParts[2];
if (type === 'article') {
if (type === "article") {
const identifier = urlParts[3];
Gleap.openHelpCenterArticle(identifier, true);
}

if (type === 'collection') {
if (type === "collection") {
const identifier = urlParts[3];
Gleap.openHelpCenterCollection(identifier, true);
}

if (type === 'flow') {
if (type === "flow") {
const identifier = urlParts[3];
Gleap.startFeedbackFlow(identifier, true);
}

if (type === 'survey') {
if (type === "survey") {
const identifier = urlParts[3];
Gleap.showSurvey(identifier);
}

if (type === 'bot') {
if (type === "bot") {
const identifier = urlParts[3];
Gleap.startBot(identifier, true);
}

if (type === 'news') {
if (type === "news") {
const identifier = urlParts[3];
Gleap.openNewsArticle(identifier, true);
}

if (type === 'checklist') {
if (type === "checklist") {
const identifier = urlParts[3];
Gleap.startChecklist(identifier, true);
}

if (type === 'tour') {
if (type === "tour") {
const identifier = urlParts[3];
Gleap.startProductTour(identifier);
}
} catch (e) {
console.error("Failed to handle Gleap link: ", href);
}
}
};

export {
GleapNetworkIntercepter,
Expand Down

0 comments on commit 5c692a2

Please sign in to comment.