@elliemae/ssf-guest 2.7.8 → 2.9.0

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.
package/dist/cjs/guest.js CHANGED
@@ -91,11 +91,15 @@ class SSFGuest {
91
91
  /**
92
92
  * flag to keep host session alive
93
93
  */
94
- #keepAlive = false;
94
+ #keepAlive = true;
95
95
  /**
96
96
  * interval to keep host session alive.
97
97
  */
98
98
  #keepAliveInterval = KEEP_ALIVE_INTERVAL;
99
+ /**
100
+ * options for the logger
101
+ */
102
+ #loggerOptions;
99
103
  /**
100
104
  * throttled keep alive function
101
105
  */
@@ -112,9 +116,10 @@ class SSFGuest {
112
116
  index,
113
117
  team,
114
118
  appName
115
- } = options?.logger || {};
119
+ } = options?.logger ?? {};
120
+ this.#loggerOptions = options?.logger;
116
121
  this.#usesDevConnectAPI = options?.usesDevConnectAPI ?? false;
117
- this.#keepAlive = options?.keepAlive ?? false;
122
+ this.#keepAlive = options?.keepAlive ?? true;
118
123
  this.#keepAliveInterval = options?.keepAliveInterval ?? KEEP_ALIVE_INTERVAL;
119
124
  const transport = logToConsole ? (0, import_pui_diagnostics.Console)() : (0, import_pui_diagnostics.http)(url);
120
125
  this.#logger = (0, import_pui_diagnostics.logger)({
@@ -430,6 +435,10 @@ class SSFGuest {
430
435
  userInteractionEvents.forEach((eventType) => {
431
436
  document.addEventListener(eventType, this.#throttledKeepAlive);
432
437
  });
438
+ } else {
439
+ this.#logger.warn(
440
+ "Application object not available to send keep alive"
441
+ );
433
442
  }
434
443
  } catch (e) {
435
444
  this.#logger.error(
@@ -438,6 +447,27 @@ class SSFGuest {
438
447
  }
439
448
  }
440
449
  };
450
+ /**
451
+ * send all log messages to parent
452
+ */
453
+ #useParentApplicationLogger = async () => {
454
+ try {
455
+ const appObj = await this.getObject("Application");
456
+ if (appObj?.log && !this.#loggerOptions.console) {
457
+ const { index, team, appName } = this.#loggerOptions;
458
+ this.#logger = (0, import_pui_diagnostics.logger)({
459
+ transport: (0, import_pui_diagnostics.parentApp)(appObj),
460
+ index,
461
+ team,
462
+ appName
463
+ });
464
+ }
465
+ } catch (e) {
466
+ this.#logger.error(
467
+ `Error getting application object. ${e.message}`
468
+ );
469
+ }
470
+ };
441
471
  /**
442
472
  * Initialize guest using script
443
473
  * @param scriptUri uri of the script
@@ -539,14 +569,15 @@ class SSFGuest {
539
569
  messageBody: guestOptions
540
570
  });
541
571
  this.#isConnected = true;
542
- this.#logger.audit({
543
- message: "Guest connected to host",
544
- guestUrl: window.location.href
545
- });
546
572
  this.#handleParentClose();
547
573
  if (this.#usesDevConnectAPI) await this.getAuthToken();
548
574
  await this.#startKeepSessionAlive();
575
+ await this.#useParentApplicationLogger();
549
576
  window.addEventListener("beforeunload", this.close);
577
+ this.#logger.audit({
578
+ message: "Guest connected to host",
579
+ guestUrl: window.location.href
580
+ });
550
581
  }
551
582
  };
552
583
  /**
@@ -562,7 +593,10 @@ class SSFGuest {
562
593
  this.#authToken = tokenInfo?.access_token;
563
594
  this.#hostDomain = tokenInfo?.host_name;
564
595
  this.#authClientId = tokenInfo?.client_id;
565
- }
596
+ } else
597
+ this.#logger.warn(
598
+ "Auth object not available to get access token from host"
599
+ );
566
600
  } catch (e) {
567
601
  console.dir(e, { depth: null });
568
602
  this.#logger.error(
@@ -33,10 +33,11 @@ var import_utils = require("../utils.js");
33
33
  const createGuest = ({
34
34
  keepAlive,
35
35
  usesDevConnectAPI,
36
- keepAliveInterval
36
+ keepAliveInterval,
37
+ console
37
38
  }) => new import__.SSFGuest({
38
39
  logger: {
39
- console: true,
40
+ console: console ?? true,
40
41
  index: "ssf",
41
42
  team: "UI Platform",
42
43
  appName: "SSF Guest"
package/dist/esm/guest.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  logger as puiLogger,
12
12
  Console,
13
13
  http,
14
+ parentApp,
14
15
  webvitals,
15
16
  logUnhandledErrors
16
17
  } from "@elliemae/pui-diagnostics";
@@ -86,11 +87,15 @@ class SSFGuest {
86
87
  /**
87
88
  * flag to keep host session alive
88
89
  */
89
- #keepAlive = false;
90
+ #keepAlive = true;
90
91
  /**
91
92
  * interval to keep host session alive.
92
93
  */
93
94
  #keepAliveInterval = KEEP_ALIVE_INTERVAL;
95
+ /**
96
+ * options for the logger
97
+ */
98
+ #loggerOptions;
94
99
  /**
95
100
  * throttled keep alive function
96
101
  */
@@ -107,9 +112,10 @@ class SSFGuest {
107
112
  index,
108
113
  team,
109
114
  appName
110
- } = options?.logger || {};
115
+ } = options?.logger ?? {};
116
+ this.#loggerOptions = options?.logger;
111
117
  this.#usesDevConnectAPI = options?.usesDevConnectAPI ?? false;
