@pendo/agent 2.279.2 → 2.279.4

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/dom.esm.js CHANGED
@@ -7228,7 +7228,7 @@ function getScreenPosition(element) {
7228
7228
  };
7229
7229
  }
7230
7230
 
7231
- var VERSION = '2.279.2_';
7231
+ var VERSION = '2.279.4_';
7232
7232
  function isExtensionAgent() {
7233
7233
  var installType = getPendoConfigValue('installType') || getPendoConfigFromEnclosingScope().installType;
7234
7234
  return installType === EXTENSION_INSTALL_TYPE;
@@ -3891,8 +3891,8 @@ var SERVER = '';
3891
3891
  var ASSET_HOST = '';
3892
3892
  var ASSET_PATH = '';
3893
3893
  var DESIGNER_ENV = '';
3894
- var VERSION = '2.279.2_';
3895
- var PACKAGE_VERSION = '2.279.2';
3894
+ var VERSION = '2.279.4_';
3895
+ var PACKAGE_VERSION = '2.279.4';
3896
3896
  var LOADER = 'xhr';
3897
3897
  /* eslint-enable agent-eslint-rules/no-gulp-env-references */
3898
3898
  /**
@@ -36432,7 +36432,6 @@ function getActiveEmbeddedGuides() {
36432
36432
  }
36433
36433
 
36434
36434
  const SESSION_ID = 'sessionId';
36435
- const SESSION_LAST_USER_INTERACTION_EVENT = 'sessionLastUserInteractionEvent';
36436
36435
  const THIRTY_MINUTES = 1000 * 60 * 30;
36437
36436
  class SessionManager {
36438
36437
  constructor() {
@@ -36442,7 +36441,6 @@ class SessionManager {
36442
36441
  this.api = PluginAPI;
36443
36442
  this.pendo = pendo;
36444
36443
  this.subscriptions = [
36445
- this.api.attachEvent(this.api.Events, 'ready', _.bind(this.ready, this)),
36446
36444
  this.api.attachEvent(this.api.Events, 'eventCaptured', _.bind(this.eventCaptured, this))
36447
36445
  ];
36448
36446
  this.inactivityDuration = this.api.ConfigReader.get('inactivityDuration', THIRTY_MINUTES);
@@ -36456,20 +36454,6 @@ class SessionManager {
36456
36454
  * @label SESSION_ID
36457
36455
  */
36458
36456
  this.api.agentStorage.registry.addLocal(SESSION_ID);
36459
- /**
36460
- * Stores the visitorId, accountId, and last user interaction timestamp.
36461
- * This is used to track inactivity across page loads for the purposes of
36462
- * expiring an old session and generating a new `pendo_sessionId`
36463
- *
36464
- * @name pendo_sessionLastUserInteractionEvent
36465
- * @category Cookies/localStorage
36466
- * @access public
36467
- * @label SESSION_LAST_USER_INTERACTION_EVENT
36468
- */
36469
- this.api.agentStorage.registry.addLocal(SESSION_LAST_USER_INTERACTION_EVENT);
36470
- if (this.api.store.getters['frames/isReady']()) {
36471
- this.ready();
36472
- }
36473
36457
  }
