@oneuptime/common 14.0.106 → 14.0.107

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 (236) hide show
  1. package/Models/AnalyticsModels/AuditLog.js +1 -1
  2. package/Models/AnalyticsModels/Index.js +3 -0
  3. package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.mts +5 -0
  4. package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.ts +5 -0
  5. package/Models/AnalyticsModels/RumProductAnalyticsEvent.js +300 -0
  6. package/Models/AnalyticsModels/RumProductAnalyticsEvent.mjs +3 -0
  7. package/Models/DatabaseModels/CallLog.d.mts +4 -0
  8. package/Models/DatabaseModels/CallLog.d.ts +4 -0
  9. package/Models/DatabaseModels/CallLog.js +85 -0
  10. package/Models/DatabaseModels/DataBiConnection.d.mts +3 -0
  11. package/Models/DatabaseModels/DataBiConnection.d.ts +3 -0
  12. package/Models/DatabaseModels/DataBiConnection.js +47 -1
  13. package/Models/DatabaseModels/DataDashboard.d.mts +10 -0
  14. package/Models/DatabaseModels/DataDashboard.d.ts +10 -0
  15. package/Models/DatabaseModels/DataDashboard.js +129 -2
  16. package/Models/DatabaseModels/Index.js +6 -0
  17. package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
  18. package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
  19. package/Models/DatabaseModels/NetworkDevice.js +55 -0
  20. package/Models/DatabaseModels/NetworkDeviceNamingRule.d.mts +26 -0
  21. package/Models/DatabaseModels/NetworkDeviceNamingRule.d.ts +26 -0
  22. package/Models/DatabaseModels/NetworkDeviceNamingRule.js +536 -0
  23. package/Models/DatabaseModels/NetworkDeviceNamingRule.mjs +2 -0
  24. package/Models/DatabaseModels/NetworkSite.d.mts +1 -0
  25. package/Models/DatabaseModels/NetworkSite.d.ts +1 -0
  26. package/Models/DatabaseModels/NetworkSite.js +51 -0
  27. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.mts +2 -0
  28. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.ts +2 -0
  29. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +41 -0
  30. package/Models/DatabaseModels/ProjectCallSMSConfig.d.mts +2 -0
  31. package/Models/DatabaseModels/ProjectCallSMSConfig.d.ts +2 -0
  32. package/Models/DatabaseModels/ProjectCallSMSConfig.js +80 -1
  33. package/Models/DatabaseModels/RumApplication.d.mts +2 -0
  34. package/Models/DatabaseModels/RumApplication.d.ts +2 -0
  35. package/Models/DatabaseModels/RumApplication.js +108 -0
  36. package/Models/DatabaseModels/Team.js +10 -2
  37. package/Models/DatabaseModels/TeamComplianceSetting.js +8 -1
  38. package/Models/DatabaseModels/TeamCustomRole.js +9 -1
  39. package/Models/DatabaseModels/TeamMember.js +15 -1
  40. package/Models/DatabaseModels/TeamOwnerTeam.d.mts +17 -0
  41. package/Models/DatabaseModels/TeamOwnerTeam.d.ts +17 -0
  42. package/Models/DatabaseModels/TeamOwnerTeam.js +325 -0
  43. package/Models/DatabaseModels/TeamOwnerTeam.mjs +2 -0
  44. package/Models/DatabaseModels/TeamOwnerUser.d.mts +17 -0
  45. package/Models/DatabaseModels/TeamOwnerUser.d.ts +17 -0
  46. package/Models/DatabaseModels/TeamOwnerUser.js +331 -0
  47. package/Models/DatabaseModels/TeamOwnerUser.mjs +2 -0
  48. package/Models/DatabaseModels/TeamPermission.js +12 -1
  49. package/Models/DatabaseModels/TelemetryUsageBilling.d.mts +1 -0
  50. package/Models/DatabaseModels/TelemetryUsageBilling.d.ts +1 -0
  51. package/Models/DatabaseModels/TelemetryUsageBilling.js +34 -0
  52. package/Types/AI/AIActionWords.d.mts +1 -0
  53. package/Types/AI/AIActionWords.d.ts +1 -0
  54. package/Types/AI/AIActionWords.js +15 -4
  55. package/Types/AI/AIChatRecordSeen.d.mts +3 -0
  56. package/Types/AI/AIChatRecordSeen.d.ts +3 -0
  57. package/Types/AI/AIChatRecordSeen.js +28 -3
  58. package/Types/AI/AIChatRecordSeen.mjs +1 -0
  59. package/Types/AnalyticsDatabase/AnalyticsTableName.d.mts +2 -1
  60. package/Types/AnalyticsDatabase/AnalyticsTableName.d.ts +2 -1
  61. package/Types/AnalyticsDatabase/AnalyticsTableName.js +7 -0
  62. package/Types/AuditLog/AuditLogRetention.d.mts +10 -0
  63. package/Types/AuditLog/AuditLogRetention.d.ts +10 -0
  64. package/Types/AuditLog/AuditLogRetention.js +91 -0
  65. package/Types/AuditLog/AuditLogRetention.mjs +8 -0
  66. package/Types/CallAndSMS/TwilioConfigDefaults.d.mts +37 -0
  67. package/Types/CallAndSMS/TwilioConfigDefaults.d.ts +37 -0
  68. package/Types/CallAndSMS/TwilioConfigDefaults.js +224 -0
  69. package/Types/CallAndSMS/TwilioConfigDefaults.mjs +3 -0
  70. package/Types/CodeRepository/CodeFileSeen.d.mts +3 -0
  71. package/Types/CodeRepository/CodeFileSeen.d.ts +3 -0
  72. package/Types/CodeRepository/CodeFileSeen.js +61 -3
  73. package/Types/DataObservability/DataDashboardActivity.d.mts +40 -0
  74. package/Types/DataObservability/DataDashboardActivity.d.ts +40 -0
  75. package/Types/DataObservability/DataDashboardActivity.js +119 -0
  76. package/Types/DataObservability/DataDashboardActivity.mjs +12 -0
  77. package/Types/DataObservability/DataObservabilityApiTypes.d.mts +7 -0
  78. package/Types/DataObservability/DataObservabilityApiTypes.d.ts +7 -0
  79. package/Types/DataObservability/DataObservabilityApiTypes.js +2 -0
  80. package/Types/DataObservability/DataTableLineage.d.mts +87 -0
  81. package/Types/DataObservability/DataTableLineage.d.ts +87 -0
  82. package/Types/DataObservability/DataTableLineage.js +111 -0
  83. package/Types/DataObservability/DataTableLineage.mjs +19 -0
  84. package/Types/DataSecurity/DataStoreKind.d.mts +1 -0
  85. package/Types/DataSecurity/DataStoreKind.d.ts +1 -0
  86. package/Types/DataSecurity/DataStoreKind.js +3 -0
  87. package/Types/Database/AccessControl/PermissionScopeNarrowing.js +6 -0
  88. package/Types/DatabaseServer/DatabaseServerMetricCatalog.js +71 -82
  89. package/Types/Date.d.mts +4 -0
  90. package/Types/Date.d.ts +4 -0
  91. package/Types/Date.js +47 -2
  92. package/Types/Date.mjs +2 -0
  93. package/Types/DateLanguage.d.mts +9 -0
  94. package/Types/DateLanguage.d.ts +9 -0
  95. package/Types/DateLanguage.js +79 -1
  96. package/Types/DateLanguage.mjs +4 -0
  97. package/Types/MessageQueue/MessageQueueMetricCatalog.js +61 -61
  98. package/Types/Monitor/CriteriaFilterTerms.d.mts +4 -0
  99. package/Types/Monitor/CriteriaFilterTerms.d.ts +4 -0
  100. package/Types/Monitor/CriteriaFilterTerms.js +166 -0
  101. package/Types/Monitor/CriteriaFilterTerms.mjs +4 -0
  102. package/Types/Monitor/EvaluationSentence.d.mts +37 -0
  103. package/Types/Monitor/EvaluationSentence.d.ts +37 -0
  104. package/Types/Monitor/EvaluationSentence.js +298 -0
  105. package/Types/Monitor/EvaluationSentence.mjs +12 -0
  106. package/Types/Monitor/MonitorCriteria.d.mts +2 -0
  107. package/Types/Monitor/MonitorCriteria.d.ts +2 -0
  108. package/Types/Monitor/MonitorCriteria.js +8 -0
  109. package/Types/Monitor/MonitorCriteriaInstance.d.mts +5 -0
  110. package/Types/Monitor/MonitorCriteriaInstance.d.ts +5 -0
  111. package/Types/Monitor/MonitorCriteriaInstance.js +243 -194
  112. package/Types/Monitor/MonitorEvaluationDetails.d.mts +2 -0
  113. package/Types/Monitor/MonitorEvaluationDetails.d.ts +2 -0
  114. package/Types/Monitor/MonitorEvaluationSummary.d.mts +4 -0
  115. package/Types/Monitor/MonitorEvaluationSummary.d.ts +4 -0
  116. package/Types/Monitor/MonitorStep.d.mts +2 -0
  117. package/Types/Monitor/MonitorStep.d.ts +2 -0
  118. package/Types/Monitor/MonitorSteps.d.mts +2 -0
  119. package/Types/Monitor/MonitorSteps.d.ts +2 -0
  120. package/Types/Monitor/MonitorType.d.mts +1 -0
  121. package/Types/Monitor/MonitorType.d.ts +1 -0
  122. package/Types/Monitor/MonitorType.js +12 -0
  123. package/Types/Monitor/TelemetryObservation.d.mts +15 -0
  124. package/Types/Monitor/TelemetryObservation.d.ts +15 -0
  125. package/Types/Monitor/TelemetryObservation.js +28 -0
  126. package/Types/Monitor/TelemetryObservation.mjs +2 -0
  127. package/Types/NetworkDevice/DeviceNaming.d.mts +87 -0
  128. package/Types/NetworkDevice/DeviceNaming.d.ts +87 -0
  129. package/Types/NetworkDevice/DeviceNaming.js +279 -0
  130. package/Types/NetworkDevice/DeviceNaming.mjs +24 -0
  131. package/Types/NetworkDevice/DiscoveredDevice.d.mts +1 -0
  132. package/Types/NetworkDevice/DiscoveredDevice.d.ts +1 -0
  133. package/Types/NetworkDevice/DiscoveredDevice.js +4 -0
  134. package/Types/OnCallDutyPolicy/OnCallPageChannel.d.mts +68 -0
  135. package/Types/OnCallDutyPolicy/OnCallPageChannel.d.ts +68 -0
  136. package/Types/OnCallDutyPolicy/OnCallPageChannel.js +351 -0
  137. package/Types/OnCallDutyPolicy/OnCallPageChannel.mjs +15 -0
  138. package/Types/Permission.d.mts +5 -0
  139. package/Types/Permission.d.ts +5 -0
  140. package/Types/Permission.js +61 -5
  141. package/Types/Rules/RuleCriteriaFieldRegistry.js +12 -0
  142. package/Types/Rules/RuleCriteriaSubject.js +1 -0
  143. package/Types/Rum/ProductAnalyticsEventReads.d.mts +115 -0
  144. package/Types/Rum/ProductAnalyticsEventReads.d.ts +115 -0
  145. package/Types/Rum/ProductAnalyticsEventReads.js +166 -0
  146. package/Types/Rum/ProductAnalyticsEventReads.mjs +27 -0
  147. package/Types/Rum/ProductAnalyticsEvents.d.mts +121 -0
  148. package/Types/Rum/ProductAnalyticsEvents.d.ts +121 -0
  149. package/Types/Rum/ProductAnalyticsEvents.js +477 -0
  150. package/Types/Rum/ProductAnalyticsEvents.mjs +40 -0
  151. package/Types/Rum/SessionReplay.d.mts +4 -0
  152. package/Types/Rum/SessionReplay.d.ts +4 -0
  153. package/Types/Rum/SessionReplayHealth.js +1 -1
  154. package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.mts +10 -0
  155. package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.ts +10 -0
  156. package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.js +51 -0
  157. package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.mjs +4 -0
  158. package/Types/Team/BuiltInTeam.d.mts +1 -0
  159. package/Types/Team/BuiltInTeam.d.ts +1 -0
  160. package/Types/Team/BuiltInTeam.js +14 -1
  161. package/Types/Team/BuiltInTeam.mjs +1 -0
  162. package/Types/Telemetry/TelemetryUsage.d.mts +7 -2
  163. package/Types/Telemetry/TelemetryUsage.d.ts +7 -2
  164. package/Types/Telemetry/TelemetryUsage.js +24 -5
  165. package/Types/Telemetry/TelemetryUsage.mjs +3 -0
  166. package/Types/UserNotification/UserNotificationStatus.d.mts +2 -1
  167. package/Types/UserNotification/UserNotificationStatus.d.ts +2 -1
  168. package/Types/UserNotification/UserNotificationStatus.js +8 -0
  169. package/Types/Workspace/NotificationRules/EventType.d.mts +2 -1
  170. package/Types/Workspace/NotificationRules/EventType.d.ts +2 -1
  171. package/Types/Workspace/NotificationRules/EventType.js +8 -0
  172. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +7 -1
  173. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +7 -1
  174. package/Types/Workspace/NotificationRules/NotificationRuleInvites.js +5 -1
  175. package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.mts +4 -0
  176. package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.ts +4 -0
  177. package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.js +2 -0
  178. package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.mjs +1 -0
  179. package/Utils/AI/InvestigationReport.js +93 -21
  180. package/Utils/AI/InvestigationReportLanguages.d.mts +25 -0
  181. package/Utils/AI/InvestigationReportLanguages.d.ts +25 -0
  182. package/Utils/AI/InvestigationReportLanguages.js +603 -0
  183. package/Utils/AI/InvestigationReportLanguages.mjs +11 -0
  184. package/Utils/Dashboard/TableThresholds.js +5 -2
  185. package/Utils/Monitor/MonitorLogSummaryUtil.d.mts +8 -0
  186. package/Utils/Monitor/MonitorLogSummaryUtil.d.ts +8 -0
  187. package/Utils/Monitor/MonitorLogSummaryUtil.js +170 -0
  188. package/Utils/Monitor/MonitorRootCauseWording.d.mts +17 -0
  189. package/Utils/Monitor/MonitorRootCauseWording.d.ts +17 -0
  190. package/Utils/Monitor/MonitorRootCauseWording.js +242 -0
  191. package/Utils/Monitor/MonitorRootCauseWording.mjs +2 -0
  192. package/Utils/Monitor/MonitorSummarySnapshotUtil.d.mts +3 -0
  193. package/Utils/Monitor/MonitorSummarySnapshotUtil.d.ts +3 -0
  194. package/Utils/Monitor/MonitorSummarySnapshotUtil.js +5 -2
  195. package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.mts +75 -0
  196. package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.ts +75 -0
  197. package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.js +303 -0
  198. package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.mjs +8 -0
  199. package/Utils/NetworkDevice/Naming/NamePattern.d.mts +122 -0
  200. package/Utils/NetworkDevice/Naming/NamePattern.d.ts +122 -0
  201. package/Utils/NetworkDevice/Naming/NamePattern.js +649 -0
  202. package/Utils/NetworkDevice/Naming/NamePattern.mjs +22 -0
  203. package/Utils/NetworkDevice/Naming/NamingLookup.d.mts +77 -0
  204. package/Utils/NetworkDevice/Naming/NamingLookup.d.ts +77 -0
  205. package/Utils/NetworkDevice/Naming/NamingLookup.js +467 -0
  206. package/Utils/NetworkDevice/Naming/NamingLookup.mjs +14 -0
  207. package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.mts +26 -0
  208. package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.ts +26 -0
  209. package/Utils/NetworkDevice/Naming/NamingRuleMatcher.js +327 -0
  210. package/Utils/NetworkDevice/Naming/NamingRuleMatcher.mjs +7 -0
  211. package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.mts +1 -0
  212. package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.ts +1 -0
  213. package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.js +8 -0
  214. package/Utils/NetworkDiscovery/PingMonitorBuilder.d.mts +2 -0
  215. package/Utils/NetworkDiscovery/PingMonitorBuilder.d.ts +2 -0
  216. package/Utils/NetworkDiscovery/PingMonitorBuilder.js +1 -0
  217. package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.mts +7 -6
  218. package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.ts +7 -6
  219. package/Utils/SessionReplay/SessionReplayHealth.js +703 -0
  220. package/Utils/Slo/SloErrorBudgetPolicy.d.mts +7 -0
  221. package/Utils/Slo/SloErrorBudgetPolicy.d.ts +7 -0
  222. package/Utils/Slo/SloErrorBudgetPolicy.js +39 -0
  223. package/Utils/Slo/SloErrorBudgetPolicy.mjs +1 -0
  224. package/Utils/Slo/SloFeedMarkdown.d.mts +19 -4
  225. package/Utils/Slo/SloFeedMarkdown.d.ts +19 -4
  226. package/Utils/Slo/SloFeedMarkdown.js +64 -17
  227. package/Utils/Slo/SloFeedMarkdown.mjs +4 -0
  228. package/Utils/StatusPage/ResourceExplorer.js +9 -8
  229. package/Utils/TotpSetupKey.d.mts +3 -0
  230. package/Utils/TotpSetupKey.d.ts +3 -0
  231. package/Utils/TotpSetupKey.js +72 -0
  232. package/Utils/TotpSetupKey.mjs +4 -0
  233. package/Utils/Workspace/WorkspaceChannelName.js +5 -1
  234. package/package.json +1 -1
  235. package/Utils/Rum/SessionReplayHealth.js +0 -558
  236. /package/Utils/{Rum → SessionReplay}/SessionReplayHealth.mjs +0 -0
