@oneuptime/common 12.0.19 → 12.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/ChangeEvent.ts +331 -0
- package/Models/AnalyticsModels/Index.ts +2 -0
- package/Server/API/EnterpriseLicenseAPI.ts +94 -19
- package/Server/EnvironmentConfig.ts +15 -5
- package/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.ts +42 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +0 -2
- package/Server/Services/ChangeEventService.ts +11 -0
- package/Server/Services/EnterpriseLicenseService.ts +3 -3
- package/Server/Services/Index.ts +2 -0
- package/Server/Services/ProjectService.ts +104 -0
- package/Server/Utils/Attribution.ts +11 -11
- package/Server/Utils/Marketing/MarketingEventWebhook.ts +4 -5
- package/Server/Utils/Response.ts +2 -2
- package/Server/Utils/StartServer.ts +2 -2
- package/Server/Utils/Telemetry/ChangeEventRow.ts +228 -0
- package/Server/Views/Partials/AnalyticsConsent.ejs +441 -0
- package/Tests/App/Dashboard/AlertEpisodeViewFields.test.tsx +465 -0
- package/Tests/App/Dashboard/DashboardChartWidgetZoom.test.tsx +366 -0
- package/Tests/App/Dashboard/DiscoveryScanWizardValidation.test.tsx +408 -0
- package/Tests/App/Dashboard/EventOverlayHook.test.tsx +249 -0
- package/Tests/App/Dashboard/IncidentEpisodeViewFields.test.tsx +474 -0
- package/Tests/App/Dashboard/InvestigationArtifacts.test.tsx +315 -0
- package/Tests/App/Dashboard/InvestigationDrawer.test.tsx +258 -0
- package/Tests/App/Dashboard/MetricChartsCompare.test.tsx +171 -0
- package/Tests/App/Dashboard/MetricSeriesInvestigateMenu.test.tsx +368 -0
- package/Tests/App/Dashboard/MetricViewCompare.test.tsx +233 -0
- package/Tests/Server/API/EnterpriseLicenseReportUserCount.test.ts +763 -0
- package/Tests/Server/Infrastructure/Postgres/AddUserSlackAndMicrosoftTeamsMigration.test.ts +236 -0
- package/Tests/Server/Services/ProjectServiceChangePlan.test.ts +138 -0
- package/Tests/Server/Services/ProjectServiceCreateSubscriptionStarted.test.ts +516 -0
- package/Tests/Server/Utils/AI/SRE/Insights/Detectors/ExceptionIdentity.test.ts +224 -0
- package/Tests/Server/Utils/Attribution.test.ts +4 -5
- package/Tests/Server/Utils/Marketing/MarketingEventUtil.test.ts +2 -2
- package/Tests/Server/Utils/Monitor/MonitorCriteriaExpectationBuilder.test.ts +300 -0
- package/Tests/Server/Utils/ResponseRenderAnalytics.test.ts +53 -0
- package/Tests/Server/Views/AnalyticsConsentPartial.test.ts +241 -0
- package/Tests/UI/Components/Charts/ChartGhostSeries.test.tsx +103 -0
- package/Tests/UI/Components/Charts/ChartTooltipSorted.test.tsx +129 -0
- package/Tests/UI/Components/Charts/TooltipEntries.test.ts +191 -0
- package/Tests/UI/Components/Detail/DetailFieldErrors.test.tsx +347 -0
- package/Tests/UI/Components/Forms/BasicFormStepValidation.test.tsx +392 -0
- package/Tests/UI/Components/Forms/ValidationFormSteps.test.ts +549 -0
- package/Tests/Utils/EnterpriseLicenseSync.test.ts +562 -0
- package/Tests/Utils/Telemetry/CrossSignalScope.test.ts +13 -2
- package/Types/Analytics/RevenueEvent.ts +1 -0
- package/Types/AnalyticsDatabase/AnalyticsTableName.ts +7 -0
- package/Types/Marketing/Attribution.ts +9 -15
- package/Types/Marketing/MarketingEvent.ts +19 -12
- package/UI/Components/Charts/Area/AreaChart.tsx +23 -1
- package/UI/Components/Charts/Bar/BarChart.tsx +8 -1
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +16 -1
- package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +208 -97
- package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +26 -3
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +232 -118
- package/UI/Components/Charts/ChartLibrary/Utils/TooltipEntries.ts +120 -0
- package/UI/Components/Charts/Line/LineChart.tsx +23 -1
- package/UI/Components/Detail/Detail.tsx +18 -1
- package/Utils/EnterpriseLicense/EnterpriseLicenseSync.ts +244 -0
- package/Utils/Metrics/MetricExplorerUrl.ts +119 -5
- package/Utils/Telemetry/CrossSignalScope.ts +19 -10
- package/build/dist/Models/AnalyticsModels/ChangeEvent.js +298 -0
- package/build/dist/Models/AnalyticsModels/ChangeEvent.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/Index.js +2 -0
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Server/API/EnterpriseLicenseAPI.js +66 -12
- package/build/dist/Server/API/EnterpriseLicenseAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +14 -5
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js +39 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789000000000-AddUserSlackAndMicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +0 -2
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/ChangeEventService.js +9 -0
- package/build/dist/Server/Services/ChangeEventService.js.map +1 -0
- package/build/dist/Server/Services/EnterpriseLicenseService.js +3 -3
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +88 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Utils/Attribution.js +6 -6
- package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js +4 -5
- package/build/dist/Server/Utils/Marketing/MarketingEventWebhook.js.map +1 -1
- package/build/dist/Server/Utils/Response.js +2 -2
- package/build/dist/Server/Utils/Response.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +2 -2
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/ChangeEventRow.js +150 -0
- package/build/dist/Server/Utils/Telemetry/ChangeEventRow.js.map +1 -0
- package/build/dist/Types/Analytics/RevenueEvent.js +1 -0
- package/build/dist/Types/Analytics/RevenueEvent.js.map +1 -1
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +7 -0
- package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
- package/build/dist/Types/Marketing/Attribution.js +9 -15
- package/build/dist/Types/Marketing/Attribution.js.map +1 -1
- package/build/dist/Types/Marketing/MarketingEvent.js +12 -4
- package/build/dist/Types/Marketing/MarketingEvent.js.map +1 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +10 -2
- package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +9 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +9 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +114 -51
- package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +35 -23
- package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +122 -55
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/TooltipEntries.js +86 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/TooltipEntries.js.map +1 -0
- package/build/dist/UI/Components/Charts/Line/LineChart.js +10 -2
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Detail/Detail.js +17 -1
- package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
- package/build/dist/Utils/EnterpriseLicense/EnterpriseLicenseSync.js +174 -0
- package/build/dist/Utils/EnterpriseLicense/EnterpriseLicenseSync.js.map +1 -0
- package/build/dist/Utils/Metrics/MetricExplorerUrl.js +81 -0
- package/build/dist/Utils/Metrics/MetricExplorerUrl.js.map +1 -1
- package/build/dist/Utils/Telemetry/CrossSignalScope.js +14 -8
- package/build/dist/Utils/Telemetry/CrossSignalScope.js.map +1 -1
- package/package.json +1 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.ts +0 -117
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js +0 -106
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1788900000000-RedactStoredMonitorIngestSecrets.js.map +0 -1
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import EnterpriseLicenseSyncUtil, {
|
|
2
|
+
EnterpriseLicenseSyncResult,
|
|
3
|
+
} from "../../Utils/EnterpriseLicense/EnterpriseLicenseSync";
|
|
4
|
+
import { JSONObject } from "../../Types/JSON";
|
|
5
|
+
import { describe, expect, it } from "@jest/globals";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* The mapper that turns a license-server response into the GlobalConfig
|
|
9
|
+
* columns a self-hosted installation mirrors.
|
|
10
|
+
*
|
|
11
|
+
* This exists because of a real, reported bug: a customer raised their seat
|
|
12
|
+
* limit on oneuptime.com, their installation called home every day as
|
|
13
|
+
* designed, and the modal kept showing the old limit forever. The daily job
|
|
14
|
+
* read four fields out of the response and silently dropped userLimit, and the
|
|
15
|
+
* only other writer of that column is a human re-typing the license key.
|
|
16
|
+
*
|
|
17
|
+
* Every field here is three-state, and keeping those states apart IS the
|
|
18
|
+
* contract:
|
|
19
|
+
*
|
|
20
|
+
* key absent -> leave the stored column alone. This is what an oneuptime.com
|
|
21
|
+
* older than the installation looks like, and collapsing it to
|
|
22
|
+
* null would let a daily report wipe a valid license expiry
|
|
23
|
+
* and take the installation down.
|
|
24
|
+
* null -> the server means "no value"; write null.
|
|
25
|
+
* a value -> validate, then write.
|
|
26
|
+
*
|
|
27
|
+
* The absent case cannot be asserted with toBeUndefined(): reading a missing
|
|
28
|
+
* key and reading a key set to undefined both give undefined, and only one of
|
|
29
|
+
* them is safe to hand to updateOneById. Every "left alone" assertion below
|
|
30
|
+
* therefore goes through Object.keys / toHaveProperty.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const REPORTED_AT: Date = new Date("2026-08-24T10:00:00.000Z");
|
|
34
|
+
|
|
35
|
+
type SyncFunction = (payload: JSONObject) => EnterpriseLicenseSyncResult;
|
|
36
|
+
|
|
37
|
+
const sync: SyncFunction = (
|
|
38
|
+
payload: JSONObject,
|
|
39
|
+
): EnterpriseLicenseSyncResult => {
|
|
40
|
+
return EnterpriseLicenseSyncUtil.getGlobalConfigUpdateFromLicenseResponse({
|
|
41
|
+
payload: payload,
|
|
42
|
+
reportedAt: REPORTED_AT,
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type KeysFunction = (payload: JSONObject) => Array<string>;
|
|
47
|
+
|
|
48
|
+
const keys: KeysFunction = (payload: JSONObject): Array<string> => {
|
|
49
|
+
return Object.keys(sync(payload).updateData);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/*
|
|
53
|
+
* The exact body Common/Server/API/EnterpriseLicenseAPI.ts sends from
|
|
54
|
+
* /report-user-count for a healthy license. Kept in one place so the contract
|
|
55
|
+
* test at the bottom and the happy-path tests cannot drift apart.
|
|
56
|
+
*/
|
|
57
|
+
type ServerResponseFunction = (overrides?: JSONObject) => JSONObject;
|
|
58
|
+
|
|
59
|
+
const serverResponse: ServerResponseFunction = (
|
|
60
|
+
overrides?: JSONObject,
|
|
61
|
+
): JSONObject => {
|
|
62
|
+
return {
|
|
63
|
+
companyName: "Acme Inc",
|
|
64
|
+
expiresAt: "2027-01-01T00:00:00.000Z",
|
|
65
|
+
licenseKey: "the-key-the-server-knows",
|
|
66
|
+
userLimit: 150,
|
|
67
|
+
currentUserCount: 42,
|
|
68
|
+
userCountUpdatedAt: "2026-08-24T09:59:00.000Z",
|
|
69
|
+
isEvaluationLicense: false,
|
|
70
|
+
instances: [
|
|
71
|
+
{
|
|
72
|
+
instanceId: "instance-1",
|
|
73
|
+
host: "oneuptime.acme.internal",
|
|
74
|
+
userCount: 42,
|
|
75
|
+
lastReportedAt: "2026-08-24T09:59:00.000Z",
|
|
76
|
+
version: "12.0.19",
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
token: "signed.jwt.token",
|
|
80
|
+
...overrides,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
describe("EnterpriseLicenseSyncUtil - the reported bug: the seat limit", () => {
|
|
85
|
+
it("writes a raised seat limit, which is the regression this whole file guards", () => {
|
|
86
|
+
const result: EnterpriseLicenseSyncResult = sync({ userLimit: 150 });
|
|
87
|
+
|
|
88
|
+
expect(result.updateData.enterpriseLicenseUserLimit).toBe(150);
|
|
89
|
+
expect(result.warnings).toEqual([]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("writes a lowered seat limit too - the sync is not one-directional", () => {
|
|
93
|
+
expect(sync({ userLimit: 5 }).updateData.enterpriseLicenseUserLimit).toBe(
|
|
94
|
+
5,
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("writes an explicit null, so clearing the limit on oneuptime.com clears it here", () => {
|
|
99
|
+
const result: EnterpriseLicenseSyncResult = sync({ userLimit: null });
|
|
100
|
+
|
|
101
|
+
expect(Object.keys(result.updateData)).toContain(
|
|
102
|
+
"enterpriseLicenseUserLimit",
|
|
103
|
+
);
|
|
104
|
+
expect(result.updateData.enterpriseLicenseUserLimit).toBeNull();
|
|
105
|
+
expect(result.warnings).toEqual([]);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("leaves the stored limit alone when the server never mentions it", () => {
|
|
109
|
+
// An oneuptime.com older than this build. Must be a no-op, not a clear.
|
|
110
|
+
expect(keys({ currentUserCount: 3 })).not.toContain(
|
|
111
|
+
"enterpriseLicenseUserLimit",
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it("treats an explicit undefined as silence, not as a clear", () => {
|
|
116
|
+
expect(keys({ userLimit: undefined })).not.toContain(
|
|
117
|
+
"enterpriseLicenseUserLimit",
|
|
118
|
+
);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("writes zero rather than skipping it on a truthiness check", () => {
|
|
122
|
+
const result: EnterpriseLicenseSyncResult = sync({ userLimit: 0 });
|
|
123
|
+
|
|
124
|
+
expect(Object.keys(result.updateData)).toContain(
|
|
125
|
+
"enterpriseLicenseUserLimit",
|
|
126
|
+
);
|
|
127
|
+
expect(result.updateData.enterpriseLicenseUserLimit).toBe(0);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it.each([
|
|
131
|
+
["a numeric string", "150"],
|
|
132
|
+
["NaN", Number.NaN],
|
|
133
|
+
["Infinity", Number.POSITIVE_INFINITY],
|
|
134
|
+
["a fraction", 12.5],
|
|
135
|
+
["a negative number", -1],
|
|
136
|
+
["a boolean", true],
|
|
137
|
+
["an object", {}],
|
|
138
|
+
["an array", [150]],
|
|
139
|
+
])(
|
|
140
|
+
"refuses to store %s as the seat limit, and says so",
|
|
141
|
+
(_label: string, value: unknown) => {
|
|
142
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
143
|
+
userLimit: value,
|
|
144
|
+
} as JSONObject);
|
|
145
|
+
|
|
146
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
147
|
+
"enterpriseLicenseUserLimit",
|
|
148
|
+
);
|
|
149
|
+
expect(result.warnings).toHaveLength(1);
|
|
150
|
+
expect(result.warnings[0]).toContain("userLimit");
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
describe("EnterpriseLicenseSyncUtil - user count and its timestamp", () => {
|
|
156
|
+
it("stores the deduplicated count the server computed across every instance", () => {
|
|
157
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
158
|
+
currentUserCount: 42,
|
|
159
|
+
userCountUpdatedAt: "2026-08-24T09:59:00.000Z",
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
expect(result.updateData.enterpriseLicenseCurrentUserCount).toBe(42);
|
|
163
|
+
expect(result.updateData.enterpriseLicenseUserCountUpdatedAt).toEqual(
|
|
164
|
+
new Date("2026-08-24T09:59:00.000Z"),
|
|
165
|
+
);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("falls back to the caller's clock when the server sends a count but no stamp", () => {
|
|
169
|
+
const result: EnterpriseLicenseSyncResult = sync({ currentUserCount: 7 });
|
|
170
|
+
|
|
171
|
+
expect(result.updateData.enterpriseLicenseUserCountUpdatedAt).toEqual(
|
|
172
|
+
REPORTED_AT,
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("falls back to the caller's clock when the stamp is unparseable", () => {
|
|
177
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
178
|
+
currentUserCount: 7,
|
|
179
|
+
userCountUpdatedAt: "last tuesday",
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
expect(result.updateData.enterpriseLicenseUserCountUpdatedAt).toEqual(
|
|
183
|
+
REPORTED_AT,
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("stores a count of zero", () => {
|
|
188
|
+
const result: EnterpriseLicenseSyncResult = sync({ currentUserCount: 0 });
|
|
189
|
+
|
|
190
|
+
expect(result.updateData.enterpriseLicenseCurrentUserCount).toBe(0);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("never stamps a timestamp onto a count it did not store", () => {
|
|
194
|
+
/*
|
|
195
|
+
* A fresh stamp on a stale count is the specific lie that made this bug
|
|
196
|
+
* hard to see: the modal reads "last reported today" underneath a number
|
|
197
|
+
* from weeks ago.
|
|
198
|
+
*/
|
|
199
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
200
|
+
currentUserCount: "many",
|
|
201
|
+
userCountUpdatedAt: "2026-08-24T09:59:00.000Z",
|
|
202
|
+
} as JSONObject);
|
|
203
|
+
|
|
204
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
205
|
+
"enterpriseLicenseCurrentUserCount",
|
|
206
|
+
);
|
|
207
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
208
|
+
"enterpriseLicenseUserCountUpdatedAt",
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it.each([
|
|
213
|
+
["a string", "42"],
|
|
214
|
+
["NaN", Number.NaN],
|
|
215
|
+
["Infinity", Number.POSITIVE_INFINITY],
|
|
216
|
+
["a fraction", 4.5],
|
|
217
|
+
["a negative number", -3],
|
|
218
|
+
])(
|
|
219
|
+
"keeps the previously stored usage when the count arrives as %s",
|
|
220
|
+
(_label: string, value: unknown) => {
|
|
221
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
222
|
+
currentUserCount: value,
|
|
223
|
+
} as JSONObject);
|
|
224
|
+
|
|
225
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
226
|
+
"enterpriseLicenseCurrentUserCount",
|
|
227
|
+
);
|
|
228
|
+
expect(result.warnings).toHaveLength(1);
|
|
229
|
+
},
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
it("keeps the previously stored usage when the server reports null", () => {
|
|
233
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
234
|
+
currentUserCount: null,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
238
|
+
"enterpriseLicenseCurrentUserCount",
|
|
239
|
+
);
|
|
240
|
+
expect(result.warnings).toHaveLength(1);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it("leaves both usage columns alone when the server never mentions the count", () => {
|
|
244
|
+
expect(keys({ userLimit: 10 })).toEqual(["enterpriseLicenseUserLimit"]);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("still syncs everything else when only the count is unusable", () => {
|
|
248
|
+
/*
|
|
249
|
+
* The job used to bail out entirely here, so one malformed count also cost
|
|
250
|
+
* the customer that day's seat limit, expiry and evaluation flag.
|
|
251
|
+
*/
|
|
252
|
+
const result: EnterpriseLicenseSyncResult = sync(
|
|
253
|
+
serverResponse({ currentUserCount: "nope" }),
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
expect(result.updateData.enterpriseLicenseUserLimit).toBe(150);
|
|
257
|
+
expect(result.updateData.enterpriseLicenseExpiresAt).toEqual(
|
|
258
|
+
new Date("2027-01-01T00:00:00.000Z"),
|
|
259
|
+
);
|
|
260
|
+
expect(result.updateData.enterpriseLicenseIsEvaluation).toBe(false);
|
|
261
|
+
expect(result.updateData.enterpriseCompanyName).toBe("Acme Inc");
|
|
262
|
+
expect(result.updateData.enterpriseLicenseToken).toBe("signed.jwt.token");
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe("EnterpriseLicenseSyncUtil - expiry", () => {
|
|
267
|
+
it("stores a renewal, so extending a license on oneuptime.com reaches the installation", () => {
|
|
268
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
269
|
+
expiresAt: "2027-01-01T00:00:00.000Z",
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
expect(result.updateData.enterpriseLicenseExpiresAt).toEqual(
|
|
273
|
+
new Date("2027-01-01T00:00:00.000Z"),
|
|
274
|
+
);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("stores an expiry in the past, because an instance must be able to learn it expired", () => {
|
|
278
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
279
|
+
expiresAt: "2020-01-01T00:00:00.000Z",
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
expect(result.updateData.enterpriseLicenseExpiresAt).toEqual(
|
|
283
|
+
new Date("2020-01-01T00:00:00.000Z"),
|
|
284
|
+
);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("leaves the stored expiry alone when the server never mentions it", () => {
|
|
288
|
+
/*
|
|
289
|
+
* The compatibility case that matters most: an installation upgraded ahead
|
|
290
|
+
* of oneuptime.com must not have its expiry blanked and go dark.
|
|
291
|
+
*/
|
|
292
|
+
expect(keys({ currentUserCount: 1 })).not.toContain(
|
|
293
|
+
"enterpriseLicenseExpiresAt",
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("treats an explicit null as silence - a report never strips an expiry", () => {
|
|
298
|
+
expect(keys({ expiresAt: null })).not.toContain(
|
|
299
|
+
"enterpriseLicenseExpiresAt",
|
|
300
|
+
);
|
|
301
|
+
expect(sync({ expiresAt: null }).warnings).toEqual([]);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it.each([
|
|
305
|
+
["an unparseable string", "not a date"],
|
|
306
|
+
["an empty string", ""],
|
|
307
|
+
["a number", 1767225600000],
|
|
308
|
+
["a boolean", true],
|
|
309
|
+
])(
|
|
310
|
+
"keeps the stored expiry when the server sends %s, and says so",
|
|
311
|
+
(_label: string, value: unknown) => {
|
|
312
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
313
|
+
expiresAt: value,
|
|
314
|
+
} as JSONObject);
|
|
315
|
+
|
|
316
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
317
|
+
"enterpriseLicenseExpiresAt",
|
|
318
|
+
);
|
|
319
|
+
expect(result.warnings).toHaveLength(1);
|
|
320
|
+
expect(result.warnings[0]).toContain("expiresAt");
|
|
321
|
+
},
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
it("accepts a Date instance, in case the transport ever deserializes one", () => {
|
|
325
|
+
const expiry: Date = new Date("2027-06-01T00:00:00.000Z");
|
|
326
|
+
|
|
327
|
+
expect(
|
|
328
|
+
sync({ expiresAt: expiry }).updateData.enterpriseLicenseExpiresAt,
|
|
329
|
+
).toEqual(expiry);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
describe("EnterpriseLicenseSyncUtil - evaluation flag", () => {
|
|
334
|
+
it.each([
|
|
335
|
+
[true, true],
|
|
336
|
+
[false, false],
|
|
337
|
+
])(
|
|
338
|
+
"mirrors the boolean the server sent (%s)",
|
|
339
|
+
(value: boolean, expected: boolean) => {
|
|
340
|
+
expect(
|
|
341
|
+
sync({ isEvaluationLicense: value }).updateData
|
|
342
|
+
.enterpriseLicenseIsEvaluation,
|
|
343
|
+
).toBe(expected);
|
|
344
|
+
},
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
it("leaves the stored flag alone when the server never mentions it", () => {
|
|
348
|
+
expect(keys({ userLimit: 1 })).not.toContain(
|
|
349
|
+
"enterpriseLicenseIsEvaluation",
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it.each([
|
|
354
|
+
['the string "true"', "true"],
|
|
355
|
+
["a number", 1],
|
|
356
|
+
["null", null],
|
|
357
|
+
])(
|
|
358
|
+
"refuses to guess at %s and keeps the stored flag",
|
|
359
|
+
(_label: string, value: unknown) => {
|
|
360
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
361
|
+
isEvaluationLicense: value,
|
|
362
|
+
} as JSONObject);
|
|
363
|
+
|
|
364
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
365
|
+
"enterpriseLicenseIsEvaluation",
|
|
366
|
+
);
|
|
367
|
+
expect(result.warnings).toHaveLength(1);
|
|
368
|
+
},
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
describe("EnterpriseLicenseSyncUtil - company name", () => {
|
|
373
|
+
it("stores a rename", () => {
|
|
374
|
+
expect(
|
|
375
|
+
sync({ companyName: "Acme Inc" }).updateData.enterpriseCompanyName,
|
|
376
|
+
).toBe("Acme Inc");
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("trims what it stores", () => {
|
|
380
|
+
expect(
|
|
381
|
+
sync({ companyName: " Acme Inc " }).updateData.enterpriseCompanyName,
|
|
382
|
+
).toBe("Acme Inc");
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it.each([
|
|
386
|
+
["an empty string", ""],
|
|
387
|
+
["whitespace", " "],
|
|
388
|
+
["null", null],
|
|
389
|
+
["a number", 42],
|
|
390
|
+
])(
|
|
391
|
+
"keeps the stored name rather than blanking the modal for %s",
|
|
392
|
+
(_label: string, value: unknown) => {
|
|
393
|
+
expect(
|
|
394
|
+
Object.keys(sync({ companyName: value } as JSONObject).updateData),
|
|
395
|
+
).not.toContain("enterpriseCompanyName");
|
|
396
|
+
},
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
it("leaves the stored name alone when the server never mentions it", () => {
|
|
400
|
+
expect(keys({ userLimit: 1 })).not.toContain("enterpriseCompanyName");
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
describe("EnterpriseLicenseSyncUtil - token", () => {
|
|
405
|
+
it("stores a freshly signed token", () => {
|
|
406
|
+
expect(sync({ token: "a.b.c" }).updateData.enterpriseLicenseToken).toBe(
|
|
407
|
+
"a.b.c",
|
|
408
|
+
);
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it.each([
|
|
412
|
+
["null, as an expired license gets", null],
|
|
413
|
+
["an empty string", ""],
|
|
414
|
+
["a non-string", 7],
|
|
415
|
+
])(
|
|
416
|
+
"never clears the stored token for %s",
|
|
417
|
+
(_label: string, value: unknown) => {
|
|
418
|
+
/*
|
|
419
|
+
* An expired license is legitimately issued no token. Clearing the stored
|
|
420
|
+
* one would compound an expiry the customer may be in the middle of
|
|
421
|
+
* renewing, and the refreshed expiresAt already tells the truth.
|
|
422
|
+
*/
|
|
423
|
+
expect(
|
|
424
|
+
Object.keys(sync({ token: value } as JSONObject).updateData),
|
|
425
|
+
).not.toContain("enterpriseLicenseToken");
|
|
426
|
+
},
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
it("leaves the stored token alone when the server never mentions it", () => {
|
|
430
|
+
expect(keys({ userLimit: 1 })).not.toContain("enterpriseLicenseToken");
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
describe("EnterpriseLicenseSyncUtil - instances", () => {
|
|
435
|
+
it("stores the instance list", () => {
|
|
436
|
+
const instances: Array<JSONObject> = [
|
|
437
|
+
{ instanceId: "a", host: "a.example.com" },
|
|
438
|
+
];
|
|
439
|
+
|
|
440
|
+
expect(
|
|
441
|
+
sync({ instances: instances } as JSONObject).updateData
|
|
442
|
+
.enterpriseLicenseInstances,
|
|
443
|
+
).toEqual(instances);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it("stores an empty list, so a license that lost its instances shows none", () => {
|
|
447
|
+
const result: EnterpriseLicenseSyncResult = sync({ instances: [] });
|
|
448
|
+
|
|
449
|
+
expect(Object.keys(result.updateData)).toContain(
|
|
450
|
+
"enterpriseLicenseInstances",
|
|
451
|
+
);
|
|
452
|
+
expect(result.updateData.enterpriseLicenseInstances).toEqual([]);
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it.each([
|
|
456
|
+
["null", null],
|
|
457
|
+
["an object", {}],
|
|
458
|
+
["a string", "instance"],
|
|
459
|
+
])(
|
|
460
|
+
"keeps the stored list when the server sends %s",
|
|
461
|
+
(_label: string, value: unknown) => {
|
|
462
|
+
const result: EnterpriseLicenseSyncResult = sync({
|
|
463
|
+
instances: value,
|
|
464
|
+
} as JSONObject);
|
|
465
|
+
|
|
466
|
+
expect(Object.keys(result.updateData)).not.toContain(
|
|
467
|
+
"enterpriseLicenseInstances",
|
|
468
|
+
);
|
|
469
|
+
expect(result.warnings).toHaveLength(1);
|
|
470
|
+
},
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
it("leaves the stored list alone when the server never mentions it", () => {
|
|
474
|
+
expect(keys({ userLimit: 1 })).not.toContain("enterpriseLicenseInstances");
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
describe("EnterpriseLicenseSyncUtil - what it must never write", () => {
|
|
479
|
+
it("never syncs the license key back onto the installation", () => {
|
|
480
|
+
/*
|
|
481
|
+
* The installation authenticates with the key it already holds. A response
|
|
482
|
+
* must not be able to swap it for a different one.
|
|
483
|
+
*/
|
|
484
|
+
expect(keys(serverResponse())).not.toContain("enterpriseLicenseKey");
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
it("never invents columns from unknown fields", () => {
|
|
488
|
+
expect(
|
|
489
|
+
keys({ somethingNew: "from a future oneuptime.com" } as JSONObject),
|
|
490
|
+
).toEqual([]);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it("returns an empty update for an empty response rather than a pile of nulls", () => {
|
|
494
|
+
const result: EnterpriseLicenseSyncResult = sync({});
|
|
495
|
+
|
|
496
|
+
expect(result.updateData).toEqual({});
|
|
497
|
+
expect(result.warnings).toEqual([]);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("survives a null payload", () => {
|
|
501
|
+
const result: EnterpriseLicenseSyncResult =
|
|
502
|
+
EnterpriseLicenseSyncUtil.getGlobalConfigUpdateFromLicenseResponse({
|
|
503
|
+
payload: null as unknown as JSONObject,
|
|
504
|
+
reportedAt: REPORTED_AT,
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
expect(result.updateData).toEqual({});
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
describe("EnterpriseLicenseSyncUtil - the whole response at once", () => {
|
|
512
|
+
it("mirrors every field of a healthy report", () => {
|
|
513
|
+
const result: EnterpriseLicenseSyncResult = sync(serverResponse());
|
|
514
|
+
|
|
515
|
+
expect(result.warnings).toEqual([]);
|
|
516
|
+
expect(result.updateData).toEqual({
|
|
517
|
+
enterpriseCompanyName: "Acme Inc",
|
|
518
|
+
enterpriseLicenseExpiresAt: new Date("2027-01-01T00:00:00.000Z"),
|
|
519
|
+
enterpriseLicenseUserLimit: 150,
|
|
520
|
+
enterpriseLicenseCurrentUserCount: 42,
|
|
521
|
+
enterpriseLicenseUserCountUpdatedAt: new Date("2026-08-24T09:59:00.000Z"),
|
|
522
|
+
enterpriseLicenseIsEvaluation: false,
|
|
523
|
+
enterpriseLicenseToken: "signed.jwt.token",
|
|
524
|
+
enterpriseLicenseInstances: [
|
|
525
|
+
{
|
|
526
|
+
instanceId: "instance-1",
|
|
527
|
+
host: "oneuptime.acme.internal",
|
|
528
|
+
userCount: 42,
|
|
529
|
+
lastReportedAt: "2026-08-24T09:59:00.000Z",
|
|
530
|
+
version: "12.0.19",
|
|
531
|
+
},
|
|
532
|
+
],
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it("is a no-op against the response an oneuptime.com from before this change would send", () => {
|
|
537
|
+
/*
|
|
538
|
+
* The old /report-user-count body, verbatim. userLimit already shipped in
|
|
539
|
+
* it, so the fix works against every deployed license server; the fields
|
|
540
|
+
* added alongside it must simply be left alone.
|
|
541
|
+
*/
|
|
542
|
+
const legacyBody: JSONObject = {
|
|
543
|
+
currentUserCount: 42,
|
|
544
|
+
userCountUpdatedAt: "2026-08-24T09:59:00.000Z",
|
|
545
|
+
userLimit: 150,
|
|
546
|
+
isEvaluationLicense: false,
|
|
547
|
+
instances: [],
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
const result: EnterpriseLicenseSyncResult = sync(legacyBody);
|
|
551
|
+
|
|
552
|
+
expect(result.warnings).toEqual([]);
|
|
553
|
+
expect(Object.keys(result.updateData).sort()).toEqual([
|
|
554
|
+
"enterpriseLicenseCurrentUserCount",
|
|
555
|
+
"enterpriseLicenseInstances",
|
|
556
|
+
"enterpriseLicenseIsEvaluation",
|
|
557
|
+
"enterpriseLicenseUserCountUpdatedAt",
|
|
558
|
+
"enterpriseLicenseUserLimit",
|
|
559
|
+
]);
|
|
560
|
+
expect(result.updateData.enterpriseLicenseUserLimit).toBe(150);
|
|
561
|
+
});
|
|
562
|
+
});
|
|
@@ -597,9 +597,20 @@ describe("toMetricsExplorerQueryParams", () => {
|
|
|
597
597
|
});
|
|
598
598
|
|
|
599
599
|
test("reports the signal-specific fields the metric grammar cannot express", () => {
|
|
600
|
+
const result: CrossSignalQueryParams = toMetricsExplorerQueryParams(
|
|
601
|
+
fullScope(),
|
|
602
|
+
"container.cpu.time",
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
/*
|
|
606
|
+
* serviceIds now CARRY: they ride the explorer's one-shot
|
|
607
|
+
* `services` param (resolved to resource.service.name filters on
|
|
608
|
+
* load) instead of being reported dropped.
|
|
609
|
+
*/
|
|
610
|
+
expect(result.dropped).toEqual(["traceIds", "spanIds", "severityTexts"]);
|
|
600
611
|
expect(
|
|
601
|
-
|
|
602
|
-
).
|
|
612
|
+
JSON.parse(result.params["services"] as string).length,
|
|
613
|
+
).toBeGreaterThan(0);
|
|
603
614
|
});
|
|
604
615
|
});
|
|
605
616
|
|
|
@@ -12,6 +12,7 @@ export enum RevenueEventName {
|
|
|
12
12
|
WorkspaceCreated = "workspace_created",
|
|
13
13
|
MonitorCreated = "monitor_created",
|
|
14
14
|
TeammateInvited = "teammate_invited",
|
|
15
|
+
SubscriptionStarted = "subscription_started",
|
|
15
16
|
SubscriptionUpgraded = "subscription_upgraded",
|
|
16
17
|
SubscriptionDowngraded = "subscription_downgraded",
|
|
17
18
|
}
|
|
@@ -7,6 +7,13 @@ enum AnalyticsTableName {
|
|
|
7
7
|
* attributes with a keys sidecar for arbitrary-field filtering.
|
|
8
8
|
*/
|
|
9
9
|
SecurityEvent = "SecurityEventItemV1",
|
|
10
|
+
/*
|
|
11
|
+
* Deploy/config-change markers posted by CI/CD, rendered as dashed
|
|
12
|
+
* vertical lines on metric charts. Peer of LogItemV3 in layout (tenant
|
|
13
|
+
* projectId, per-row retentionDate TTL, attributes Map + keys sidecar)
|
|
14
|
+
* but tiny in volume.
|
|
15
|
+
*/
|
|
16
|
+
ChangeEvent = "ChangeEventV1",
|
|
10
17
|
Metric = "MetricItemV3",
|
|
11
18
|
ExceptionInstance = "ExceptionItemV3",
|
|
12
19
|
Span = "SpanItemV3",
|
|
@@ -3,19 +3,14 @@
|
|
|
3
3
|
* writes it.
|
|
4
4
|
*
|
|
5
5
|
* Attribution starts in the browser (Home/Views/head-basic.ejs stores it in
|
|
6
|
-
* localStorage) and reaches the server through
|
|
6
|
+
* localStorage) and reaches the server through the signup form
|
|
7
|
+
* (App/FeatureSet/Accounts/src/Pages/Register.tsx), which posts it onto the
|
|
8
|
+
* User record.
|
|
7
9
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* /enterprise/demo, /support, /enterprise/self-hosted — goes through it.
|
|
13
|
-
*
|
|
14
|
-
* Both doors are reachable by an unauthenticated caller, so both must whitelist
|
|
15
|
-
* and length-bound what they accept. Keeping the key lists here rather than in
|
|
16
|
-
* each door means a key added for the browser cannot be silently dropped by one
|
|
17
|
-
* of the readers — which is exactly what happened to UTM parameters on the Cal
|
|
18
|
-
* path, where the webhook parsed click IDs the embed never sent.
|
|
10
|
+
* That door is reachable by an unauthenticated caller, so it must whitelist and
|
|
11
|
+
* length-bound what it accepts. Keeping the key lists here rather than in the
|
|
12
|
+
* door itself means a key added for the browser cannot be silently dropped on
|
|
13
|
+
* arrival.
|
|
19
14
|
*/
|
|
20
15
|
|
|
21
16
|
// Ad-platform click identifiers, in the spelling each platform uses on the URL.
|
|
@@ -31,9 +26,8 @@ export const AdClickIdKeys: Array<string> = [
|
|
|
31
26
|
];
|
|
32
27
|
|
|
33
28
|
/*
|
|
34
|
-
* UTM parameters travel as snake_case on a URL and
|
|
35
|
-
*
|
|
36
|
-
* Both spellings are accepted on the way in — Cal booking questions and hand
|
|
29
|
+
* UTM parameters travel as snake_case on a URL and as camelCase once they are
|
|
30
|
+
* columns on User/Project. Both spellings are accepted on the way in — hand
|
|
37
31
|
* written links produce either — and only the camelCase form is stored.
|
|
38
32
|
*/
|
|
39
33
|
export const UtmWireKeyToPropertyKey: Record<string, string> = {
|