Skip to content

Commit 4dfb6b6

Browse files
committed
v13.5.0
1 parent d37b18e commit 4dfb6b6

File tree

12 files changed

+99
-18
lines changed

12 files changed

+99
-18
lines changed

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/main.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
11
const Gleap = window.Gleap;
22

3+
Gleap.setLanguage("en");
34
Gleap.setFrameUrl("http://0.0.0.0:3001");
45
Gleap.setApiUrl("http://0.0.0.0:9000");
56
Gleap.setWSApiUrl("ws://0.0.0.0:8080");
67

7-
Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV");
8+
Gleap.setAiTools([{
9+
name: 'send-money',
10+
description: 'Send money to a given contact.',
11+
response: 'The transfer got initiated but not completed yet. The user must confirm the transfer in the banking app.',
12+
parameters: [{
13+
name: 'amount',
14+
description: 'The amount of money to send. Must be positive and provided by the user.',
15+
type: 'number',
16+
required: true
17+
}, {
18+
name: 'contact',
19+
description: 'The contact to send money to.',
20+
type: 'string',
21+
enum: ["Alice", "Bob"],
22+
required: true
23+
}]
24+
}]);
825

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

13-
Gleap.setNetworkLogPropsToIgnore(["password", "token"]);
14-
15-
Gleap.registerCustomAction((customAction) => {
16-
console.log("Custom action: ", customAction);
31+
// Initiate the transfer here.
32+
}
1733
});
1834

19-
Gleap.on("unread-count-changed", (unreadCount) => {
20-
console.log("Unread count changed: ", unreadCount);
21-
});
35+
Gleap.setTicketAttribute("notes", "This is a test value.");
36+
37+
Gleap.initialize("ixFtcUWCFjENqupXkb39Ca7uncprVfjA");

