@rustrak/client 0.15.0 → 0.15.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.
- package/README.md +4 -2
- package/dist/index.cjs +119 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +119 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -135,6 +135,8 @@ await client.issues.delete(projectId, issueId);
|
|
|
135
135
|
```typescript
|
|
136
136
|
const { items } = await client.events.list(projectId, issueId, { order: 'desc' });
|
|
137
137
|
const event = await client.events.get(projectId, issueId, eventId);
|
|
138
|
+
// Resolve the ID returned by a Sentry SDK without knowing its issue first.
|
|
139
|
+
const captured = await client.events.getBySentryId(projectId, sentryEventId);
|
|
138
140
|
console.log(event.data); // Full Sentry event payload
|
|
139
141
|
```
|
|
140
142
|
|
|
@@ -264,7 +266,7 @@ export default async function ProjectsPage() {
|
|
|
264
266
|
// `kind` is what decides: only 'unauthenticated' means "send to login".
|
|
265
267
|
// Redirecting on 'network' or 'server_error' turns a flaky connection
|
|
266
268
|
// into a login loop.
|
|
267
|
-
if (projects.error.kind === 'unauthenticated') redirect('/
|
|
269
|
+
if (projects.error.kind === 'unauthenticated') redirect('/login');
|
|
268
270
|
return <LoadFailed error={projects.error} />;
|
|
269
271
|
}
|
|
270
272
|
|
|
@@ -317,7 +319,7 @@ import type {
|
|
|
317
319
|
|
|
318
320
|
## What is Rustrak?
|
|
319
321
|
|
|
320
|
-
[Rustrak](https://rustrak.github.io/rustrak) is a self-hosted error tracking server written in Rust that
|
|
322
|
+
[Rustrak](https://rustrak.github.io/rustrak) is a self-hosted error tracking server written in Rust that accepts events from any Sentry SDK: point the SDK's DSN at it and nothing else changes. One container serves the API and the dashboard.
|
|
321
323
|
|
|
322
324
|
- [Getting Started](https://rustrak.github.io/rustrak/getting-started/overview)
|
|
323
325
|
- [Self-Hosting Guide](https://rustrak.github.io/rustrak/configuration/production)
|
package/dist/index.cjs
CHANGED
|
@@ -443,6 +443,14 @@ var projectSchema = zod.z.object({
|
|
|
443
443
|
dsn: zod.z.string(),
|
|
444
444
|
stored_event_count: zod.z.number().int(),
|
|
445
445
|
digested_event_count: zod.z.number().int(),
|
|
446
|
+
/** Accepted events the quota dropped instead of storing. */
|
|
447
|
+
rate_limited_event_count: zod.z.number().int(),
|
|
448
|
+
/**
|
|
449
|
+
* The project's own limits, or null where it follows the server's. They can
|
|
450
|
+
* only tighten `MAX_EVENTS_PER_PROJECT_*`, never raise it.
|
|
451
|
+
*/
|
|
452
|
+
rate_limit_per_minute: zod.z.number().int().nullable(),
|
|
453
|
+
rate_limit_per_hour: zod.z.number().int().nullable(),
|
|
446
454
|
created_at: dateTimeSchema,
|
|
447
455
|
updated_at: dateTimeSchema,
|
|
448
456
|
platform: zod.z.string().nullable(),
|
|
@@ -469,7 +477,14 @@ var updateProjectSchema = zod.z.object({
|
|
|
469
477
|
* Slugified server-side. Unlike on create, a taken slug is a 409 rather than
|
|
470
478
|
* being silently de-duplicated.
|
|
471
479
|
*/
|
|
472
|
-
slug: zod.z.string().min(1).optional()
|
|
480
|
+
slug: zod.z.string().min(1).optional(),
|
|
481
|
+
/** A number sets the project's own limit; null removes it. */
|
|
482
|
+
rate_limit_per_minute: zod.z.number().int().min(1).nullable().optional(),
|
|
483
|
+
rate_limit_per_hour: zod.z.number().int().min(1).nullable().optional()
|
|
484
|
+
});
|
|
485
|
+
var rateLimitsSchema = zod.z.object({
|
|
486
|
+
project_per_minute: zod.z.number().int(),
|
|
487
|
+
project_per_hour: zod.z.number().int()
|
|
473
488
|
});
|
|
474
489
|
var releaseHealthRowSchema = zod.z.object({
|
|
475
490
|
release: zod.z.string(),
|
|
@@ -712,6 +727,24 @@ var registerRequestSchema = zod.z.object({
|
|
|
712
727
|
email: zod.z.string().email(),
|
|
713
728
|
password: zod.z.string().min(1)
|
|
714
729
|
});
|
|
730
|
+
var ssoConfigSchema = zod.z.object({
|
|
731
|
+
enabled: zod.z.boolean(),
|
|
732
|
+
provider_name: zod.z.string().nullable()
|
|
733
|
+
});
|
|
734
|
+
var ssoStartSchema = zod.z.object({
|
|
735
|
+
authorization_url: zod.z.string().url()
|
|
736
|
+
});
|
|
737
|
+
var ssoLinkSchema = zod.z.object({
|
|
738
|
+
email: zod.z.string(),
|
|
739
|
+
provider_name: zod.z.string()
|
|
740
|
+
});
|
|
741
|
+
var confirmSsoLinkRequestSchema = zod.z.object({
|
|
742
|
+
password: zod.z.string().min(1)
|
|
743
|
+
});
|
|
744
|
+
var changePasswordRequestSchema = zod.z.object({
|
|
745
|
+
current_password: zod.z.string().min(1),
|
|
746
|
+
new_password: zod.z.string().min(1)
|
|
747
|
+
});
|
|
715
748
|
|
|
716
749
|
// src/errors.ts
|
|
717
750
|
var FIELD_ERROR_CODES = [
|
|
@@ -1384,6 +1417,59 @@ function readSetCookie(response) {
|
|
|
1384
1417
|
return folded === null ? [] : [folded];
|
|
1385
1418
|
}
|
|
1386
1419
|
var AuthResource = class extends BaseResource {
|
|
1420
|
+
/** Return the public SSO login configuration. */
|
|
1421
|
+
async getSsoConfig() {
|
|
1422
|
+
return this.request(
|
|
1423
|
+
() => this.http.get("auth/sso/config"),
|
|
1424
|
+
ssoConfigSchema
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
/** Begin SSO and return the provider URL plus the encrypted state cookie. */
|
|
1428
|
+
async startSso() {
|
|
1429
|
+
return this.requestResponse(
|
|
1430
|
+
() => this.http.post("auth/sso/start"),
|
|
1431
|
+
async (response) => {
|
|
1432
|
+
const cookies = readSetCookie(response);
|
|
1433
|
+
const body = await this.readJson(response);
|
|
1434
|
+
if (!body.success) return body;
|
|
1435
|
+
const data = this.validate(body.data, ssoStartSchema);
|
|
1436
|
+
if (!data.success) return data;
|
|
1437
|
+
return Ok({
|
|
1438
|
+
authorizationUrl: data.data.authorization_url,
|
|
1439
|
+
cookies
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
/** The account an SSO login is waiting to link, if any. */
|
|
1445
|
+
async getSsoLink() {
|
|
1446
|
+
return this.request(() => this.http.get("auth/sso/link"), ssoLinkSchema);
|
|
1447
|
+
}
|
|
1448
|
+
/** Link the pending SSO identity with the account's password and sign in. */
|
|
1449
|
+
async confirmSsoLink(password) {
|
|
1450
|
+
const validatedInput = this.validateInput(
|
|
1451
|
+
{ password },
|
|
1452
|
+
confirmSsoLinkRequestSchema
|
|
1453
|
+
);
|
|
1454
|
+
if (!validatedInput.success) {
|
|
1455
|
+
return validatedInput;
|
|
1456
|
+
}
|
|
1457
|
+
return this.requestResponse(
|
|
1458
|
+
() => this.http.post("auth/sso/link", { json: validatedInput.data }),
|
|
1459
|
+
(response) => this.readLoginResult(response)
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
/** Complete an OIDC callback and return the normal Rustrak session cookie. */
|
|
1463
|
+
async completeSso(callback) {
|
|
1464
|
+
const searchParams = new URLSearchParams();
|
|
1465
|
+
if (callback.code) searchParams.set("code", callback.code);
|
|
1466
|
+
if (callback.state) searchParams.set("state", callback.state);
|
|
1467
|
+
if (callback.error) searchParams.set("error", callback.error);
|
|
1468
|
+
return this.requestResponse(
|
|
1469
|
+
() => this.http.get("auth/sso/callback", { searchParams }),
|
|
1470
|
+
(response) => this.readLoginResult(response)
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1387
1473
|
/**
|
|
1388
1474
|
* Register a new user account
|
|
1389
1475
|
* Creates a new user and automatically logs them in (sets session cookie)
|
|
@@ -1466,6 +1552,20 @@ var AuthResource = class extends BaseResource {
|
|
|
1466
1552
|
userSchema
|
|
1467
1553
|
);
|
|
1468
1554
|
}
|
|
1555
|
+
/** Replaces the signed-in user's password, given the current one. */
|
|
1556
|
+
async changePassword(request) {
|
|
1557
|
+
const validatedInput = this.validateInput(
|
|
1558
|
+
request,
|
|
1559
|
+
changePasswordRequestSchema
|
|
1560
|
+
);
|
|
1561
|
+
if (!validatedInput.success) return validatedInput;
|
|
1562
|
+
return this.requestVoid(
|
|
1563
|
+
() => this.http.post("auth/me/password", {
|
|
1564
|
+
json: validatedInput.data,
|
|
1565
|
+
retry: 0
|
|
1566
|
+
})
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1469
1569
|
/**
|
|
1470
1570
|
* Get the details of a pending invitation by its token (public endpoint)
|
|
1471
1571
|
* Used by the accept-invitation page before the user has an account
|
|
@@ -1545,6 +1645,15 @@ var EventsResource = class extends BaseResource {
|
|
|
1545
1645
|
eventDetailSchema
|
|
1546
1646
|
);
|
|
1547
1647
|
}
|
|
1648
|
+
/** Resolve the client-supplied Sentry event ID, including its owning issue. */
|
|
1649
|
+
async getBySentryId(projectId, eventId) {
|
|
1650
|
+
return this.request(
|
|
1651
|
+
() => this.http.get(
|
|
1652
|
+
`api/projects/${projectId}/events/sentry/${encodeURIComponent(eventId)}`
|
|
1653
|
+
),
|
|
1654
|
+
eventDetailSchema
|
|
1655
|
+
);
|
|
1656
|
+
}
|
|
1548
1657
|
};
|
|
1549
1658
|
var serverVersionSchema = zod.z.object({
|
|
1550
1659
|
version: zod.z.string()
|
|
@@ -1919,6 +2028,15 @@ var ProjectsResource = class extends BaseResource {
|
|
|
1919
2028
|
offsetPaginatedResponseSchema(projectSchema)
|
|
1920
2029
|
);
|
|
1921
2030
|
}
|
|
2031
|
+
/**
|
|
2032
|
+
* The server's per-project limits, which a project without its own follows
|
|
2033
|
+
*/
|
|
2034
|
+
async rateLimits() {
|
|
2035
|
+
return this.request(
|
|
2036
|
+
() => this.http.get("api/rate-limits"),
|
|
2037
|
+
rateLimitsSchema
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
1922
2040
|
/**
|
|
1923
2041
|
* Get a single project by ID
|
|
1924
2042
|
*/
|