Skip to content

Commit

Permalink
v13.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
boehlerlukas committed Mar 6, 2024
1 parent d37b18e commit 4dfb6b6
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 18 deletions.
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.

38 changes: 27 additions & 11 deletions demo/main.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
const Gleap = window.Gleap;

Gleap.setLanguage("en");
Gleap.setFrameUrl("http://0.0.0.0:3001");
Gleap.setApiUrl("http://0.0.0.0:9000");
Gleap.setWSApiUrl("ws://0.0.0.0:8080");

Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV");
Gleap.setAiTools([{
name: 'send-money',
description: 'Send money to a given contact.',
response: 'The transfer got initiated but not completed yet. The user must confirm the transfer in the banking app.',
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
}]
}]);

/*Gleap.setUrlHandler((url, newTab) => {
alert("URL: " + url + " newTab: " + newTab);
});*/
Gleap.on("tool-execution", (tool) => {
if (tool.name === "send-money") {
const amount = tool.params.amount;
const contact = tool.params.contact;

Gleap.setNetworkLogPropsToIgnore(["password", "token"]);

Gleap.registerCustomAction((customAction) => {
console.log("Custom action: ", customAction);
// Initiate the transfer here.
}
});

Gleap.on("unread-count-changed", (unreadCount) => {
console.log("Unread count changed: ", unreadCount);
});
Gleap.setTicketAttribute("notes", "This is a test value.");

Gleap.initialize("ixFtcUWCFjENqupXkb39Ca7uncprVfjA");
13 changes: 13 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export namespace Gleap {
function startBot(botId: string, showBackButton?: boolean): void;
function startConversation(showBackButton?: boolean): void;
function attachCustomData(customData: any): void;
function setTicketAttribute(key: string, value: string): void;
function setCustomData(key: string, value: string): void;
function removeCustomData(key: string): void;
function clearCustomData(): void;
Expand Down Expand Up @@ -78,6 +79,18 @@ export namespace Gleap {
function enableShortcuts(enabled: boolean): void;
function setLanguage(language: string): void;
function preFillForm(data: object): void;
function setAiTools(tools: {
name: string;
description: string;
response: string;
parameters: {
name: string;
description: string;
type: "string" | "number" | "boolean";
required: boolean;
enums?: string[];
}[];
}[]): void;
function showTabNotificationBadge(showNotificationBadge: boolean): void;
function attachNetworkLogs(networkLogs: string): void;
function clearIdentity(): void;
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": "13.2.8",
"version": "13.5.0",
"main": "build/cjs/index.js",
"module": "build/esm/index.mjs",
"exports": {
Expand Down
1 change: 1 addition & 0 deletions published/13.5.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 @@ -136,6 +136,14 @@ class Gleap {
GleapConsoleLogManager.getInstance().stop();
}

/**
* Set the AI tools.
* @param {*} tools
*/
static setAiTools(tools) {
GleapConfigManager.getInstance().setAiTools(tools);
}

/**
* Attaches external network logs.
*/
Expand Down Expand Up @@ -488,6 +496,15 @@ class Gleap {
GleapFrameManager.getInstance().frameUrl = frameUrl;
}

/**
* This method is used to set ticket attributes programmatically.
* @param {*} key The key of the attribute you want to add.
* @param {*} value The value to set.
*/
static setTicketAttribute(key, value) {
GleapCustomDataManager.getInstance().setTicketAttribute(key, value);
}

/**
* Set custom data that will be attached to the bug-report.
* @param {*} data
Expand Down
9 changes: 9 additions & 0 deletions src/GleapConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class GleapConfigManager {
flowConfig = null;
projectActions = null;
onConfigLoadedListener = [];
aiTools = [];

onConfigLoaded = (onConfigLoaded) => {
if (this.flowConfig !== null) {
Expand All @@ -39,6 +40,14 @@ export default class GleapConfigManager {
return this.flowConfig;
}

setAiTools = (aiTools) => {
this.aiTools = aiTools;
};

getAiTools = () => {
return this.aiTools;
}

/**
* Load config.
* @returns {string}
Expand Down
15 changes: 14 additions & 1 deletion src/GleapCustomDataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { gleapDataParser } from "./GleapHelper";

export default class GleapCustomDataManager {
customData = {};
ticketAttributes = {};

// GleapCustomDataManager singleton
static instance;
Expand All @@ -20,7 +21,6 @@ export default class GleapCustomDataManager {
return this.customData;
}


/**
* Set custom data that will be attached to the bug-report.
* @param {*} data
Expand Down Expand Up @@ -55,4 +55,17 @@ export default class GleapCustomDataManager {
clearCustomData() {
this.customData = {};
}

/**
* This method is used to set ticket attributes programmatically.
* @param {*} key The key of the attribute you want to add.
* @param {*} value The value to set.
*/
setTicketAttribute(key, value) {
this.ticketAttributes[key] = value;
}

getTicketAttributes() {
return this.ticketAttributes;
}
}
8 changes: 7 additions & 1 deletion src/GleapFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default class GleapFeedback {
type = "BUG";
priority = "LOW";
customData = {};
ticketAttributes = {};
metaData = {};
consoleLog = [];
networkLogs = [];
Expand Down Expand Up @@ -36,6 +37,7 @@ export default class GleapFeedback {
this.consoleLog = GleapConsoleLogManager.getInstance().getLogs();
this.networkLogs = GleapNetworkIntercepter.getInstance().getRequests();
this.customEventLog = GleapStreamedEvent.getInstance().getEventArray();
this.ticketAttributes = GleapCustomDataManager.getInstance().getTicketAttributes();

var dataPromises = [];

Expand Down Expand Up @@ -81,7 +83,11 @@ export default class GleapFeedback {
consoleLog: this.consoleLog,
networkLogs: this.networkLogs,
customEventLog: this.customEventLog,
formData: this.formData,
// Merge ticket attributes and form data.
formData: {
...this.ticketAttributes,
...this.formData
},
isSilent: this.isSilent,
outbound: this.outboundId,
screenshotData: this.screenshotData,
Expand Down
8 changes: 7 additions & 1 deletion src/GleapFrameManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ export default class GleapFrameManager {
name: "config-update",
data: {
config: GleapConfigManager.getInstance().getFlowConfig(),
aiTools: GleapConfigManager.getInstance().getAiTools(),
overrideLanguage:
GleapTranslationManager.getInstance().getOverrideLanguage(),
},
Expand Down Expand Up @@ -488,7 +489,8 @@ export default class GleapFrameManager {
metaData: GleapMetaDataManager.getInstance().getMetaData(),
consoleLog: GleapConsoleLogManager.getInstance().getLogs(),
networkLogs: GleapNetworkIntercepter.getInstance().getRequests(),
customEventLog: GleapStreamedEvent.getInstance().getEventArray()
customEventLog: GleapStreamedEvent.getInstance().getEventArray(),
formData: GleapCustomDataManager.getInstance().getTicketAttributes(),
};

// Add tags
Expand Down Expand Up @@ -539,6 +541,10 @@ export default class GleapFrameManager {
this.hideWidget();
}

if (data.name === "tool-execution") {
GleapEventManager.notifyEvent("tool-execution", data.data);
}

if (data.name === "send-feedback") {
const formData = data.data.formData;
const action = data.data.action;
Expand Down

0 comments on commit 4dfb6b6

Please sign in to comment.