112
- this.#keepAlive = options?.keepAlive ?? false;
118
+ this.#keepAlive = options?.keepAlive ?? true;
113
119
  this.#keepAliveInterval = options?.keepAliveInterval ?? KEEP_ALIVE_INTERVAL;
114
120
  const transport = logToConsole ? Console() : http(url);
115
121
  this.#logger = puiLogger({
@@ -425,6 +431,10 @@ class SSFGuest {
425
431
  userInteractionEvents.forEach((eventType) => {
426
432
  document.addEventListener(eventType, this.#throttledKeepAlive);
427
433
  });
434
+ } else {
435
+ this.#logger.warn(
436
+ "Application object not available to send keep alive"
437
+ );
428
438
  }
429
439
  } catch (e) {
430
440
  this.#logger.error(
@@ -433,6 +443,27 @@ class SSFGuest {
433
443
  }
434
444
  }
435
445
  };
446
+ /**
447
+ * send all log messages to parent
448
+ */
449
+ #useParentApplicationLogger = async () => {
450
+ try {
451
+ const appObj = await this.getObject("Application");
452
+ if (appObj?.log && !this.#loggerOptions.console) {
453
+ const { index, team, appName } = this.#loggerOptions;
454
+ this.#logger = puiLogger({
455
+ transport: parentApp(appObj),
456
+ index,
457
+ team,
458
+ appName
459
+ });
460
+ }
461
+ } catch (e) {
462
+ this.#logger.error(
463
+ `Error getting application object. ${e.message}`
464
+ );
465
+ }
466
+ };
436
467
  /**
437
468
  * Initialize guest using script
438
469
  * @param scriptUri uri of the script
@@ -534,14 +565,15 @@ class SSFGuest {
534
565
  messageBody: guestOptions
535
566
  });
536
567
  this.#isConnected = true;
537
- this.#logger.audit({
538
- message: "Guest connected to host",
539
- guestUrl: window.location.href
540
- });
541
568
  this.#handleParentClose();
542
569
  if (this.#usesDevConnectAPI) await this.getAuthToken();
543
570
  await this.#startKeepSessionAlive();
571
+ await this.#useParentApplicationLogger();
544
572
  window.addEventListener("beforeunload", this.close);
573
+ this.#logger.audit({
574
+ message: "Guest connected to host",
575
+ guestUrl: window.location.href
576
+ });
545
577
  }
546
578
  };
547
579
  /**
@@ -557,7 +589,10 @@ class SSFGuest {
557
589
  this.#authToken = tokenInfo?.access_token;
558
590
  this.#hostDomain = tokenInfo?.host_name;
559
591
  this.#authClientId = tokenInfo?.client_id;
560
- }
592
+ } else
593
+ this.#logger.warn(
594
+ "Auth object not available to get access token from host"
595
+ );
561
596
  } catch (e) {
562
597
  console.dir(e, { depth: null });
563
598
  this.#logger.error(
@@ -10,10 +10,11 @@ import { getOrigin } from "../utils.js";
10
10
  const createGuest = ({
11
11
  keepAlive,
12
12
  usesDevConnectAPI,
13
- keepAliveInterval
13
+ keepAliveInterval,
14
+ console
14
15
  }) => new SSFGuest({
15
16
  logger: {
16
- console: true,
17
+ console: console ?? true,
17
18
  index: "ssf",
18
19
  team: "UI Platform",
19
20
  appName: "SSF Guest"
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Credit Service</title><style>body{margin:0}</style><script src="https://qa.assets.rd.elliemae.io/pui-diagnostics@3"></script><script>window.addEventListener("DOMContentLoaded",(async()=>{window.__ICE__={diagnosticsUrl:"https://int.api.ellielabs.com/diagnostics/v2/logging"};const e=new URL(window.location),i=e?.searchParams?.get?.("src");window.__ICE__.ssfGuest=new ice.guest.SSFGuest({logger:{index:"creditServiceGuest",team:"ui platform",appName:"credit-service"}}),await window.__ICE__.ssfGuest.addScript(i,document.body)}))</script><script defer="defer" src="js/emuiSsfGuest.f2b22c9cfe6072950785.js"></script></head><body></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Credit Service</title><style>body{margin:0}</style><script src="https://qa.assets.rd.elliemae.io/pui-diagnostics@3"></script><script>window.addEventListener("DOMContentLoaded",(async()=>{window.__ICE__={diagnosticsUrl:"https://int.api.ellielabs.com/diagnostics/v2/logging"};const e=new URL(window.location),i=e?.searchParams?.get?.("src");window.__ICE__.ssfGuest=new ice.guest.SSFGuest({logger:{index:"creditServiceGuest",team:"ui platform",appName:"credit-service"}}),await window.__ICE__.ssfGuest.addScript(i,document.body)}))</script><script defer="defer" src="js/emuiSsfGuest.79824cd8e03bf31d572a.js"></script></head><body></body></html>
@@ -1 +1 @@
1
- <!doctype html><html lang="en" style="height:100%"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Plugin</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfGuest.f2b22c9cfe6072950785.js"></script></head><body class="px-2 h-full"><main class="h-full"><h1 class="text-md font-bold">Credit Score Service</h1><div class="h-full mt-2"><output id="msg" class="mt-2 p-2"></output></div></main></body></html>
1
+ <!doctype html><html lang="en" style="height:100%"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Plugin</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfGuest.79824cd8e03bf31d572a.js"></script></head><body class="px-2 h-full"><main class="h-full"><h1 class="text-md font-bold">Credit Score Service</h1><div class="h-full mt-2"><output id="msg" class="mt-2 p-2"></output></div></main></body></html>