Skip to content

Commit e407f25

Browse files
authored
Merge pull request #40 from GleapSDK/tooltipsnew
Tooltips
2 parents 570813b + 65a29bc commit e407f25

File tree

15 files changed

+682
-16
lines changed

15 files changed

+682
-16
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/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,12 @@ <h2 class="sub-headline">
326326
}
327327

328328
</script>
329-
329+
<script>
330+
window.intercomSettings = {
331+
api_base: "https://api-iam.intercom.io",
332+
app_id: "vm8dcoo6"
333+
};
334+
</script>
330335
</body>
331336

332337
</html>

demo/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ Gleap.on("tool-execution", (tool) => {
3535
3636
Gleap.setTicketAttribute("notes", "This is a test value.");*/
3737

38-
Gleap.initialize("ogWhNhuiZcGWrva5nlDS8l7a78OfaLlV");
38+
Gleap.initialize("Vx0SXWPHGU7Af54CabNL07k6HRELKTxu");

package-lock.json

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "13.5.16",
3+
"version": "13.6.0",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {
@@ -70,7 +70,8 @@
7070
}
7171
},
7272
"dependencies": {
73+
"@floating-ui/dom": "^1.6.3",
7374
"pick-dom-element": "^0.2.3",
7475
"unique-selector": "^0.5.0"
7576
}
76-
}
77+
}

published/13.5.16/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.

published/13.6.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: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,50 @@ if (typeof window !== "undefined") {
11831183
}
11841184
}
11851185

1186+
const handleGleapLink = (href) => {
1187+
try {
1188+
// gleap://article/123
1189+
const urlParts = href.split('/');
1190+
const type = urlParts[2];
1191+
if (type === 'article') {
1192+
const identifier = urlParts[3];
1193+
Gleap.openHelpCenterArticle(identifier);
1194+
}
1195+
1196+
if (type === 'collection') {
1197+
const identifier = urlParts[3];
1198+
Gleap.openHelpCenterCollection(identifier);
1199+
}
1200+
1201+
if (type === 'survey') {
1202+
const identifier = urlParts[3];
1203+
Gleap.showSurvey(identifier);
1204+
}
1205+
1206+
if (type === 'bot') {
1207+
const identifier = urlParts[3];
1208+
Gleap.startBot(identifier);
1209+
}
1210+
1211+
if (type === 'news') {
1212+
const identifier = urlParts[3];
1213+
Gleap.openNews(identifier);
1214+
}
1215+
1216+
if (type === 'checklist') {
1217+
const identifier = urlParts[3];
1218+
Gleap.startChecklist(identifier);
1219+
}
1220+
1221+
if (type === 'tour') {
1222+
const identifier = urlParts[3];
1223+
Gleap.startProductTour(identifier);
1224+
}
1225+
} catch (e) {
1226+
console.error("Failed to handle Gleap link: ", href);
1227+
}
1228+
}
1229+
11861230
export {
11871231
GleapNetworkIntercepter,
11881232
GleapAudioManager,
@@ -1206,5 +1250,6 @@ export {
12061250
GleapFrameManager,
12071251
GleapMetaDataManager,
12081252
GleapTagManager,
1253+
handleGleapLink,
12091254
};
12101255
export default Gleap;

src/GleapAdminManager.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ export default class GleapAdminManager {
106106
self.configData = data.data;
107107
self.initAdminHelper();
108108
}
109+
110+
if (data.name === "smartlink-search-result") {
111+
this.sendMessageToTourBuilder({
112+
name: "smartlink-search-result",
113+
data: data.data,
114+
});
115+
}
109116
}
110117

111118
if (data.type === "tourbuilder") {
@@ -116,6 +123,13 @@ export default class GleapAdminManager {
116123
});
117124
}
118125

126+
if (data.name === "smartlink-search") {
127+
this.sendMessage({
128+
name: "smartlink-search",
129+
data: data.data,
130+
});
131+
}
132+
119133
if (data.name === "save") {
120134
this.sendMessage({
121135
name: "save",
@@ -141,7 +155,7 @@ export default class GleapAdminManager {
141155
}
142156
}
143157
}
144-
} catch (exp) {}
158+
} catch (exp) { }
145159
});
146160

147161
this.sendMessage({
@@ -226,7 +240,7 @@ export default class GleapAdminManager {
226240
var elem = document.createElement("div");
227241
elem.className =
228242
"gleap-admin-frame-container";
229-
elem.innerHTML = `<iframe src="https://app.gleap.io/producttourbuilder" class="gleap-admin-frame" scrolling="no" title="Gleap Admin Window" allow="autoplay; encrypted-media; fullscreen;" frameborder="0"></iframe>`;
243+
elem.innerHTML = `<iframe src="https://app.gleap.io/${this?.configData?.type === 'tooltips' ? 'tooltipbuilder' : 'producttourbuilder'}" class="gleap-admin-frame" scrolling="no" title="Gleap Admin Window" allow="autoplay; encrypted-media; fullscreen;" frameborder="0"></iframe>`;
230244
document.body.appendChild(elem);
231245

232246
this.gleapFrameContainer = elem;

src/GleapClickListener.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GleapConsoleLogManager, GleapFrameManager } from "./Gleap";
1+
import { GleapConsoleLogManager, GleapFrameManager, handleGleapLink } from "./Gleap";
22
import { getDOMElementDescription } from "./GleapHelper";
33

44
export default class GleapClickListener {
@@ -11,14 +11,21 @@ export default class GleapClickListener {
1111
}
1212

1313
start() {
14-
document.addEventListener("click", (event) => {
15-
if (!event.target) {
14+
document.addEventListener("click", (e) => {
15+
if (!e.target) {
1616
return;
1717
}
1818

19+
if (e.target.tagName === 'A' && e.target.protocol === 'gleap:') {
20+
e.preventDefault();
21+
22+
const href = e.target.href;
23+
handleGleapLink(href);
24+
}
25+
1926
if (!GleapFrameManager.getInstance().isOpened()) {
2027
GleapConsoleLogManager.getInstance().addLog(
21-
getDOMElementDescription(event.target),
28+
getDOMElementDescription(e.target),
2229
"CLICK"
2330
);
2431
}

src/GleapSession.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { GleapEventManager, GleapTranslationManager, GleapFrameManager, GleapNotificationManager, GleapStreamedEvent, GleapBannerManager } from "./Gleap";
22
import { eraseGleapCookie, getGleapCookie, loadFromGleapCache, saveToGleapCache, setGleapCookie } from "./GleapHelper";
3+
import GleapTooltipManager from "./GleapTooltipManager";
34

45
export default class GleapSession {
56
apiUrl = "https://api.gleap.io";
@@ -201,6 +202,9 @@ export default class GleapSession {
201202

202203
// Initially track.
203204
GleapStreamedEvent.getInstance().restart();
205+
206+
// Load tooltips.
207+
GleapTooltipManager.getInstance().load();
204208
} catch (exp) { }
205209
} else {
206210
if (http.status !== 429) {
@@ -341,6 +345,8 @@ export default class GleapSession {
341345
// Initially track.
342346
GleapStreamedEvent.getInstance().restart();
343347

348+
// Load tooltips.
349+
GleapTooltipManager.getInstance().load();
344350
resolve(sessionData);
345351
} catch (exp) {
346352
reject(exp);

0 commit comments

Comments
 (0)