@cloudcare/browser-rum 3.1.0 → 3.1.1

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.
Files changed (58) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/recorderApi.js +25 -21
  4. package/cjs/boot/recorderApi.js.map +1 -1
  5. package/cjs/boot/startRecording.js +5 -2
  6. package/cjs/boot/startRecording.js.map +1 -1
  7. package/cjs/domain/contexts/pageStateHistory.js +0 -1
  8. package/cjs/domain/contexts/pageStateHistory.js.map +1 -1
  9. package/cjs/domain/replay/deflate/deflateEncoder.js +82 -0
  10. package/cjs/domain/replay/deflate/deflateEncoder.js.map +1 -0
  11. package/cjs/domain/replay/deflate/deflateWorker.js +142 -0
  12. package/cjs/domain/replay/deflate/deflateWorker.js.map +1 -0
  13. package/cjs/domain/replay/deflate/index.js +44 -0
  14. package/cjs/domain/replay/deflate/index.js.map +1 -0
  15. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  16. package/cjs/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  17. package/cjs/domain/replay/segmentCollection/index.js +0 -7
  18. package/cjs/domain/replay/segmentCollection/index.js.map +1 -1
  19. package/cjs/domain/replay/segmentCollection/segment.js +19 -67
  20. package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
  21. package/cjs/domain/replay/segmentCollection/segmentCollection.js +36 -40
  22. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  23. package/esm/boot/buildEnv.js +1 -1
  24. package/esm/boot/recorderApi.js +27 -23
  25. package/esm/boot/recorderApi.js.map +1 -1
  26. package/esm/boot/startRecording.js +6 -3
  27. package/esm/boot/startRecording.js.map +1 -1
  28. package/esm/domain/contexts/pageStateHistory.js +0 -1
  29. package/esm/domain/contexts/pageStateHistory.js.map +1 -1
  30. package/esm/domain/replay/deflate/deflateEncoder.js +74 -0
  31. package/esm/domain/replay/deflate/deflateEncoder.js.map +1 -0
  32. package/esm/domain/replay/deflate/deflateWorker.js +129 -0
  33. package/esm/domain/replay/deflate/deflateWorker.js.map +1 -0
  34. package/esm/domain/replay/deflate/index.js +3 -0
  35. package/esm/domain/replay/deflate/index.js.map +1 -0
  36. package/esm/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  37. package/esm/domain/replay/segmentCollection/buildReplayPayload.js.map +1 -1
  38. package/esm/domain/replay/segmentCollection/index.js +0 -1
  39. package/esm/domain/replay/segmentCollection/index.js.map +1 -1
  40. package/esm/domain/replay/segmentCollection/segment.js +20 -68
  41. package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
  42. package/esm/domain/replay/segmentCollection/segmentCollection.js +36 -40
  43. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  44. package/package.json +4 -4
  45. package/src/boot/recorderApi.js +43 -32
  46. package/src/boot/startRecording.js +7 -3
  47. package/src/domain/contexts/pageStateHistory.js +0 -1
  48. package/src/domain/replay/deflate/deflateEncoder.js +88 -0
  49. package/src/domain/replay/{segmentCollection/startDeflateWorker.js → deflate/deflateWorker.js} +55 -32
  50. package/src/domain/replay/deflate/index.js +7 -0
  51. package/src/domain/replay/segmentCollection/buildReplayPayload.js +1 -1
  52. package/src/domain/replay/segmentCollection/index.js +0 -1
  53. package/src/domain/replay/segmentCollection/segment.js +28 -83
  54. package/src/domain/replay/segmentCollection/segmentCollection.js +49 -55
  55. package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +0 -126
  56. package/cjs/domain/replay/segmentCollection/startDeflateWorker.js.map +0 -1
  57. package/esm/domain/replay/segmentCollection/startDeflateWorker.js +0 -117
  58. package/esm/domain/replay/segmentCollection/startDeflateWorker.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"buildReplayPayload.js","names":["_browserCore","require","_typeof","obj","Symbol","iterator","constructor","prototype","buildReplayPayload","data","metadata","rawSegmentBytesCount","formData","FormData","append","Blob","type","session","id","start","toFormEntries","key","value","toString","bytesCount","byteLength","input","onEntry","prefix","undefined","each","objectEntries","item","String"],"sources":["../../../../src/domain/replay/segmentCollection/buildReplayPayload.js"],"sourcesContent":["import { objectEntries, each } from '@cloudcare/browser-core'\n\nexport function buildReplayPayload(data, metadata, rawSegmentBytesCount) {\n var formData = new FormData()\n formData.append(\n 'segment',\n new Blob([data], {\n type: 'application/octet-stream'\n }),\n metadata.session.id + '-' + metadata.start\n )\n\n toFormEntries(metadata, function (key, value) {\n formData.append(key, value)\n })\n formData.append('raw_segment_size', rawSegmentBytesCount.toString())\n\n return { data: formData, bytesCount: data.byteLength }\n}\n\nexport function toFormEntries(input, onEntry, prefix) {\n if (prefix === undefined) {\n prefix = ''\n }\n each(objectEntries(input), function (item) {\n var value = item[1]\n var key = item[0]\n if (typeof value === 'object' && value !== null) {\n toFormEntries(value, onEntry, '' + prefix + key + '_')\n } else {\n onEntry('' + prefix + key, String(value))\n }\n })\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAA6D,SAAAC,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAEtD,SAASK,kBAAkBA,CAACC,IAAI,EAAEC,QAAQ,EAAEC,oBAAoB,EAAE;EACvE,IAAIC,QAAQ,GAAG,IAAIC,QAAQ,CAAC,CAAC;EAC7BD,QAAQ,CAACE,MAAM,CACb,SAAS,EACT,IAAIC,IAAI,CAAC,CAACN,IAAI,CAAC,EAAE;IACfO,IAAI,EAAE;EACR,CAAC,CAAC,EACFN,QAAQ,CAACO,OAAO,CAACC,EAAE,GAAG,GAAG,GAAGR,QAAQ,CAACS,KACvC,CAAC;EAEDC,aAAa,CAACV,QAAQ,EAAE,UAAUW,GAAG,EAAEC,KAAK,EAAE;IAC5CV,QAAQ,CAACE,MAAM,CAACO,GAAG,EAAEC,KAAK,CAAC;EAC7B,CAAC,CAAC;EACFV,QAAQ,CAACE,MAAM,CAAC,kBAAkB,EAAEH,oBAAoB,CAACY,QAAQ,CAAC,CAAC,CAAC;EAEpE,OAAO;IAAEd,IAAI,EAAEG,QAAQ;IAAEY,UAAU,EAAEf,IAAI,CAACgB;EAAW,CAAC;AACxD;AAEO,SAASL,aAAaA,CAACM,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE;EACpD,IAAIA,MAAM,KAAKC,SAAS,EAAE;IACxBD,MAAM,GAAG,EAAE;EACb;EACA,IAAAE,iBAAI,EAAC,IAAAC,0BAAa,EAACL,KAAK,CAAC,EAAE,UAAUM,IAAI,EAAE;IACzC,IAAIV,KAAK,GAAGU,IAAI,CAAC,CAAC,CAAC;IACnB,IAAIX,GAAG,GAAGW,IAAI,CAAC,CAAC,CAAC;IACjB,IAAI9B,OAAA,CAAOoB,KAAK,MAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAC/CF,aAAa,CAACE,KAAK,EAAEK,OAAO,EAAE,EAAE,GAAGC,MAAM,GAAGP,GAAG,GAAG,GAAG,CAAC;IACxD,CAAC,MAAM;MACLM,OAAO,CAAC,EAAE,GAAGC,MAAM,GAAGP,GAAG,EAAEY,MAAM,CAACX,KAAK,CAAC,CAAC;IAC3C;EACF,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"buildReplayPayload.js","names":["_browserCore","require","_typeof","obj","Symbol","iterator","constructor","prototype","buildReplayPayload","data","metadata","rawSegmentBytesCount","formData","FormData","append","Blob","type","session","id","start","toFormEntries","key","value","bytesCount","byteLength","input","onEntry","prefix","undefined","each","objectEntries","item","String"],"sources":["../../../../src/domain/replay/segmentCollection/buildReplayPayload.js"],"sourcesContent":["import { objectEntries, each } from '@cloudcare/browser-core'\n\nexport function buildReplayPayload(data, metadata, rawSegmentBytesCount) {\n var formData = new FormData()\n formData.append(\n 'segment',\n new Blob([data], {\n type: 'application/octet-stream'\n }),\n metadata.session.id + '-' + metadata.start\n )\n\n toFormEntries(metadata, function (key, value) {\n formData.append(key, value)\n })\n formData.append('raw_segment_size', rawSegmentBytesCount)\n\n return { data: formData, bytesCount: data.byteLength }\n}\n\nexport function toFormEntries(input, onEntry, prefix) {\n if (prefix === undefined) {\n prefix = ''\n }\n each(objectEntries(input), function (item) {\n var value = item[1]\n var key = item[0]\n if (typeof value === 'object' && value !== null) {\n toFormEntries(value, onEntry, '' + prefix + key + '_')\n } else {\n onEntry('' + prefix + key, String(value))\n }\n })\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAA6D,SAAAC,QAAAC,GAAA,sCAAAD,OAAA,wBAAAE,MAAA,uBAAAA,MAAA,CAAAC,QAAA,aAAAF,GAAA,kBAAAA,GAAA,gBAAAA,GAAA,WAAAA,GAAA,yBAAAC,MAAA,IAAAD,GAAA,CAAAG,WAAA,KAAAF,MAAA,IAAAD,GAAA,KAAAC,MAAA,CAAAG,SAAA,qBAAAJ,GAAA,KAAAD,OAAA,CAAAC,GAAA;AAEtD,SAASK,kBAAkBA,CAACC,IAAI,EAAEC,QAAQ,EAAEC,oBAAoB,EAAE;EACvE,IAAIC,QAAQ,GAAG,IAAIC,QAAQ,CAAC,CAAC;EAC7BD,QAAQ,CAACE,MAAM,CACb,SAAS,EACT,IAAIC,IAAI,CAAC,CAACN,IAAI,CAAC,EAAE;IACfO,IAAI,EAAE;EACR,CAAC,CAAC,EACFN,QAAQ,CAACO,OAAO,CAACC,EAAE,GAAG,GAAG,GAAGR,QAAQ,CAACS,KACvC,CAAC;EAEDC,aAAa,CAACV,QAAQ,EAAE,UAAUW,GAAG,EAAEC,KAAK,EAAE;IAC5CV,QAAQ,CAACE,MAAM,CAACO,GAAG,EAAEC,KAAK,CAAC;EAC7B,CAAC,CAAC;EACFV,QAAQ,CAACE,MAAM,CAAC,kBAAkB,EAAEH,oBAAoB,CAAC;EAEzD,OAAO;IAAEF,IAAI,EAAEG,QAAQ;IAAEW,UAAU,EAAEd,IAAI,CAACe;EAAW,CAAC;AACxD;AAEO,SAASJ,aAAaA,CAACK,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE;EACpD,IAAIA,MAAM,KAAKC,SAAS,EAAE;IACxBD,MAAM,GAAG,EAAE;EACb;EACA,IAAAE,iBAAI,EAAC,IAAAC,0BAAa,EAACL,KAAK,CAAC,EAAE,UAAUM,IAAI,EAAE;IACzC,IAAIT,KAAK,GAAGS,IAAI,CAAC,CAAC,CAAC;IACnB,IAAIV,GAAG,GAAGU,IAAI,CAAC,CAAC,CAAC;IACjB,IAAI7B,OAAA,CAAOoB,KAAK,MAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,EAAE;MAC/CF,aAAa,CAACE,KAAK,EAAEI,OAAO,EAAE,EAAE,GAAGC,MAAM,GAAGN,GAAG,GAAG,GAAG,CAAC;IACxD,CAAC,MAAM;MACLK,OAAO,CAAC,EAAE,GAAGC,MAAM,GAAGN,GAAG,EAAEW,MAAM,CAACV,KAAK,CAAC,CAAC;IAC3C;EACF,CAAC,CAAC;AACJ"}
@@ -15,12 +15,6 @@ Object.defineProperty(exports, "setSegmentBytesLimit", {
15
15
  return _segmentCollection.setSegmentBytesLimit;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "startDeflateWorker", {
19
- enumerable: true,
20
- get: function get() {
21
- return _startDeflateWorker.startDeflateWorker;
22
- }
23
- });
24
18
  Object.defineProperty(exports, "startSegmentCollection", {
25
19
  enumerable: true,
26
20
  get: function get() {
@@ -28,5 +22,4 @@ Object.defineProperty(exports, "startSegmentCollection", {
28
22
  }
29
23
  });
30
24
  var _segmentCollection = require("./segmentCollection");
31
- var _startDeflateWorker = require("./startDeflateWorker");
32
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_segmentCollection","require","_startDeflateWorker"],"sources":["../../../../src/domain/replay/segmentCollection/index.js"],"sourcesContent":["export {\n startSegmentCollection,\n setSegmentBytesLimit\n} from './segmentCollection'\nexport { startDeflateWorker } from './startDeflateWorker'\nexport { SEGMENT_BYTES_LIMIT } from './segmentCollection'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAIA,IAAAC,mBAAA,GAAAD,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_segmentCollection","require"],"sources":["../../../../src/domain/replay/segmentCollection/index.js"],"sourcesContent":["export {\n startSegmentCollection,\n setSegmentBytesLimit\n} from './segmentCollection'\nexport { SEGMENT_BYTES_LIMIT } from './segmentCollection'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA"}
@@ -10,88 +10,40 @@ var _types = require("../../../types");
10
10
  var replayStats = _interopRequireWildcard(require("../replayStats"));
11
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
- var STREAM_ID = 1;
14
- var nextId = 0;
15
- function Segment(worker, context, creationReason, initialRecord, onWrote, onFlushed) {
16
- this.worker = worker;
17
- this.pendingWriteCount = 0;
18
- this.id = nextId++;
13
+ function Segment(encoder, context, creationReason) {
14
+ this.encoder = encoder;
19
15
  var viewId = context.view.id;
20
16
  this.metadata = (0, _browserCore.assign)({
21
- start: initialRecord.timestamp,
22
- end: initialRecord.timestamp,
17
+ start: Infinity,
18
+ end: -Infinity,
23
19
  creation_reason: creationReason,
24
- records_count: 1,
25
- has_full_snapshot: initialRecord.type === _types.RecordType.FullSnapshot,
20
+ records_count: 0,
21
+ has_full_snapshot: false,
26
22
  index_in_view: replayStats.getSegmentsCount(viewId),
27
23
  source: 'browser'
28
24
  }, context);
29
25
  replayStats.addSegment(viewId);
30
- replayStats.addRecord(viewId);
31
- var rawBytesCount = 0;
32
- var compressedBytesCount = 0;
33
- var compressedData = [];
34
- var _this = this;
35
- var wokerListener = (0, _browserCore.addEventListener)(worker, 'message', function (params) {
36
- var data = params.data;
37
- if (data.type !== 'wrote') {
38
- return;
39
- }
40
- if (data.id === _this.id) {
41
- _this.pendingWriteCount -= 1;
42
- replayStats.addWroteData(viewId, data.additionalBytesCount);
43
- rawBytesCount += data.additionalBytesCount;
44
- compressedBytesCount += data.result.length;
45
- compressedData.push(data.result);
46
- if (_this.flushReason && _this.pendingWriteCount === 0) {
47
- compressedData.push(data.trailer);
48
- onFlushed((0, _browserCore.concatBuffers)(compressedData), rawBytesCount);
49
- removeMessageListener();
50
- } else {
51
- onWrote(compressedBytesCount);
52
- }
53
- } else if (data.id > _this.id) {
54
- // Messages should be received in the same order as they are sent, so if we receive a
55
- // message with an id superior to this Segment instance id, we know that another, more
56
- // recent Segment instance is being used.
57
- //
58
- // In theory, a "flush" response should have been received at this point, so the listener
59
- // should already have been removed. But if something goes wrong and we didn't receive a
60
- // "flush" response, remove the listener to avoid any leak, and send a monitor message to
61
- // help investigate the issue.
62
- removeMessageListener();
63
- }
64
- });
65
- var removeMessageListener = wokerListener.stop;
66
- // worker.addEventListener('message', listener)
67
-
68
- this.write('{"records":[' + JSON.stringify(initialRecord));
69
26
  }
70
- Segment.prototype.addRecord = function (record) {
27
+ Segment.prototype.addRecord = function (record, callback) {
71
28
  this.metadata.start = Math.min(this.metadata.start, record.timestamp);
72
29
  this.metadata.end = Math.max(this.metadata.end, record.timestamp);
73
30
  this.metadata.records_count += 1;
74
- replayStats.addRecord(this.metadata.view.id);
75
31
  if (!this.metadata.has_full_snapshot) {
76
32
  this.metadata.has_full_snapshot = record.type === _types.RecordType.FullSnapshot;
77
33
  }
78
- this.write(',' + JSON.stringify(record));
79
- };
80
- Segment.prototype.flush = function (reason) {
81
- this.write('],' + JSON.stringify(this.metadata).slice(1) + '\n');
82
- this.worker.postMessage({
83
- action: 'reset',
84
- streamId: STREAM_ID
85
- });
86
- this.flushReason = reason;
34
+ replayStats.addRecord(this.metadata.view.id);
35
+ var prefix = this.metadata.records_count === 1 ? '{"records":[' : ',';
36
+ this.encoder.write(prefix + JSON.stringify(record), callback);
87
37
  };
88
- Segment.prototype.write = function (data) {
89
- this.pendingWriteCount += 1;
90
- this.worker.postMessage({
91
- data: data,
92
- id: this.id,
93
- streamId: STREAM_ID,
94
- action: 'write'
38
+ Segment.prototype.flush = function (callback) {
39
+ if (this.metadata.records_count === 0) {
40
+ throw new Error('Empty segment flushed');
41
+ }
42
+ var _this = this;
43
+ this.encoder.write('],' + JSON.stringify(this.metadata).slice(1) + '\n', function () {
44
+ replayStats.addWroteData(_this.metadata.view.id, _this.encoder.getRawBytesCount());
45
+ callback(_this.metadata);
95
46
  });
47
+ this.encoder.reset();
96
48
  };
97
49
  //# sourceMappingURL=segment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"segment.js","names":["_browserCore","require","_types","replayStats","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","STREAM_ID","nextId","Segment","worker","context","creationReason","initialRecord","onWrote","onFlushed","pendingWriteCount","id","viewId","view","metadata","assign","start","timestamp","end","creation_reason","records_count","has_full_snapshot","type","RecordType","FullSnapshot","index_in_view","getSegmentsCount","source","addSegment","addRecord","rawBytesCount","compressedBytesCount","compressedData","_this","wokerListener","addEventListener","params","data","addWroteData","additionalBytesCount","result","length","push","flushReason","trailer","concatBuffers","removeMessageListener","stop","write","JSON","stringify","record","Math","min","max","flush","reason","slice","postMessage","action","streamId"],"sources":["../../../../src/domain/replay/segmentCollection/segment.js"],"sourcesContent":["import {\n assign,\n addEventListener,\n concatBuffers\n} from '@cloudcare/browser-core'\nimport { RecordType } from '../../../types'\nimport * as replayStats from '../replayStats'\nvar STREAM_ID = 1\nvar nextId = 0\nexport function Segment(\n worker,\n context,\n creationReason,\n initialRecord,\n onWrote,\n onFlushed\n) {\n this.worker = worker\n this.pendingWriteCount = 0\n this.id = nextId++\n var viewId = context.view.id\n\n this.metadata = assign(\n {\n start: initialRecord.timestamp,\n end: initialRecord.timestamp,\n creation_reason: creationReason,\n records_count: 1,\n has_full_snapshot: initialRecord.type === RecordType.FullSnapshot,\n index_in_view: replayStats.getSegmentsCount(viewId),\n source: 'browser'\n },\n context\n )\n replayStats.addSegment(viewId)\n replayStats.addRecord(viewId)\n var rawBytesCount = 0\n var compressedBytesCount = 0\n var compressedData = []\n var _this = this\n var wokerListener = addEventListener(worker, 'message', function (params) {\n var data = params.data\n if (data.type !== 'wrote') {\n return\n }\n\n if (data.id === _this.id) {\n _this.pendingWriteCount -= 1\n replayStats.addWroteData(viewId, data.additionalBytesCount)\n rawBytesCount += data.additionalBytesCount\n compressedBytesCount += data.result.length\n compressedData.push(data.result)\n if (_this.flushReason && _this.pendingWriteCount === 0) {\n compressedData.push(data.trailer)\n onFlushed(concatBuffers(compressedData), rawBytesCount)\n removeMessageListener()\n } else {\n onWrote(compressedBytesCount)\n }\n } else if (data.id > _this.id) {\n // Messages should be received in the same order as they are sent, so if we receive a\n // message with an id superior to this Segment instance id, we know that another, more\n // recent Segment instance is being used.\n //\n // In theory, a \"flush\" response should have been received at this point, so the listener\n // should already have been removed. But if something goes wrong and we didn't receive a\n // \"flush\" response, remove the listener to avoid any leak, and send a monitor message to\n // help investigate the issue.\n removeMessageListener()\n }\n })\n var removeMessageListener = wokerListener.stop\n // worker.addEventListener('message', listener)\n\n this.write('{\"records\":[' + JSON.stringify(initialRecord))\n}\nSegment.prototype.addRecord = function (record) {\n this.metadata.start = Math.min(this.metadata.start, record.timestamp)\n this.metadata.end = Math.max(this.metadata.end, record.timestamp)\n this.metadata.records_count += 1\n replayStats.addRecord(this.metadata.view.id)\n if (!this.metadata.has_full_snapshot) {\n this.metadata.has_full_snapshot = record.type === RecordType.FullSnapshot\n }\n this.write(',' + JSON.stringify(record))\n}\nSegment.prototype.flush = function (reason) {\n this.write('],' + JSON.stringify(this.metadata).slice(1) + '\\n')\n\n this.worker.postMessage({\n action: 'reset',\n streamId: STREAM_ID\n })\n this.flushReason = reason\n}\n\nSegment.prototype.write = function (data) {\n this.pendingWriteCount += 1\n this.worker.postMessage({\n data: data,\n id: this.id,\n streamId: STREAM_ID,\n action: 'write'\n })\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA6C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,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EAC1C,IAAI,CAACR,KAAK,CAAC,IAAI,GAAGC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACpC,QAAQ,CAAC,CAAC2C,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;EAEhE,IAAI,CAACrD,MAAM,CAACsD,WAAW,CAAC;IACtBC,MAAM,EAAE,OAAO;IACfC,QAAQ,EAAE3D;EACZ,CAAC,CAAC;EACF,IAAI,CAAC0C,WAAW,GAAGa,MAAM;AAC3B,CAAC;AAEDrD,OAAO,CAACP,SAAS,CAACoD,KAAK,GAAG,UAAUX,IAAI,EAAE;EACxC,IAAI,CAAC3B,iBAAiB,IAAI,CAAC;EAC3B,IAAI,CAACN,MAAM,CAACsD,WAAW,CAAC;IACtBrB,IAAI,EAAEA,IAAI;IACV1B,EAAE,EAAE,IAAI,CAACA,EAAE;IACXiD,QAAQ,EAAE3D,SAAS;IACnB0D,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"segment.js","names":["_browserCore","require","_types","replayStats","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Segment","encoder","context","creationReason","viewId","view","id","metadata","assign","start","Infinity","end","creation_reason","records_count","has_full_snapshot","index_in_view","getSegmentsCount","source","addSegment","addRecord","record","callback","Math","min","timestamp","max","type","RecordType","FullSnapshot","prefix","write","JSON","stringify","flush","Error","_this","slice","addWroteData","getRawBytesCount","reset"],"sources":["../../../../src/domain/replay/segmentCollection/segment.js"],"sourcesContent":["import { assign } from '@cloudcare/browser-core'\nimport { RecordType } from '../../../types'\nimport * as replayStats from '../replayStats'\n\nexport function Segment(encoder, context, creationReason) {\n this.encoder = encoder\n var viewId = context.view.id\n\n this.metadata = assign(\n {\n start: Infinity,\n end: -Infinity,\n creation_reason: creationReason,\n records_count: 0,\n has_full_snapshot: false,\n index_in_view: replayStats.getSegmentsCount(viewId),\n source: 'browser'\n },\n context\n )\n replayStats.addSegment(viewId)\n}\nSegment.prototype.addRecord = function (record, callback) {\n this.metadata.start = Math.min(this.metadata.start, record.timestamp)\n this.metadata.end = Math.max(this.metadata.end, record.timestamp)\n this.metadata.records_count += 1\n if (!this.metadata.has_full_snapshot) {\n this.metadata.has_full_snapshot = record.type === RecordType.FullSnapshot\n }\n replayStats.addRecord(this.metadata.view.id)\n const prefix = this.metadata.records_count === 1 ? '{\"records\":[' : ','\n this.encoder.write(prefix + JSON.stringify(record), callback)\n}\nSegment.prototype.flush = function (callback) {\n if (this.metadata.records_count === 0) {\n throw new Error('Empty segment flushed')\n }\n var _this = this\n this.encoder.write(\n '],' + JSON.stringify(this.metadata).slice(1) + '\\n',\n function () {\n replayStats.addWroteData(\n _this.metadata.view.id,\n _this.encoder.getRawBytesCount()\n )\n callback(_this.metadata)\n }\n )\n this.encoder.reset()\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,uBAAA,CAAAH,OAAA;AAA6C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,uCAAAA,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,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B,CAAC,CACjC,CAAC;IACDjB,QAAQ,CAACc,KAAK,CAAC5B,QAAQ,CAAC;EAC1B,CACF,CAAC;EACD,IAAI,CAACN,OAAO,CAACsC,KAAK,CAAC,CAAC;AACtB,CAAC"}
@@ -44,17 +44,17 @@ var SEGMENT_BYTES_LIMIT = 60000;
44
44
  // To help investigate session replays issues, each segment is created with a "creation reason",
45
45
  // indicating why the session has been created.
46
46
  exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT;
47
- function startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, httpRequest, worker) {
47
+ function startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, httpRequest, encoder) {
48
48
  return doStartSegmentCollection(lifeCycle, function () {
49
49
  return computeSegmentContext(configuration, sessionManager, viewContexts);
50
- }, httpRequest, worker);
50
+ }, httpRequest, encoder);
51
51
  }
52
52
  var SegmentCollectionStatus = {
53
53
  WaitingForInitialRecord: 0,
54
54
  SegmentPending: 1,
55
55
  Stopped: 2
56
56
  };
57
- function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, worker) {
57
+ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, encoder) {
58
58
  var state = {
59
59
  status: SegmentCollectionStatus.WaitingForInitialRecord,
60
60
  nextSegmentCreationReason: 'init'
@@ -69,7 +69,14 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
69
69
  var unsubscribePageExited = subscribePageExited.unsubscribe;
70
70
  function flushSegment(flushReason) {
71
71
  if (state.status === SegmentCollectionStatus.SegmentPending) {
72
- state.segment.flush(flushReason);
72
+ state.segment.flush(function (metadata) {
73
+ var payload = (0, _buildReplayPayload.buildReplayPayload)(encoder.getEncodedBytes(), metadata, encoder.getRawBytesCount());
74
+ if ((0, _browserCore.isPageExitReason)(flushReason)) {
75
+ httpRequest.sendOnExit(payload);
76
+ } else {
77
+ httpRequest.send(payload);
78
+ }
79
+ });
73
80
  (0, _browserCore.clearTimeout)(state.expirationTimeoutId);
74
81
  }
75
82
  if (flushReason !== 'stop') {
@@ -83,41 +90,32 @@ function doStartSegmentCollection(lifeCycle, getSegmentContext, httpRequest, wor
83
90
  };
84
91
  }
85
92
  }
86
- function createNewSegment(creationReason, initialRecord) {
87
- var context = getSegmentContext();
88
- if (!context) {
89
- return;
90
- }
91
- var segment = new _segment.Segment(worker, context, creationReason, initialRecord, function (compressedSegmentBytesCount) {
92
- if (!segment.flushReason && compressedSegmentBytesCount > SEGMENT_BYTES_LIMIT) {
93
- flushSegment('segment_bytes_limit');
94
- }
95
- }, function (data, rawSegmentBytesCount) {
96
- var payload = (0, _buildReplayPayload.buildReplayPayload)(data, segment.metadata, rawSegmentBytesCount);
97
- if ((0, _browserCore.isPageExitReason)(segment.flushReason)) {
98
- httpRequest.sendOnExit(payload);
99
- } else {
100
- httpRequest.send(payload);
101
- }
102
- });
103
- state = {
104
- status: SegmentCollectionStatus.SegmentPending,
105
- segment: segment,
106
- expirationTimeoutId: (0, _browserCore.setTimeout)(function () {
107
- flushSegment('segment_duration_limit');
108
- }, SEGMENT_DURATION_LIMIT)
109
- };
110
- }
111
93
  return {
112
94
  addRecord: function addRecord(record) {
113
- switch (state.status) {
114
- case SegmentCollectionStatus.WaitingForInitialRecord:
115
- createNewSegment(state.nextSegmentCreationReason, record);
116
- break;
117
- case SegmentCollectionStatus.SegmentPending:
118
- state.segment.addRecord(record);
119
- break;
95
+ if (state.status === SegmentCollectionStatus.Stopped) {
96
+ return;
97
+ }
98
+ if (state.status === SegmentCollectionStatus.WaitingForInitialRecord) {
99
+ var context = getSegmentContext();
100
+ if (!context) {
101
+ return;
102
+ }
103
+ state = {
104
+ status: SegmentCollectionStatus.SegmentPending,
105
+ segment: new _segment.Segment(encoder, context, state.nextSegmentCreationReason),
106
+ expirationTimeoutId: (0, _browserCore.setTimeout)(function () {
107
+ flushSegment('segment_duration_limit');
108
+ }, SEGMENT_DURATION_LIMIT)
109
+ };
120
110
  }
111
+ var segment = state.segment;
112
+ segment.addRecord(record, function () {
113
+ if (
114
+ // the written segment is still pending
115
+ state.status === SegmentCollectionStatus.SegmentPending && state.segment === segment && encoder.getEncodedBytesCount() > SEGMENT_BYTES_LIMIT) {
116
+ flushSegment('segment_bytes_limit');
117
+ }
118
+ });
121
119
  },
122
120
  stop: function stop() {
123
121
  flushSegment('stop');
@@ -151,10 +149,8 @@ function computeSegmentContext(configuration, sessionManager, viewContexts) {
151
149
  }
152
150
  };
153
151
  }
154
- function setSegmentBytesLimit(newSegmentBytesLimit) {
155
- if (newSegmentBytesLimit === undefined) {
156
- newSegmentBytesLimit = 60000;
157
- }
152
+ function setSegmentBytesLimit() {
153
+ var newSegmentBytesLimit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 60000;
158
154
  exports.SEGMENT_BYTES_LIMIT = SEGMENT_BYTES_LIMIT = newSegmentBytesLimit;
159
155
  }
160
156
  //# sourceMappingURL=segmentCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"segmentCollection.js","names":["_browserCore","require","_buildReplayPayload","_segment","SEGMENT_DURATION_LIMIT","ONE_SECOND","exports","SEGMENT_BYTES_LIMIT","startSegmentCollection","lifeCycle","configuration","sessionManager","viewContexts","httpRequest","worker","doStartSegmentCollection","computeSegmentContext","SegmentCollectionStatus","WaitingForInitialRecord","SegmentPending","Stopped","getSegmentContext","state","status","nextSegmentCreationReason","subscribeViewCreated","subscribe","LifeCycleEventType","VIEW_CREATED","flushSegment","unsubscribeViewCreated","unsubscribe","subscribePageExited","PAGE_EXITED","pageExitEvent","reason","unsubscribePageExited","flushReason","segment","flush","clearTimeout","expirationTimeoutId","createNewSegment","creationReason","initialRecord","context","Segment","compressedSegmentBytesCount","data","rawSegmentBytesCount","payload","buildReplayPayload","metadata","isPageExitReason","sendOnExit","send","setTimeout","addRecord","record","stop","session","findTrackedSession","viewContext","findView","undefined","sdk","name","sdkName","version","sdkVersion","env","service","app","id","applicationId","view","setSegmentBytesLimit","newSegmentBytesLimit"],"sources":["../../../../src/domain/replay/segmentCollection/segmentCollection.js"],"sourcesContent":["import {\n ONE_SECOND,\n LifeCycleEventType,\n isPageExitReason,\n setTimeout,\n clearTimeout\n} from '@cloudcare/browser-core'\nimport { buildReplayPayload } from './buildReplayPayload'\nimport { Segment } from './segment'\n\nexport var SEGMENT_DURATION_LIMIT = 30 * ONE_SECOND\n/**\n * beacon payload max queue size implementation is 64kb\n * ensure that we leave room for logs, rum and potential other users\n */\nexport var SEGMENT_BYTES_LIMIT = 60000\n\n// Segments are the main data structure for session replays. They contain context information used\n// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing\n// namings). They are stored without any processing from the intake, and fetched one after the\n// other while a session is being replayed. Their encoding (deflate) are carefully crafted to allow\n// concatenating multiple segments together. Segments have a size overhead (metadata), so our goal is to\n// build segments containing as many records as possible while complying with the various flush\n// strategies to guarantee a good replay quality.\n//\n// When the recording starts, a segment is initially created. The segment is flushed (finalized and\n// sent) based on various events (non-exhaustive list):\n//\n// * the page visibility change or becomes to unload\n// * the segment duration reaches a limit\n// * the encoded segment bytes count reaches a limit\n// * ...\n//\n// A segment cannot be created without its context. If the RUM session ends and no session id is\n// available when creating a new segment, records will be ignored, until the session is renewed and\n// a new session id is available.\n//\n// Empty segments (segments with no record) aren't useful and should be ignored.\n//\n// To help investigate session replays issues, each segment is created with a \"creation reason\",\n// indicating why the session has been created.\n\nexport function startSegmentCollection(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n httpRequest,\n worker\n) {\n return doStartSegmentCollection(\n lifeCycle,\n function () {\n return computeSegmentContext(configuration, sessionManager, viewContexts)\n },\n httpRequest,\n worker\n )\n}\n\nvar SegmentCollectionStatus = {\n WaitingForInitialRecord: 0,\n SegmentPending: 1,\n Stopped: 2\n}\n\nexport function doStartSegmentCollection(\n lifeCycle,\n getSegmentContext,\n httpRequest,\n worker\n) {\n var state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: 'init'\n }\n var subscribeViewCreated = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_CREATED,\n function () {\n flushSegment('view_change')\n }\n )\n var unsubscribeViewCreated = subscribeViewCreated.unsubscribe\n var subscribePageExited = lifeCycle.subscribe(\n LifeCycleEventType.PAGE_EXITED,\n function (pageExitEvent) {\n flushSegment(pageExitEvent.reason)\n }\n )\n var unsubscribePageExited = subscribePageExited.unsubscribe\n\n function flushSegment(flushReason) {\n if (state.status === SegmentCollectionStatus.SegmentPending) {\n state.segment.flush(flushReason)\n clearTimeout(state.expirationTimeoutId)\n }\n\n if (flushReason !== 'stop') {\n state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: flushReason\n }\n } else {\n state = {\n status: SegmentCollectionStatus.Stopped\n }\n }\n }\n\n function createNewSegment(creationReason, initialRecord) {\n var context = getSegmentContext()\n if (!context) {\n return\n }\n\n var segment = new Segment(\n worker,\n context,\n creationReason,\n initialRecord,\n function (compressedSegmentBytesCount) {\n if (\n !segment.flushReason &&\n compressedSegmentBytesCount > SEGMENT_BYTES_LIMIT\n ) {\n flushSegment('segment_bytes_limit')\n }\n },\n function (data, rawSegmentBytesCount) {\n var payload = buildReplayPayload(\n data,\n segment.metadata,\n rawSegmentBytesCount\n )\n if (isPageExitReason(segment.flushReason)) {\n httpRequest.sendOnExit(payload)\n } else {\n httpRequest.send(payload)\n }\n }\n )\n state = {\n status: SegmentCollectionStatus.SegmentPending,\n segment: segment,\n expirationTimeoutId: setTimeout(function () {\n flushSegment('segment_duration_limit')\n }, SEGMENT_DURATION_LIMIT)\n }\n }\n\n return {\n addRecord: function (record) {\n switch (state.status) {\n case SegmentCollectionStatus.WaitingForInitialRecord:\n createNewSegment(state.nextSegmentCreationReason, record)\n break\n\n case SegmentCollectionStatus.SegmentPending:\n state.segment.addRecord(record)\n break\n }\n },\n\n stop: function () {\n flushSegment('stop')\n unsubscribeViewCreated()\n unsubscribePageExited()\n }\n }\n}\n\nexport function computeSegmentContext(\n configuration,\n sessionManager,\n viewContexts\n) {\n var session = sessionManager.findTrackedSession()\n var viewContext = viewContexts.findView()\n if (!session || !viewContext) {\n return undefined\n }\n return {\n sdk: {\n name: configuration.sdkName,\n version: configuration.sdkVersion\n },\n env: configuration.env || '',\n service: viewContext.service || configuration.service || 'browser',\n version: viewContext.version || configuration.version || '',\n app: {\n id: configuration.applicationId\n },\n session: {\n id: session.id\n },\n view: {\n id: viewContext.id\n }\n }\n}\n\nexport function setSegmentBytesLimit(newSegmentBytesLimit) {\n if (newSegmentBytesLimit === undefined) {\n newSegmentBytesLimit = 60000\n }\n SEGMENT_BYTES_LIMIT = newSegmentBytesLimit\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEO,IAAIG,sBAAsB,GAAG,EAAE,GAAGC,uBAAU;AACnD;AACA;AACA;AACA;AAHAC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA;AAIO,IAAIG,mBAAmB,GAAG,KAAK;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAAD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAEO,SAASC,sBAAsBA,CACpCC,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,WAAW,EACXC,MAAM,EACN;EACA,OAAOC,wBAAwB,CAC7BN,SAAS,EACT,YAAY;IACV,OAAOO,qBAAqB,CAACN,aAAa,EAAEC,cAAc,EAAEC,YAAY,CAAC;EAC3E,CAAC,EACDC,WAAW,EACXC,MACF,CAAC;AACH;AAEA,IAAIG,uBAAuB,GAAG;EAC5BC,uBAAuB,EAAE,CAAC;EAC1BC,cAAc,EAAE,CAAC;EACjBC,OAAO,EAAE;AACX,CAAC;AAEM,SAASL,wBAAwBA,CACtC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EACdC,YAAY,EACZ;EACA,IAAIgD,OAAO,GAAGjD,cAAc,CAACkD,kBAAkB,CAAC,CAAC;EACjD,IAAIC,WAAW,GAAGlD,YAAY,CAACmD,QAAQ,CAAC,CAAC;EACzC,IAAI,CAACH,OAAO,IAAI,CAACE,WAAW,EAAE;IAC5B,OAAOE,SAAS;EAClB;EACA,OAAO;IACLC,GAAG,EAAE;MACHC,IAAI,EAAExD,aAAa,CAACyD,OAAO;MAC3BC,OAAO,EAAE1D,aAAa,CAAC2D;IACzB,CAAC;IACDC,GAAG,EAAE5D,aAAa,CAAC4D,GAAG,IAAI,EAAE;IAC5BC,OAAO,EAAET,WAAW,CAACS,OAAO,IAAI7D,aAAa,CAAC6D,OAAO,IAAI,SAAS;IAClEH,OAAO,EAAEN,WAAW,CAACM,OAAO,IAAI1D,aAAa,CAAC0D,OAAO,IAAI,EAAE;IAC3DI,GAAG,EAAE;MACHC,EAAE,EAAE/D,aAAa,CAACgE;IACpB,CAAC;IACDd,OAAO,EAAE;MACPa,EAAE,EAAEb,OAAO,CAACa;IACd,CAAC;IACDE,IAAI,EAAE;MACJF,EAAE,EAAEX,WAAW,CAACW;IAClB;EACF,CAAC;AACH;AAEO,SAASG,oBAAoBA,CAACC,oBAAoB,EAAE;EACzD,IAAIA,oBAAoB,KAAKb,SAAS,EAAE;IACtCa,oBAAoB,GAAG,KAAK;EAC9B;EACAvE,OAAA,CAAAC,mBAAA,GAAAA,mBAAmB,GAAGsE,oBAAoB;AAC5C"}
1
+ {"version":3,"file":"segmentCollection.js","names":["_browserCore","require","_buildReplayPayload","_segment","SEGMENT_DURATION_LIMIT","ONE_SECOND","exports","SEGMENT_BYTES_LIMIT","startSegmentCollection","lifeCycle","configuration","sessionManager","viewContexts","httpRequest","encoder","doStartSegmentCollection","computeSegmentContext","SegmentCollectionStatus","WaitingForInitialRecord","SegmentPending","Stopped","getSegmentContext","state","status","nextSegmentCreationReason","subscribeViewCreated","subscribe","LifeCycleEventType","VIEW_CREATED","flushSegment","unsubscribeViewCreated","unsubscribe","subscribePageExited","PAGE_EXITED","pageExitEvent","reason","unsubscribePageExited","flushReason","segment","flush","metadata","payload","buildReplayPayload","getEncodedBytes","getRawBytesCount","isPageExitReason","sendOnExit","send","clearTimeout","expirationTimeoutId","addRecord","record","context","Segment","setTimeout","getEncodedBytesCount","stop","session","findTrackedSession","viewContext","findView","undefined","sdk","name","sdkName","version","sdkVersion","env","service","app","id","applicationId","view","setSegmentBytesLimit","newSegmentBytesLimit","arguments","length"],"sources":["../../../../src/domain/replay/segmentCollection/segmentCollection.js"],"sourcesContent":["import {\n ONE_SECOND,\n LifeCycleEventType,\n isPageExitReason,\n setTimeout,\n clearTimeout\n} from '@cloudcare/browser-core'\nimport { buildReplayPayload } from './buildReplayPayload'\nimport { Segment } from './segment'\n\nexport var SEGMENT_DURATION_LIMIT = 30 * ONE_SECOND\n/**\n * beacon payload max queue size implementation is 64kb\n * ensure that we leave room for logs, rum and potential other users\n */\nexport var SEGMENT_BYTES_LIMIT = 60000\n\n// Segments are the main data structure for session replays. They contain context information used\n// for indexing or UI needs, and a list of records (RRWeb 'events', renamed to avoid confusing\n// namings). They are stored without any processing from the intake, and fetched one after the\n// other while a session is being replayed. Their encoding (deflate) are carefully crafted to allow\n// concatenating multiple segments together. Segments have a size overhead (metadata), so our goal is to\n// build segments containing as many records as possible while complying with the various flush\n// strategies to guarantee a good replay quality.\n//\n// When the recording starts, a segment is initially created. The segment is flushed (finalized and\n// sent) based on various events (non-exhaustive list):\n//\n// * the page visibility change or becomes to unload\n// * the segment duration reaches a limit\n// * the encoded segment bytes count reaches a limit\n// * ...\n//\n// A segment cannot be created without its context. If the RUM session ends and no session id is\n// available when creating a new segment, records will be ignored, until the session is renewed and\n// a new session id is available.\n//\n// Empty segments (segments with no record) aren't useful and should be ignored.\n//\n// To help investigate session replays issues, each segment is created with a \"creation reason\",\n// indicating why the session has been created.\n\nexport function startSegmentCollection(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n httpRequest,\n encoder\n) {\n return doStartSegmentCollection(\n lifeCycle,\n function () {\n return computeSegmentContext(configuration, sessionManager, viewContexts)\n },\n httpRequest,\n encoder\n )\n}\n\nvar SegmentCollectionStatus = {\n WaitingForInitialRecord: 0,\n SegmentPending: 1,\n Stopped: 2\n}\n\nexport function doStartSegmentCollection(\n lifeCycle,\n getSegmentContext,\n httpRequest,\n encoder\n) {\n var state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: 'init'\n }\n var subscribeViewCreated = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_CREATED,\n function () {\n flushSegment('view_change')\n }\n )\n var unsubscribeViewCreated = subscribeViewCreated.unsubscribe\n var subscribePageExited = lifeCycle.subscribe(\n LifeCycleEventType.PAGE_EXITED,\n function (pageExitEvent) {\n flushSegment(pageExitEvent.reason)\n }\n )\n var unsubscribePageExited = subscribePageExited.unsubscribe\n\n function flushSegment(flushReason) {\n if (state.status === SegmentCollectionStatus.SegmentPending) {\n state.segment.flush(function (metadata) {\n var payload = buildReplayPayload(\n encoder.getEncodedBytes(),\n metadata,\n encoder.getRawBytesCount()\n )\n\n if (isPageExitReason(flushReason)) {\n httpRequest.sendOnExit(payload)\n } else {\n httpRequest.send(payload)\n }\n })\n clearTimeout(state.expirationTimeoutId)\n }\n\n if (flushReason !== 'stop') {\n state = {\n status: SegmentCollectionStatus.WaitingForInitialRecord,\n nextSegmentCreationReason: flushReason\n }\n } else {\n state = {\n status: SegmentCollectionStatus.Stopped\n }\n }\n }\n\n return {\n addRecord: function (record) {\n if (state.status === SegmentCollectionStatus.Stopped) {\n return\n }\n\n if (state.status === SegmentCollectionStatus.WaitingForInitialRecord) {\n var context = getSegmentContext()\n if (!context) {\n return\n }\n\n state = {\n status: SegmentCollectionStatus.SegmentPending,\n segment: new Segment(\n encoder,\n context,\n state.nextSegmentCreationReason\n ),\n expirationTimeoutId: setTimeout(function () {\n flushSegment('segment_duration_limit')\n }, SEGMENT_DURATION_LIMIT)\n }\n }\n\n var segment = state.segment\n\n segment.addRecord(record, function () {\n if (\n // the written segment is still pending\n state.status === SegmentCollectionStatus.SegmentPending &&\n state.segment === segment &&\n encoder.getEncodedBytesCount() > SEGMENT_BYTES_LIMIT\n ) {\n flushSegment('segment_bytes_limit')\n }\n })\n },\n\n stop: function () {\n flushSegment('stop')\n unsubscribeViewCreated()\n unsubscribePageExited()\n }\n }\n}\n\nexport function computeSegmentContext(\n configuration,\n sessionManager,\n viewContexts\n) {\n var session = sessionManager.findTrackedSession()\n var viewContext = viewContexts.findView()\n if (!session || !viewContext) {\n return undefined\n }\n return {\n sdk: {\n name: configuration.sdkName,\n version: configuration.sdkVersion\n },\n env: configuration.env || '',\n service: viewContext.service || configuration.service || 'browser',\n version: viewContext.version || configuration.version || '',\n app: {\n id: configuration.applicationId\n },\n session: {\n id: session.id\n },\n view: {\n id: viewContext.id\n }\n }\n}\n\nexport function setSegmentBytesLimit(newSegmentBytesLimit = 60_000) {\n SEGMENT_BYTES_LIMIT = newSegmentBytesLimit\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAOA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEO,IAAIG,sBAAsB,GAAG,EAAE,GAAGC,uBAAU;AACnD;AACA;AACA;AACA;AAHAC,OAAA,CAAAF,sBAAA,GAAAA,sBAAA;AAIO,IAAIG,mBAAmB,GAAG,KAAK;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAAD,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAEO,SAASC,sBAAsBA,CACpCC,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,WAAW,EACXC,OAAO,EACP;EACA,OAAOC,wBAAwB,CAC7BN,SAAS,EACT,YAAY;IACV,OA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Version: "3.1.0",
2
+ sdkVersion: "3.1.1",
3
3
  sdkName: 'df_web_rum_sdk'
4
4
  };
5
5
  //# sourceMappingURL=buildEnv.js.map
@@ -1,6 +1,6 @@
1
- import { noop, runOnReadyState, LifeCycleEventType, canUseEventBridge } from '@cloudcare/browser-core';
2
- import { getReplayStats } from '../domain/replay/replayStats';
3
- import { startDeflateWorker } from '../domain/replay/segmentCollection';
1
+ import { noop, runOnReadyState, LifeCycleEventType, canUseEventBridge, Observable, relativeNow } from '@cloudcare/browser-core';
2
+ import { getReplayStats as getReplayStatsImpl } from '../domain/replay/replayStats';
3
+ import { DeflateEncoderStreamId, createDeflateEncoder, startDeflateWorker, DeflateWorkerStatus, getDeflateWorkerStatus } from '../domain/replay/deflate';
4
4
  var RecorderStatus = {
5
5
  // The recorder is stopped.
6
6
  Stopped: 0,
@@ -12,10 +12,8 @@ var RecorderStatus = {
12
12
  // The recorder is started, it records the session.
13
13
  Started: 3
14
14
  };
15
- export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
16
- if (typeof startDeflateWorkerImpl === 'undefined') {
17
- startDeflateWorkerImpl = startDeflateWorker;
18
- }
15
+ export function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {
16
+ var recorderStartObservable = new Observable();
19
17
  if (canUseEventBridge() || !isBrowserSupported()) {
20
18
  return {
21
19
  start: noop,
@@ -26,7 +24,8 @@ export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
26
24
  onRumStart: noop,
27
25
  isRecording: function isRecording() {
28
26
  return false;
29
- }
27
+ },
28
+ recorderStartObservable: recorderStartObservable
30
29
  };
31
30
  }
32
31
  var state = {
@@ -49,7 +48,10 @@ export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
49
48
  stop: function stop() {
50
49
  stopStrategy();
51
50
  },
52
- getReplayStats: getReplayStats,
51
+ recorderStartObservable: recorderStartObservable,
52
+ getReplayStats: function getReplayStats(viewId) {
53
+ return getDeflateWorkerStatus() === DeflateWorkerStatus.Initialized ? getReplayStatsImpl(viewId) : undefined;
54
+ },
53
55
  onRumStart: function onRumStart(lifeCycle, configuration, sessionManager, viewContexts) {
54
56
  lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {
55
57
  if (state.status === RecorderStatus.Starting || state.status === RecorderStatus.Started) {
@@ -82,22 +84,24 @@ export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
82
84
  if (state.status !== RecorderStatus.Starting) {
83
85
  return;
84
86
  }
85
- startDeflateWorkerImpl(function (worker) {
86
- if (state.status !== RecorderStatus.Starting) {
87
- return;
88
- }
89
- if (!worker) {
90
- state = {
91
- status: RecorderStatus.Stopped
92
- };
93
- return;
94
- }
95
- var recordingImpl = startRecordingImpl(lifeCycle, configuration, sessionManager, viewContexts, worker);
87
+ if (state.status !== RecorderStatus.Starting) {
88
+ return;
89
+ }
90
+ var worker = startDeflateWorker(function () {
91
+ stopStrategy();
92
+ }, createDeflateWorkerImpl);
93
+ if (!worker) {
96
94
  state = {
97
- status: RecorderStatus.Started,
98
- stopRecording: recordingImpl.stop
95
+ status: RecorderStatus.Stopped
99
96
  };
100
- });
97
+ return;
98
+ }
99
+ var recordingImpl = startRecordingImpl(lifeCycle, configuration, sessionManager, viewContexts, createDeflateEncoder(worker, DeflateEncoderStreamId.REPLAY));
100
+ recorderStartObservable.notify(relativeNow());
101
+ state = {
102
+ status: RecorderStatus.Started,
103
+ stopRecording: recordingImpl.stop
104
+ };
101
105
  });
102
106
  };
103
107
  stopStrategy = function stopStrategy() {
@@ -1 +1 @@
1
- {"version":3,"file":"recorderApi.js","names":["noop","runOnReadyState","LifeCycleEventType","canUseEventBridge","getReplayStats","startDeflateWorker","RecorderStatus","Stopped","IntentToStart","Starting","Started","makeRecorderApi","startRecordingImpl","startDeflateWorkerImpl","isBrowserSupported","start","stop","undefined","onRumStart","isRecording","state","status","startStrategy","stopStrategy","lifeCycle","configuration","sessionManager","viewContexts","subscribe","SESSION_EXPIRED","SESSION_RENEWED","session","findTrackedSession","sessionReplayAllowed","worker","recordingImpl","stopRecording","Array","from","CSSSupportsRule","URL","createObjectURL","NodeList","prototype"],"sources":["../../src/boot/recorderApi.js"],"sourcesContent":["import {\n noop,\n runOnReadyState,\n LifeCycleEventType,\n canUseEventBridge\n} from '@cloudcare/browser-core'\n\nimport { getReplayStats } from '../domain/replay/replayStats'\nimport { startDeflateWorker } from '../domain/replay/segmentCollection'\n\nvar RecorderStatus = {\n // The recorder is stopped.\n Stopped: 0,\n // The user started the recording while it wasn't possible yet. The recorder should start as soon\n // as possible.\n IntentToStart: 1,\n // The recorder is starting. It does not record anything yet.\n Starting: 2,\n // The recorder is started, it records the session.\n Started: 3\n}\n\nexport function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {\n if (typeof startDeflateWorkerImpl === 'undefined') {\n startDeflateWorkerImpl = startDeflateWorker\n }\n if (canUseEventBridge() || !isBrowserSupported()) {\n return {\n start: noop,\n stop: noop,\n getReplayStats: function () {\n return undefined\n },\n onRumStart: noop,\n isRecording: function () {\n return false\n }\n }\n }\n\n var state = {\n status: RecorderStatus.Stopped\n }\n\n var startStrategy = function () {\n state = { status: RecorderStatus.IntentToStart }\n }\n var stopStrategy = function () {\n state = { status: RecorderStatus.Stopped }\n }\n return {\n start: function () {\n startStrategy()\n },\n stop: function () {\n stopStrategy()\n },\n getReplayStats: getReplayStats,\n\n onRumStart: function (\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts\n ) {\n lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {\n if (\n state.status === RecorderStatus.Starting ||\n state.status === RecorderStatus.Started\n ) {\n stopStrategy()\n state = { status: RecorderStatus.IntentToStart }\n }\n })\n\n lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {\n if (state.status === RecorderStatus.IntentToStart) {\n startStrategy()\n }\n })\n\n startStrategy = function () {\n var session = sessionManager.findTrackedSession()\n if (!session || !session.sessionReplayAllowed) {\n state = { status: RecorderStatus.IntentToStart }\n return\n }\n\n if (\n state.status === RecorderStatus.Starting ||\n state.status === RecorderStatus.Started\n ) {\n return\n }\n\n state = { status: RecorderStatus.Starting }\n\n runOnReadyState('interactive', function () {\n if (state.status !== RecorderStatus.Starting) {\n return\n }\n\n startDeflateWorkerImpl(function (worker) {\n if (state.status !== RecorderStatus.Starting) {\n return\n }\n\n if (!worker) {\n state = {\n status: RecorderStatus.Stopped\n }\n return\n }\n var recordingImpl = startRecordingImpl(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n worker\n )\n state = {\n status: RecorderStatus.Started,\n stopRecording: recordingImpl.stop\n }\n })\n })\n }\n\n stopStrategy = function () {\n if (state.status === RecorderStatus.Stopped) {\n return\n }\n\n if (state.status === RecorderStatus.Started) {\n state.stopRecording()\n }\n\n state = {\n status: RecorderStatus.Stopped\n }\n }\n\n if (state.status === RecorderStatus.IntentToStart) {\n startStrategy()\n }\n },\n\n isRecording: function () {\n return state.status === RecorderStatus.Started\n }\n }\n}\n\n/**\n * Test for Browser features used while recording\n */\nfunction isBrowserSupported() {\n return (\n // Array.from is a bit less supported by browsers than CSSSupportsRule, but has higher chances\n // to be polyfilled. Test for both to be more confident. We could add more things if we find out\n // this test is not sufficient.\n typeof Array.from === 'function' &&\n typeof CSSSupportsRule === 'function' &&\n typeof URL.createObjectURL === 'function' &&\n 'forEach' in NodeList.prototype\n )\n}\n"],"mappings":"AAAA,SACEA,IAAI,EACJC,eAAe,EACfC,kBAAkB,EAClBC,iBAAiB,QACZ,yBAAyB;AAEhC,SAASC,cAAc,QAAQ,8BAA8B;AAC7D,SAASC,kBAAkB,QAAQ,oCAAoC;AAEvE,IAAIC,cAAc,GAAG;EACnB;EACAC,OAAO,EAAE,CAAC;EACV;EACA;EACAC,aAAa,EAAE,CAAC;EAChB;EACAC,QAAQ,EAAE,CAAC;EACX;EACAC,OAAO,EAAE;AACX,CAAC;AAED,OAAO,SAASC,eAAeA,CAACC,kBAAkB,EAAEC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J,CAAC;MAEDO,YAAY,GAAG,SAAAA,aAAA,EAAY;QACzB,IAAIH,KAAK,CAACC,MAAM,KAAKf,cAAc,CAACC,OAAO,EAAE;UAC3C;QACF;QAEA,IAAIa,KAAK,CAACC,MAAM,KAAKf,cAAc,CAACI,OAAO,EAAE;UAC3CU,KAAK,CAACgB,aAAa,CAAC,CAAC;QACvB;QAEAhB,KAAK,GAAG;UACNC,MAAM,EAAEf,cAAc,CAACC;QACzB,CAAC;MACH,CAAC;MAED,IAAIa,KAAK,CAACC,MAAM,KAAKf,cAAc,CAACE,aAAa,EAAE;QACjDc,aAAa,CAAC,CAAC;MACjB;IACF,CAAC;IAEDH,WAAW,EAAE,SAAAA,YAAA,EAAY;MACvB,OAAOC,KAAK,CAACC,MAAM,KAAKf,cAAc,CAACI,OAAO;IAChD;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASI,kBAAkBA,CAAA,EAAG;EAC5B;IACE;IACA;IACA;IACA,OAAOuB,KAAK,CAACC,IAAI,KAAK,UAAU,IAChC,OAAOC,eAAe,KAAK,UAAU,IACrC,OAAOC,GAAG,CAACC,eAAe,KAAK,UAAU,IACzC,SAAS,IAAIC,QAAQ,CAACC;EAAS;AAEnC"}
1
+ {"version":3,"file":"recorderApi.js","names":["noop","runOnReadyState","LifeCycleEventType","canUseEventBridge","Observable","relativeNow","getReplayStats","getReplayStatsImpl","DeflateEncoderStreamId","createDeflateEncoder","startDeflateWorker","DeflateWorkerStatus","getDeflateWorkerStatus","RecorderStatus","Stopped","IntentToStart","Starting","Started","makeRecorderApi","startRecordingImpl","createDeflateWorkerImpl","recorderStartObservable","isBrowserSupported","start","stop","undefined","onRumStart","isRecording","state","status","startStrategy","stopStrategy","viewId","Initialized","lifeCycle","configuration","sessionManager","viewContexts","subscribe","SESSION_EXPIRED","SESSION_RENEWED","session","findTrackedSession","sessionReplayAllowed","worker","recordingImpl","REPLAY","notify","stopRecording","Array","from","CSSSupportsRule","URL","createObjectURL","NodeList","prototype"],"sources":["../../src/boot/recorderApi.js"],"sourcesContent":["import {\n noop,\n runOnReadyState,\n LifeCycleEventType,\n canUseEventBridge,\n Observable,\n relativeNow\n} from '@cloudcare/browser-core'\n\nimport { getReplayStats as getReplayStatsImpl } from '../domain/replay/replayStats'\nimport {\n DeflateEncoderStreamId,\n createDeflateEncoder,\n startDeflateWorker,\n DeflateWorkerStatus,\n getDeflateWorkerStatus\n} from '../domain/replay/deflate'\nvar RecorderStatus = {\n // The recorder is stopped.\n Stopped: 0,\n // The user started the recording while it wasn't possible yet. The recorder should start as soon\n // as possible.\n IntentToStart: 1,\n // The recorder is starting. It does not record anything yet.\n Starting: 2,\n // The recorder is started, it records the session.\n Started: 3\n}\n\nexport function makeRecorderApi(startRecordingImpl, createDeflateWorkerImpl) {\n var recorderStartObservable = new Observable()\n if (canUseEventBridge() || !isBrowserSupported()) {\n return {\n start: noop,\n stop: noop,\n getReplayStats: function () {\n return undefined\n },\n onRumStart: noop,\n isRecording: function () {\n return false\n },\n recorderStartObservable: recorderStartObservable\n }\n }\n\n var state = {\n status: RecorderStatus.Stopped\n }\n\n var startStrategy = function () {\n state = { status: RecorderStatus.IntentToStart }\n }\n var stopStrategy = function () {\n state = { status: RecorderStatus.Stopped }\n }\n return {\n start: function () {\n startStrategy()\n },\n stop: function () {\n stopStrategy()\n },\n recorderStartObservable: recorderStartObservable,\n getReplayStats: function (viewId) {\n return getDeflateWorkerStatus() === DeflateWorkerStatus.Initialized\n ? getReplayStatsImpl(viewId)\n : undefined\n },\n\n onRumStart: function (\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts\n ) {\n lifeCycle.subscribe(LifeCycleEventType.SESSION_EXPIRED, function () {\n if (\n state.status === RecorderStatus.Starting ||\n state.status === RecorderStatus.Started\n ) {\n stopStrategy()\n state = { status: RecorderStatus.IntentToStart }\n }\n })\n\n lifeCycle.subscribe(LifeCycleEventType.SESSION_RENEWED, function () {\n if (state.status === RecorderStatus.IntentToStart) {\n startStrategy()\n }\n })\n\n startStrategy = function () {\n var session = sessionManager.findTrackedSession()\n if (!session || !session.sessionReplayAllowed) {\n state = { status: RecorderStatus.IntentToStart }\n return\n }\n\n if (\n state.status === RecorderStatus.Starting ||\n state.status === RecorderStatus.Started\n ) {\n return\n }\n\n state = { status: RecorderStatus.Starting }\n\n runOnReadyState('interactive', function () {\n if (state.status !== RecorderStatus.Starting) {\n return\n }\n if (state.status !== RecorderStatus.Starting) {\n return\n }\n var worker = startDeflateWorker(function () {\n stopStrategy()\n }, createDeflateWorkerImpl)\n if (!worker) {\n state = {\n status: RecorderStatus.Stopped\n }\n return\n }\n var recordingImpl = startRecordingImpl(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n createDeflateEncoder(worker, DeflateEncoderStreamId.REPLAY)\n )\n recorderStartObservable.notify(relativeNow())\n state = {\n status: RecorderStatus.Started,\n stopRecording: recordingImpl.stop\n }\n })\n }\n\n stopStrategy = function () {\n if (state.status === RecorderStatus.Stopped) {\n return\n }\n\n if (state.status === RecorderStatus.Started) {\n state.stopRecording()\n }\n\n state = {\n status: RecorderStatus.Stopped\n }\n }\n\n if (state.status === RecorderStatus.IntentToStart) {\n startStrategy()\n }\n },\n\n isRecording: function () {\n return state.status === RecorderStatus.Started\n }\n }\n}\n\n/**\n * Test for Browser features used while recording\n */\nfunction isBrowserSupported() {\n return (\n // Array.from is a bit less supported by browsers than CSSSupportsRule, but has higher chances\n // to be polyfilled. Test for both to be more confident. We could add more things if we find out\n // this test is not sufficient.\n typeof Array.from === 'function' &&\n typeof CSSSupportsRule === 'function' &&\n typeof URL.createObjectURL === 'function' &&\n 'forEach' in NodeList.prototype\n )\n}\n"],"mappings":"AAAA,SACEA,IAAI,EACJC,eAAe,EACfC,kBAAkB,EAClBC,iBAAiB,EACjBC,UAAU,EACVC,WAAW,QACN,yBAAyB;AAEhC,SAASC,cAAc,IAAIC,kBAAkB,QAAQ,8BAA8B;AACnF,SACEC,sBAAsB,EACtBC,oBAAoB,EACpBC,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,OAAO2B,KAAK,CAACC,IAAI,KAAK,UAAU,IAChC,OAAOC,eAAe,KAAK,UAAU,IACrC,OAAOC,GAAG,CAACC,eAAe,KAAK,UAAU,IACzC,SAAS,IAAIC,QAAQ,CAACC;EAAS;AAEnC"}
@@ -1,15 +1,18 @@
1
- import { timeStampNow, createHttpRequest, LifeCycleEventType } from '@cloudcare/browser-core';
1
+ import { timeStampNow, createHttpRequest, LifeCycleEventType, addTelemetryDebug } from '@cloudcare/browser-core';
2
2
  import { record } from '../domain/replay/record';
3
3
  import { startSegmentCollection, SEGMENT_BYTES_LIMIT } from '../domain/replay/segmentCollection';
4
4
  import { RecordType } from '../types';
5
- export function startRecording(lifeCycle, configuration, sessionManager, viewContexts, worker, httpRequest) {
5
+ export function startRecording(lifeCycle, configuration, sessionManager, viewContexts, encoder, httpRequest) {
6
6
  var reportError = function reportError(error) {
7
7
  lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, {
8
8
  error: error
9
9
  });
10
+ addTelemetryDebug('Error reported to customer', {
11
+ 'error.message': error.message
12
+ });
10
13
  };
11
14
  var replayRequest = httpRequest || createHttpRequest(configuration.sessionReplayEndPoint, SEGMENT_BYTES_LIMIT, reportError);
12
- var segmentCollection = startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, replayRequest, worker);
15
+ var segmentCollection = startSegmentCollection(lifeCycle, configuration, sessionManager, viewContexts, replayRequest, encoder);
13
16
  var addRecord = segmentCollection.addRecord;
14
17
  var stopSegmentCollection = segmentCollection.stop;
15
18
  var _record = record({
@@ -1 +1 @@
1
- {"version":3,"file":"startRecording.js","names":["timeStampNow","createHttpRequest","LifeCycleEventType","record","startSegmentCollection","SEGMENT_BYTES_LIMIT","RecordType","startRecording","lifeCycle","configuration","sessionManager","viewContexts","worker","httpRequest","reportError","error","notify","RAW_ERROR_COLLECTED","replayRequest","sessionReplayEndPoint","segmentCollection","addRecord","stopSegmentCollection","stop","_record","emit","stopRecording","takeSubsequentFullSnapshot","flushMutations","subscribeViewEnded","subscribe","VIEW_ENDED","timestamp","type","ViewEnd","scribeViewCreated","VIEW_CREATED","view","startClocks","timeStamp","unsubscribe"],"sources":["../../src/boot/startRecording.js"],"sourcesContent":["import {\n timeStampNow,\n createHttpRequest,\n LifeCycleEventType\n} from '@cloudcare/browser-core'\nimport { record } from '../domain/replay/record'\nimport {\n startSegmentCollection,\n SEGMENT_BYTES_LIMIT\n} from '../domain/replay/segmentCollection'\nimport { RecordType } from '../types'\n\nexport function startRecording(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n worker,\n httpRequest\n) {\n var reportError = function (error) {\n lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })\n }\n\n var replayRequest =\n httpRequest ||\n createHttpRequest(\n configuration.sessionReplayEndPoint,\n SEGMENT_BYTES_LIMIT,\n reportError\n )\n\n var segmentCollection = startSegmentCollection(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n replayRequest,\n worker\n )\n var addRecord = segmentCollection.addRecord\n var stopSegmentCollection = segmentCollection.stop\n\n var _record = record({\n emit: addRecord,\n configuration: configuration,\n lifeCycle: lifeCycle\n })\n var stopRecording = _record.stop\n var takeSubsequentFullSnapshot = _record.takeSubsequentFullSnapshot\n var flushMutations = _record.flushMutations\n var subscribeViewEnded = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_ENDED,\n function () {\n flushMutations()\n addRecord({\n timestamp: timeStampNow(),\n type: RecordType.ViewEnd\n })\n }\n )\n var scribeViewCreated = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_CREATED,\n function (view) {\n takeSubsequentFullSnapshot(view.startClocks.timeStamp)\n }\n )\n\n return {\n stop: function () {\n subscribeViewEnded.unsubscribe()\n scribeViewCreated.unsubscribe()\n stopRecording()\n stopSegmentCollection()\n }\n }\n}\n"],"mappings":"AAAA,SACEA,YAAY,EACZC,iBAAiB,EACjBC,kBAAkB,QACb,yBAAyB;AAChC,SAASC,MAAM,QAAQ,yBA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B,SAAS,CAACsB,SAAS,CACzC5B,kBAAkB,CAACkC,YAAY,EAC/B,UAAUC,IAAI,EAAE;IACdV,0BAA0B,CAACU,IAAI,CAACC,WAAW,CAACC,SAAS,CAAC;EACxD,CACF,CAAC;EAED,OAAO;IACLhB,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBM,kBAAkB,CAACW,WAAW,CAAC,CAAC;MAChCL,iBAAiB,CAACK,WAAW,CAAC,CAAC;MAC/Bd,aAAa,CAAC,CAAC;MACfJ,qBAAqB,CAAC,CAAC;IACzB;EACF,CAAC;AACH"}
1
+ {"version":3,"file":"startRecording.js","names":["timeStampNow","createHttpRequest","LifeCycleEventType","addTelemetryDebug","record","startSegmentCollection","SEGMENT_BYTES_LIMIT","RecordType","startRecording","lifeCycle","configuration","sessionManager","viewContexts","encoder","httpRequest","reportError","error","notify","RAW_ERROR_COLLECTED","message","replayRequest","sessionReplayEndPoint","segmentCollection","addRecord","stopSegmentCollection","stop","_record","emit","stopRecording","takeSubsequentFullSnapshot","flushMutations","subscribeViewEnded","subscribe","VIEW_ENDED","timestamp","type","ViewEnd","scribeViewCreated","VIEW_CREATED","view","startClocks","timeStamp","unsubscribe"],"sources":["../../src/boot/startRecording.js"],"sourcesContent":["import {\n timeStampNow,\n createHttpRequest,\n LifeCycleEventType,\n addTelemetryDebug\n} from '@cloudcare/browser-core'\nimport { record } from '../domain/replay/record'\nimport {\n startSegmentCollection,\n SEGMENT_BYTES_LIMIT\n} from '../domain/replay/segmentCollection'\nimport { RecordType } from '../types'\n\nexport function startRecording(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n encoder,\n httpRequest\n) {\n var reportError = function (error) {\n lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { error: error })\n addTelemetryDebug('Error reported to customer', {\n 'error.message': error.message\n })\n }\n\n var replayRequest =\n httpRequest ||\n createHttpRequest(\n configuration.sessionReplayEndPoint,\n SEGMENT_BYTES_LIMIT,\n reportError\n )\n\n var segmentCollection = startSegmentCollection(\n lifeCycle,\n configuration,\n sessionManager,\n viewContexts,\n replayRequest,\n encoder\n )\n var addRecord = segmentCollection.addRecord\n var stopSegmentCollection = segmentCollection.stop\n\n var _record = record({\n emit: addRecord,\n configuration: configuration,\n lifeCycle: lifeCycle\n })\n var stopRecording = _record.stop\n var takeSubsequentFullSnapshot = _record.takeSubsequentFullSnapshot\n var flushMutations = _record.flushMutations\n var subscribeViewEnded = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_ENDED,\n function () {\n flushMutations()\n addRecord({\n timestamp: timeStampNow(),\n type: RecordType.ViewEnd\n })\n }\n )\n var scribeViewCreated = lifeCycle.subscribe(\n LifeCycleEventType.VIEW_CREATED,\n function (view) {\n takeSubsequentFullSnapshot(view.startClocks.timeStamp)\n }\n )\n\n return {\n stop: function () {\n subscribeViewEnded.unsubscribe()\n scribeViewCreated.unsubscribe()\n stopRecording()\n stopSegmentCollection()\n }\n }\n}\n"],"mappings":"AAAA,SACEA,YAAY,EACZC,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,QACZ,yBAAyB;AAChC,SAASC,MAAM,QAAQ,yBAAyB;AAChD,SACEC,sBAAsB,EACtBC,mBAAmB,QACd,oCAAoC;AAC3C,SAASC,UAAU,QAAQ,UAAU;AAErC,OAAO,SAASC,cAAcA,CAC5BC,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,OAAO,EACPC,WAAW,EACX;EACA,IAAIC,WAAW,GAAG,SAAdA,WAAWA,CAAaC,KAAK,EAAE;IACjCP,SAAS,CAACQ,MAAM,CAACf,kBAAkB,CAACgB,mBAAmB,EAAE;MAAEF,KAAK,EAAEA;IAAM,CAAC,CAAC;IAC1Eb,iBAAiB,CAAC,4BAA4B,EAAE;MAC9C,eAAe,EAAEa,KAAK,CAACG;IACzB,CAAC,CAAC;EACJ,CAAC;EAED,IAAIC,aAAa,GACfN,WAAW,IACXb,iBAAiB,CACfS,aAAa,CAACW,qBAAqB,EACnCf,mBAAmB,EACnBS,WACF,CAAC;EAEH,IAAIO,iBAAiB,GAAGjB,sBAAsB,CAC5CI,SAAS,EACTC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZQ,aAAa,EACbP,OACF,CAAC;EACD,IAAIU,SAAS,GAAGD,iBAAiB,CAACC,SAAS;EAC3C,IAAIC,qBAAqB,GAAGF,iBAAiB,CAACG,IAAI;EAElD,IAAIC,OAAO,GAAGtB,MAAM,CAAC;IACnBuB,IAAI,EAAEJ,SAAS;IACfb,aAAa,EAAEA,aAAa;IAC5BD,SAAS,EAAEA;EACb,CAAC,CAAC;EACF,IAAImB,aAAa,GAAGF,OAAO,CAACD,IAAI;EAChC,IAAII,0BAA0B,GAAGH,OAAO,CAACG,0BAA0B;EACnE,IAAIC,cAAc,GAAGJ,OAAO,CAACI,cAAc;EAC3C,IAAIC,kBAAkB,GAAGtB,SAAS,CAACuB,SAAS,CAC1C9B,kBAAkB,CAAC+B,UAAU,EAC7B,YAAY;IACVH,cAAc,CAAC,CAAC;IAChBP,SAAS,CAAC;MACRW,SAAS,EAAElC,YAAY,CAAC,CAAC;MACzBmC,IAAI,EAAE5B,UAAU,CAAC6B;IACnB,CAAC,CAAC;EACJ,CACF,CAAC;EACD,IAAIC,iBAAiB,GAAG5B,SAAS,CAACuB,SAAS,CACzC9B,kBAAkB,CAACoC,YAAY,EAC/B,UAAUC,IAAI,EAAE;IACdV,0BAA0B,CAACU,IAAI,CAACC,WAAW,CAACC,SAAS,CAAC;EACxD,CACF,CAAC;EAED,OAAO;IACLhB,IAAI,EAAE,SAAAA,KAAA,EAAY;MAChBM,kBAAkB,CAACW,WAAW,CAAC,CAAC;MAChCL,iBAAiB,CAACK,WAAW,CAAC,CAAC;MAC/Bd,aAAa,CAAC,CAAC;MACfJ,qBAAqB,CAAC,CAAC;IACzB;EACF,CAAC;AACH"}
@@ -21,7 +21,6 @@ export function startPageStateHistory(maxPageStateEntriesSelectable) {
21
21
  addPageState(getPageState(), relativeNow());
22
22
  var _addEventListeners = addEventListeners(window, [DOM_EVENT.PAGE_SHOW, DOM_EVENT.FOCUS, DOM_EVENT.BLUR, DOM_EVENT.VISIBILITY_CHANGE, DOM_EVENT.RESUME, DOM_EVENT.FREEZE, DOM_EVENT.PAGE_HIDE], function (event) {
23
23
  // Only get events fired by the browser to avoid false currentPageState changes done with custom events
24
- // cf: developer extension auto flush: https://github.com/DataDog/browser-sdk/blob/2f72bf05a672794c9e33965351964382a94c72ba/developer-extension/src/panel/flushEvents.ts#L11-L12
25
24
  if (event.isTrusted) {
26
25
  addPageState(computePageState(event), event.timeStamp);
27
26
  }