index.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export namespace Gleap {
3737
function startBot(botId: string, showBackButton?: boolean): void;
3838
function startConversation(showBackButton?: boolean): void;
3939
function attachCustomData(customData: any): void;
40+
function setTicketAttribute(key: string, value: string): void;
4041
function setCustomData(key: string, value: string): void;
4142
function removeCustomData(key: string): void;
4243
function clearCustomData(): void;
@@ -78,6 +79,18 @@ export namespace Gleap {
7879
function enableShortcuts(enabled: boolean): void;
7980
function setLanguage(language: string): void;
8081
function preFillForm(data: object): void;
82+
function setAiTools(tools: {
83+
name: string;
84+
description: string;
85+
response: string;
86+
parameters: {
87+
name: string;
88+
description: string;
89+
type: "string" | "number" | "boolean";
90+
required: boolean;
91+
enums?: string[];
92+
}[];
93+
}[]): void;
8194
function showTabNotificationBadge(showNotificationBadge: boolean): void;
8295
function attachNetworkLogs(networkLogs: string): void;
8396
function clearIdentity(): void;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "13.2.8",
3+
"version": "13.5.0",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/13.5.0/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Gleap.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ class Gleap {
136136
GleapConsoleLogManager.getInstance().stop();
137137
}
138138

139+
/**
140+
* Set the AI tools.
141+
* @param {*} tools
142+
*/
143+
static setAiTools(tools) {
144+
GleapConfigManager.getInstance().setAiTools(tools);
145+
}
146+
139147
/**
140148
* Attaches external network logs.
141149
*/
@@ -488,6 +496,15 @@ class Gleap {
488496
GleapFrameManager.getInstance().frameUrl = frameUrl;
489497
}
490498

499+
/**
500+
* This method is used to set ticket attributes programmatically.
501+
* @param {*} key The key of the attribute you want to add.
502+
* @param {*} value The value to set.
503+
*/
504+
static setTicketAttribute(key, value) {
505+
GleapCustomDataManager.getInstance().setTicketAttribute(key, value);
506+
}
507+
491508
/**
492509
* Set custom data that will be attached to the bug-report.
493510
* @param {*} data

src/GleapConfigManager.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default class GleapConfigManager {
1313
flowConfig = null;
1414
projectActions = null;
1515
onConfigLoadedListener = [];
16+
aiTools = [];
1617

1718
onConfigLoaded = (onConfigLoaded) => {
1819
if (this.flowConfig !== null) {
@@ -39,6 +40,14 @@ export default class GleapConfigManager {
3940
return this.flowConfig;
4041
}
4142

43+
setAiTools = (aiTools) => {
44+
this.aiTools = aiTools;
45+
};
46+
47+
getAiTools = () => {
48+
return this.aiTools;
49+
}
50+
4251
/**
4352
* Load config.
4453
* @returns {string}

src/GleapCustomDataManager.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { gleapDataParser } from "./GleapHelper";
22

33
export default class GleapCustomDataManager {
44
customData = {};
5+
ticketAttributes = {};
56

67
// GleapCustomDataManager singleton
78
static instance;
@@ -20,7 +21,6 @@ export default class GleapCustomDataManager {
2021
return this.customData;
2122
}
2223

23-
2424
/**
2525
* Set custom data that will be attached to the bug-report.
2626
* @param {*} data
@@ -55,4 +55,17 @@ export default class GleapCustomDataManager {
5555
clearCustomData() {
5656
this.customData = {};
5757
}
58+
59+
/**
60+
* This method is used to set ticket attributes programmatically.
61+
* @param {*} key The key of the attribute you want to add.
62+
* @param {*} value The value to set.
63+
*/
64+
setTicketAttribute(key, value) {
65+
this.ticketAttributes[key] = value;
66+
}
67+
68+
getTicketAttributes() {
69+
return this.ticketAttributes;
70+
}
5871
}

src/GleapFeedback.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export default class GleapFeedback {
77
type = "BUG";
88
priority = "LOW";
99
customData = {};
10+
ticketAttributes = {};
1011
metaData = {};
1112
consoleLog = [];
1213
networkLogs = [];
@@ -36,6 +37,7 @@ export default class GleapFeedback {
3637
this.consoleLog = GleapConsoleLogManager.getInstance().getLogs();
3738
this.networkLogs = GleapNetworkIntercepter.getInstance().getRequests();
3839
this.customEventLog = GleapStreamedEvent.getInstance().getEventArray();
40+
this.ticketAttributes = GleapCustomDataManager.getInstance().getTicketAttributes();
3941

4042
var dataPromises = [];
4143

@@ -81,7 +83,11 @@ export default class GleapFeedback {
8183
consoleLog: this.consoleLog,
8284
networkLogs: this.networkLogs,
8385
customEventLog: this.customEventLog,
84-
formData: this.formData,
86+
// Merge ticket attributes and form data.
87+
formData: {
88+
...this.ticketAttributes,
89+
...this.formData
90+
},
8591
isSilent: this.isSilent,
8692
outbound: this.outboundId,
8793
screenshotData: this.screenshotData,

src/GleapFrameManager.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ export default class GleapFrameManager {
420420
name: "config-update",
421421
data: {
422422
config: GleapConfigManager.getInstance().getFlowConfig(),
423+
aiTools: GleapConfigManager.getInstance().getAiTools(),
423424
overrideLanguage:
424425
GleapTranslationManager.getInstance().getOverrideLanguage(),
425426
},
@@ -488,7 +489,8 @@ export default class GleapFrameManager {
488489
metaData: GleapMetaDataManager.getInstance().getMetaData(),
489490
consoleLog: GleapConsoleLogManager.getInstance().getLogs(),
490491
networkLogs: GleapNetworkIntercepter.getInstance().getRequests(),
491-
customEventLog: GleapStreamedEvent.getInstance().getEventArray()
492+
customEventLog: GleapStreamedEvent.getInstance().getEventArray(),
493+
formData: GleapCustomDataManager.getInstance().getTicketAttributes(),
492494
};
493495

494496
// Add tags
@@ -539,6 +541,10 @@ export default class GleapFrameManager {
539541
this.hideWidget();
540542
}
541543

544+
if (data.name === "tool-execution") {
545+
GleapEventManager.notifyEvent("tool-execution", data.data);
546+
}
547+
542548
if (data.name === "send-feedback") {
543549
const formData = data.data.formData;
544550
const action = data.data.action;

0 commit comments

Comments
 (0)