@webex/internal-plugin-metrics 3.12.0 → 3.13.0-next.2

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 (98) hide show
  1. package/.repo-context.json +466 -0
  2. package/.sdd/manifest.json +626 -0
  3. package/AGENTS.md +208 -0
  4. package/README.md +274 -0
  5. package/dist/automated-user.js +19 -0
  6. package/dist/automated-user.js.map +1 -0
  7. package/dist/batcher.js +3 -0
  8. package/dist/batcher.js.map +1 -1
  9. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js +639 -66
  10. package/dist/call-diagnostic/call-diagnostic-metrics-latencies.js.map +1 -1
  11. package/dist/call-diagnostic/call-diagnostic-metrics.js +240 -103
  12. package/dist/call-diagnostic/call-diagnostic-metrics.js.map +1 -1
  13. package/dist/call-diagnostic/call-diagnostic-metrics.util.js +7 -2
  14. package/dist/call-diagnostic/call-diagnostic-metrics.util.js.map +1 -1
  15. package/dist/call-diagnostic/config.js +19 -4
  16. package/dist/call-diagnostic/config.js.map +1 -1
  17. package/dist/config.js +8 -0
  18. package/dist/config.js.map +1 -1
  19. package/dist/index.js +25 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/metrics.js +118 -5
  22. package/dist/metrics.js.map +1 -1
  23. package/dist/metrics.types.js +4 -0
  24. package/dist/metrics.types.js.map +1 -1
  25. package/dist/network-telemetry.js +610 -0
  26. package/dist/network-telemetry.js.map +1 -0
  27. package/dist/new-metrics.js +63 -17
  28. package/dist/new-metrics.js.map +1 -1
  29. package/dist/privacy-and-security-permission-enricher/constants.js +18 -0
  30. package/dist/privacy-and-security-permission-enricher/constants.js.map +1 -0
  31. package/dist/privacy-and-security-permission-enricher/index.js +143 -0
  32. package/dist/privacy-and-security-permission-enricher/index.js.map +1 -0
  33. package/dist/privacy-and-security-permission-enricher/types.js +7 -0
  34. package/dist/privacy-and-security-permission-enricher/types.js.map +1 -0
  35. package/dist/privacy-and-security-permission-enricher/utils.js +71 -0
  36. package/dist/privacy-and-security-permission-enricher/utils.js.map +1 -0
  37. package/dist/types/automated-user.d.ts +2 -0
  38. package/dist/types/call-diagnostic/call-diagnostic-metrics-latencies.d.ts +208 -5
  39. package/dist/types/call-diagnostic/call-diagnostic-metrics.d.ts +83 -17
  40. package/dist/types/call-diagnostic/config.d.ts +6 -0
  41. package/dist/types/config.d.ts +9 -0
  42. package/dist/types/index.d.ts +5 -3
  43. package/dist/types/metrics.types.d.ts +11 -5
  44. package/dist/types/network-telemetry.d.ts +108 -0
  45. package/dist/types/new-metrics.d.ts +17 -1
  46. package/dist/types/privacy-and-security-permission-enricher/constants.d.ts +6 -0
  47. package/dist/types/privacy-and-security-permission-enricher/index.d.ts +40 -0
  48. package/dist/types/privacy-and-security-permission-enricher/types.d.ts +14 -0
  49. package/dist/types/privacy-and-security-permission-enricher/utils.d.ts +5 -0
  50. package/dist/types/unhandled-exception-telemetry/index.d.ts +60 -0
  51. package/dist/types/unhandled-exception-telemetry/utils.d.ts +6 -0
  52. package/dist/unhandled-exception-telemetry/index.js +331 -0
  53. package/dist/unhandled-exception-telemetry/index.js.map +1 -0
  54. package/dist/unhandled-exception-telemetry/utils.js +105 -0
  55. package/dist/unhandled-exception-telemetry/utils.js.map +1 -0
  56. package/docs/adr/index.md +27 -0
  57. package/docs/architecture.md +437 -0
  58. package/docs/getting-started.md +131 -0
  59. package/docs/index.md +52 -0
  60. package/docs/specs/README.md +88 -0
  61. package/package.json +12 -11
  62. package/schemas/repo-context.schema.json +796 -0
  63. package/src/automated-user.ts +16 -0
  64. package/src/batcher.js +4 -0
  65. package/src/call-diagnostic/call-diagnostic-metrics-latencies.ts +801 -74
  66. package/src/call-diagnostic/call-diagnostic-metrics.ts +184 -42
  67. package/src/call-diagnostic/call-diagnostic-metrics.util.ts +7 -1
  68. package/src/call-diagnostic/config.ts +16 -0
  69. package/src/call-diagnostic/docs/README.md +535 -0
  70. package/src/config.js +8 -0
  71. package/src/docs/README.md +703 -0
  72. package/src/index.ts +16 -0
  73. package/src/metrics.js +123 -5
  74. package/src/metrics.types.ts +29 -6
  75. package/src/network-telemetry.ts +757 -0
  76. package/src/new-metrics.ts +56 -6
  77. package/src/privacy-and-security-permission-enricher/constants.ts +33 -0
  78. package/src/privacy-and-security-permission-enricher/docs/README.md +356 -0
  79. package/src/privacy-and-security-permission-enricher/index.ts +142 -0
  80. package/src/privacy-and-security-permission-enricher/types.ts +21 -0
  81. package/src/privacy-and-security-permission-enricher/utils.ts +82 -0
  82. package/src/rtcMetrics/docs/README.md +447 -0
  83. package/src/unhandled-exception-telemetry/docs/README.md +536 -0
  84. package/src/unhandled-exception-telemetry/index.ts +404 -0
  85. package/src/unhandled-exception-telemetry/utils.ts +101 -0
  86. package/test/unit/spec/automated-user.ts +43 -0
  87. package/test/unit/spec/batcher.js +43 -0
  88. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-batcher.ts +14 -2
  89. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics-latencies.ts +1435 -304
  90. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.ts +1265 -207
  91. package/test/unit/spec/call-diagnostic/call-diagnostic-metrics.util.ts +27 -0
  92. package/test/unit/spec/metrics.js +14 -5
  93. package/test/unit/spec/network-telemetry.ts +610 -0
  94. package/test/unit/spec/new-metrics.ts +203 -50
  95. package/test/unit/spec/prelogin-metrics-batcher.ts +71 -36
  96. package/test/unit/spec/privacy-and-security-permission-enricher.ts +318 -0
  97. package/test/unit/spec/unhandled-exception-telemetry/utils.ts +109 -0
  98. package/test/unit/spec/unhandled-exception-telemetry.ts +689 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","_utils","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","PERMISSION_ENRICHMENT_RULES","exports","events","CAMERA_AND_MICROPHONE_PERMISSION_EVENTS","resolve","resources","terminal","MEDIA_TX_PERMISSION_EVENTS","payload","resolveMediaResources","CONTENT_SHARE_PERMISSION_EVENTS","resolveContentShareResources","FINAL_PERMISSION_EVENTS","resolvePermissionEnrichmentPolicy","name","_PERMISSION_ENRICHMEN","_PERMISSION_ENRICHMEN2","find","_ref","has","NO_PERMISSION_ENRICHMENT","PrivacyAndSecurityPermissionEnricher","onEnrichmentError","_classCallCheck2","_map","_createClass2","key","value","setPermission","permission","projectPrivacyAndSecurityPermission","enrich","_ref2","scope","policy","_this$lastReported$ge","privacyAndSecurityPermission","undefined","lastReported","set","get","projectedPermission","changedPermission","getChangedPermission","error","delete"],"sources":["index.ts"],"sourcesContent":["import type {ClientEventPayload, PrivacyAndSecurityPermission} from '../metrics.types';\nimport {\n CAMERA_AND_MICROPHONE_PERMISSION_EVENTS,\n CONTENT_SHARE_PERMISSION_EVENTS,\n FINAL_PERMISSION_EVENTS,\n MEDIA_TX_PERMISSION_EVENTS,\n NO_PERMISSION_ENRICHMENT,\n} from './constants';\nimport type {\n PermissionEnrichmentContext,\n PermissionEnrichmentPolicy,\n PermissionEnrichmentRule,\n} from './types';\nimport {\n getChangedPermission,\n projectPrivacyAndSecurityPermission,\n resolveContentShareResources,\n resolveMediaResources,\n} from './utils';\n\nexport const PERMISSION_ENRICHMENT_RULES = [\n {\n events: CAMERA_AND_MICROPHONE_PERMISSION_EVENTS,\n resolve: () => ({resources: ['camera', 'microphone'], terminal: false}),\n },\n {\n events: MEDIA_TX_PERMISSION_EVENTS,\n resolve: (payload) => ({resources: resolveMediaResources(payload), terminal: false}),\n },\n {\n events: CONTENT_SHARE_PERMISSION_EVENTS,\n resolve: (payload) => ({\n resources: resolveContentShareResources(payload),\n terminal: false,\n }),\n },\n {\n events: FINAL_PERMISSION_EVENTS,\n resolve: () => ({resources: ['camera', 'microphone', 'contentShare'], terminal: true}),\n },\n] satisfies readonly PermissionEnrichmentRule[];\n\nconst resolvePermissionEnrichmentPolicy = (\n name: PermissionEnrichmentContext['name'],\n payload?: ClientEventPayload\n): PermissionEnrichmentPolicy =>\n PERMISSION_ENRICHMENT_RULES.find(({events}) => events.has(name))?.resolve(payload) ??\n NO_PERMISSION_ENRICHMENT;\n\n/**\n * Enriches eligible client events with relevant browser permission changes.\n */\nexport default class PrivacyAndSecurityPermissionEnricher {\n private permission?: PrivacyAndSecurityPermission;\n\n private lastReported = new Map<string, PrivacyAndSecurityPermission>();\n\n private readonly onEnrichmentError: (error: unknown) => void;\n\n /**\n * Creates a permission enricher.\n * @param {Function} onEnrichmentError permission enrichment error handler\n */\n constructor(onEnrichmentError: (error: unknown) => void) {\n this.onEnrichmentError = onEnrichmentError;\n }\n\n /**\n * Stores the latest normalized browser permission state.\n * @param {PrivacyAndSecurityPermission} permission permission snapshot\n * @returns {void}\n */\n public setPermission(permission: PrivacyAndSecurityPermission): void {\n this.permission = projectPrivacyAndSecurityPermission(permission, [\n 'camera',\n 'microphone',\n 'contentShare',\n ]);\n }\n\n /**\n * Returns the original payload or a copy enriched with relevant permission changes.\n * @param {PermissionEnrichmentContext} context event context and permission history scope\n * @returns {ClientEventPayload | undefined}\n */\n public enrich({\n name,\n payload,\n scope,\n }: PermissionEnrichmentContext): ClientEventPayload | undefined {\n const policy = resolvePermissionEnrichmentPolicy(name, payload);\n\n try {\n if (payload?.privacyAndSecurityPermission !== undefined) {\n // An explicitly supplied permission payload is authoritative for this event.\n if (!policy.terminal) {\n this.lastReported.set(scope, {\n ...this.lastReported.get(scope),\n ...(payload.privacyAndSecurityPermission as PrivacyAndSecurityPermission),\n });\n }\n\n return payload;\n }\n\n if (policy.resources.length === 0) {\n return payload;\n }\n\n const projectedPermission = this.permission\n ? projectPrivacyAndSecurityPermission(this.permission, policy.resources)\n : undefined;\n\n if (!projectedPermission) {\n return payload;\n }\n\n if (policy.terminal) {\n return {...payload, privacyAndSecurityPermission: projectedPermission};\n }\n\n const lastReported = this.lastReported.get(scope) ?? {};\n const changedPermission = getChangedPermission(projectedPermission, lastReported);\n\n if (!changedPermission) {\n return payload;\n }\n\n this.lastReported.set(scope, {...lastReported, ...changedPermission});\n\n return {...payload, privacyAndSecurityPermission: changedPermission};\n } catch (error) {\n this.onEnrichmentError(error);\n\n return payload;\n } finally {\n if (policy.terminal) {\n this.lastReported.delete(scope);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAYA,IAAAC,MAAA,GAAAD,OAAA;AAKiB,SAAAE,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAG,CAAA,YAAAH,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAe,MAAA,CAAAZ,CAAA,OAAAa,OAAA,WAAAd,CAAA,QAAAe,gBAAA,CAAAC,OAAA,EAAAjB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAiB,iCAAA,GAAAC,wBAAA,CAAAnB,CAAA,EAAAkB,iCAAA,CAAAhB,CAAA,KAAAH,OAAA,CAAAe,MAAA,CAAAZ,CAAA,GAAAa,OAAA,WAAAd,CAAA,IAAAmB,sBAAA,CAAApB,CAAA,EAAAC,CAAA,EAAAM,gCAAA,CAAAL,CAAA,EAAAD,CAAA,iBAAAD,CAAA;AAEV,IAAMqB,2BA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ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
+ _Object$defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n ClientEvent,\n ClientEventPayload,\n PrivacyAndSecurityPermissionResource,\n} from '../metrics.types';\n\nexport type PermissionEnrichmentPolicy = {\n resources: readonly PrivacyAndSecurityPermissionResource[];\n terminal: boolean;\n};\n\nexport type PermissionEnrichmentRule = {\n events: ReadonlySet<ClientEvent['name']>;\n resolve: (payload?: ClientEventPayload) => PermissionEnrichmentPolicy;\n};\n\nexport type PermissionEnrichmentContext = {\n name: ClientEvent['name'];\n payload?: ClientEventPayload;\n scope: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
4
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
5
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
6
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
7
+ var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
8
+ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
9
+ var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
10
+ _Object$defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ exports.resolveMediaResources = exports.resolveContentShareResources = exports.projectPrivacyAndSecurityPermission = exports.getChangedPermission = void 0;
14
+ var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
16
+ var _lodash = require("lodash");
17
+ function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
19
+ var resolveMediaResources = exports.resolveMediaResources = function resolveMediaResources(payload) {
20
+ switch (payload === null || payload === void 0 ? void 0 : payload.mediaType) {
21
+ case 'audio':
22
+ return ['microphone'];
23
+ case 'video':
24
+ return ['camera'];
25
+ case 'share':
26
+ return ['contentShare'];
27
+ default:
28
+ return [];
29
+ }
30
+ };
31
+ var resolveContentShareResources = exports.resolveContentShareResources = function resolveContentShareResources(payload) {
32
+ if ((payload === null || payload === void 0 ? void 0 : payload.mediaType) !== 'share') {
33
+ return [];
34
+ }
35
+ return ['contentShare'];
36
+ };
37
+ var copyPermissionState = function copyPermissionState(source, target, resource) {
38
+ switch (resource) {
39
+ case 'camera':
40
+ if (source.camera) {
41
+ target.camera = _objectSpread({}, source.camera);
42
+ }
43
+ break;
44
+ case 'microphone':
45
+ if (source.microphone) {
46
+ target.microphone = _objectSpread({}, source.microphone);
47
+ }
48
+ break;
49
+ case 'contentShare':
50
+ if (source.contentShare) {
51
+ target.contentShare = _objectSpread({}, source.contentShare);
52
+ }
53
+ break;
54
+ default:
55
+ break;
56
+ }
57
+ };
58
+ var projectPrivacyAndSecurityPermission = exports.projectPrivacyAndSecurityPermission = function projectPrivacyAndSecurityPermission(permission, resources) {
59
+ var projectedPermission = {};
60
+ resources.forEach(function (resource) {
61
+ copyPermissionState(permission, projectedPermission, resource);
62
+ });
63
+ return (0, _keys.default)(projectedPermission).length > 0 ? projectedPermission : undefined;
64
+ };
65
+ var getChangedPermission = exports.getChangedPermission = function getChangedPermission(current, previous) {
66
+ var changedResources = (0, _keys.default)(current).filter(function (resource) {
67
+ return !(0, _lodash.isEqual)(current[resource], previous[resource]);
68
+ });
69
+ return projectPrivacyAndSecurityPermission(current, changedResources);
70
+ };
71
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_lodash","require","ownKeys","e","r","t","_Object$keys2","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","resolveMediaResources","exports","payload","mediaType","resolveContentShareResources","copyPermissionState","source","target","resource","camera","microphone","contentShare","projectPrivacyAndSecurityPermission","permission","resources","projectedPermission","_keys","undefined","getChangedPermission","current","previous","changedResources","isEqual"],"sources":["utils.ts"],"sourcesContent":["import {isEqual} from 'lodash';\n\nimport type {\n ClientEventPayload,\n PrivacyAndSecurityPermission,\n PrivacyAndSecurityPermissionResource,\n} from '../metrics.types';\n\nexport const resolveMediaResources = (\n payload?: ClientEventPayload\n): PrivacyAndSecurityPermissionResource[] => {\n switch (payload?.mediaType) {\n case 'audio':\n return ['microphone'];\n case 'video':\n return ['camera'];\n case 'share':\n return ['contentShare'];\n default:\n return [];\n }\n};\n\nexport const resolveContentShareResources = (\n payload?: ClientEventPayload\n): PrivacyAndSecurityPermissionResource[] => {\n if (payload?.mediaType !== 'share') {\n return [];\n }\n\n return ['contentShare'];\n};\n\nconst copyPermissionState = (\n source: PrivacyAndSecurityPermission,\n target: PrivacyAndSecurityPermission,\n resource: PrivacyAndSecurityPermissionResource\n): void => {\n switch (resource) {\n case 'camera':\n if (source.camera) {\n target.camera = {...source.camera};\n }\n break;\n case 'microphone':\n if (source.microphone) {\n target.microphone = {...source.microphone};\n }\n break;\n case 'contentShare':\n if (source.contentShare) {\n target.contentShare = {...source.contentShare};\n }\n break;\n default:\n break;\n }\n};\n\nexport const projectPrivacyAndSecurityPermission = (\n permission: PrivacyAndSecurityPermission,\n resources: readonly PrivacyAndSecurityPermissionResource[]\n): PrivacyAndSecurityPermission | undefined => {\n const projectedPermission: PrivacyAndSecurityPermission = {};\n\n resources.forEach((resource) => {\n copyPermissionState(permission, projectedPermission, resource);\n });\n\n return Object.keys(projectedPermission).length > 0 ? projectedPermission : undefined;\n};\n\nexport const getChangedPermission = (\n current: PrivacyAndSecurityPermission,\n previous: PrivacyAndSecurityPermission\n): PrivacyAndSecurityPermission | undefined => {\n const changedResources = (Object.keys(current) as PrivacyAndSecurityPermissionResource[]).filter(\n (resource) => !isEqual(current[resource], previous[resource])\n );\n\n return projectPrivacyAndSecurityPermission(current, changedResources);\n};\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAA+B,SAAAC,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,aAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAG,CAAA,YAAAH,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAe,MAAA,CAAAZ,CAAA,OAAAa,OAAA,WAAAd,CAAA,QA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,aAAA,KAAOgB,MAAM,CAACI,UAAU,CAAC;MAC5C;MACA;IACF,KAAK,cAAc;MACjB,IAAIJ,MAAM,CAACK,YAAY,EAAE;QACvBJ,MAAM,CAACI,YAAY,GAAArB,aAAA,KAAOgB,MAAM,CAACK,YAAY,CAAC;MAChD;MACA;IACF;MACE;EACJ;AACF,CAAC;AAEM,IAAMC,mCAAmC,GAAAX,OAAA,CAAAW,mCAAA,GAAG,SAAtCA,mCAAmCA,CAC9CC,UAAwC,EACxCC,SAA0D,EACb;EAC7C,IAAMC,mBAAiD,GAAG,CAAC,CAAC;EAE5DD,SAAS,CAACpB,OAAO,CAAC,UAACc,QAAQ,EAAK;IAC9BH,mBAAmB,CAACQ,UAAU,EAAEE,mBAAmB,EAAEP,QAAQ,CAAC;EAChE,CAAC,CAAC;EAEF,OAAO,IAAAQ,KAAA,CAAApB,OAAA,EAAYmB,mBAAmB,CAAC,CAACvB,MAAM,GAAG,CAAC,GAAGuB,mBAAmB,GAAGE,SAAS;AACtF,CAAC;AAEM,IAAMC,oBAAoB,GAAAjB,OAAA,CAAAiB,oBAAA,GAAG,SAAvBA,oBAAoBA,CAC/BC,OAAqC,EACrCC,QAAsC,EACO;EAC7C,IAAMC,gBAAgB,GAAI,IAAAL,KAAA,CAAApB,OAAA,EAAYuB,OAAO,CAAC,CAA4ClC,MAAM,CAC9F,UAACuB,QAAQ;IAAA,OAAK,CAAC,IAAAc,eAAO,EAACH,OAAO,CAACX,QAAQ,CAAC,EAAEY,QAAQ,CAACZ,QAAQ,CAAC,CAAC;EAAA,CAC/D,CAAC;EAED,OAAOI,mCAAmC,CAACO,OAAO,EAAEE,gBAAgB,CAAC;AACvE,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export declare const isAutomatedUserAgent: (userAgent?: string | null) => boolean;
2
+ export declare const isAutomatedUser: () => boolean;
@@ -1,5 +1,35 @@
1
1
  import { WebexPlugin } from '@webex/webex-core';
2
2
  import { MetricEventNames, PreComputedLatencies } from '../metrics.types';
3
+ type SaveTimestampOptions = {
4
+ meetingId?: string;
5
+ dataSetName?: string;
6
+ trackingId?: string;
7
+ };
8
+ type SaveLatencyOptions = {
9
+ accumulate?: boolean;
10
+ meetingId?: string;
11
+ dataSetName?: string;
12
+ };
13
+ type LocusSyncLatencyRecord = {
14
+ meetingId: string;
15
+ dataSetName: string;
16
+ randomBackoffTime: number;
17
+ trackingId?: string;
18
+ syncStart?: number;
19
+ hashTreeRequest?: number;
20
+ hashTreeResponse?: number;
21
+ syncRequest?: number;
22
+ syncResponse?: number;
23
+ messageReceived?: number;
24
+ };
25
+ /**
26
+ * Container for the latencies tracked for a single meeting. Locus sync is currently the only
27
+ * meeting-specific latency we track, but this wrapper lets us add other latency records in the
28
+ * future without changing the shape of `meetingLatencies`.
29
+ */
30
+ type MeetingLatencyRecord = {
31
+ locusSync: LocusSyncLatencyRecord;
32
+ };
3
33
  /**
4
34
  * @description Helper class to store latencies timestamp and to calculate various latencies for CA.
5
35
  * @exports
@@ -8,8 +38,12 @@ import { MetricEventNames, PreComputedLatencies } from '../metrics.types';
8
38
  export default class CallDiagnosticLatencies extends WebexPlugin {
9
39
  latencyTimestamps: Map<MetricEventNames, number>;
10
40
  precomputedLatencies: Map<PreComputedLatencies, number>;
41
+ meetingLatencies: Map<string, MeetingLatencyRecord[]>;
11
42
  private meetingId?;
12
43
  private MAX_INTEGER;
44
+ private LOCUS_SYNC_SKEW_THRESHOLD_MS;
45
+ private LOCUS_SYNC_PENDING_RECORD_TTL_MS;
46
+ private LOCUS_SYNC_MAX_RECORDS_PER_DATASET;
13
47
  /**
14
48
  * @constructor
15
49
  */
@@ -18,6 +52,164 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
18
52
  * Clear timestamps
19
53
  */
20
54
  clearTimestamps(): void;
55
+ /**
56
+ * Clear tracked Locus sync latency state for a dataset.
57
+ *
58
+ * When a `trackingId` is supplied only the single record matching it is dropped, mirroring the
59
+ * native client which discards the individual in-progress record on a sync error (by syncId).
60
+ * When no `trackingId` is supplied every record for the dataset is dropped (legacy behavior).
61
+ *
62
+ * @param dataSetName dataset name
63
+ * @param meetingId meeting id
64
+ * @param trackingId optional sync tracking id to drop a single record instead of the whole dataset
65
+ */
66
+ clearLocusSyncLatency(dataSetName: string, meetingId: string, trackingId?: string): void;
67
+ /**
68
+ * Calculates Locus sync latency values from stored milestone timestamps.
69
+ * @param meetingId meeting id
70
+ * @param trackingId sync tracking id used to match the record
71
+ * @returns sync latency metrics
72
+ */
73
+ getLocusSyncLatency(meetingId: string, trackingId: string): {
74
+ totalTime: number;
75
+ syncMessageReceiveTime?: number;
76
+ syncResponseTime?: number;
77
+ randomBackoffTime: number;
78
+ hashtreePrepTime: number;
79
+ hashtreeResponseTime: number;
80
+ syncPrepTime: number;
81
+ };
82
+ /**
83
+ * Records the time the LLM state-update message for a Locus sync arrived. This is the milestone
84
+ * that gates the client.locus.sync.complete metric: the metric is emitted only for flows where
85
+ * the update came over LLM (aligned with the agreed requirement that body/http-only syncs do not
86
+ * emit). The record is matched by meeting id + tracking id, regardless of which other milestones
87
+ * are present yet, so the real arrival time is captured even if the /sync response has not landed.
88
+ * @param meetingId meeting id
89
+ * @param trackingId sync tracking id used to match the pending record
90
+ * @returns void
91
+ */
92
+ recordLocusSyncMessageReceived(meetingId: string, trackingId: string): void;
93
+ /**
94
+ * Complete and remove the Locus sync latency record for a meeting + tracking id.
95
+ *
96
+ * Both milestones are required, in any arrival order: the metric is emitted only once BOTH the
97
+ * matching LLM broadcast (messageReceived) AND the /sync response have arrived. The LLM broadcast
98
+ * confirms the client that issued the /sync received the resulting state update for its tracking
99
+ * id (so sync cancel, or a sync storm where the final broadcast echoed another client's tracking
100
+ * id, never emit); the /sync response is always waited for too, since the LLM message can arrive
101
+ * before the HTTP response. If either milestone is missing the record is kept so the other can
102
+ * still arrive; it is only consumed when the metric is actually emitted.
103
+ * @param meetingId meeting id
104
+ * @param trackingId sync tracking id used to match the pending record
105
+ * @returns completed sync latency metric payload, or undefined when not completed
106
+ */
107
+ completeLocusSyncLatency(meetingId: string, trackingId: string): {
108
+ dataSet: string;
109
+ syncLatency: {
110
+ totalTime: number;
111
+ syncMessageReceiveTime?: number;
112
+ syncResponseTime?: number;
113
+ randomBackoffTime: number;
114
+ hashtreePrepTime: number;
115
+ hashtreeResponseTime: number;
116
+ syncPrepTime: number;
117
+ };
118
+ };
119
+ /**
120
+ * Helper to calculate end - start for Locus sync milestones.
121
+ * @param record tracked milestone timestamps
122
+ * @param a start milestone
123
+ * @param b end milestone
124
+ * @returns latency
125
+ */
126
+ private getDiffBetweenLocusSyncTimestamps;
127
+ /**
128
+ * Get the timestamp that starts the sync prep segment.
129
+ * @param record tracked milestone timestamps
130
+ * @returns sync prep start milestone
131
+ */
132
+ private getLocusSyncPrepStart;
133
+ /**
134
+ * Round and clamp Locus sync latency values.
135
+ * @param latency latency value
136
+ * @returns rounded latency
137
+ */
138
+ private getClampedLocusSyncLatency;
139
+ /**
140
+ * Finds a Locus sync latency record for a meeting using a predicate run against each stored
141
+ * locusSync record.
142
+ * @param meetingId meeting id
143
+ * @param predicate matcher run against each locusSync record
144
+ * @param options.searchFromLatest when true, iterate from the most recently added record first
145
+ * @returns matching Locus sync latency record
146
+ */
147
+ private findLocusSyncRecord;
148
+ /**
149
+ * Get the Locus sync latency record for a meeting and tracking id.
150
+ * @param meetingId meeting id
151
+ * @param trackingId /sync response tracking id
152
+ * @returns matching Locus sync latency record
153
+ */
154
+ private getLocusSyncLatencyRecord;
155
+ /**
156
+ * Remove the Locus sync latency record for a meeting and tracking id.
157
+ * @param meetingId meeting id
158
+ * @param trackingId sync tracking id used to match the record
159
+ * @returns void
160
+ */
161
+ private removeLocusSyncLatencyRecord;
162
+ /**
163
+ * Prune stale never-completed Locus sync latency records for the same dataset as the record that
164
+ * just changed. Records are dropped when they have been pending longer than the TTL, or to keep
165
+ * the number of records per dataset under the safety cap (oldest pending candidates first).
166
+ * @param records current records for the meeting
167
+ * @param changedRecord the record that was just updated, used as the reference point
168
+ * @returns the records to keep
169
+ */
170
+ private pruneStaleLocusSyncLatencyRecords;
171
+ /**
172
+ * Get the most recent milestone timestamp stored on a Locus sync latency record, checking
173
+ * milestones from latest to earliest so the newest available one is returned.
174
+ * @param record tracked milestone timestamps
175
+ * @returns latest milestone timestamp, or undefined when none are set
176
+ */
177
+ private getLatestLocusSyncTimestamp;
178
+ /**
179
+ * Persist the Locus sync latency records for a meeting, deleting the meeting entry when no
180
+ * records remain. When pruneOptions is provided, stale records are pruned before saving.
181
+ * @param meetingId meeting id
182
+ * @param records records to save
183
+ * @param pruneOptions when provided, triggers stale record pruning relative to changedRecord
184
+ * @returns void
185
+ */
186
+ private setMeetingLatencyRecords;
187
+ /**
188
+ * Get the latest Locus sync latency record waiting for sync.start.
189
+ * @param meetingId meeting id
190
+ * @param dataSetName dataset name
191
+ * @returns latest pending Locus sync latency record
192
+ */
193
+ private getLatestPendingLocusSyncLatencyRecord;
194
+ /**
195
+ * Store random backoff latency for the current or next Locus sync latency record.
196
+ * @param meetingId meeting id
197
+ * @param dataSetName dataset name
198
+ * @param randomBackoffTime random backoff latency value
199
+ * @returns void
200
+ */
201
+ private saveLocusSyncBackoffLatency;
202
+ /**
203
+ * Checks if metric event name is a Locus sync latency milestone.
204
+ * @param key event name
205
+ * @returns whether event is Locus sync latency milestone
206
+ */
207
+ private isLocusSyncLatencyEvent;
208
+ /**
209
+ * Stores a Locus sync latency milestone timestamp.
210
+ * @param options options
211
+ */
212
+ private saveLocusSyncLatencyTimestamp;
21
213
  /**
22
214
  * Associate current latencies with a meeting id
23
215
  * @param meetingId
@@ -39,19 +231,20 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
39
231
  saveTimestamp({ key, value, options, }: {
40
232
  key: MetricEventNames;
41
233
  value?: number;
42
- options?: {
43
- meetingId?: string;
44
- };
234
+ options?: SaveTimestampOptions;
45
235
  }): void;
46
236
  /**
47
237
  * Store precomputed latency value
48
238
  * @param key - key
49
239
  * @param value - value
50
- * @param accumulate - when it is true, it overwrites existing value with sum of the current value and the new measurement otherwise just store the new measurement
240
+ * @param options - store options (a legacy boolean `accumulate` flag is also accepted)
241
+ * @param options.accumulate - when it is true, it overwrites existing value with sum of the current value and the new measurement otherwise just store the new measurement
242
+ * @param options.meetingId - meeting id, only used for Locus sync latency records
243
+ * @param options.dataSetName - dataset name, only used for Locus sync latency records
51
244
  * @throws
52
245
  * @returns
53
246
  */
54
- saveLatency(key: PreComputedLatencies, value: number, accumulate?: boolean): void;
247
+ saveLatency(key: PreComputedLatencies, value: number, options?: SaveLatencyOptions): void;
55
248
  /**
56
249
  * Measure latency for a request
57
250
  * @param callback - callback for which you would like to measure latency
@@ -149,6 +342,15 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
149
342
  * @returns - latency
150
343
  */
151
344
  getStayLobbyTime(): number;
345
+ /**
346
+ * Stay lobby time capped by a certain timestamp.
347
+ * This is to handle the case where the target end timestamp could happen before the lobby is exited,
348
+ * for example media-engine.ready or client.ice.end
349
+ * This is supposed to be called AFTER the end timestamp happens
350
+ * @param endTimestampKey name of the target end event
351
+ * @returns - latency
352
+ */
353
+ getStayLobbyTimeCappedBy(endTimestampKey: MetricEventNames): number;
152
354
  /**
153
355
  * Page JMT
154
356
  * @returns - latency
@@ -258,3 +460,4 @@ export default class CallDiagnosticLatencies extends WebexPlugin {
258
460
  */
259
461
  getOtherAppApiReqResp(): number;
260
462
  }
463
+ export {};