36474
36458
  teardown() {
36475
36459
  _.each(this.subscriptions, function (unsubscribe) {
@@ -36477,14 +36461,8 @@ class SessionManager {
36477
36461
  });
36478
36462
  this.subscriptions.length = 0;
36479
36463
  }
36480
- ready() {
36481
- if (!this.isReady) {
36482
- this.sessionId(); // generate/load id
36483
- this.isReady = true;
36484
- }
36485
- }
36486
- isExpired(timestamp) {
36487
- const prevLastEmitTime = _.get(this._sessionInfo, 'timestamp');
36464
+ isExpired(sessionInfo, timestamp) {
36465
+ const prevLastEmitTime = _.get(sessionInfo, 'timestamp');
36488
36466
  if (prevLastEmitTime && timestamp - prevLastEmitTime > this.inactivityDuration) {
36489
36467
  return true;
36490
36468
  }
@@ -36494,41 +36472,34 @@ class SessionManager {
36494
36472
  if (!event || !event.data || !event.data.length)
36495
36473
  return;
36496
36474
  var capturedEvent = event.data[0];
36497
- this.ready(); // ensure IDs are loaded
36498
36475
  const eventTime = capturedEvent.browser_time || new Date().getTime();
36499
- if (this.isExpired(eventTime)) {
36476
+ let sessionInfo = this.sessionInfo();
36477
+ if (this.isExpired(sessionInfo, eventTime)) {
36500
36478
  // the current event will be attributed to the *new* session
36501
- this.clearSessionInfo();
36479
+ sessionInfo = this.clearSessionInfo();
36502
36480
  this.api.Events.sessionChanged.trigger();
36503
36481
  }
36504
- this.storeLastInteractionEventInformation(eventTime);
36505
- capturedEvent.sessionId = this.sessionId();
36482
+ this.storeLastInteractionEventInformation(sessionInfo, eventTime);
36483
+ capturedEvent.sessionId = sessionInfo.sessionId;
36506
36484
  }
36507
- sessionId(defaultId = this.pendo.randomString(16)) {
36508
- if (!this._sessionInfo) {
36509
- let currentSessionInfo = this.api.agentStorage.read(SESSION_ID);
36510
- if (!currentSessionInfo) {
36511
- currentSessionInfo = JSON.stringify({
36512
- 'sessionId': defaultId,
36513
- 'timestamp': new Date().getTime()
36514
- });
36515
- this.api.agentStorage.write(SESSION_ID, currentSessionInfo);
36516
- }
36517
- this._sessionInfo = JSON.parse(currentSessionInfo);
36485
+ sessionInfo(defaultId = this.pendo.randomString(16)) {
36486
+ let currentSessionInfo = this.api.agentStorage.read(SESSION_ID);
36487
+ if (!currentSessionInfo) {
36488
+ currentSessionInfo = JSON.stringify({
36489
+ 'sessionId': defaultId,
36490
+ 'timestamp': new Date().getTime()
36491
+ });
36492
+ this.api.agentStorage.write(SESSION_ID, currentSessionInfo);
36518
36493
  }
36519
- return this._sessionInfo.sessionId;
36494
+ return JSON.parse(currentSessionInfo);
36520
36495
  }
36521
36496
  clearSessionInfo() {
36522
- let currentSessionInfo = this.api.agentStorage.read(SESSION_ID);
36523
- if (currentSessionInfo && JSON.parse(currentSessionInfo).sessionId === this._sessionInfo.sessionId) {
36524
- this.api.agentStorage.clear(SESSION_ID);
36525
- }
36526
- delete this._sessionInfo;
36527
- this.sessionId();
36497
+ this.api.agentStorage.clear(SESSION_ID);
36498
+ return this.sessionInfo();
36528
36499
  }
36529
- storeLastInteractionEventInformation(timestamp) {
36530
- this._sessionInfo.timestamp = timestamp;
36531
- this.api.agentStorage.write(SESSION_ID, JSON.stringify(this._sessionInfo));
36500
+ storeLastInteractionEventInformation(sessionInfo, timestamp) {
36501
+ sessionInfo.timestamp = timestamp;
36502
+ this.api.agentStorage.write(SESSION_ID, JSON.stringify(sessionInfo));
36532
36503
  }
36533
36504
  }
36534
36505
  var SessionManager$1 = new SessionManager();
@@ -37580,6 +37551,7 @@ class DOMPrompt {
37580
37551
  *
37581
37552
  * Built-in Plugin adding optional support for monitoring a Prompt like a search box or chat text box.
37582
37553
  */
37554
+ const PENDO_HEADERS_KEY = '_pendoHeaders';
37583
37555
  class PromptPlugin {
37584
37556
  constructor() {
37585
37557
  this.name = 'PromptAnalytics';
@@ -37645,6 +37617,14 @@ class PromptPlugin {
37645
37617
  if (pluginInstance._networkPatched)
37646
37618
  return;
37647
37619
  pluginInstance._networkPatched = true;
37620
+ if (!pluginInstance._originalSetRequestHeader) {
37621
+ pluginInstance._originalSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
37622
+ XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
37623
+ this[PENDO_HEADERS_KEY] = this[PENDO_HEADERS_KEY] || {};
37624
+ this[PENDO_HEADERS_KEY][header] = value;
37625
+ return pluginInstance._originalSetRequestHeader.apply(this, arguments);
37626
+ };
37627
+ }
37648
37628
  pluginInstance._originalFetch = window.fetch;
37649
37629
  window.fetch = function (...args) {
37650
37630
  return __awaiter(this, void 0, void 0, function* () {
@@ -37745,6 +37725,10 @@ class PromptPlugin {
37745
37725
  }
37746
37726
  this._networkPatched = false;
37747
37727
  this._.each(this.prompts, (prompt) => prompt.teardown());
37728
+ if (this._originalSetRequestHeader) {
37729
+ XMLHttpRequest.prototype.setRequestHeader = this._originalSetRequestHeader;
37730
+ this._originalSetRequestHeader = null;
37731
+ }
37748
37732
  }
37749
37733
  }
37750
37734
  function safelySerializeBody(body) {
@@ -37780,14 +37764,8 @@ function extractHeaders(headers = {}) {
37780
37764
  }
37781
37765
  return result;
37782
37766
  }
37783
- const originalSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
37784
- XMLHttpRequest.prototype.setRequestHeader = function (header, value) {
37785
- this._headers = this._headers || {};
37786
- this._headers[header] = value;
37787
- return originalSetRequestHeader.apply(this, arguments);
37788
- };
37789
37767
  function extractXHRHeaders(xhr) {
37790
- return xhr._headers || {};
37768
+ return xhr[PENDO_HEADERS_KEY] || {};
37791
37769
  }
37792
37770
  var PromptAnalytics = new PromptPlugin();
37793
37771