ahdjs 0.0.34 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ export default class GuideChimp {
68
68
  * @param tour
69
69
  * @return {this}
70
70
  */
71
- setTour(tour: any): this;
71
+ setTour(tour: any, options?: {}): this;
72
72
  /**
73
73
  * Get tour name or steps
74
74
  */
@@ -15,6 +15,7 @@ declare class AHD extends GuideChimp {
15
15
  showAppBanner(url: string, refetch: boolean): Promise<any>;
16
16
  fetchFaqs(slug: any): Promise<any>;
17
17
  showPageBeacons(url: string, refetch: boolean): Promise<void>;
18
+ setBeacons(beacons: any): Promise<void>;
18
19
  showPageHighlights(url: string, refetch: boolean, force?: boolean): Promise<void>;
19
20
  clearCachedData(): Promise<void>;
20
21
  acknowledgeHighlight(id: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ahdjs",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/types/index.d.ts",
package/testing.html CHANGED
@@ -6,24 +6,28 @@
6
6
  <body>
7
7
  <div class="tour-container">
8
8
  User input: <input id="user-input" /> <br /><br />
9
- <div id="try-and-buy" class="tour-section" data-ahd="create-new-entity">
10
- Try & Buy
11
- </div>
12
- <div id="subscription" class="tour-section">Subscription</div>
13
- <div id="pricing-table" class="tour-section" data-ahd="heading">
14
- Pricing Table
15
- </div>
16
- <div
9
+ <span
10
+ id="try-and-buy"
11
+ class="tour-section"
12
+ data-ahd="create-new-entity"
13
+ >
14
+ Try & Buy </span
15
+ ><br />
16
+ <span id="subscription" class="tour-section">Subscription</span><br />
17
+ <span id="pricing-table" class="tour-section" data-ahd="heading">
18
+ Pricing Table </span
19
+ ><br />
20
+ <span
17
21
  id="multi-feature"
18
22
  class="tour-section"
19
23
  data-ahd="add-fields-application"
20
24
  >
21
- Multi-Feature
22
- </div>
23
- <div id="node-locked" class="tour-section" data-ahd="widget-video">
24
- Node-Locked
25
- </div>
26
- <div id="pay-per-use" class="tour-section">Pay-per-Use</div>
25
+ Multi-Feature </span
26
+ ><br />
27
+ <span id="node-locked" class="tour-section" data-ahd="widget-video">
28
+ Node-Locked </span
29
+ ><br />
30
+ <span id="pay-per-use" class="tour-section">Pay-per-Use</span>
27
31
  </div>
28
32
  <script>
29
33
  const tour1 = [
@@ -211,25 +215,157 @@
211
215
  },
212
216
  },
213
217
  ];
218
+
214
219
  const AHDjs = window.AHDjs.default;
220
+ const userId = "675c5d10b73dc091ba239699";
215
221
  let _ahdJs = new AHDjs(undefined, {
216
222
  applicationId: "6655bc2b30a6760d8f897581",
217
223
  apiHost: "https://pagepilot.fabbuilder.com",
224
+ userId: userId,
218
225
  });
219
226
  _ahdJs.initializeSiteMap();
220
227
 
221
- setTimeout(() => {
222
- _ahdJs.clearCachedData();
223
- }, 50000);
228
+ const requestOptions = {
229
+ method: "GET",
230
+ redirect: "follow",
231
+ };
232
+
233
+ fetch(
234
+ `https://asia-south1.gcp.data.mongodb-api.com/app/mock-wallet-vrughwh/endpoint/ahd/get/unacknowledged?userId=${userId}`,
235
+ requestOptions
236
+ )
237
+ .then((response) => response.json())
238
+ .then((result) => {
239
+ if (result.type === "dialog") {
240
+ const dialogContent = [
241
+ {
242
+ title: result.content.title,
243
+ description: result.content.body,
244
+
245
+ buttons: [
246
+ {
247
+ title: "Ok",
248
+ class: "tour-button",
249
+ onClick: function () {
250
+ fetch(
251
+ `https://asia-south1.gcp.data.mongodb-api.com/app/mock-wallet-vrughwh/endpoint/ahd/acknowledge?id=${result._id}`,
252
+ requestOptions
253
+ )
254
+ .then(() => {
255
+ ahdJS.stop();
256
+ })
257
+ .catch((error) => {
258
+ console.error("Error acknowledging:", error);
259
+ });
260
+ },
261
+ },
262
+ ],
263
+ },
264
+ ];
265
+ _ahdJs.setTour(dialogContent);
266
+ _ahdJs.start();
267
+ }
268
+
269
+ if (result.type === "snackbar") {
270
+ const snackbarContent = [
271
+ {
272
+ title: result.content.title,
273
+ description: result.content.body,
274
+ position: result.content.position,
275
+ },
276
+ ];
277
+ _ahdJs.setTour(snackbarContent, {
278
+ type: "snackbar",
279
+ showNavigation: false,
280
+ });
281
+ _ahdJs.start();
282
+ _ahdJs.removeOverlayEl();
283
+ _ahdJs.removePreloaderEl();
284
+ // setTimeout(() => {
285
+ // _ahdJs.stop();
286
+ // }, result.timeout);
287
+ }
288
+ if (result.type === "beacon") {
289
+ const beacon = {
290
+ element: result.content.selector,
291
+ // title: result.content.title,
292
+ // description: result.content.body,
293
+ // position: result.content.position || "top",
294
+ // shape: result.content.shape || "circle",
295
+ // color: result.content.color || "blue",
296
+ // background: result.content.background,
297
+ // textColor: result.content.textColor,
298
+
299
+ tour: {
300
+ steps: [
301
+ {
302
+ element: result.content.selector,
303
+ title: result.content.title,
304
+ description: result.content.body,
305
+ position: result.content.position || "top",
306
+ },
307
+ ],
308
+ options: {
309
+ position: result.content.position,
310
+ shape: result.content.shape || "circle",
311
+ color: result.content.color || "blue",
312
+ background: result.content.background,
313
+ textColor: result.content.textColor,
314
+ },
315
+ },
316
+ };
317
+
318
+
319
+ // const targetElement = document.querySelector(beacon.element);
320
+ // if (!targetElement) {
321
+ // console.error(
322
+ // "Target element not found for beacon selector:",
323
+ // beacon.element
324
+ // );
325
+ // return;
326
+ // }
327
+
328
+ debugger;
329
+ _ahdJs.setBeacons(beacon);
330
+ // _ahdJs.showAll();
331
+ }
332
+
333
+ if (result.type === "tour") {
334
+ _ahdJs.setTour(result.tourContent);
335
+
336
+ _ahdJs.start();
337
+ // _ahdJs.showAll();
338
+ }
339
+ if (result.type === "tooltip") {
340
+ const tooltip = [
341
+ {
342
+ element: result.content.selector,
343
+ position: result.content.position,
344
+ title: result.content.title,
345
+ tour: [
346
+ ...result.content.map((record) => ({
347
+ ...record,
348
+ })),
349
+ ],
350
+ },
351
+ ];
352
+
353
+ _ahdJs.setBeacons(tooltip);
354
+ // _ahdJs.showAll();
355
+ }
356
+ })
357
+
358
+ .catch((error) => console.error(error));
359
+ // setTimeout(() => {
360
+ // _ahdJs.clearCachedData();
361
+ // }, 50000);
224
362
 
225
363
  // _ahdJs.start();
226
- _ahdJs.showPageTour("/slug");
227
- _ahdJs.showAppBanner().then((banner) => {
228
- alert(JSON.stringify(banner));
229
- });
364
+ // _ahdJs.showPageTour("/slug");
365
+ // _ahdJs.showAppBanner();
230
366
 
231
- _ahdJs.fetchFaqs("/help-support");
232
- _ahdJs.showPageBeacons("beacon-labs64");
367
+ // _ahdJs.fetchFaqs("/help-support");
368
+ // _ahdJs.showPageBeacons("/auth/signin");
233
369
  //_ahdJs.showPageFAQs("/auth/signin");
234
370
  // _ahdJs.showPageHelpDrawer("/auth/signin");
235
371
  // _ahdJs.showInformation(beacons);
@@ -241,9 +377,9 @@
241
377
  // }, 10000);
242
378
  // setTimeout(async () => {
243
379
  // await _ahdJs.stop();
244
- // debugger;
245
- // _ahdJs.setTour(tour);
246
- // _ahdJs.start();
380
+ // ;
381
+ // _ahdJs.setTour(tour);
382
+ // _ahdJs.start();
247
383
  // }, 15000);
248
384
  </script>
249
385
  </body>