@pendo/agent 2.300.0 → 2.301.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.
@@ -3540,7 +3540,6 @@ var ConfigReader = (function () {
3540
3540
  addOption('formValidation', [PENDO_CONFIG_SRC], false);
3541
3541
  // Performance Metrics
3542
3542
  addOption('performanceMetricsEnabled', [SNIPPET_SRC, PENDO_CONFIG_SRC], true);
3543
- addOption('sendPerformanceMetrics', [SNIPPET_SRC, PENDO_CONFIG_SRC], false);
3544
3543
  }
3545
3544
  initializeOptions();
3546
3545
  var sourceGetters = {};
@@ -3905,8 +3904,8 @@ let SERVER = '';
3905
3904
  let ASSET_HOST = '';
3906
3905
  let ASSET_PATH = '';
3907
3906
  let DESIGNER_SERVER = '';
3908
- let VERSION = '2.300.0_';
3909
- let PACKAGE_VERSION = '2.300.0';
3907
+ let VERSION = '2.301.0_';
3908
+ let PACKAGE_VERSION = '2.301.0';
3910
3909
  let LOADER = 'xhr';
3911
3910
  /* eslint-enable agent-eslint-rules/no-gulp-env-references */
3912
3911
  /**
@@ -5559,6 +5558,8 @@ var Events = (function () {
5559
5558
  new EventType('sessionChanged', [LIFECYCLE]),
5560
5559
  new EventType('ptm:unpaused', [LIFECYCLE]),
5561
5560
  new EventType('ptm:paused', [LIFECYCLE]),
5561
+ new EventType('recording:unpaused', [LIFECYCLE]),
5562
+ new EventType('recording:paused', [LIFECYCLE]),
5562
5563
  new EventType('childFrameJoined', [FRAMES]),
5563
5564
  new EventType('tabIdChanged:self', [DEBUG, LIFECYCLE])
5564
5565
  ];
@@ -6110,7 +6111,7 @@ var URL = (function(global, factory) {
6110
6111
  })(window, URLPolyfillFactory);
6111
6112
 
6112
6113
  function hasComposedPath(evt) {
6113
- return evt && _.isFunction(evt.composedPath);
6114
+ return evt && typeof evt.composedPath === 'function';
6114
6115
  }
6115
6116
  function getComposedPath(evt) {
6116
6117
  if (hasComposedPath(evt)) {
@@ -6262,6 +6263,7 @@ var sizzle = {exports: {}};
6262
6263
  tokenCache = createCache(),
6263
6264
  compilerCache = createCache(),
6264
6265
  nonnativeSelectorCache = createCache(),
6266
+ nativeishSelectorCache = createCache(),
6265
6267
  sortOrder = function( a, b ) {
6266
6268
  if ( a === b ) {
6267
6269
  hasDuplicate = true;
@@ -6455,6 +6457,46 @@ var sizzle = {exports: {}};
6455
6457
  };
6456
6458
  }
6457
6459
 
6460
+ function isContains(token) {
6461
+ return token.type === 'PSEUDO' && token.matches.length && token.matches[0].replace(rtrim, "$1").toLowerCase() === 'contains';
6462
+ }
6463
+
6464
+ function filterTokens(tokens, predicate) {
6465
+ if (tokens[0].length) {
6466
+ return tokens.map(function(innerTokens) {
6467
+ return filterTokens(innerTokens, predicate);
6468
+ });
6469
+ } else {
6470
+ return tokens.filter(predicate);
6471
+ }
6472
+ }
6473
+
6474
+ function tokensToSelector(tokens) {
6475
+ if (tokens[0].length) {
6476
+ return tokens.map(tokensToSelector).join(',');
6477
+ } else {
6478
+ return toSelector(tokens);
6479
+ }
6480
+ }
6481
+
6482
+ function findSeedForNonNativeSelector(selector, context, selectorCache) {
6483
+ var hopefullyNativeSelector = selectorCache[ selector + " " ];
6484
+ if (!hopefullyNativeSelector) {
6485
+ var nonnativeTokens = tokenize(selector);
6486
+ var hopefullyNativeTokens = filterTokens(nonnativeTokens, function(token) {
6487
+ return !isContains(token);
6488
+ });
6489
+ hopefullyNativeSelector = tokensToSelector(hopefullyNativeTokens);
6490
+ }
6491
+ try {
6492
+ var seed = [];
6493
+ push.apply(seed, context.querySelectorAll(hopefullyNativeSelector));
6494
+ selectorCache(selector, hopefullyNativeSelector);
6495
+ return seed;
6496
+ } catch (e) {
6497
+ }
6498
+ }
6499
+
6458
6500
  function Sizzle( selector, context, results, seed ) {
6459
6501
  var m, i, elem, nid, match, groups, newSelector,
6460
6502
  newContext = context && context.ownerDocument,
@@ -6531,7 +6573,7 @@ var sizzle = {exports: {}};
6531
6573
 
6532
6574
  // Take advantage of querySelectorAll
6533
6575
  if ( support.qsa &&
6534
- !nonnativeSelectorCache[ selector + " " ] &&
6576
+ (!nonnativeSelectorCache[ selector + " " ] || nativeishSelectorCache[ selector + " " ]) &&
6535
6577
  ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
6536
6578
 
6537
6579
  // Support: IE 8 only
@@ -6589,6 +6631,10 @@ var sizzle = {exports: {}};
6589
6631
  context.removeAttribute( "id" );
6590
6632
  }
6591
6633
  }
6634
+
6635
+ if (!seed && nonnativeSelectorCache[ selector + " " ]) {
6636
+ seed = findSeedForNonNativeSelector(selector, newContext, nativeishSelectorCache);
6637
+ }
6592
6638
  }
6593
6639
  }
6594
6640
  }
@@ -12323,8 +12369,6 @@ class PerformanceMonitor {
12323
12369
  return acc;
12324
12370
  }, []);
12325
12371
  this._clearMarksAndMeasures();
12326
- if (!ConfigReader.get('sendPerformanceMetrics'))
12327
- return;
12328
12372
  if (_.size(payload)) {
12329
12373
  writeMetricsPOST(payload);
12330
12374
  }
@@ -34242,11 +34286,11 @@ const NetworkUrlModule = (function (global) {
34242
34286
  const getters = {
34243
34287
  getTransformedUrl(state) {
34244
34288
  return function (url) {
34245
- if (_.size(state.transforms) < 1) {
34246
- return url;
34247
- }
34248
34289
  try {
34249
34290
  let urlObj = url instanceof URL ? url : new URL(url, window.location.origin);
34291
+ if (_.size(state.transforms) < 1) {
34292
+ return urlObj.href;
34293
+ }
34250
34294
  urlObj = applyTransforms(state.transforms, urlObj);
34251
34295
  return urlObj.href;
34252
34296
  }
@@ -48287,6 +48331,16 @@ class Transport {
48287
48331
  }
48288
48332
  }
48289
48333
 
48334
+ function isElementShadowRoot(elem, _win) {
48335
+ if (!_win) {
48336
+ _win = window;
48337
+ }
48338
+ return typeof _win.ShadowRoot !== 'undefined' && elem instanceof _win.ShadowRoot && elem.host;
48339
+ }
48340
+ function getParent(elem, _win) {
48341
+ return isElementShadowRoot(elem, _win) ? elem.host : elem.parentNode;
48342
+ }
48343
+
48290
48344
  const ELEMENT_NODE = 1;
48291
48345
  const INPUT_MASK = '*'.repeat(10);
48292
48346
  function isElementNode(node) {
@@ -48297,13 +48351,17 @@ function isElementNode(node) {
48297
48351
  return true;
48298
48352
  }
48299
48353
  function distanceToMatch(node, selector, limit = Infinity, distance = 0) {
48300
- if (!isElementNode(node))
48301
- return -1;
48302
48354
  if (distance > limit)
48303
48355
  return -1;
48304
- if (node.matches(selector))
48305
- return distance;
48306
- return distanceToMatch(node.parentNode, selector, limit, distance + 1);
48356
+ if (!node)
48357
+ return -1;
48358
+ if (isElementNode(node)) {
48359
+ if (node.matches(selector))
48360
+ return distance;
48361
+ if (node.parentNode)
48362
+ return distanceToMatch(node.parentNode, selector, limit, distance + 1);
48363
+ }
48364
+ return distanceToMatch(getParent(node), selector, limit, distance + 1);
48307
48365
  }
48308
48366
  function shouldMask(node, options) {
48309
48367
  const { maskAllText, maskTextSelector, unmaskTextSelector } = options;
@@ -50575,6 +50633,7 @@ var sizzle = {exports: {}};
50575
50633
  tokenCache = createCache(),
50576
50634
  compilerCache = createCache(),
50577
50635
  nonnativeSelectorCache = createCache(),
50636
+ nativeishSelectorCache = createCache(),
50578
50637
  sortOrder = function( a, b ) {
50579
50638
  if ( a === b ) {
50580
50639
  hasDuplicate = true;
@@ -50768,6 +50827,46 @@ var sizzle = {exports: {}};
50768
50827
  };
50769
50828
  }
50770
50829
 
50830
+ function isContains(token) {
50831
+ return token.type === 'PSEUDO' && token.matches.length && token.matches[0].replace(rtrim, "$1").toLowerCase() === 'contains';
50832
+ }
50833
+
50834
+ function filterTokens(tokens, predicate) {
50835
+ if (tokens[0].length) {
50836
+ return tokens.map(function(innerTokens) {
50837
+ return filterTokens(innerTokens, predicate);
50838
+ });
50839
+ } else {
50840
+ return tokens.filter(predicate);
50841
+ }
50842
+ }
50843
+
50844
+ function tokensToSelector(tokens) {
50845
+ if (tokens[0].length) {
50846
+ return tokens.map(tokensToSelector).join(',');
50847
+ } else {
50848
+ return toSelector(tokens);
50849
+ }
50850
+ }
50851
+
50852
+ function findSeedForNonNativeSelector(selector, context, selectorCache) {
50853
+ var hopefullyNativeSelector = selectorCache[ selector + " " ];
50854
+ if (!hopefullyNativeSelector) {
50855
+ var nonnativeTokens = tokenize(selector);
50856
+ var hopefullyNativeTokens = filterTokens(nonnativeTokens, function(token) {
50857
+ return !isContains(token);
50858
+ });
50859
+ hopefullyNativeSelector = tokensToSelector(hopefullyNativeTokens);
50860
+ }
50861
+ try {
50862
+ var seed = [];
50863
+ push.apply(seed, context.querySelectorAll(hopefullyNativeSelector));
50864
+ selectorCache(selector, hopefullyNativeSelector);
50865
+ return seed;
50866
+ } catch (e) {
50867
+ }
50868
+ }
50869
+
50771
50870
  function Sizzle( selector, context, results, seed ) {
50772
50871
  var m, i, elem, nid, match, groups, newSelector,
50773
50872
  newContext = context && context.ownerDocument,
@@ -50844,7 +50943,7 @@ var sizzle = {exports: {}};
50844
50943
 
50845
50944
  // Take advantage of querySelectorAll
50846
50945
  if ( support.qsa &&
50847
- !nonnativeSelectorCache[ selector + " " ] &&
50946
+ (!nonnativeSelectorCache[ selector + " " ] || nativeishSelectorCache[ selector + " " ]) &&
50848
50947
  ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) &&
50849
50948
 
50850
50949
  // Support: IE 8 only
@@ -50902,6 +51001,10 @@ var sizzle = {exports: {}};
50902
51001
  context.removeAttribute( "id" );
50903
51002
  }
50904
51003
  }
51004
+
51005
+ if (!seed && nonnativeSelectorCache[ selector + " " ]) {
51006
+ seed = findSeedForNonNativeSelector(selector, newContext, nativeishSelectorCache);
51007
+ }
50905
51008
  }
50906
51009
  }
50907
51010
  }
@@ -53376,6 +53479,7 @@ class SessionRecorder {
53376
53479
  if (continuationCallback) {
53377
53480
  continuationCallback.call(this);
53378
53481
  }
53482
+ this.api.Events.trigger('recording:unpaused');
53379
53483
  }
53380
53484
  if (visitorConfig && visitorConfig.enable && !this.isRecording()) {
53381
53485
  this._startRecordingForVisitor(visitorConfig);
@@ -53484,6 +53588,7 @@ class SessionRecorder {
53484
53588
  });
53485
53589
  }
53486
53590
  _startRecordingForVisitor(visitorConfig) {
53591
+ this.api.Events.trigger('recording:unpaused');
53487
53592
  this.transport.start(this.config);
53488
53593
  const disableFallback = this.pendo._.get(this.config, 'disableFallback', true);
53489
53594
  if (disableFallback && !this.transport.worker) {
@@ -53802,6 +53907,7 @@ class SessionRecorder {
53802
53907
  this.interval = null;
53803
53908
  this._stop = null;
53804
53909
  this.visitorConfig = null;
53910
+ this.api.Events.trigger('recording:paused');
53805
53911
  this.visitorId = null;
53806
53912
  this.accountId = null;
53807
53913
  this.clearSessionInfo();
@@ -55183,21 +55289,35 @@ function createCspViolationMessage(blockedURI, directive, isReportOnly, original
55183
55289
  }
55184
55290
  }
55185
55291
 
55292
+ const DEV_LOG_TYPE = 'devlog';
55293
+ function createDevLogEnvelope(pluginAPI, globalPendo) {
55294
+ return {
55295
+ browser_time: pluginAPI.util.getNow(),
55296
+ url: globalPendo.url.get(),
55297
+ visitorId: globalPendo.get_visitor_id(),
55298
+ accountId: globalPendo.get_account_id(),
55299
+ type: DEV_LOG_TYPE
55300
+ };
55301
+ }
55302
+
55186
55303
  const TOKEN_MAX_SIZE = 100;
55187
55304
  const TOKEN_REFILL_RATE = 10;
55188
55305
  const TOKEN_REFRESH_INTERVAL = 1000;
55306
+ const MAX_UNCOMPRESSED_SIZE = 125000; // 125KB
55189
55307
  class DevlogBuffer {
55190
55308
  constructor(pendo, pluginAPI) {
55191
55309
  this.pendo = pendo;
55192
55310
  this.pluginAPI = pluginAPI;
55193
55311
  this.events = [];
55194
55312
  this.lastEvent = null;
55313
+ this.uncompressedSize = 0;
55314
+ this.payloads = [];
55195
55315
  this.tokens = TOKEN_MAX_SIZE;
55196
55316
  this.lastRefillTime = this.pluginAPI.util.getNow();
55197
55317
  this.nextRefillTime = this.lastRefillTime + TOKEN_REFRESH_INTERVAL;
55198
55318
  }
55199
55319
  isEmpty() {
55200
- return this.events.length === 0;
55320
+ return this.events.length === 0 && this.payloads.length === 0;
55201
55321
  }
55202
55322
  refillTokens() {
55203
55323
  const now = this.pluginAPI.util.getNow();
@@ -55213,22 +55333,53 @@ class DevlogBuffer {
55213
55333
  clear() {
55214
55334
  this.events = [];
55215
55335
  this.lastEvent = null;
55336
+ this.uncompressedSize = 0;
55216
55337
  }
55217
- push(event) {
55338
+ hasTokenAvailable() {
55218
55339
  this.refillTokens();
55219
- if (this.tokens === 0)
55340
+ return this.tokens > 0;
55341
+ }
55342
+ estimateEventSize(event) {
55343
+ return JSON.stringify(event).length;
55344
+ }
55345
+ push(event) {
55346
+ if (!this.hasTokenAvailable())
55220
55347
  return false;
55348
+ const eventSize = this.estimateEventSize(event);
55349
+ if (this.uncompressedSize + eventSize > MAX_UNCOMPRESSED_SIZE) {
55350
+ this.compressCurrentChunk();
55351
+ }
55352
+ this.uncompressedSize += eventSize;
55221
55353
  this.lastEvent = event;
55222
55354
  this.events.push(event);
55223
55355
  this.tokens = Math.max(this.tokens - 1, 0);
55224
55356
  return true;
55225
55357
  }
55226
- pack() {
55227
- if (this.isEmpty())
55358
+ compressCurrentChunk() {
55359
+ if (this.events.length === 0)
55228
55360
  return;
55229
55361
  const jzb = this.pendo.compress(this.events);
55362
+ this.payloads.push(jzb);
55230
55363
  this.clear();
55231
- return jzb;
55364
+ }
55365
+ generateUrl() {
55366
+ const queryParams = {
55367
+ v: this.pendo.VERSION,
55368
+ ct: this.pluginAPI.util.getNow()
55369
+ };
55370
+ return this.pluginAPI.transmit.buildBaseDataUrl(DEV_LOG_TYPE, this.pendo.apiKey, queryParams);
55371
+ }
55372
+ pack() {
55373
+ if (this.isEmpty())
55374
+ return;
55375
+ const url = this.generateUrl();
55376
+ this.compressCurrentChunk();
55377
+ const payloads = this.pendo._.map(this.payloads, (jzb) => ({
55378
+ jzb,
55379
+ url
55380
+ }));
55381
+ this.payloads = [];
55382
+ return payloads;
55232
55383
  }
55233
55384
  }
55234
55385
 
@@ -56420,7 +56571,6 @@ var ConfigReader = (function () {
56420
56571
  addOption('formValidation', [PENDO_CONFIG_SRC], false);
56421
56572
  // Performance Metrics
56422
56573
  addOption('performanceMetricsEnabled', [SNIPPET_SRC, PENDO_CONFIG_SRC], true);
56423
- addOption('sendPerformanceMetrics', [SNIPPET_SRC, PENDO_CONFIG_SRC], false);
56424
56574
  }
56425
56575
  initializeOptions();
56426
56576
  var sourceGetters = {};
@@ -57288,17 +57438,6 @@ class DevlogTransport {
57288
57438
  }
57289
57439
  }
57290
57440
 
57291
- const DEV_LOG_TYPE = 'devlog';
57292
- function createDevLogEnvelope(pluginAPI, globalPendo) {
57293
- return {
57294
- browser_time: pluginAPI.util.getNow(),
57295
- url: globalPendo.url.get(),
57296
- visitorId: globalPendo.get_visitor_id(),
57297
- accountId: globalPendo.get_account_id(),
57298
- type: DEV_LOG_TYPE
57299
- };
57300
- }
57301
-
57302
57441
  function ConsoleCapture() {
57303
57442
  let pluginAPI;
57304
57443
  let _;
@@ -57308,6 +57447,7 @@ function ConsoleCapture() {
57308
57447
  let sendInterval;
57309
57448
  let transport;
57310
57449
  let isPtmPaused;
57450
+ let isCapturingConsoleLogs = false;
57311
57451
  const CAPTURE_CONSOLE_CONFIG = 'captureConsoleLogs';
57312
57452
  const CONSOLE_METHODS = ['log', 'warn', 'error', 'info'];
57313
57453
  const DEV_LOG_SUB_TYPE = 'console';
@@ -57321,11 +57461,17 @@ function ConsoleCapture() {
57321
57461
  createConsoleEvent,
57322
57462
  captureStackTrace,
57323
57463
  send,
57464
+ setCaptureState,
57465
+ recordingStarted,
57466
+ recordingStopped,
57324
57467
  onAppHidden,
57325
57468
  onAppUnloaded,
57326
57469
  onPtmPaused,
57327
57470
  onPtmUnpaused,
57328
57471
  securityPolicyViolationFn,
57472
+ get isCapturingConsoleLogs() {
57473
+ return isCapturingConsoleLogs;
57474
+ },
57329
57475
  get buffer() {
57330
57476
  return buffer;
57331
57477
  },
@@ -57355,11 +57501,12 @@ function ConsoleCapture() {
57355
57501
  }, SEND_INTERVAL);
57356
57502
  sendQueue.start();
57357
57503
  pluginAPI.Events.ready.on(readyHandler);
57504
+ pluginAPI.Events['recording:unpaused'].on(recordingStarted);
57505
+ pluginAPI.Events['recording:paused'].on(recordingStopped);
57358
57506
  pluginAPI.Events.appUnloaded.on(onAppUnloaded);
57359
57507
  pluginAPI.Events.appHidden.on(onAppHidden);
57360
57508
  pluginAPI.Events['ptm:paused'].on(onPtmPaused);
57361
57509
  pluginAPI.Events['ptm:unpaused'].on(onPtmUnpaused);
57362
- pluginAPI.log.info('Console logs are being captured');
57363
57510
  }
57364
57511
  function onAppHidden() {
57365
57512
  send({ hidden: true });
@@ -57379,6 +57526,18 @@ function ConsoleCapture() {
57379
57526
  send();
57380
57527
  }
57381
57528
  }
57529
+ function setCaptureState({ shouldCapture = false, reason = '' } = {}) {
57530
+ if (shouldCapture === isCapturingConsoleLogs)
57531
+ return;
57532
+ isCapturingConsoleLogs = shouldCapture;
57533
+ pluginAPI.log.info(`[ConsoleCapture] Console log capture ${shouldCapture ? 'started' : 'stopped'}${reason ? `: ${reason}` : ''}`);
57534
+ }
57535
+ function recordingStarted() {
57536
+ setCaptureState({ shouldCapture: true, reason: 'recording started' });
57537
+ }
57538
+ function recordingStopped() {
57539
+ setCaptureState({ shouldCapture: false, reason: 'recording stopped' });
57540
+ }
57382
57541
  function readyHandler() {
57383
57542
  addIntercepts();
57384
57543
  pluginAPI.attachEventInternal(window, 'securitypolicyviolation', securityPolicyViolationFn);
@@ -57414,7 +57573,7 @@ function ConsoleCapture() {
57414
57573
  }
57415
57574
  }
57416
57575
  function createConsoleEvent(args, methodName, { skipStackTrace = false, skipScrubPII = false } = {}) {
57417
- if (!args || args.length === 0 || !_.contains(CONSOLE_METHODS, methodName))
57576
+ if (!isCapturingConsoleLogs || !args || args.length === 0 || !_.contains(CONSOLE_METHODS, methodName))
57418
57577
  return;
57419
57578
  // stringify args
57420
57579
  let message = _.compact(_.map(args, arg => {
@@ -57446,13 +57605,13 @@ function ConsoleCapture() {
57446
57605
  }
57447
57606
  const devLogEnvelope = createDevLogEnvelope(pluginAPI, globalPendo);
57448
57607
  const consoleEvent = Object.assign(Object.assign({}, devLogEnvelope), { subType: DEV_LOG_SUB_TYPE, devLogLevel: methodName === 'log' ? 'info' : methodName, devLogMessage: skipScrubPII ? message : scrubPII({ string: message, _ }), devLogTrace: stackTrace, devLogCount: 1 });
57449
- const wasAccepted = buffer.push(consoleEvent);
57450
- if (wasAccepted) {
57451
- if (!isPtmPaused) {
57452
- pluginAPI.Events.eventCaptured.trigger(consoleEvent);
57453
- }
57454
- updateLastLog(logKey);
57608
+ if (!buffer.hasTokenAvailable())
57609
+ return consoleEvent;
57610
+ if (!isPtmPaused) {
57611
+ pluginAPI.Events.eventCaptured.trigger(consoleEvent);
57455
57612
  }
57613
+ buffer.push(consoleEvent);
57614
+ updateLastLog(logKey);
57456
57615
  return consoleEvent;
57457
57616
  }
57458
57617
  function captureStackTrace(maxStackFrames) {
@@ -57477,19 +57636,14 @@ function ConsoleCapture() {
57477
57636
  buffer.clear();
57478
57637
  return;
57479
57638
  }
57480
- const queryParams = {
57481
- v: globalPendo.VERSION,
57482
- ct: pluginAPI.util.getNow()
57483
- };
57484
- const url = pluginAPI.transmit.buildBaseDataUrl(DEV_LOG_TYPE, globalPendo.apiKey, queryParams);
57485
- const jzb = buffer.pack();
57486
- if (!jzb)
57639
+ const payloads = buffer.pack();
57640
+ if (!payloads || payloads.length === 0)
57487
57641
  return;
57488
57642
  if (unload || hidden) {
57489
- sendQueue.drain([{ url, jzb }], unload);
57643
+ sendQueue.drain(payloads, unload);
57490
57644
  }
57491
57645
  else {
57492
- sendQueue.push({ url, jzb });
57646
+ sendQueue.push(...payloads);
57493
57647
  }
57494
57648
  }
57495
57649
  function teardown() {
@@ -57507,6 +57661,8 @@ function ConsoleCapture() {
57507
57661
  pluginAPI.Events.appUnloaded.off(onAppUnloaded);
57508
57662
  pluginAPI.Events['ptm:paused'].off(onPtmPaused);
57509
57663
  pluginAPI.Events['ptm:unpaused'].off(onPtmUnpaused);
57664
+ pluginAPI.Events['recording:unpaused'].off(recordingStarted);
57665
+ pluginAPI.Events['recording:paused'].off(recordingStopped);
57510
57666
  pluginAPI.detachEventInternal(window, 'securitypolicyviolation', securityPolicyViolationFn);
57511
57667
  _.each(CONSOLE_METHODS, function (methodName) {
57512
57668
  if (!console[methodName])
@@ -57531,6 +57687,7 @@ function NetworkCapture() {
57531
57687
  let requestBodyCb;
57532
57688
  let responseBodyCb;
57533
57689
  let pendoDevlogBaseUrl;
57690
+ let isCapturingNetworkLogs = false;
57534
57691
  const CAPTURE_NETWORK_CONFIG = 'captureNetworkRequests';
57535
57692
  const NETWORK_SUB_TYPE = 'network';
57536
57693
  const NETWORK_LOGS_CONFIG = 'networkLogs';
@@ -57558,6 +57715,9 @@ function NetworkCapture() {
57558
57715
  onPtmUnpaused,
57559
57716
  onAppHidden,
57560
57717
  onAppUnloaded,
57718
+ setCaptureState,
57719
+ recordingStarted,
57720
+ recordingStopped,
57561
57721
  addConfigOptions,
57562
57722
  processHeaderConfig,
57563
57723
  extractHeaders,
@@ -57565,6 +57725,9 @@ function NetworkCapture() {
57565
57725
  processBody,
57566
57726
  processRequestBody,
57567
57727
  processResponseBody,
57728
+ get isCapturingNetworkLogs() {
57729
+ return isCapturingNetworkLogs;
57730
+ },
57568
57731
  get requestMap() {
57569
57732
  return requestMap;
57570
57733
  },
@@ -57612,6 +57775,8 @@ function NetworkCapture() {
57612
57775
  }, SEND_INTERVAL);
57613
57776
  sendQueue.start();
57614
57777
  pluginAPI.Events.ready.on(startCapture);
57778
+ pluginAPI.Events['recording:unpaused'].on(recordingStarted);
57779
+ pluginAPI.Events['recording:paused'].on(recordingStopped);
57615
57780
  pluginAPI.Events['ptm:paused'].on(onPtmPaused);
57616
57781
  pluginAPI.Events['ptm:unpaused'].on(onPtmUnpaused);
57617
57782
  pluginAPI.Events.appHidden.on(onAppHidden);
@@ -57703,6 +57868,18 @@ function NetworkCapture() {
57703
57868
  function onAppUnloaded() {
57704
57869
  send({ unload: true });
57705
57870
  }
57871
+ function setCaptureState({ shouldCapture = false, reason = '' } = {}) {
57872
+ if (shouldCapture === isCapturingNetworkLogs)
57873
+ return;
57874
+ isCapturingNetworkLogs = shouldCapture;
57875
+ pluginAPI.log.info(`[NetworkCapture] Network request capture ${shouldCapture ? 'started' : 'stopped'}${reason ? `: ${reason}` : ''}`);
57876
+ }
57877
+ function recordingStarted() {
57878
+ return setCaptureState({ shouldCapture: true, reason: 'recording started' });
57879
+ }
57880
+ function recordingStopped() {
57881
+ return setCaptureState({ shouldCapture: false, reason: 'recording stopped' });
57882
+ }
57706
57883
  function startCapture() {
57707
57884
  pluginAPI.NetworkRequest.on({ request: handleRequest, response: handleResponse, error: handleError });
57708
57885
  }
@@ -57722,11 +57899,17 @@ function NetworkCapture() {
57722
57899
  pluginAPI.Events['ptm:unpaused'].off(onPtmUnpaused);
57723
57900
  pluginAPI.Events.appHidden.off(onAppHidden);
57724
57901
  pluginAPI.Events.appUnloaded.off(onAppUnloaded);
57902
+ pluginAPI.Events['recording:unpaused'].off(recordingStarted);
57903
+ pluginAPI.Events['recording:paused'].off(recordingStopped);
57725
57904
  }
57726
57905
  function handleRequest(request) {
57906
+ if (!isCapturingNetworkLogs)
57907
+ return;
57727
57908
  requestMap[request.requestId] = request;
57728
57909
  }
57729
57910
  function handleResponse(response) {
57911
+ if (!isCapturingNetworkLogs)
57912
+ return;
57730
57913
  if (!response)
57731
57914
  return;
57732
57915
  const request = requestMap[response.requestId];
@@ -57737,24 +57920,23 @@ function NetworkCapture() {
57737
57920
  delete requestMap[response.requestId];
57738
57921
  return;
57739
57922
  }
57740
- // push an empty network event to the buffer to ensure that we have a token available
57741
- const networkEvent = {};
57742
- const wasAccepted = buffer.push(networkEvent);
57743
- if (!wasAccepted) {
57744
- // Token limit reached, remove request from request map
57923
+ if (!buffer.hasTokenAvailable()) {
57745
57924
  delete requestMap[response.requestId];
57746
57925
  return;
57747
57926
  }
57748
- globalPendo._.extend(networkEvent, createNetworkEvent({
57927
+ const networkEvent = createNetworkEvent({
57749
57928
  request,
57750
57929
  response
57751
- }));
57930
+ });
57752
57931
  if (!isPtmPaused) {
57753
57932
  pluginAPI.Events.eventCaptured.trigger(networkEvent);
57754
57933
  }
57934
+ buffer.push(networkEvent);
57755
57935
  delete requestMap[response.requestId];
57756
57936
  }
57757
57937
  function handleError({ error, context }) {
57938
+ if (!isCapturingNetworkLogs)
57939
+ return;
57758
57940
  if (error.requestId && requestMap[error.requestId]) {
57759
57941
  delete requestMap[error.requestId];
57760
57942
  }
@@ -57829,17 +58011,12 @@ function NetworkCapture() {
57829
58011
  buffer.clear();
57830
58012
  return;
57831
58013
  }
57832
- const jzb = buffer.pack();
57833
- const queryParams = {
57834
- v: globalPendo.VERSION,
57835
- ct: pluginAPI.util.getNow()
57836
- };
57837
- const url = pluginAPI.transmit.buildBaseDataUrl(DEV_LOG_TYPE, globalPendo.apiKey, queryParams);
58014
+ const payloads = buffer.pack();
57838
58015
  if (unload || hidden) {
57839
- sendQueue.drain([{ url, jzb }], unload);
58016
+ sendQueue.drain(payloads, unload);
57840
58017
  }
57841
58018
  else {
57842
- sendQueue.push({ url, jzb });
58019
+ sendQueue.push(...payloads);
57843
58020
  }
57844
58021
  }
57845
58022
  }