@@ -0,0 +1,703 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SESSION_REPLAY_RECORDER_ACTIVE_WINDOW_MS = exports.SESSION_REPLAY_STALE_CHUNK_MS = exports.SESSION_REPLAY_REFUSAL_ALERT_THRESHOLD = void 0;
7
+ exports.formatRelativeAge = formatRelativeAge;
8
+ exports.formatDurationForCopy = formatDurationForCopy;
9
+ exports.formatCountForCopy = formatCountForCopy;
10
+ exports.formatBytesForCopy = formatBytesForCopy;
11
+ exports.parseHealthTimestamp = parseHealthTimestamp;
12
+ exports.parseRecordingHealthStatus = parseRecordingHealthStatus;
13
+ exports.getTopRefusal = getTopRefusal;
14
+ exports.describeRefusalReason = describeRefusalReason;
15
+ exports.diagnoseRecordingHealth = diagnoseRecordingHealth;
16
+ const SessionReplayHealth_1 = require("../../Types/Rum/SessionReplayHealth");
17
+ const SessionReplayCaptureTrigger_1 = __importDefault(require("../../Types/Rum/SessionReplayCaptureTrigger"));
18
+ const SessionReplayConsentMode_1 = __importDefault(require("../../Types/Rum/SessionReplayConsentMode"));
19
+ const SessionReplayApi_1 = require("../../Types/Rum/SessionReplayApi");
20
+ const Translator_1 = require("../../Types/Translator");
21
+ /*
22
+ * diagnoseRecordingHealth: one pure function that turns the ingest-status
23
+ * response into the single sentence the list page, the settings page and
24
+ * the setup guide all show.
25
+ *
26
+ * Pure and isomorphic (no Date.now(), no I/O, no DOM) so every state in
27
+ * the priority table is a unit test with a fixed clock. The copy rules it
28
+ * enforces are the product's, not decoration: name the cause, quantify
29
+ * it, offer ONE action, never render a counter that was not read as 0,
30
+ * and never say "disconnected" without saying why.
31
+ *
32
+ * It lives here rather than in Utils/Rum because it speaks the reader's
33
+ * language (Types/Translator). Utils/Rum and Types/Rum hold what the
34
+ * browser recorder inlines into the pages it is served on, and may import
35
+ * nothing outside those two folders (BrowserRecorder's SourceHygiene test);
36
+ * the recorder never draws a health sentence.
37
+ */
38
+ /*
39
+ * A refusal reason has to recur before it is reported as THE problem: a
40
+ * handful of origin-not-allowed refusals in a day is a developer's local
41
+ * build, hundreds is a misconfigured allowlist.
42
+ */
43
+ exports.SESSION_REPLAY_REFUSAL_ALERT_THRESHOLD = 5;
44
+ /*
45
+ * A recorder that keeps fetching its policy but has not delivered a chunk
46
+ * for this long is stuck, not quiet. 6h spans a working day's lull
47
+ * without flagging a site that simply has evening traffic.
48
+ */
49
+ exports.SESSION_REPLAY_STALE_CHUNK_MS = 6 * 60 * 60 * 1000;
50
+ /*
51
+ * "The recorder is loading on the site" means a policy fetch inside this
52
+ * window. Past it no recorder is running right now, which is why a silent
53
+ * application splits in two: a recorder that keeps fetching but delivers
54
+ * nothing is STUCK (state "stale"), while one that is not fetching either
55
+ * is simply not on any page being served - and the health copy says so
56
+ * rather than calling the second one healthy.
57
+ */
58
+ exports.SESSION_REPLAY_RECORDER_ACTIVE_WINDOW_MS = 24 * 60 * 60 * 1000;
59
+ const SECOND_MS = 1000;
60
+ const MINUTE_MS = 60 * SECOND_MS;
61
+ const HOUR_MS = 60 * MINUTE_MS;
62
+ const DAY_MS = 24 * HOUR_MS;
63
+ /*
64
+ * The words below are the reader's when the caller hands its Translator in
65
+ * (the Dashboard passes useTranslator()), and English, word for word as
66
+ * they always were, without one: what a unit test and the server get. Each
67
+ * is a key of the Dashboard's locales, read from this file by the
68
+ * extractor (SOURCE_ROOTS in scripts/i18n/ExtractStrings.ts), which reads
69
+ * only what the file marks: the text of a translate…() call, a
70
+ * translationKey(), and a count's two sentences marked as keys.
71
+ *
72
+ * Every sentence is looked up whole with its values in place: an age, a
73
+ * duration or a byte figure goes in as a composedValue, so it is written in
74
+ * the language the sentence is read in, and a refusal's label as a
75
+ * translatableTerm, translated along with the sentence.
76
+ */
77
+ const ENGLISH = (0, Translator_1.createTranslator)(undefined, Translator_1.DEFAULT_LANGUAGE);
78
+ // A fixed word, label or sentence in the translator's language.
79
+ function translateWord(text, translator) {
80
+ return translator.translateText(text) || text;
81
+ }
82
+ /*
83
+ * "12s ago", "5m ago", "7h ago", "3d ago". A future or sub-second time is
84
+ * "just now" (clock skew between the browser and the server is normal); a
85
+ * non-finite input is "unknown" so a bad timestamp can never render as
86
+ * "0s ago", which would claim liveness that was never observed.
87
+ */
88
+ function formatRelativeAge(fromUnixMs, nowUnixMs, translator = ENGLISH) {
89
+ if (!Number.isFinite(fromUnixMs) || !Number.isFinite(nowUnixMs)) {
90
+ return translateWord("unknown", translator);
91
+ }
92
+ const ageMs = nowUnixMs - fromUnixMs;
93
+ if (ageMs < SECOND_MS) {
94
+ return translateWord("just now", translator);
95
+ }
96
+ if (ageMs < MINUTE_MS) {
97
+ return translator.translateTemplate("{{count}}s ago", {
98
+ count: Math.floor(ageMs / SECOND_MS),
99
+ });
100
+ }
101
+ if (ageMs < HOUR_MS) {
102
+ return translator.translateTemplate("{{count}}m ago", {
103
+ count: Math.floor(ageMs / MINUTE_MS),
104
+ });
105
+ }
106
+ if (ageMs < DAY_MS) {
107
+ return translator.translateTemplate("{{count}}h ago", {
108
+ count: Math.floor(ageMs / HOUR_MS),
109
+ });
110
+ }
111
+ return translator.translateTemplate("{{count}}d ago", {
112
+ count: Math.floor(ageMs / DAY_MS),
113
+ });
114
+ }
115
+ /* "1h", "6h", "3d" - a duration rather than an age, for "no chunk for 7h". */
116
+ function formatDurationForCopy(durationMs, translator = ENGLISH) {
117
+ if (!Number.isFinite(durationMs) || durationMs < 0) {
118
+ return translateWord("unknown", translator);
119
+ }
120
+ if (durationMs < MINUTE_MS) {
121
+ return translator.translateTemplate("{{count}}s", {
122
+ count: Math.floor(durationMs / SECOND_MS),
123
+ });
124
+ }
125
+ if (durationMs < HOUR_MS) {
126
+ return translator.translateTemplate("{{count}}m", {
127
+ count: Math.floor(durationMs / MINUTE_MS),
128
+ });
129
+ }
130
+ if (durationMs < DAY_MS) {
131
+ return translator.translateTemplate("{{count}}h", {
132
+ count: Math.floor(durationMs / HOUR_MS),
133
+ });
134
+ }
135
+ return translator.translateTemplate("{{count}}d", {
136
+ count: Math.floor(durationMs / DAY_MS),
137
+ });
138
+ }
139
+ /*
140
+ * A count for copy: "1,234", or "unknown" for null. Without a translator it
141
+ * is formatted by hand rather than toLocaleString, so the sentence is
142
+ * identical in every browser locale and in tests; with one, in the digits
143
+ * and grouping of the reader's language ("1.234" in German).
144
+ */
145
+ function formatCountForCopy(count, translator) {
146
+ if (count === null || !Number.isFinite(count)) {
147
+ return translateWord("unknown", translator || ENGLISH);
148
+ }
149
+ const rounded = Math.max(0, Math.floor(count));
150
+ if (translator) {
151
+ return translator.formatNumber(rounded);
152
+ }
153
+ const digits = String(rounded);
154
+ let formatted = "";
155
+ for (let index = 0; index < digits.length; index++) {
156
+ const fromEnd = digits.length - index;
157
+ if (index > 0 && fromEnd % 3 === 0) {
158
+ formatted += ",";
159
+ }
160
+ formatted += digits[index];
161
+ }
162
+ return formatted;
163
+ }
164
+ /*
165
+ * "1 GB", "512 MB", "2.5 GB". Byte budgets are set in whole GB or MB. The
166
+ * unit is written as it is in every language; with a translator the
167
+ * figure is the reader's ("2,5 GB" in German).
168
+ */
169
+ function formatBytesForCopy(bytes, translator) {
170
+ if (!Number.isFinite(bytes) || bytes < 0) {
171
+ return translateWord("unknown", translator || ENGLISH);
172
+ }
173
+ const gb = bytes / (1024 * 1024 * 1024);
174
+ if (gb >= 1) {
175
+ const figure = Number.isInteger(gb) ? gb : Math.round(gb * 10) / 10;
176
+ return `${translator ? translator.formatNumber(figure) : Number.isInteger(gb) ? String(gb) : gb.toFixed(1)} GB`;
177
+ }
178
+ const mb = Math.round(bytes / (1024 * 1024));
179
+ return `${translator ? translator.formatNumber(mb) : String(mb)} MB`;
180
+ }
181
+ /* ISO string -> unix ms, or null when absent or unparseable. */
182
+ function parseHealthTimestamp(value) {
183
+ if (typeof value !== "string" || value.length === 0) {
184
+ return null;
185
+ }
186
+ const parsed = Date.parse(value);
187
+ return Number.isFinite(parsed) ? parsed : null;
188
+ }
189
+ /*
190
+ * Normalise the /ingest-status JSON. The legacy top-level policy fields
191
+ * are folded into `policy`; every additive field defaults to null (not
192
+ * measured) rather than 0 or "", and unknown refusal reasons are dropped
193
+ * so the diagnosis only ever names a reason it has copy for. Returns null
194
+ * for a body that is not an object at all, which the caller reports as
195
+ * "unknown" health.
196
+ */
197
+ function parseRecordingHealthStatus(raw) {
198
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
199
+ return null;
200
+ }
201
+ const row = raw;
202
+ const readNullableString = (key) => {
203
+ const value = row[key];
204
+ return typeof value === "string" && value.length > 0 ? value : null;
205
+ };
206
+ const readNullableNumber = (key) => {
207
+ const value = (0, SessionReplayApi_1.readDtoOptionalNumber)(row, key);
208
+ return value === undefined ? null : value;
209
+ };
210
+ const rawRefusals = row["refusalsLast24h"];
211
+ let refusals = null;
212
+ if (Array.isArray(rawRefusals)) {
213
+ refusals = [];
214
+ for (const entry of rawRefusals) {
215
+ if (entry === null || typeof entry !== "object") {
216
+ continue;
217
+ }
218
+ const entryRow = entry;
219
+ const reason = entryRow["reason"];
220
+ const count = (0, SessionReplayApi_1.readDtoOptionalNumber)(entryRow, "count");
221
+ if ((0, SessionReplayHealth_1.isSessionReplayRefusalReason)(reason) && count !== undefined) {
222
+ refusals.push({ reason: reason, count: count });
223
+ }
224
+ }
225
+ }
226
+ /*
227
+ * Drops keep whatever reason string the worker used: they are shown
228
+ * verbatim ("12 chunks dropped after acceptance: scrub-incomplete") and
229
+ * never drive a diagnosis state, so an unknown reason is still worth
230
+ * showing rather than filtering.
231
+ */
232
+ const rawDrops = row["dropsLast24h"];
233
+ let drops = null;
234
+ if (Array.isArray(rawDrops)) {
235
+ drops = [];
236
+ for (const entry of rawDrops) {
237
+ if (entry === null || typeof entry !== "object") {
238
+ continue;
239
+ }
240
+ const entryRow = entry;
241
+ const reason = entryRow["reason"];
242
+ const count = (0, SessionReplayApi_1.readDtoOptionalNumber)(entryRow, "count");
243
+ if (typeof reason === "string" && reason && count !== undefined) {
244
+ drops.push({ reason: reason, count: count });
245
+ }
246
+ }
247
+ }
248
+ /*
249
+ * Absent or not an array means the server never reported capabilities
250
+ * (unknown); an empty array means a recorder uploaded and announced
251
+ * none. Entries are kept verbatim rather than filtered against a known
252
+ * list: the vocabulary belongs to the recorder, and a capability this
253
+ * build has not heard of is exactly what somebody debugging a mixed
254
+ * rollout needs to see.
255
+ */
256
+ const rawCapabilities = row["recorderCapabilities"];
257
+ const recorderCapabilities = Array.isArray(rawCapabilities)
258
+ ? (0, SessionReplayApi_1.readDtoStringArray)(row, "recorderCapabilities")
259
+ : null;
260
+ const retentionInDays = (0, SessionReplayApi_1.readDtoOptionalNumber)(row, "retentionInDays");
261
+ const policy = {
262
+ isProjectEnabled: (0, SessionReplayApi_1.readDtoBoolean)(row, "isProjectAllowed"),
263
+ isApplicationEnabled: (0, SessionReplayApi_1.readDtoBoolean)(row, "isApplicationEnabled"),
264
+ captureTrigger: (0, SessionReplayApi_1.readDtoString)(row, "captureTrigger"),
265
+ samplePercentage: (0, SessionReplayApi_1.readDtoNumber)(row, "samplePercentage"),
266
+ consentMode: (0, SessionReplayApi_1.readDtoString)(row, "consentMode"),
267
+ maskingMode: (0, SessionReplayApi_1.readDtoString)(row, "maskingMode"),
268
+ retentionInDays: retentionInDays === undefined ? null : retentionInDays,
269
+ };
270
+ return {
271
+ appIdentifier: (0, SessionReplayApi_1.readDtoString)(row, "appIdentifier"),
272
+ allowedOrigins: (0, SessionReplayApi_1.readDtoStringArray)(row, "allowedOrigins"),
273
+ policy: policy,
274
+ publishedRecorderVersion: readNullableString("publishedRecorderVersion"),
275
+ lastConfigFetchAt: readNullableString("lastConfigFetchAt"),
276
+ lastChunkReceivedAt: readNullableString("lastChunkReceivedAt"),
277
+ lastSessionStartedAt: readNullableString("lastSessionStartedAt"),
278
+ budgetExceededAt: readNullableString("budgetExceededAt"),
279
+ sessionsLast24h: readNullableNumber("sessionsLast24h"),
280
+ playableSessionsLast24h: readNullableNumber("playableSessionsLast24h"),
281
+ refusalsLast24h: refusals,
282
+ dropsLast24h: drops,
283
+ recorderCapabilities: recorderCapabilities,
284
+ projectBytesUsedToday: readNullableNumber("projectBytesUsedToday"),
285
+ dailyByteLimit: (0, SessionReplayApi_1.readDtoNumber)(row, "dailyByteLimit"),
286
+ applicationBytesUsedThisMonth: readNullableNumber("applicationBytesUsedThisMonth"),
287
+ monthlyBudgetInGB: readNullableNumber("monthlyBudgetInGB"),
288
+ };
289
+ }
290
+ /* The most frequent refusal reason, or null when nothing was refused. */
291
+ function getTopRefusal(refusals) {
292
+ if (refusals === null || refusals.length === 0) {
293
+ return null;
294
+ }
295
+ let top = null;
296
+ for (const refusal of refusals) {
297
+ if (top === null || refusal.count > top.count) {
298
+ top = refusal;
299
+ }
300
+ }
301
+ return top;
302
+ }
303
+ /*
304
+ * One entry per gate reason, so the title never shows the bare reason
305
+ * code. Deployment-level causes (ingest switched off, no artifact, Redis
306
+ * down) have no action: nothing on a settings page fixes them, and
307
+ * offering a link that cannot help is worse than saying so.
308
+ *
309
+ * Each label, detail and action label is an English key, looked up where
310
+ * the diagnosis and describeRefusalReason write it. The label goes into
311
+ * the diagnosis's title as a term ("212 uploads refused in 24h: origin not
312
+ * allowed"), so it is worded for the middle of a sentence.
313
+ */
314
+ const REFUSAL_COPY = {
315
+ "ingest-disabled": {
316
+ label: (0, Translator_1.translationKey)("ingest is switched off on this deployment"),
317
+ detail: (0, Translator_1.translationKey)("SESSION_REPLAY_INGEST_ENABLED is false on the server, so every chunk is refused. Only the operator of this deployment can change that."),
318
+ },
319
+ "instance-not-offering-replay": {
320
+ label: (0, Translator_1.translationKey)("this deployment publishes no recorder"),
321
+ detail: (0, Translator_1.translationKey)("No recorder artifact is built on this deployment, so chunks from a cached recorder are refused. Only the operator of this deployment can change that."),
322
+ },
323
+ "policy-unavailable": {
324
+ label: (0, Translator_1.translationKey)("the policy lookup failed"),
325
+ detail: (0, Translator_1.translationKey)("The server could not load this application's replay policy and refused rather than guess. This clears on its own once the database is reachable."),
326
+ },
327
+ "not-enabled": {
328
+ label: (0, Translator_1.translationKey)("replay was switched off when they arrived"),
329
+ detail: (0, Translator_1.translationKey)("Chunks arrived while the application or project had session replay switched off."),
330
+ action: {
331
+ label: (0, Translator_1.translationKey)("Check the switch"),
332
+ target: "app-settings",
333
+ },
334
+ },
335
+ "origin-not-allowed": {
336
+ label: (0, Translator_1.translationKey)("origin not allowed"),
337
+ detail: (0, Translator_1.translationKey)("Requests came from an origin that is not in your allowed origins."),
338
+ action: {
339
+ label: (0, Translator_1.translationKey)("Edit allowed origins"),
340
+ target: "allowed-origins",
341
+ },
342
+ },
343
+ "session-chunk-cap": {
344
+ label: (0, Translator_1.translationKey)("sessions hit the chunk cap"),
345
+ detail: (0, Translator_1.translationKey)("Some sessions reached the per-session chunk cap and stopped uploading; the recording up to that point is kept."),
346
+ },
347
+ "not-sampled": {
348
+ label: (0, Translator_1.translationKey)("not sampled"),
349
+ detail: (0, Translator_1.translationKey)("The server's sampling draw refused chunks the recorder sent, which happens when the sample percentage was lowered while sessions were live."),
350
+ action: {
351
+ label: (0, Translator_1.translationKey)("Review sampling"),
352
+ target: "app-settings",
353
+ },
354
+ },
355
+ "rate-limited": {
356
+ label: (0, Translator_1.translationKey)("rate limited"),
357
+ detail: (0, Translator_1.translationKey)("Uploads exceeded the per-application rate limit and were refused. A burst of page loads clears on its own."),
358
+ },
359
+ "rate-counter-unavailable": {
360
+ label: (0, Translator_1.translationKey)("the rate counter was unreachable"),
361
+ detail: (0, Translator_1.translationKey)("The server could not reach its rate counter and refused rather than guess. This clears on its own once the counter store is reachable."),
362
+ },
363
+ "budget-exhausted": {
364
+ label: (0, Translator_1.translationKey)("the project's daily budget is spent"),
365
+ detail: (0, Translator_1.translationKey)("This project used its daily byte budget for session replay."),
366
+ action: { label: (0, Translator_1.translationKey)("Review the budget"), target: "budget" },
367
+ },
368
+ "budget-counter-unavailable": {
369
+ label: (0, Translator_1.translationKey)("the budget counter was unreachable"),
370
+ detail: (0, Translator_1.translationKey)("The server could not reach its budget counter and refused rather than guess. This clears on its own once the counter store is reachable."),
371
+ },
372
+ "app-monthly-budget-exhausted": {
373
+ label: (0, Translator_1.translationKey)("the monthly budget is spent"),
374
+ detail: (0, Translator_1.translationKey)("This application used its monthly byte budget for session replay."),
375
+ action: { label: (0, Translator_1.translationKey)("Raise the budget"), target: "budget" },
376
+ },
377
+ "consent-required": {
378
+ label: (0, Translator_1.translationKey)("consent was not granted"),
379
+ detail: (0, Translator_1.translationKey)("Uploads arrived before your page called OneUptimeReplay.grantConsent(). The recorder keeps recording in memory; nothing is stored until consent is granted."),
380
+ action: {
381
+ label: (0, Translator_1.translationKey)("How consent works"),
382
+ target: "docs-consent",
383
+ },
384
+ },
385
+ };
386
+ /*
387
+ * The short human label for a refusal reason ("origin not allowed"), or
388
+ * null for a string this build has no copy for. The health page prints it
389
+ * beside the reason code so the counter reads as a cause, not a slug. In
390
+ * the translator's language; English without one.
391
+ */
392
+ function describeRefusalReason(reason, translator = ENGLISH) {
393
+ return (0, SessionReplayHealth_1.isSessionReplayRefusalReason)(reason)
394
+ ? translateWord(REFUSAL_COPY[reason].label, translator)
395
+ : null;
396
+ }
397
+ function action(label, target) {
398
+ return { label: label, target: target };
399
+ }
400
+ // An age ("5m ago") in the language of the sentence it goes into.
401
+ function ageIn(fromUnixMs, nowUnixMs) {
402
+ return (0, Translator_1.composedValue)((sentence) => {
403
+ return formatRelativeAge(fromUnixMs, nowUnixMs, sentence);
404
+ });
405
+ }
406
+ // A duration ("7h") in the language of the sentence it goes into.
407
+ function durationIn(durationMs) {
408
+ return (0, Translator_1.composedValue)((sentence) => {
409
+ return formatDurationForCopy(durationMs, sentence);
410
+ });
411
+ }
412
+ // A byte figure ("1 GB") as the sentence's language writes a number.
413
+ function bytesIn(bytes) {
414
+ return (0, Translator_1.composedValue)((sentence) => {
415
+ return formatBytesForCopy(bytes, sentence);
416
+ });
417
+ }
418
+ // A number ("100", "2.5") as the sentence's language writes it.
419
+ function numberIn(value) {
420
+ return (0, Translator_1.composedValue)((sentence) => {
421
+ return sentence.formatNumber(value);
422
+ });
423
+ }
424
+ /*
425
+ * What keeps a loaded recorder from ever uploading, read off the policy
426
+ * alone. Ordered by how absolute the block is: sampling at 0% records
427
+ * nothing at all; consent gates every upload until the page grants it;
428
+ * the error/frustration trigger uploads nothing on a quiet day. When
429
+ * none applies, the generic explanation points at the request path.
430
+ */
431
+ function explainLoadedNeverUploaded(status, translator = ENGLISH) {
432
+ const policy = status.policy;
433
+ if (policy.samplePercentage <= 0) {
434
+ return {
435
+ detail: translateWord("Your sample percentage is 0%, so no session is recorded. Raise it to record the next visitor.", translator),
436
+ action: action(translateWord("Set sampling to 100%", translator), "app-settings"),
437
+ };
438
+ }
439
+ if (policy.consentMode === SessionReplayConsentMode_1.default.RequireExplicit) {
440
+ return {
441
+ detail: translateWord("Waiting for consent: the page has not called OneUptimeReplay.grantConsent(), and nothing uploads until it does.", translator),
442
+ action: action(translateWord("How consent works", translator), "docs-consent"),
443
+ };
444
+ }
445
+ if (policy.captureTrigger === SessionReplayCaptureTrigger_1.default.OnErrorOrFrustration) {
446
+ return {
447
+ detail: translateWord("Uploads only start when an error or frustration signal fires; a quiet day looks like nothing. Switch the trigger to Always to record every session.", translator),
448
+ action: action(translateWord("Record every session", translator), "app-settings"),
449
+ };
450
+ }
451
+ return {
452
+ detail: translateWord("The policy fetch succeeds but no chunk has arrived. Uploads flush every 15s, so a request is being blocked on the way: check the browser console for a CSP or ad-blocker refusal of the ingest URL.", translator),
453
+ action: action(translateWord("Allow the recorder through your CSP", translator), "docs-csp"),
454
+ };
455
+ }
456
+ function isDailyBudgetSpent(status) {
457
+ return (status.projectBytesUsedToday !== null &&
458
+ status.dailyByteLimit > 0 &&
459
+ status.projectBytesUsedToday >= status.dailyByteLimit);
460
+ }
461
+ /*
462
+ * budgetExceededAt is a stamp, not a live flag. When the month's usage is
463
+ * known and sits under the budget, the stamp is from a previous month and
464
+ * uploads are flowing again; only then is it ignored.
465
+ */
466
+ function isMonthlyBudgetPaused(status) {
467
+ if (status.budgetExceededAt === null) {
468
+ return false;
469
+ }
470
+ if (status.applicationBytesUsedThisMonth !== null &&
471
+ status.monthlyBudgetInGB !== null &&
472
+ status.monthlyBudgetInGB > 0 &&
473
+ status.applicationBytesUsedThisMonth <
474
+ status.monthlyBudgetInGB * 1024 * 1024 * 1024) {
475
+ return false;
476
+ }
477
+ return true;
478
+ }
479
+ /*
480
+ * "143 sessions in 24h (120 playable)", with unknown counters said so, in
481
+ * the translator's language: each case is a whole phrase of its own.
482
+ */
483
+ function describeSessions(status, translator = ENGLISH) {
484
+ if (status.sessionsLast24h === null) {
485
+ return translateWord("sessions in 24h: unknown", translator);
486
+ }
487
+ const sessions = formatCountForCopy(status.sessionsLast24h, translator);
488
+ if (status.playableSessionsLast24h === null) {
489
+ return translator.translatePlural({
490
+ one: (0, Translator_1.translationKey)("{{count}} session in 24h"),
491
+ other: (0, Translator_1.translationKey)("{{count}} sessions in 24h"),
492
+ }, status.sessionsLast24h, { count: sessions });
493
+ }
494
+ return translator.translatePlural({
495
+ one: (0, Translator_1.translationKey)("{{count}} session in 24h ({{playable}} playable)"),
496
+ other: (0, Translator_1.translationKey)("{{count}} sessions in 24h ({{playable}} playable)"),
497
+ }, status.sessionsLast24h, {
498
+ count: sessions,
499
+ playable: formatCountForCopy(status.playableSessionsLast24h, translator),
500
+ });
501
+ }
502
+ /*
503
+ * The diagnosis. Strict priority, first match wins:
504
+ *
505
+ * disabled-project > disabled-app > budget-paused > refusing >
506
+ * never-loaded > loaded-never-uploaded > stale > healthy-quiet > healthy
507
+ *
508
+ * The last two split the same silence by whether a recorder is still
509
+ * running: past SESSION_REPLAY_STALE_CHUNK_MS without a chunk, a policy
510
+ * fetch inside SESSION_REPLAY_RECORDER_ACTIVE_WINDOW_MS means "stale"
511
+ * (loading but not uploading - something is blocking the request), and no
512
+ * policy fetch in that window means "healthy-quiet" (no recorder is on a
513
+ * page right now: quiet traffic, or a snippet that was removed).
514
+ *
515
+ * and "unknown" when there is no status to read. The order is the order
516
+ * in which a fix has to happen: a switched-off project makes every later
517
+ * signal moot, a spent budget explains any refusal, a refusal explains a
518
+ * missing chunk, and only a recorder that is loading and uploading can be
519
+ * stale or healthy.
520
+ *
521
+ * The title, the detail and the action's label are in the translator's
522
+ * language (the Dashboard hands in the reader's: useSessionReplayHealth),
523
+ * each sentence whole; without one they are English, word for word.
524
+ */
525
+ function diagnoseRecordingHealth(status, nowUnixMs, translator = ENGLISH) {
526
+ if (status === null) {
527
+ return {
528
+ state: "unknown",
529
+ severity: "info",
530
+ title: translateWord("Recording health is unknown", translator),
531
+ detail: translateWord("The health status could not be loaded, so nothing here says whether recording works. Reload to try again.", translator),
532
+ };
533
+ }
534
+ const policy = status.policy;
535
+ if (!policy.isProjectEnabled) {
536
+ return {
537
+ state: "disabled-project",
538
+ severity: "error",
539
+ title: translateWord("Session replay is switched off for this project", translator),
540
+ detail: translateWord("Nothing is recorded for any application while the project switch is off, whatever the application settings say.", translator),
541
+ action: action(translateWord("Turn it on", translator), "project-settings"),
542
+ };
543
+ }
544
+ if (!policy.isApplicationEnabled) {
545
+ return {
546
+ state: "disabled-app",
547
+ severity: "error",
548
+ title: status.appIdentifier
549
+ ? translator.translateTemplate("Session replay is switched off for {{application}}", { application: status.appIdentifier })
550
+ : translateWord("Session replay is switched off", translator),
551
+ detail: translateWord("Recorders on this application's pages fetch a disabled policy and record nothing.", translator),
552
+ action: action(translateWord("Turn it on", translator), "app-settings"),
553
+ };
554
+ }
555
+ if (isMonthlyBudgetPaused(status)) {
556
+ const since = parseHealthTimestamp(status.budgetExceededAt);
557
+ const budgetInGB = status.monthlyBudgetInGB;
558
+ return {
559
+ state: "budget-paused",
560
+ severity: "error",
561
+ title: since === null
562
+ ? translateWord("Uploads paused", translator)
563
+ : translator.translateTemplate("Uploads paused {{age}}", {
564
+ age: ageIn(since, nowUnixMs),
565
+ }),
566
+ detail: budgetInGB === null
567
+ ? translateWord("This application used its monthly budget. Uploads resume next month, or as soon as the budget is raised.", translator)
568
+ : translator.translateTemplate("This application used its {{budget}} GB monthly budget. Uploads resume next month, or as soon as the budget is raised.", { budget: numberIn(budgetInGB) }),
569
+ action: action(translateWord("Raise the budget", translator), "budget"),
570
+ };
571
+ }
572
+ if (isDailyBudgetSpent(status)) {
573
+ return {
574
+ state: "budget-paused",
575
+ severity: "error",
576
+ title: translateWord("Uploads paused for today", translator),
577
+ detail: translator.translateTemplate("This project used its {{limit}} daily budget for session replay ({{used}} used). Uploads resume tomorrow.", {
578
+ limit: bytesIn(status.dailyByteLimit),
579
+ used: bytesIn(status.projectBytesUsedToday),
580
+ }),
581
+ action: action(translateWord("Review the budget", translator), "budget"),
582
+ };
583
+ }
584
+ const topRefusal = getTopRefusal(status.refusalsLast24h);
585
+ if (topRefusal !== null &&
586
+ topRefusal.count >= exports.SESSION_REPLAY_REFUSAL_ALERT_THRESHOLD) {
587
+ const copy = REFUSAL_COPY[topRefusal.reason];
588
+ return Object.assign({ state: "refusing", severity: "warning", title: translator.translatePlural({
589
+ one: (0, Translator_1.translationKey)("{{count}} upload refused in 24h: {{reason}}"),
590
+ other: (0, Translator_1.translationKey)("{{count}} uploads refused in 24h: {{reason}}"),
591
+ }, topRefusal.count, {
592
+ count: formatCountForCopy(topRefusal.count, translator),
593
+ reason: (0, Translator_1.translatableTerm)(copy.label),
594
+ }), detail: translateWord(copy.detail, translator) }, (copy.action && {
595
+ action: action(translateWord(copy.action.label, translator), copy.action.target),
596
+ }));
597
+ }
598
+ const lastConfigFetchUnixMs = parseHealthTimestamp(status.lastConfigFetchAt);
599
+ const lastChunkUnixMs = parseHealthTimestamp(status.lastChunkReceivedAt);
600
+ /*
601
+ * Both null, not just the config stamp: an older server never sends
602
+ * lastConfigFetchAt, and a recorder that has delivered a chunk has
603
+ * self-evidently loaded.
604
+ */
605
+ if (lastConfigFetchUnixMs === null && lastChunkUnixMs === null) {
606
+ return {
607
+ state: "never-loaded",
608
+ severity: "warning",
609
+ title: status.appIdentifier
610
+ ? translator.translateTemplate("The recorder has never loaded for {{application}}", { application: status.appIdentifier })
611
+ : translateWord("The recorder has never loaded", translator),
612
+ detail: translateWord("No page has fetched this application's replay policy and no chunk has arrived. Add the script tag to your site, then reload a page that uses it.", translator),
613
+ action: action(translateWord("Open the setup guide", translator), "setup-guide"),
614
+ };
615
+ }
616
+ if (lastChunkUnixMs === null) {
617
+ const explanation = explainLoadedNeverUploaded(status, translator);
618
+ return {
619
+ state: "loaded-never-uploaded",
620
+ severity: "warning",
621
+ title: translator.translateTemplate("The recorder loaded {{age}} but nothing has been uploaded", { age: ageIn(lastConfigFetchUnixMs, nowUnixMs) }),
622
+ detail: explanation.detail,
623
+ action: explanation.action,
624
+ };
625
+ }
626
+ const chunkAgeMs = nowUnixMs - lastChunkUnixMs;
627
+ const isRecorderStillLoading = lastConfigFetchUnixMs !== null &&
628
+ nowUnixMs - lastConfigFetchUnixMs <=
629
+ exports.SESSION_REPLAY_RECORDER_ACTIVE_WINDOW_MS;
630
+ if (chunkAgeMs > exports.SESSION_REPLAY_STALE_CHUNK_MS && isRecorderStillLoading) {
631
+ const explanation = explainLoadedNeverUploaded(status, translator);
632
+ return {
633
+ state: "stale",
634
+ severity: "warning",
635
+ title: translator.translateTemplate("No chunk for {{duration}} while the recorder keeps loading", { duration: durationIn(chunkAgeMs) }),
636
+ /*
637
+ * The explanation is a sentence of its own, written in the language
638
+ * this one is read in.
639
+ */
640
+ detail: translator.translateTemplate("The recorder last fetched its policy {{fetchAge}}, but the last chunk arrived {{chunkAge}}. {{explanation}}", {
641
+ fetchAge: ageIn(lastConfigFetchUnixMs, nowUnixMs),
642
+ chunkAge: ageIn(lastChunkUnixMs, nowUnixMs),
643
+ explanation: (0, Translator_1.composedValue)((sentence) => {
644
+ return explainLoadedNeverUploaded(status, sentence).detail;
645
+ }),
646
+ }),
647
+ action: explanation.action,
648
+ };
649
+ }
650
+ /*
651
+ * What is left of the >6h case: no chunk AND no policy fetch inside the
652
+ * active window either (or no policy-fetch stamp at all on an older
653
+ * server). Nothing is switched off, over budget or being refused, so
654
+ * this is not an error - but "no recorder has loaded for a day" is also
655
+ * exactly what a removed script tag looks like, and the previous copy
656
+ * ("quiet traffic rather than a broken install") handed out that
657
+ * reassurance for the one silent case it cannot actually vouch for. The
658
+ * copy now names what it knows, quantifies both silences, and offers
659
+ * the install check as the single next step.
660
+ */
661
+ if (chunkAgeMs > exports.SESSION_REPLAY_STALE_CHUNK_MS) {
662
+ const quietTitle = translator.translateTemplate("No session recorded in the past {{duration}}", { duration: durationIn(chunkAgeMs) });
663
+ /*
664
+ * No action in this branch: an older server sends no lastConfigFetchAt
665
+ * at all, so nothing here says the install is wrong, and pointing at
666
+ * the setup guide would be a guess dressed as advice.
667
+ */
668
+ if (lastConfigFetchUnixMs === null) {
669
+ return {
670
+ state: "healthy-quiet",
671
+ severity: "info",
672
+ title: quietTitle,
673
+ detail: translator.translateTemplate("The last chunk arrived {{chunkAge}} and this server does not report policy fetches, so whether a recorder is still loading on your pages cannot be told from here. The policy is healthy (sampling {{percent}}%).", {
674
+ chunkAge: ageIn(lastChunkUnixMs, nowUnixMs),
675
+ percent: numberIn(policy.samplePercentage),
676
+ }),
677
+ };
678
+ }
679
+ return {
680
+ state: "healthy-quiet",
681
+ severity: "info",
682
+ title: quietTitle,
683
+ detail: translator.translateTemplate("The last chunk arrived {{chunkAge}} and no page has fetched the policy for {{fetchSilence}} either, so no recorder is running on this application right now - quiet traffic on a low-traffic or staging app, or a snippet that is no longer on the page. The policy is healthy (sampling {{percent}}%).", {
684
+ chunkAge: ageIn(lastChunkUnixMs, nowUnixMs),
685
+ fetchSilence: durationIn(nowUnixMs - lastConfigFetchUnixMs),
686
+ percent: numberIn(policy.samplePercentage),
687
+ }),
688
+ action: action(translateWord("Check the install", translator), "setup-guide"),
689
+ };
690
+ }
691
+ return {
692
+ state: "healthy",
693
+ severity: "ok",
694
+ title: translateWord("Recording healthy", translator),
695
+ detail: translator.translateTemplate("Last chunk {{age}} - {{sessions}} - sampling {{percent}}%.", {
696
+ age: ageIn(lastChunkUnixMs, nowUnixMs),
697
+ sessions: (0, Translator_1.composedValue)((sentence) => {
698
+ return describeSessions(status, sentence);
699
+ }),
700
+ percent: numberIn(policy.samplePercentage),
701
+ }),
702
+ };
703
+ }