Development #24
@@ -41,6 +41,7 @@
|
||||
"twilio": "^5.8.0",
|
||||
"vaul": "^1.1.2",
|
||||
"web-push": "^3.6.7",
|
||||
"web-vitals": "^6.2.0",
|
||||
"zod": "^4.0.15",
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1590,6 +1591,8 @@
|
||||
|
||||
"web-push": ["web-push@3.6.7", "", { "dependencies": { "asn1.js": "^5.3.0", "http_ece": "1.2.0", "https-proxy-agent": "^7.0.0", "jws": "^4.0.0", "minimist": "^1.2.5" }, "bin": { "web-push": "src/cli.js" } }, "sha512-OpiIUe8cuGjrj3mMBFWY+e4MMIkW3SVT+7vEIjvD9kejGUypv8GPDf84JdPWskK8zMRIJ6xYGm+Kxr8YkPyA0A=="],
|
||||
|
||||
"web-vitals": ["web-vitals@6.2.0", "", {}, "sha512-i2jhLkq6eB38jgJX5OIjEkyzQKgsG7FR56v7GphJNjzKAySgbRbwAfsFC0dDfHROWmCycf912SJpU2QoYIcMVg=="],
|
||||
|
||||
"webidl-conversions": ["webidl-conversions@4.0.2", "", {}, "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg=="],
|
||||
|
||||
"webpack-virtual-modules": ["webpack-virtual-modules@0.6.2", "", {}, "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ=="],
|
||||
|
||||
@@ -55,6 +55,12 @@ spec:
|
||||
value: "3000"
|
||||
- name: NODE_ENV
|
||||
value: "production"
|
||||
- name: TELEMETRY_EXCLUDE_PHONES
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: flxn-secrets
|
||||
key: telemetry_exclude_phones
|
||||
optional: true
|
||||
|
||||
- name: TWILIO_ACCOUNT_SID
|
||||
valueFrom:
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
"twilio": "^5.8.0",
|
||||
"vaul": "^1.1.2",
|
||||
"web-push": "^3.6.7",
|
||||
"web-vitals": "^6.2.0",
|
||||
"zod": "^4.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1262591861")
|
||||
|
||||
unmarshal({
|
||||
"indexes": [
|
||||
"CREATE INDEX `idx_activities_created` ON `activities` (`created`)",
|
||||
"CREATE INDEX `idx_activities_name_created` ON `activities` (`name`, `created`)",
|
||||
"CREATE INDEX `idx_activities_player_created` ON `activities` (`player`, `created`)",
|
||||
"CREATE INDEX `idx_activities_success_created` ON `activities` (`success`, `created`)"
|
||||
]
|
||||
}, collection)
|
||||
|
||||
return app.save(collection)
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_1262591861")
|
||||
|
||||
unmarshal({
|
||||
"indexes": []
|
||||
}, collection)
|
||||
|
||||
return app.save(collection)
|
||||
})
|
||||
@@ -0,0 +1,167 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = new Collection({
|
||||
"createRule": null,
|
||||
"deleteRule": null,
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ce_name",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "name",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_3072146508",
|
||||
"hidden": false,
|
||||
"id": "relation_ce_player",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "player",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ce_session_id",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "session_id",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ce_path",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "path",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ce_route_id",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "route_id",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number_ce_value",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "value",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json_ce_props",
|
||||
"maxSize": 0,
|
||||
"name": "props",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ce_user_agent",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "user_agent",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"id": "pbc_client_events",
|
||||
"indexes": [
|
||||
"CREATE INDEX `idx_client_events_created` ON `client_events` (`created`)",
|
||||
"CREATE INDEX `idx_client_events_name_created` ON `client_events` (`name`, `created`)",
|
||||
"CREATE INDEX `idx_client_events_player_created` ON `client_events` (`player`, `created`)",
|
||||
"CREATE INDEX `idx_client_events_session_id` ON `client_events` (`session_id`)"
|
||||
],
|
||||
"listRule": null,
|
||||
"name": "client_events",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": null,
|
||||
"viewRule": null
|
||||
});
|
||||
|
||||
return app.save(collection);
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_client_events");
|
||||
|
||||
return app.delete(collection);
|
||||
})
|
||||
@@ -0,0 +1,207 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const collection = new Collection({
|
||||
"createRule": null,
|
||||
"deleteRule": null,
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_message",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "message",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_stack",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "stack",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "select_cerr_source",
|
||||
"maxSelect": 1,
|
||||
"name": "source",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"window",
|
||||
"unhandledrejection",
|
||||
"error-boundary",
|
||||
"sw"
|
||||
]
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_path",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "path",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_route_id",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "route_id",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_group_hash",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "group_hash",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "bool_cerr_resolved",
|
||||
"name": "resolved",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"cascadeDelete": false,
|
||||
"collectionId": "pbc_3072146508",
|
||||
"hidden": false,
|
||||
"id": "relation_cerr_player",
|
||||
"maxSelect": 1,
|
||||
"minSelect": 0,
|
||||
"name": "player",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "relation"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_session_id",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "session_id",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_cerr_user_agent",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "user_agent",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json_cerr_props",
|
||||
"maxSize": 0,
|
||||
"name": "props",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"id": "pbc_client_errors",
|
||||
"indexes": [
|
||||
"CREATE INDEX `idx_client_errors_group_created` ON `client_errors` (`group_hash`, `created`)",
|
||||
"CREATE INDEX `idx_client_errors_created` ON `client_errors` (`created`)",
|
||||
"CREATE INDEX `idx_client_errors_resolved_created` ON `client_errors` (`resolved`, `created`)"
|
||||
],
|
||||
"listRule": null,
|
||||
"name": "client_errors",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": null,
|
||||
"viewRule": null
|
||||
});
|
||||
|
||||
return app.save(collection);
|
||||
}, (app) => {
|
||||
const collection = app.findCollectionByNameOrId("pbc_client_errors");
|
||||
|
||||
return app.delete(collection);
|
||||
})
|
||||
@@ -0,0 +1,240 @@
|
||||
/// <reference path="../pb_data/types.d.ts" />
|
||||
migrate((app) => {
|
||||
const rollups = new Collection({
|
||||
"createRule": null,
|
||||
"deleteRule": null,
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_tr_date",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "date",
|
||||
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_tr_metric",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "metric",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_tr_dim",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "dim",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number_tr_value",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "value",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json_tr_meta",
|
||||
"maxSize": 0,
|
||||
"name": "meta",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"id": "pbc_telemetry_rollups",
|
||||
"indexes": [
|
||||
"CREATE UNIQUE INDEX `idx_rollups_date_metric_dim` ON `telemetry_rollups` (`date`, `metric`, `dim`)",
|
||||
"CREATE INDEX `idx_rollups_metric_date` ON `telemetry_rollups` (`metric`, `date`)"
|
||||
],
|
||||
"listRule": null,
|
||||
"name": "telemetry_rollups",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": null,
|
||||
"viewRule": null
|
||||
});
|
||||
|
||||
app.save(rollups);
|
||||
|
||||
const alerts = new Collection({
|
||||
"createRule": null,
|
||||
"deleteRule": null,
|
||||
"fields": [
|
||||
{
|
||||
"autogeneratePattern": "[a-z0-9]{15}",
|
||||
"hidden": false,
|
||||
"id": "text3208210256",
|
||||
"max": 15,
|
||||
"min": 15,
|
||||
"name": "id",
|
||||
"pattern": "^[a-z0-9]+$",
|
||||
"presentable": false,
|
||||
"primaryKey": true,
|
||||
"required": true,
|
||||
"system": true,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ta_kind",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "kind",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": true,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ta_dim",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "dim",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text_ta_message",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "message",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "number_ta_value",
|
||||
"max": null,
|
||||
"min": null,
|
||||
"name": "value",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "json_ta_meta",
|
||||
"maxSize": 0,
|
||||
"name": "meta",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "json"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate2990389176",
|
||||
"name": "created",
|
||||
"onCreate": true,
|
||||
"onUpdate": false,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"id": "autodate3332085495",
|
||||
"name": "updated",
|
||||
"onCreate": true,
|
||||
"onUpdate": true,
|
||||
"presentable": false,
|
||||
"system": false,
|
||||
"type": "autodate"
|
||||
}
|
||||
],
|
||||
"id": "pbc_telemetry_alerts",
|
||||
"indexes": [
|
||||
"CREATE INDEX `idx_alerts_kind_dim_created` ON `telemetry_alerts` (`kind`, `dim`, `created`)"
|
||||
],
|
||||
"listRule": null,
|
||||
"name": "telemetry_alerts",
|
||||
"system": false,
|
||||
"type": "base",
|
||||
"updateRule": null,
|
||||
"viewRule": null
|
||||
});
|
||||
|
||||
return app.save(alerts);
|
||||
}, (app) => {
|
||||
app.delete(app.findCollectionByNameOrId("pbc_telemetry_alerts"));
|
||||
return app.delete(app.findCollectionByNameOrId("pbc_telemetry_rollups"));
|
||||
})
|
||||
+206
-1
@@ -22,6 +22,7 @@ import { Route as AuthedAdminRouteImport } from './routes/_authed/admin'
|
||||
import { Route as AuthedTournamentsIndexRouteImport } from './routes/_authed/tournaments/index'
|
||||
import { Route as AuthedAdminIndexRouteImport } from './routes/_authed/admin/index'
|
||||
import { Route as ApiTournamentsUploadLogoRouteImport } from './routes/api/tournaments/upload-logo'
|
||||
import { Route as ApiTelemetryBeaconRouteImport } from './routes/api/telemetry/beacon'
|
||||
import { Route as ApiTeamsUploadLogoRouteImport } from './routes/api/teams/upload-logo'
|
||||
import { Route as ApiSpotifyTokenRouteImport } from './routes/api/spotify/token'
|
||||
import { Route as ApiSpotifySearchRouteImport } from './routes/api/spotify/search'
|
||||
@@ -37,19 +38,27 @@ import { Route as ApiAuthSplatRouteImport } from './routes/api/auth.$'
|
||||
import { Route as AuthedTournamentsTournamentIdRouteImport } from './routes/_authed/tournaments/$tournamentId'
|
||||
import { Route as AuthedTeamsTeamIdRouteImport } from './routes/_authed/teams.$teamId'
|
||||
import { Route as AuthedProfilePlayerIdRouteImport } from './routes/_authed/profile.$playerId'
|
||||
import { Route as AuthedAdminTelemetryRouteImport } from './routes/_authed/admin/telemetry'
|
||||
import { Route as AuthedAdminPreviewRouteImport } from './routes/_authed/admin/preview'
|
||||
import { Route as AuthedAdminBadgesRouteImport } from './routes/_authed/admin/badges'
|
||||
import { Route as AuthedAdminActivitiesRouteImport } from './routes/_authed/admin/activities'
|
||||
import { Route as AuthedAdminTournamentsIndexRouteImport } from './routes/_authed/admin/tournaments/index'
|
||||
import { Route as AuthedAdminTelemetryIndexRouteImport } from './routes/_authed/admin/telemetry/index'
|
||||
import { Route as AuthedTournamentsIdPredictionsRouteImport } from './routes/_authed/tournaments/$id.predictions'
|
||||
import { Route as AuthedTournamentsIdGroupsRouteImport } from './routes/_authed/tournaments/$id.groups'
|
||||
import { Route as AuthedTournamentsIdBracketRouteImport } from './routes/_authed/tournaments/$id.bracket'
|
||||
import { Route as AuthedAdminTelemetryUsageRouteImport } from './routes/_authed/admin/telemetry/usage'
|
||||
import { Route as AuthedAdminTelemetrySessionsRouteImport } from './routes/_authed/admin/telemetry/sessions'
|
||||
import { Route as AuthedAdminTelemetryPlayersRouteImport } from './routes/_authed/admin/telemetry/players'
|
||||
import { Route as AuthedAdminTelemetryFunctionsRouteImport } from './routes/_authed/admin/telemetry/functions'
|
||||
import { Route as AuthedAdminTelemetryErrorsRouteImport } from './routes/_authed/admin/telemetry/errors'
|
||||
import { Route as AuthedAdminTournamentsIdIndexRouteImport } from './routes/_authed/admin/tournaments/$id/index'
|
||||
import { Route as ApiFilesCollectionRecordIdFileRouteImport } from './routes/api/files/$collection/$recordId/$file'
|
||||
import { Route as AuthedTournamentsIdPredictionsMakeRouteImport } from './routes/_authed/tournaments/$id.predictions_.make'
|
||||
import { Route as AuthedTournamentsIdPredictionsPlayerIdRouteImport } from './routes/_authed/tournaments/$id.predictions_.$playerId'
|
||||
import { Route as AuthedAdminTournamentsRunIdRouteImport } from './routes/_authed/admin/tournaments/run.$id'
|
||||
import { Route as AuthedAdminTournamentsIdTeamsRouteImport } from './routes/_authed/admin/tournaments/$id/teams'
|
||||
import { Route as AuthedAdminTournamentsIdEnrollmentRouteImport } from './routes/_authed/admin/tournaments/$id/enrollment'
|
||||
import { Route as AuthedAdminTournamentsIdAssignPartnersRouteImport } from './routes/_authed/admin/tournaments/$id/assign-partners'
|
||||
|
||||
const RefreshSessionRoute = RefreshSessionRouteImport.update({
|
||||
@@ -117,6 +126,11 @@ const ApiTournamentsUploadLogoRoute =
|
||||
path: '/api/tournaments/upload-logo',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiTelemetryBeaconRoute = ApiTelemetryBeaconRouteImport.update({
|
||||
id: '/api/telemetry/beacon',
|
||||
path: '/api/telemetry/beacon',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const ApiTeamsUploadLogoRoute = ApiTeamsUploadLogoRouteImport.update({
|
||||
id: '/api/teams/upload-logo',
|
||||
path: '/api/teams/upload-logo',
|
||||
@@ -193,6 +207,11 @@ const AuthedProfilePlayerIdRoute = AuthedProfilePlayerIdRouteImport.update({
|
||||
path: '/profile/$playerId',
|
||||
getParentRoute: () => AuthedRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryRoute = AuthedAdminTelemetryRouteImport.update({
|
||||
id: '/telemetry',
|
||||
path: '/telemetry',
|
||||
getParentRoute: () => AuthedAdminRoute,
|
||||
} as any)
|
||||
const AuthedAdminPreviewRoute = AuthedAdminPreviewRouteImport.update({
|
||||
id: '/preview',
|
||||
path: '/preview',
|
||||
@@ -214,6 +233,12 @@ const AuthedAdminTournamentsIndexRoute =
|
||||
path: '/tournaments/',
|
||||
getParentRoute: () => AuthedAdminRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryIndexRoute =
|
||||
AuthedAdminTelemetryIndexRouteImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedTournamentsIdPredictionsRoute =
|
||||
AuthedTournamentsIdPredictionsRouteImport.update({
|
||||
id: '/tournaments/$id/predictions',
|
||||
@@ -232,6 +257,36 @@ const AuthedTournamentsIdBracketRoute =
|
||||
path: '/tournaments/$id/bracket',
|
||||
getParentRoute: () => AuthedRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryUsageRoute =
|
||||
AuthedAdminTelemetryUsageRouteImport.update({
|
||||
id: '/usage',
|
||||
path: '/usage',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetrySessionsRoute =
|
||||
AuthedAdminTelemetrySessionsRouteImport.update({
|
||||
id: '/sessions',
|
||||
path: '/sessions',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryPlayersRoute =
|
||||
AuthedAdminTelemetryPlayersRouteImport.update({
|
||||
id: '/players',
|
||||
path: '/players',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryFunctionsRoute =
|
||||
AuthedAdminTelemetryFunctionsRouteImport.update({
|
||||
id: '/functions',
|
||||
path: '/functions',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedAdminTelemetryErrorsRoute =
|
||||
AuthedAdminTelemetryErrorsRouteImport.update({
|
||||
id: '/errors',
|
||||
path: '/errors',
|
||||
getParentRoute: () => AuthedAdminTelemetryRoute,
|
||||
} as any)
|
||||
const AuthedAdminTournamentsIdIndexRoute =
|
||||
AuthedAdminTournamentsIdIndexRouteImport.update({
|
||||
id: '/tournaments/$id/',
|
||||
@@ -268,6 +323,12 @@ const AuthedAdminTournamentsIdTeamsRoute =
|
||||
path: '/tournaments/$id/teams',
|
||||
getParentRoute: () => AuthedAdminRoute,
|
||||
} as any)
|
||||
const AuthedAdminTournamentsIdEnrollmentRoute =
|
||||
AuthedAdminTournamentsIdEnrollmentRouteImport.update({
|
||||
id: '/tournaments/$id/enrollment',
|
||||
path: '/tournaments/$id/enrollment',
|
||||
getParentRoute: () => AuthedAdminRoute,
|
||||
} as any)
|
||||
const AuthedAdminTournamentsIdAssignPartnersRoute =
|
||||
AuthedAdminTournamentsIdAssignPartnersRouteImport.update({
|
||||
id: '/tournaments/$id/assign-partners',
|
||||
@@ -288,6 +349,7 @@ export interface FileRoutesByFullPath {
|
||||
'/admin/activities': typeof AuthedAdminActivitiesRoute
|
||||
'/admin/badges': typeof AuthedAdminBadgesRoute
|
||||
'/admin/preview': typeof AuthedAdminPreviewRoute
|
||||
'/admin/telemetry': typeof AuthedAdminTelemetryRouteWithChildren
|
||||
'/profile/$playerId': typeof AuthedProfilePlayerIdRoute
|
||||
'/teams/$teamId': typeof AuthedTeamsTeamIdRoute
|
||||
'/tournaments/$tournamentId': typeof AuthedTournamentsTournamentIdRoute
|
||||
@@ -303,14 +365,22 @@ export interface FileRoutesByFullPath {
|
||||
'/api/spotify/search': typeof ApiSpotifySearchRoute
|
||||
'/api/spotify/token': typeof ApiSpotifyTokenRoute
|
||||
'/api/teams/upload-logo': typeof ApiTeamsUploadLogoRoute
|
||||
'/api/telemetry/beacon': typeof ApiTelemetryBeaconRoute
|
||||
'/api/tournaments/upload-logo': typeof ApiTournamentsUploadLogoRoute
|
||||
'/admin/': typeof AuthedAdminIndexRoute
|
||||
'/tournaments/': typeof AuthedTournamentsIndexRoute
|
||||
'/admin/telemetry/errors': typeof AuthedAdminTelemetryErrorsRoute
|
||||
'/admin/telemetry/functions': typeof AuthedAdminTelemetryFunctionsRoute
|
||||
'/admin/telemetry/players': typeof AuthedAdminTelemetryPlayersRoute
|
||||
'/admin/telemetry/sessions': typeof AuthedAdminTelemetrySessionsRoute
|
||||
'/admin/telemetry/usage': typeof AuthedAdminTelemetryUsageRoute
|
||||
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||
'/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||
'/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||
'/admin/telemetry/': typeof AuthedAdminTelemetryIndexRoute
|
||||
'/admin/tournaments/': typeof AuthedAdminTournamentsIndexRoute
|
||||
'/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||
'/admin/tournaments/$id/enrollment': typeof AuthedAdminTournamentsIdEnrollmentRoute
|
||||
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||
'/tournaments/$id/predictions/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||
@@ -345,14 +415,22 @@ export interface FileRoutesByTo {
|
||||
'/api/spotify/search': typeof ApiSpotifySearchRoute
|
||||
'/api/spotify/token': typeof ApiSpotifyTokenRoute
|
||||
'/api/teams/upload-logo': typeof ApiTeamsUploadLogoRoute
|
||||
'/api/telemetry/beacon': typeof ApiTelemetryBeaconRoute
|
||||
'/api/tournaments/upload-logo': typeof ApiTournamentsUploadLogoRoute
|
||||
'/admin': typeof AuthedAdminIndexRoute
|
||||
'/tournaments': typeof AuthedTournamentsIndexRoute
|
||||
'/admin/telemetry/errors': typeof AuthedAdminTelemetryErrorsRoute
|
||||
'/admin/telemetry/functions': typeof AuthedAdminTelemetryFunctionsRoute
|
||||
'/admin/telemetry/players': typeof AuthedAdminTelemetryPlayersRoute
|
||||
'/admin/telemetry/sessions': typeof AuthedAdminTelemetrySessionsRoute
|
||||
'/admin/telemetry/usage': typeof AuthedAdminTelemetryUsageRoute
|
||||
'/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||
'/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||
'/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||
'/admin/telemetry': typeof AuthedAdminTelemetryIndexRoute
|
||||
'/admin/tournaments': typeof AuthedAdminTournamentsIndexRoute
|
||||
'/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||
'/admin/tournaments/$id/enrollment': typeof AuthedAdminTournamentsIdEnrollmentRoute
|
||||
'/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||
'/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||
'/tournaments/$id/predictions/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||
@@ -375,6 +453,7 @@ export interface FileRoutesById {
|
||||
'/_authed/admin/activities': typeof AuthedAdminActivitiesRoute
|
||||
'/_authed/admin/badges': typeof AuthedAdminBadgesRoute
|
||||
'/_authed/admin/preview': typeof AuthedAdminPreviewRoute
|
||||
'/_authed/admin/telemetry': typeof AuthedAdminTelemetryRouteWithChildren
|
||||
'/_authed/profile/$playerId': typeof AuthedProfilePlayerIdRoute
|
||||
'/_authed/teams/$teamId': typeof AuthedTeamsTeamIdRoute
|
||||
'/_authed/tournaments/$tournamentId': typeof AuthedTournamentsTournamentIdRoute
|
||||
@@ -390,14 +469,22 @@ export interface FileRoutesById {
|
||||
'/api/spotify/search': typeof ApiSpotifySearchRoute
|
||||
'/api/spotify/token': typeof ApiSpotifyTokenRoute
|
||||
'/api/teams/upload-logo': typeof ApiTeamsUploadLogoRoute
|
||||
'/api/telemetry/beacon': typeof ApiTelemetryBeaconRoute
|
||||
'/api/tournaments/upload-logo': typeof ApiTournamentsUploadLogoRoute
|
||||
'/_authed/admin/': typeof AuthedAdminIndexRoute
|
||||
'/_authed/tournaments/': typeof AuthedTournamentsIndexRoute
|
||||
'/_authed/admin/telemetry/errors': typeof AuthedAdminTelemetryErrorsRoute
|
||||
'/_authed/admin/telemetry/functions': typeof AuthedAdminTelemetryFunctionsRoute
|
||||
'/_authed/admin/telemetry/players': typeof AuthedAdminTelemetryPlayersRoute
|
||||
'/_authed/admin/telemetry/sessions': typeof AuthedAdminTelemetrySessionsRoute
|
||||
'/_authed/admin/telemetry/usage': typeof AuthedAdminTelemetryUsageRoute
|
||||
'/_authed/tournaments/$id/bracket': typeof AuthedTournamentsIdBracketRoute
|
||||
'/_authed/tournaments/$id/groups': typeof AuthedTournamentsIdGroupsRoute
|
||||
'/_authed/tournaments/$id/predictions': typeof AuthedTournamentsIdPredictionsRoute
|
||||
'/_authed/admin/telemetry/': typeof AuthedAdminTelemetryIndexRoute
|
||||
'/_authed/admin/tournaments/': typeof AuthedAdminTournamentsIndexRoute
|
||||
'/_authed/admin/tournaments/$id/assign-partners': typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||
'/_authed/admin/tournaments/$id/enrollment': typeof AuthedAdminTournamentsIdEnrollmentRoute
|
||||
'/_authed/admin/tournaments/$id/teams': typeof AuthedAdminTournamentsIdTeamsRoute
|
||||
'/_authed/admin/tournaments/run/$id': typeof AuthedAdminTournamentsRunIdRoute
|
||||
'/_authed/tournaments/$id/predictions_/$playerId': typeof AuthedTournamentsIdPredictionsPlayerIdRoute
|
||||
@@ -420,6 +507,7 @@ export interface FileRouteTypes {
|
||||
| '/admin/activities'
|
||||
| '/admin/badges'
|
||||
| '/admin/preview'
|
||||
| '/admin/telemetry'
|
||||
| '/profile/$playerId'
|
||||
| '/teams/$teamId'
|
||||
| '/tournaments/$tournamentId'
|
||||
@@ -435,14 +523,22 @@ export interface FileRouteTypes {
|
||||
| '/api/spotify/search'
|
||||
| '/api/spotify/token'
|
||||
| '/api/teams/upload-logo'
|
||||
| '/api/telemetry/beacon'
|
||||
| '/api/tournaments/upload-logo'
|
||||
| '/admin/'
|
||||
| '/tournaments/'
|
||||
| '/admin/telemetry/errors'
|
||||
| '/admin/telemetry/functions'
|
||||
| '/admin/telemetry/players'
|
||||
| '/admin/telemetry/sessions'
|
||||
| '/admin/telemetry/usage'
|
||||
| '/tournaments/$id/bracket'
|
||||
| '/tournaments/$id/groups'
|
||||
| '/tournaments/$id/predictions'
|
||||
| '/admin/telemetry/'
|
||||
| '/admin/tournaments/'
|
||||
| '/admin/tournaments/$id/assign-partners'
|
||||
| '/admin/tournaments/$id/enrollment'
|
||||
| '/admin/tournaments/$id/teams'
|
||||
| '/admin/tournaments/run/$id'
|
||||
| '/tournaments/$id/predictions/$playerId'
|
||||
@@ -477,14 +573,22 @@ export interface FileRouteTypes {
|
||||
| '/api/spotify/search'
|
||||
| '/api/spotify/token'
|
||||
| '/api/teams/upload-logo'
|
||||
| '/api/telemetry/beacon'
|
||||
| '/api/tournaments/upload-logo'
|
||||
| '/admin'
|
||||
| '/tournaments'
|
||||
| '/admin/telemetry/errors'
|
||||
| '/admin/telemetry/functions'
|
||||
| '/admin/telemetry/players'
|
||||
| '/admin/telemetry/sessions'
|
||||
| '/admin/telemetry/usage'
|
||||
| '/tournaments/$id/bracket'
|
||||
| '/tournaments/$id/groups'
|
||||
| '/tournaments/$id/predictions'
|
||||
| '/admin/telemetry'
|
||||
| '/admin/tournaments'
|
||||
| '/admin/tournaments/$id/assign-partners'
|
||||
| '/admin/tournaments/$id/enrollment'
|
||||
| '/admin/tournaments/$id/teams'
|
||||
| '/admin/tournaments/run/$id'
|
||||
| '/tournaments/$id/predictions/$playerId'
|
||||
@@ -506,6 +610,7 @@ export interface FileRouteTypes {
|
||||
| '/_authed/admin/activities'
|
||||
| '/_authed/admin/badges'
|
||||
| '/_authed/admin/preview'
|
||||
| '/_authed/admin/telemetry'
|
||||
| '/_authed/profile/$playerId'
|
||||
| '/_authed/teams/$teamId'
|
||||
| '/_authed/tournaments/$tournamentId'
|
||||
@@ -521,14 +626,22 @@ export interface FileRouteTypes {
|
||||
| '/api/spotify/search'
|
||||
| '/api/spotify/token'
|
||||
| '/api/teams/upload-logo'
|
||||
| '/api/telemetry/beacon'
|
||||
| '/api/tournaments/upload-logo'
|
||||
| '/_authed/admin/'
|
||||
| '/_authed/tournaments/'
|
||||
| '/_authed/admin/telemetry/errors'
|
||||
| '/_authed/admin/telemetry/functions'
|
||||
| '/_authed/admin/telemetry/players'
|
||||
| '/_authed/admin/telemetry/sessions'
|
||||
| '/_authed/admin/telemetry/usage'
|
||||
| '/_authed/tournaments/$id/bracket'
|
||||
| '/_authed/tournaments/$id/groups'
|
||||
| '/_authed/tournaments/$id/predictions'
|
||||
| '/_authed/admin/telemetry/'
|
||||
| '/_authed/admin/tournaments/'
|
||||
| '/_authed/admin/tournaments/$id/assign-partners'
|
||||
| '/_authed/admin/tournaments/$id/enrollment'
|
||||
| '/_authed/admin/tournaments/$id/teams'
|
||||
| '/_authed/admin/tournaments/run/$id'
|
||||
| '/_authed/tournaments/$id/predictions_/$playerId'
|
||||
@@ -555,6 +668,7 @@ export interface RootRouteChildren {
|
||||
ApiSpotifySearchRoute: typeof ApiSpotifySearchRoute
|
||||
ApiSpotifyTokenRoute: typeof ApiSpotifyTokenRoute
|
||||
ApiTeamsUploadLogoRoute: typeof ApiTeamsUploadLogoRoute
|
||||
ApiTelemetryBeaconRoute: typeof ApiTelemetryBeaconRoute
|
||||
ApiTournamentsUploadLogoRoute: typeof ApiTournamentsUploadLogoRoute
|
||||
ApiFilesCollectionRecordIdFileRoute: typeof ApiFilesCollectionRecordIdFileRoute
|
||||
}
|
||||
@@ -652,6 +766,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiTournamentsUploadLogoRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/telemetry/beacon': {
|
||||
id: '/api/telemetry/beacon'
|
||||
path: '/api/telemetry/beacon'
|
||||
fullPath: '/api/telemetry/beacon'
|
||||
preLoaderRoute: typeof ApiTelemetryBeaconRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/api/teams/upload-logo': {
|
||||
id: '/api/teams/upload-logo'
|
||||
path: '/api/teams/upload-logo'
|
||||
@@ -757,6 +878,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthedProfilePlayerIdRouteImport
|
||||
parentRoute: typeof AuthedRoute
|
||||
}
|
||||
'/_authed/admin/telemetry': {
|
||||
id: '/_authed/admin/telemetry'
|
||||
path: '/telemetry'
|
||||
fullPath: '/admin/telemetry'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryRouteImport
|
||||
parentRoute: typeof AuthedAdminRoute
|
||||
}
|
||||
'/_authed/admin/preview': {
|
||||
id: '/_authed/admin/preview'
|
||||
path: '/preview'
|
||||
@@ -785,6 +913,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthedAdminTournamentsIndexRouteImport
|
||||
parentRoute: typeof AuthedAdminRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/': {
|
||||
id: '/_authed/admin/telemetry/'
|
||||
path: '/'
|
||||
fullPath: '/admin/telemetry/'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryIndexRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/tournaments/$id/predictions': {
|
||||
id: '/_authed/tournaments/$id/predictions'
|
||||
path: '/tournaments/$id/predictions'
|
||||
@@ -806,6 +941,41 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthedTournamentsIdBracketRouteImport
|
||||
parentRoute: typeof AuthedRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/usage': {
|
||||
id: '/_authed/admin/telemetry/usage'
|
||||
path: '/usage'
|
||||
fullPath: '/admin/telemetry/usage'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryUsageRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/sessions': {
|
||||
id: '/_authed/admin/telemetry/sessions'
|
||||
path: '/sessions'
|
||||
fullPath: '/admin/telemetry/sessions'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetrySessionsRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/players': {
|
||||
id: '/_authed/admin/telemetry/players'
|
||||
path: '/players'
|
||||
fullPath: '/admin/telemetry/players'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryPlayersRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/functions': {
|
||||
id: '/_authed/admin/telemetry/functions'
|
||||
path: '/functions'
|
||||
fullPath: '/admin/telemetry/functions'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryFunctionsRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/admin/telemetry/errors': {
|
||||
id: '/_authed/admin/telemetry/errors'
|
||||
path: '/errors'
|
||||
fullPath: '/admin/telemetry/errors'
|
||||
preLoaderRoute: typeof AuthedAdminTelemetryErrorsRouteImport
|
||||
parentRoute: typeof AuthedAdminTelemetryRoute
|
||||
}
|
||||
'/_authed/admin/tournaments/$id/': {
|
||||
id: '/_authed/admin/tournaments/$id/'
|
||||
path: '/tournaments/$id'
|
||||
@@ -848,6 +1018,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthedAdminTournamentsIdTeamsRouteImport
|
||||
parentRoute: typeof AuthedAdminRoute
|
||||
}
|
||||
'/_authed/admin/tournaments/$id/enrollment': {
|
||||
id: '/_authed/admin/tournaments/$id/enrollment'
|
||||
path: '/tournaments/$id/enrollment'
|
||||
fullPath: '/admin/tournaments/$id/enrollment'
|
||||
preLoaderRoute: typeof AuthedAdminTournamentsIdEnrollmentRouteImport
|
||||
parentRoute: typeof AuthedAdminRoute
|
||||
}
|
||||
'/_authed/admin/tournaments/$id/assign-partners': {
|
||||
id: '/_authed/admin/tournaments/$id/assign-partners'
|
||||
path: '/tournaments/$id/assign-partners'
|
||||
@@ -858,13 +1035,36 @@ declare module '@tanstack/react-router' {
|
||||
}
|
||||
}
|
||||
|
||||
interface AuthedAdminTelemetryRouteChildren {
|
||||
AuthedAdminTelemetryErrorsRoute: typeof AuthedAdminTelemetryErrorsRoute
|
||||
AuthedAdminTelemetryFunctionsRoute: typeof AuthedAdminTelemetryFunctionsRoute
|
||||
AuthedAdminTelemetryPlayersRoute: typeof AuthedAdminTelemetryPlayersRoute
|
||||
AuthedAdminTelemetrySessionsRoute: typeof AuthedAdminTelemetrySessionsRoute
|
||||
AuthedAdminTelemetryUsageRoute: typeof AuthedAdminTelemetryUsageRoute
|
||||
AuthedAdminTelemetryIndexRoute: typeof AuthedAdminTelemetryIndexRoute
|
||||
}
|
||||
|
||||
const AuthedAdminTelemetryRouteChildren: AuthedAdminTelemetryRouteChildren = {
|
||||
AuthedAdminTelemetryErrorsRoute: AuthedAdminTelemetryErrorsRoute,
|
||||
AuthedAdminTelemetryFunctionsRoute: AuthedAdminTelemetryFunctionsRoute,
|
||||
AuthedAdminTelemetryPlayersRoute: AuthedAdminTelemetryPlayersRoute,
|
||||
AuthedAdminTelemetrySessionsRoute: AuthedAdminTelemetrySessionsRoute,
|
||||
AuthedAdminTelemetryUsageRoute: AuthedAdminTelemetryUsageRoute,
|
||||
AuthedAdminTelemetryIndexRoute: AuthedAdminTelemetryIndexRoute,
|
||||
}
|
||||
|
||||
const AuthedAdminTelemetryRouteWithChildren =
|
||||
AuthedAdminTelemetryRoute._addFileChildren(AuthedAdminTelemetryRouteChildren)
|
||||
|
||||
interface AuthedAdminRouteChildren {
|
||||
AuthedAdminActivitiesRoute: typeof AuthedAdminActivitiesRoute
|
||||
AuthedAdminBadgesRoute: typeof AuthedAdminBadgesRoute
|
||||
AuthedAdminPreviewRoute: typeof AuthedAdminPreviewRoute
|
||||
AuthedAdminTelemetryRoute: typeof AuthedAdminTelemetryRouteWithChildren
|
||||
AuthedAdminIndexRoute: typeof AuthedAdminIndexRoute
|
||||
AuthedAdminTournamentsIndexRoute: typeof AuthedAdminTournamentsIndexRoute
|
||||
AuthedAdminTournamentsIdAssignPartnersRoute: typeof AuthedAdminTournamentsIdAssignPartnersRoute
|
||||
AuthedAdminTournamentsIdEnrollmentRoute: typeof AuthedAdminTournamentsIdEnrollmentRoute
|
||||
AuthedAdminTournamentsIdTeamsRoute: typeof AuthedAdminTournamentsIdTeamsRoute
|
||||
AuthedAdminTournamentsRunIdRoute: typeof AuthedAdminTournamentsRunIdRoute
|
||||
AuthedAdminTournamentsIdIndexRoute: typeof AuthedAdminTournamentsIdIndexRoute
|
||||
@@ -874,10 +1074,13 @@ const AuthedAdminRouteChildren: AuthedAdminRouteChildren = {
|
||||
AuthedAdminActivitiesRoute: AuthedAdminActivitiesRoute,
|
||||
AuthedAdminBadgesRoute: AuthedAdminBadgesRoute,
|
||||
AuthedAdminPreviewRoute: AuthedAdminPreviewRoute,
|
||||
AuthedAdminTelemetryRoute: AuthedAdminTelemetryRouteWithChildren,
|
||||
AuthedAdminIndexRoute: AuthedAdminIndexRoute,
|
||||
AuthedAdminTournamentsIndexRoute: AuthedAdminTournamentsIndexRoute,
|
||||
AuthedAdminTournamentsIdAssignPartnersRoute:
|
||||
AuthedAdminTournamentsIdAssignPartnersRoute,
|
||||
AuthedAdminTournamentsIdEnrollmentRoute:
|
||||
AuthedAdminTournamentsIdEnrollmentRoute,
|
||||
AuthedAdminTournamentsIdTeamsRoute: AuthedAdminTournamentsIdTeamsRoute,
|
||||
AuthedAdminTournamentsRunIdRoute: AuthedAdminTournamentsRunIdRoute,
|
||||
AuthedAdminTournamentsIdIndexRoute: AuthedAdminTournamentsIdIndexRoute,
|
||||
@@ -944,6 +1147,7 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
ApiSpotifySearchRoute: ApiSpotifySearchRoute,
|
||||
ApiSpotifyTokenRoute: ApiSpotifyTokenRoute,
|
||||
ApiTeamsUploadLogoRoute: ApiTeamsUploadLogoRoute,
|
||||
ApiTelemetryBeaconRoute: ApiTelemetryBeaconRoute,
|
||||
ApiTournamentsUploadLogoRoute: ApiTournamentsUploadLogoRoute,
|
||||
ApiFilesCollectionRecordIdFileRoute: ApiFilesCollectionRecordIdFileRoute,
|
||||
}
|
||||
@@ -952,10 +1156,11 @@ export const routeTree = rootRouteImport
|
||||
._addFileTypes<FileRouteTypes>()
|
||||
|
||||
import type { getRouter } from './router.tsx'
|
||||
import type { createStart } from '@tanstack/react-start'
|
||||
import type { startInstance } from './start.ts'
|
||||
declare module '@tanstack/react-start' {
|
||||
interface Register {
|
||||
ssr: true
|
||||
router: Awaited<ReturnType<typeof getRouter>>
|
||||
config: Awaited<ReturnType<typeof startInstance.getOptions>>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ import {
|
||||
Scripts,
|
||||
createRootRouteWithContext,
|
||||
isRedirect,
|
||||
useRouter,
|
||||
} from "@tanstack/react-router";
|
||||
import * as React from "react";
|
||||
import { DefaultCatchBoundary } from "@/components/DefaultCatchBoundary";
|
||||
import { type QueryClient } from "@tanstack/react-query";
|
||||
import { ensureSuperTokensFrontend } from "@/lib/supertokens/client";
|
||||
import { initTelemetry, track } from "@/lib/telemetry/client";
|
||||
import { AuthContextType } from "@/contexts/auth-context";
|
||||
import Providers from "@/features/core/components/providers";
|
||||
import { SessionMonitor } from "@/components/session-monitor";
|
||||
@@ -175,12 +177,15 @@ export const Route = createRootRouteWithContext<{
|
||||
});
|
||||
|
||||
function RootComponent() {
|
||||
const router = useRouter();
|
||||
|
||||
React.useEffect(() => {
|
||||
ensureSuperTokensFrontend();
|
||||
initTelemetry(router);
|
||||
if (import.meta.env.PROD && 'serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('/sw.js').catch(() => {});
|
||||
navigator.serviceWorker.register('/sw.js').catch(() => track('sw_register_failed'));
|
||||
}
|
||||
}, []);
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<RootDocument>
|
||||
@@ -193,7 +198,6 @@ function RootComponent() {
|
||||
);
|
||||
}
|
||||
|
||||
// todo: analytics -> process.env data-website-id
|
||||
function RootDocument({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Outlet, redirect, createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import type { HeaderConfig } from "@/features/core/types/header-config";
|
||||
import { isAdminRole } from "@/features/core/utils/roles";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin")({
|
||||
component: Outlet,
|
||||
beforeLoad: ({ context }) => {
|
||||
if (!context.auth?.roles?.includes("Admin")) {
|
||||
if (!isAdminRole(context.auth?.roles)) {
|
||||
throw redirect({ to: "/" });
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||
import { Box, Divider, Group, Skeleton, Stack, Tabs } from "@mantine/core";
|
||||
import { Suspense, useState } from "react";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/activities")({
|
||||
component: Stats,
|
||||
beforeLoad: ({ context }) => {
|
||||
const queryClient = context.queryClient;
|
||||
prefetchServerQuery(queryClient, activityQueries.search());
|
||||
prefetchServerQuery(queryClient, playerQueries.activity());
|
||||
beforeLoad: () => {
|
||||
throw redirect({ to: "/admin/telemetry/functions" });
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
header: {
|
||||
title: msg`Activities`,
|
||||
withBackButton: true,
|
||||
},
|
||||
refresh: [activityQueries.search().queryKey, playerQueries.activity().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function ActivityRowsSkeleton({ withSearch = false }: { withSearch?: boolean }) {
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
{withSearch && (
|
||||
<Box px="md" pb="sm">
|
||||
<Skeleton height={42} radius="sm" />
|
||||
</Box>
|
||||
)}
|
||||
{Array.from({ length: 8 }).map((_, index) => (
|
||||
<div key={`activity-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||
<Group p="md" wrap="nowrap" w="100%" justify="space-between">
|
||||
<Stack gap={6}>
|
||||
<Skeleton height={14} width={160} radius="sm" />
|
||||
<Skeleton height={10} width={100} radius="sm" />
|
||||
</Stack>
|
||||
<Skeleton height={10} width={60} radius="sm" />
|
||||
</Group>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function Stats() {
|
||||
const [activeTab, setActiveTab] = useState<string | null>("server-functions");
|
||||
|
||||
return (
|
||||
<Tabs value={activeTab} onChange={setActiveTab}>
|
||||
<Tabs.List mb='md'>
|
||||
<Tabs.Tab value="server-functions"><Trans>Server Functions</Trans></Tabs.Tab>
|
||||
<Tabs.Tab value="player-activity"><Trans>Player Activity</Trans></Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Tabs.Panel value="server-functions">
|
||||
<Suspense fallback={<ActivityRowsSkeleton withSearch />}>
|
||||
<ActivitiesTable />
|
||||
</Suspense>
|
||||
</Tabs.Panel>
|
||||
|
||||
<Tabs.Panel value="player-activity">
|
||||
<Suspense fallback={<ActivityRowsSkeleton />}>
|
||||
<PlayersActivityTable />
|
||||
</Suspense>
|
||||
</Tabs.Panel>
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { AdminPage } from "@/features/admin";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { AdminDashboard } from "@/features/admin";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/")({
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, tournamentQueries.current());
|
||||
},
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
@@ -10,5 +15,5 @@ export const Route = createFileRoute("/_authed/admin/")({
|
||||
},
|
||||
withPadding: false,
|
||||
}),
|
||||
component: () => <AdminPage />,
|
||||
component: () => <AdminDashboard />,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Outlet, createFileRoute, useNavigate, useRouterState } from "@tanstack/react-router";
|
||||
import { Tabs } from "@mantine/core";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
const TAB_ROUTES = {
|
||||
usage: "/admin/telemetry/usage",
|
||||
players: "/admin/telemetry/players",
|
||||
functions: "/admin/telemetry/functions",
|
||||
sessions: "/admin/telemetry/sessions",
|
||||
errors: "/admin/telemetry/errors",
|
||||
} as const;
|
||||
|
||||
type TabValue = keyof typeof TAB_ROUTES;
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry")({
|
||||
component: TelemetryLayout,
|
||||
loader: () => ({
|
||||
header: {
|
||||
title: msg`Telemetry`,
|
||||
withBackButton: true,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
function TelemetryLayout() {
|
||||
const navigate = useNavigate();
|
||||
const pathname = useRouterState({ select: (s) => s.location.pathname });
|
||||
const activeTab =
|
||||
(Object.keys(TAB_ROUTES) as TabValue[]).find((tab) =>
|
||||
pathname.endsWith(`/${tab}`)
|
||||
) ?? "usage";
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
value={activeTab}
|
||||
onChange={(value) => {
|
||||
if (value && value in TAB_ROUTES) {
|
||||
navigate({ to: TAB_ROUTES[value as TabValue] });
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Tabs.List mb="md" style={{ flexWrap: "nowrap", overflowX: "auto", overflowY: "hidden" }}>
|
||||
<Tabs.Tab value="usage">
|
||||
<Trans>Usage</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="players">
|
||||
<Trans>Players</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="functions">
|
||||
<Trans>Functions</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="sessions">
|
||||
<Trans>Sessions</Trans>
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab value="errors">
|
||||
<Trans>Errors</Trans>
|
||||
</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
|
||||
<Outlet />
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, lastNDays, ErrorBrowser } from "@/features/telemetry";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
const errorGroupParams = () => ({ ...lastNDays(30), includeResolved: false });
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/errors")({
|
||||
component: ErrorsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.errorGroups(errorGroupParams()));
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [telemetryQueries.errorGroups(errorGroupParams()).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function ErrorsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={6} withSubtitle />}>
|
||||
<ErrorBrowser />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { ActivitiesTable, activityQueries } from "@/features/activities";
|
||||
import { playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/functions")({
|
||||
component: FunctionsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
const queryClient = context.queryClient;
|
||||
prefetchServerQuery(queryClient, activityQueries.search());
|
||||
prefetchServerQuery(queryClient, playerQueries.list());
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [activityQueries.search().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function FunctionsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSearch withSubtitle withTrailing="text" />}>
|
||||
<ActivitiesTable />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/")({
|
||||
beforeLoad: () => {
|
||||
throw redirect({ to: "/admin/telemetry/usage" });
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { PlayersActivityTable, playerQueries } from "@/features/players";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/players")({
|
||||
component: PlayersTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, playerQueries.activity());
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [playerQueries.activity().queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function PlayersTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSubtitle withTrailing="text" />}>
|
||||
<PlayersActivityTable />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, SessionsList, defaultSessionParams } from "@/features/telemetry";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/sessions")({
|
||||
component: SessionsTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.sessions(defaultSessionParams));
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [telemetryQueries.sessions(defaultSessionParams).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function SessionsTab() {
|
||||
return (
|
||||
<Suspense fallback={<ListSkeleton rows={8} withSubtitle withTrailing="text" />}>
|
||||
<SessionsList />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { telemetryQueries, lastNDays, USAGE_METRICS, UsageScreen } from "@/features/telemetry";
|
||||
|
||||
const defaultUsageParams = () => ({ metrics: USAGE_METRICS, ...lastNDays(7) });
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/telemetry/usage")({
|
||||
component: UsageTab,
|
||||
beforeLoad: ({ context }) => {
|
||||
prefetchServerQuery(context.queryClient, telemetryQueries.rollups(defaultUsageParams()));
|
||||
},
|
||||
loader: () => ({
|
||||
withPadding: false,
|
||||
fullWidth: true,
|
||||
refresh: [telemetryQueries.rollups(defaultUsageParams()).queryKey],
|
||||
}),
|
||||
});
|
||||
|
||||
function UsageTab() {
|
||||
return <UsageScreen />;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
|
||||
import { tournamentQueries, useFreeAgents, useTournament } from "@/features/tournaments/queries";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { StatTileSkeleton } from "@/components/skeletons";
|
||||
import { Stack, Text, Button, Alert, LoadingOverlay, Group, Skeleton } from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
import useGenerateRandomTeams from "@/features/tournaments/hooks/use-generate-random-teams";
|
||||
@@ -37,10 +38,7 @@ function AssignPartnersPending() {
|
||||
return (
|
||||
<Stack gap="lg">
|
||||
<Stack gap="xs">
|
||||
<Group gap="xs" align="baseline">
|
||||
<Skeleton height={28} width={36} radius="sm" />
|
||||
<Skeleton height={14} width={110} radius="sm" />
|
||||
</Group>
|
||||
<StatTileSkeleton align="row" />
|
||||
<Skeleton height={36} w="100%" radius="sm" style={{ opacity: 0.7 }} />
|
||||
</Stack>
|
||||
</Stack>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import Enrollment from "@/features/tournaments/components/enrollment";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { ListSkeleton, StatTileSkeleton } from "@/components/skeletons";
|
||||
import { Skeleton, Stack } from "@mantine/core";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/enrollment")({
|
||||
beforeLoad: async ({ context, params }) => {
|
||||
const { queryClient } = context;
|
||||
const tournament = await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.details(params.id)
|
||||
);
|
||||
if (!tournament) throw redirect({ to: "/admin/tournaments" });
|
||||
if (tournament.regional) {
|
||||
await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.free_agents(params.id)
|
||||
);
|
||||
} else {
|
||||
await ensureServerQueryData(
|
||||
queryClient,
|
||||
tournamentQueries.unenrolled(params.id)
|
||||
);
|
||||
}
|
||||
return { tournament };
|
||||
},
|
||||
loader: () => ({
|
||||
header: {
|
||||
withBackButton: true,
|
||||
title: msg`Enrollment`,
|
||||
},
|
||||
}),
|
||||
component: RouteComponent,
|
||||
pendingComponent: EnrollmentPending,
|
||||
});
|
||||
|
||||
function EnrollmentPending() {
|
||||
return (
|
||||
<Stack gap="lg">
|
||||
<StatTileSkeleton align="row" />
|
||||
<Stack gap="xs">
|
||||
<Skeleton height={14} width={80} radius="sm" />
|
||||
<Skeleton height={42} radius="sm" />
|
||||
</Stack>
|
||||
<ListSkeleton rows={6} withAvatar avatarSize={32} withTrailing padding="xs" />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function RouteComponent() {
|
||||
const { tournament } = Route.useRouteContext();
|
||||
return <Enrollment tournament={tournament} />;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import ManageTournament from "@/features/tournaments/components/manage-tournament";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||
@@ -31,18 +31,14 @@ export const Route = createFileRoute("/_authed/admin/tournaments/$id/")({
|
||||
|
||||
function ManageTournamentPending() {
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
{Array.from({ length: 5 }).map((_, index) => (
|
||||
<div key={`manage-tournament-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.14, 0.4) }}>
|
||||
<Group p="md" wrap="nowrap" w="100%">
|
||||
<Skeleton height={20} width={20} radius="sm" />
|
||||
<Skeleton height={16} width="45%" radius="sm" />
|
||||
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||
</Group>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
<ListSkeleton
|
||||
rows={5}
|
||||
withAvatar
|
||||
avatarSize={20}
|
||||
withTrailing
|
||||
fadeStep={0.14}
|
||||
fadeFloor={0.4}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import ManageTeams from "@/features/teams/components/manage-teams";
|
||||
import { ensureServerQueryData } from "@/lib/tanstack-query/utils/ensure";
|
||||
import { Box, Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { Box, Skeleton, Stack } from "@mantine/core";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
export const Route = createFileRoute("/_authed/admin/tournaments/$id/teams")({
|
||||
@@ -38,21 +39,7 @@ function ManageTeamsPending() {
|
||||
<Box px="md">
|
||||
<Skeleton height={12} width={90} radius="sm" />
|
||||
</Box>
|
||||
<Stack gap={0}>
|
||||
{Array.from({ length: 8 }).map((_, index) => (
|
||||
<div key={`manage-teams-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.1, 0.35) }}>
|
||||
<Group p="xs" wrap="nowrap" w="100%">
|
||||
<Skeleton height={40} width={40} radius="sm" />
|
||||
<Skeleton height={16} width="45%" radius="sm" />
|
||||
<Stack ml="auto" gap={6} align="flex-end">
|
||||
<Skeleton height={10} width={90} radius="sm" />
|
||||
<Skeleton height={10} width={70} radius="sm" />
|
||||
</Stack>
|
||||
</Group>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
<ListSkeleton rows={8} withAvatar avatarSize={40} withTrailing="double" padding="xs" />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import ManageTournaments from "@/features/admin/components/manage-tournaments";
|
||||
import { tournamentQueries } from "@/features/tournaments/queries";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import { Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { Suspense } from "react";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
@@ -22,25 +22,13 @@ export const Route = createFileRoute("/_authed/admin/tournaments/")({
|
||||
component: RouteComponent,
|
||||
});
|
||||
|
||||
function TournamentListSkeleton() {
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
{Array.from({ length: 6 }).map((_, index) => (
|
||||
<div key={`manage-tournaments-skeleton-${index}`} style={{ opacity: Math.max(1 - index * 0.12, 0.4) }}>
|
||||
<Group p="md" wrap="nowrap" w="100%">
|
||||
<Skeleton height={16} width="55%" radius="sm" />
|
||||
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||
</Group>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
function RouteComponent() {
|
||||
return (
|
||||
<Suspense fallback={<TournamentListSkeleton />}>
|
||||
<Suspense
|
||||
fallback={
|
||||
<ListSkeleton rows={6} titleWidth="55%" withTrailing fadeStep={0.12} fadeFloor={0.4} />
|
||||
}
|
||||
>
|
||||
<ManageTournaments />
|
||||
</Suspense>
|
||||
);
|
||||
|
||||
@@ -8,12 +8,10 @@ import SeedTournament from "@/features/tournaments/components/seed-tournament";
|
||||
import SetupGroupStage from "@/features/tournaments/components/setup-group-stage";
|
||||
import GroupStageView from "@/features/tournaments/components/group-stage-view";
|
||||
import { Container, Stack, Divider, Title, Box, Card, Group, Skeleton, SimpleGrid } from "@mantine/core";
|
||||
import { useMemo } from "react";
|
||||
import { BracketData } from "@/features/bracket/types";
|
||||
import { Match } from "@/features/matches/types";
|
||||
import BracketView from "@/features/bracket/components/bracket-view";
|
||||
import { SpotifyControlsBar } from "@/features/spotify/components";
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { useIsAdmin } from "@/features/core/hooks/use-is-admin";
|
||||
import { useTournamentRunState } from "@/features/tournaments/hooks/use-tournament-run-state";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
|
||||
@@ -83,67 +81,10 @@ function RunTournamentPending() {
|
||||
function RouteComponent() {
|
||||
const { id } = Route.useParams();
|
||||
const { data: tournament } = useTournament(id);
|
||||
const { roles } = useAuth();
|
||||
const isAdmin = roles?.includes('Admin') || false;
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const hasGroupStage = useMemo(() => {
|
||||
return tournament.matches?.some((match) => match.round === -1) || false;
|
||||
}, [tournament.matches]);
|
||||
|
||||
const hasKnockout = useMemo(() => {
|
||||
return tournament.matches?.some((match) => match.round !== -1) || false;
|
||||
}, [tournament.matches]);
|
||||
|
||||
const knockoutBracketPopulated = useMemo(() => {
|
||||
return tournament.matches?.some((match) =>
|
||||
match.round === 0 && match.lid >= 0 && (match.home || match.away)
|
||||
) || false;
|
||||
}, [tournament.matches]);
|
||||
|
||||
const nextUpMatchId = useMemo(() => {
|
||||
const ready = (tournament.matches ?? [])
|
||||
.filter(
|
||||
(match) =>
|
||||
match.status === "ready" && match.home && match.away && !match.bye
|
||||
)
|
||||
.sort((a, b) => a.order - b.order);
|
||||
return ready[0]?.id;
|
||||
}, [tournament.matches]);
|
||||
|
||||
const bracket: BracketData = useMemo(() => {
|
||||
if (!tournament.matches || tournament.matches.length === 0) {
|
||||
return { winners: [], losers: [] };
|
||||
}
|
||||
|
||||
const winnersMap = new Map<number, Match[]>();
|
||||
const losersMap = new Map<number, Match[]>();
|
||||
|
||||
tournament.matches
|
||||
.filter((match) => match.round !== -1)
|
||||
.sort((a, b) => a.lid - b.lid)
|
||||
.forEach((match) => {
|
||||
if (!match.is_losers_bracket) {
|
||||
if (!winnersMap.has(match.round)) {
|
||||
winnersMap.set(match.round, []);
|
||||
}
|
||||
winnersMap.get(match.round)!.push(match);
|
||||
} else {
|
||||
if (!losersMap.has(match.round)) {
|
||||
losersMap.set(match.round, []);
|
||||
}
|
||||
losersMap.get(match.round)!.push(match);
|
||||
}
|
||||
});
|
||||
|
||||
const winners = Array.from(winnersMap.entries())
|
||||
.sort(([a], [b]) => a - b)
|
||||
.map(([, matches]) => matches);
|
||||
|
||||
const losers = Array.from(losersMap.entries())
|
||||
.sort(([a], [b]) => a - b)
|
||||
.map(([, matches]) => matches);
|
||||
return { winners, losers };
|
||||
}, [tournament.matches]);
|
||||
const { hasGroupStage, hasKnockout, knockoutBracketPopulated, nextUpMatchId, bracket } =
|
||||
useTournamentRunState(tournament.matches);
|
||||
|
||||
return (
|
||||
<Container size="md" px={0}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { playerQueries } from "@/features/players/queries";
|
||||
import PlayerStatsTable from "@/features/players/components/player-stats-table";
|
||||
import { Suspense, useState, useDeferredValue, useEffect } from "react";
|
||||
import { Suspense, useState, useDeferredValue, useEffect, useRef } from "react";
|
||||
import PlayerStatsTableSkeleton from "@/features/players/components/player-stats-table-skeleton";
|
||||
import { prefetchServerQuery } from "@/lib/tanstack-query/utils/prefetch";
|
||||
import LeagueHeadToHead from "@/features/players/components/league-head-to-head";
|
||||
@@ -9,6 +9,7 @@ import { Box, Loader, Tabs, Button, Group, Container, Stack } from "@mantine/cor
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
export const Route = createFileRoute("/_authed/stats")({
|
||||
component: Stats,
|
||||
@@ -32,6 +33,14 @@ function Stats() {
|
||||
const isStale = viewType !== deferredViewType;
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const viewTypeRef = useRef(viewType);
|
||||
const changeViewType = (next: typeof viewType) => {
|
||||
if (viewTypeRef.current === next) return;
|
||||
viewTypeRef.current = next;
|
||||
track("stats_filtered", { value: next });
|
||||
setViewType(next);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = window.setTimeout(() => {
|
||||
prefetchServerQuery(queryClient, playerQueries.allStats('mainline'));
|
||||
@@ -54,21 +63,21 @@ function Stats() {
|
||||
<Button
|
||||
variant={viewType === 'all' ? 'filled' : 'light'}
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('all')}
|
||||
onClick={() => changeViewType('all')}
|
||||
>
|
||||
<Trans>All</Trans>
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewType === 'mainline' ? 'filled' : 'light'}
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('mainline')}
|
||||
onClick={() => changeViewType('mainline')}
|
||||
>
|
||||
<Trans>Mainline</Trans>
|
||||
</Button>
|
||||
<Button
|
||||
variant={viewType === 'regional' ? 'filled' : 'light'}
|
||||
size="compact-xs"
|
||||
onClick={() => setViewType('regional')}
|
||||
onClick={() => changeViewType('regional')}
|
||||
>
|
||||
<Trans>Regional</Trans>
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { tournamentQueries } from '@/features/tournaments/queries';
|
||||
import Profile from '@/features/tournaments/components/profile';
|
||||
import { isAdminRole } from '@/features/core/utils/roles';
|
||||
import { z } from "zod";
|
||||
import { prefetchServerQuery } from '@/lib/tanstack-query/utils/prefetch';
|
||||
import { Suspense } from 'react';
|
||||
@@ -20,7 +21,7 @@ export const Route = createFileRoute('/_authed/tournaments/$tournamentId')({
|
||||
header: {
|
||||
collapsed: true,
|
||||
withBackButton: true,
|
||||
settingsLink: context.auth.roles.includes("Admin") ? `/admin/tournaments/${params.tournamentId}` : undefined
|
||||
settingsLink: isAdminRole(context.auth.roles) ? `/admin/tournaments/${params.tournamentId}` : undefined
|
||||
},
|
||||
refresh: [tournamentQueries.details(params.tournamentId).queryKey],
|
||||
withPadding: false
|
||||
|
||||
@@ -8,8 +8,6 @@ ensureSuperTokensBackend();
|
||||
// forwards all supertokens api methods to our API
|
||||
const superTokensHandler = handleAuthAPIRequest();
|
||||
const handleRequest = async ({ request }: {request: Request}) => {
|
||||
console.log("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||
console.log("Handling auth request:", request.method, request.url);
|
||||
return superTokensHandler(request);
|
||||
};
|
||||
export const Route = createFileRoute('/api/auth/$')({
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { serverEvents, EVENT_TYPES, type ServerEvent } from "@/lib/events/emitter";
|
||||
import {
|
||||
serverEvents,
|
||||
EVENT_TYPES,
|
||||
incrementConnections,
|
||||
decrementConnections,
|
||||
type ServerEvent,
|
||||
} from "@/lib/events/emitter";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
|
||||
let activeConnections = 0;
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
export const Route = createFileRoute("/api/events/$")({
|
||||
@@ -11,9 +16,9 @@ export const Route = createFileRoute("/api/events/$")({
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
GET: ({ request }) => {
|
||||
activeConnections++;
|
||||
const active = incrementConnections();
|
||||
const connectionId = `conn_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
||||
logger.info(`ServerEvents | New connection ${connectionId}. Active: ${activeConnections}`);
|
||||
logger.info(`ServerEvents | New connection ${connectionId}. Active: ${active}`);
|
||||
|
||||
let cleanedUp = false;
|
||||
let cleanup = () => {};
|
||||
@@ -34,19 +39,20 @@ export const Route = createFileRoute("/api/events/$")({
|
||||
serverEvents.on(type, handleEvent);
|
||||
}
|
||||
|
||||
// Under the shortest idle timeout observed on proxies/PWA paths.
|
||||
const pingInterval = setInterval(() => {
|
||||
send({ type: "ping", timestamp: Date.now() });
|
||||
}, 15000);
|
||||
}, 8000);
|
||||
|
||||
cleanup = () => {
|
||||
if (cleanedUp) return;
|
||||
cleanedUp = true;
|
||||
activeConnections--;
|
||||
const remaining = decrementConnections();
|
||||
for (const type of EVENT_TYPES) {
|
||||
serverEvents.off(type, handleEvent);
|
||||
}
|
||||
clearInterval(pingInterval);
|
||||
logger.info(`ServerEvents | Connection ${connectionId} cleanup completed. Active: ${activeConnections}`);
|
||||
logger.info(`ServerEvents | Connection ${connectionId} cleanup completed. Active: ${remaining}`);
|
||||
};
|
||||
|
||||
request.signal?.addEventListener("abort", cleanup);
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { ensureTelemetryScheduler } from "@/lib/telemetry/scheduler.server";
|
||||
import { getHealthSnapshot } from "@/lib/telemetry/health.server";
|
||||
import { ensureSuperTokensBackend } from "@/lib/supertokens/server";
|
||||
|
||||
export const Route = createFileRoute("/api/health")({
|
||||
server: {
|
||||
handlers: {
|
||||
GET: () => {
|
||||
GET: async () => {
|
||||
ensureSuperTokensBackend();
|
||||
ensureTelemetryScheduler();
|
||||
const snapshot = await getHealthSnapshot();
|
||||
|
||||
// Always 200: a dependency outage must not fail the k8s probes.
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
status: "ok",
|
||||
status: snapshot.status,
|
||||
checks: snapshot.checks,
|
||||
timestamp: new Date().toISOString(),
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
headers: { "Content-Type": "application/json" },
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { apiLoggingMiddleware } from "@/lib/telemetry/api-logging.server";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
|
||||
@@ -11,7 +12,7 @@ const json = (body: unknown, status = 200) =>
|
||||
|
||||
export const Route = createFileRoute("/api/push/subscribe")({
|
||||
server: {
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
middleware: [apiLoggingMiddleware, superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const player = (context as any).player;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { apiLoggingMiddleware } from "@/lib/telemetry/api-logging.server";
|
||||
import { sendPushToPlayer } from "@/lib/push";
|
||||
import { isPushConfigured } from "@/lib/config";
|
||||
import { logger } from "@/lib/logger";
|
||||
@@ -13,7 +14,7 @@ const json = (body: unknown, status = 200) =>
|
||||
|
||||
export const Route = createFileRoute("/api/push/test")({
|
||||
server: {
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
middleware: [apiLoggingMiddleware, superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ context }) => {
|
||||
const player = (context as any).player;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { apiLoggingMiddleware } from "@/lib/telemetry/api-logging.server";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
|
||||
@@ -11,7 +12,7 @@ const json = (body: unknown, status = 200) =>
|
||||
|
||||
export const Route = createFileRoute("/api/push/unsubscribe")({
|
||||
server: {
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
middleware: [apiLoggingMiddleware, superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const player = (context as any).player;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { apiLoggingMiddleware } from "@/lib/telemetry/api-logging.server";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
@@ -12,7 +13,7 @@ const uploadSchema = z.object({
|
||||
|
||||
export const Route = createFileRoute("/api/teams/upload-logo")({
|
||||
server: {
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
middleware: [apiLoggingMiddleware, superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const i18n = localizedFor(context.metadata);
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { superTokensOptionalRequestMiddleware } from "@/utils/supertokens";
|
||||
import { beaconPayloadSchema, MAX_BEACON_BYTES, type BeaconEvent } from "@/lib/telemetry/beacon-schema";
|
||||
import { errorGroupHash } from "@/lib/telemetry/error-hash";
|
||||
import { redactArguments } from "@/lib/telemetry/redact-args";
|
||||
import { Logger } from "@/lib/logger";
|
||||
import type { Player } from "@/features/players/types";
|
||||
|
||||
const logger = new Logger("Telemetry");
|
||||
|
||||
const BUCKET_CAPACITY = 120;
|
||||
const REFILL_PER_MS = BUCKET_CAPACITY / 60_000;
|
||||
const buckets = new Map<string, { tokens: number; updatedAt: number }>();
|
||||
|
||||
const takeTokens = (key: string, count: number): boolean => {
|
||||
const now = Date.now();
|
||||
const bucket = buckets.get(key) ?? { tokens: BUCKET_CAPACITY, updatedAt: now };
|
||||
bucket.tokens = Math.min(BUCKET_CAPACITY, bucket.tokens + (now - bucket.updatedAt) * REFILL_PER_MS);
|
||||
bucket.updatedAt = now;
|
||||
if (bucket.tokens < count) {
|
||||
buckets.set(key, bucket);
|
||||
return false;
|
||||
}
|
||||
bucket.tokens -= count;
|
||||
buckets.set(key, bucket);
|
||||
|
||||
if (buckets.size > 2000) {
|
||||
for (const [k, v] of buckets) {
|
||||
if (now - v.updatedAt > 5 * 60_000) buckets.delete(k);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const clientIp = (request: Request): string =>
|
||||
request.headers.get("x-forwarded-for")?.split(",")[0]?.trim() ||
|
||||
request.headers.get("x-real-ip") ||
|
||||
"unknown";
|
||||
|
||||
const writeEvents = async (
|
||||
events: BeaconEvent[],
|
||||
base: { sessionId: string; playerId?: string; userAgent?: string }
|
||||
) => {
|
||||
const { isExcludedPlayerId } = await import("@/lib/telemetry/exclusions.server");
|
||||
if (base.playerId && (await isExcludedPlayerId(base.playerId))) {
|
||||
// Excluded players still report errors; their usage stays out.
|
||||
events = events.filter((event) => event.kind === "error");
|
||||
if (events.length === 0) return;
|
||||
}
|
||||
|
||||
const { pbAdmin } = await import("@/lib/pocketbase/client");
|
||||
await pbAdmin.authPromise;
|
||||
|
||||
for (const event of events) {
|
||||
try {
|
||||
if (event.kind === "error") {
|
||||
await pbAdmin.createClientError({
|
||||
message: event.message,
|
||||
stack: event.stack,
|
||||
source: event.source,
|
||||
path: event.path,
|
||||
route_id: event.routeId,
|
||||
group_hash: errorGroupHash(event),
|
||||
resolved: false,
|
||||
player: base.playerId,
|
||||
session_id: base.sessionId,
|
||||
user_agent: base.userAgent,
|
||||
props: redactArguments(event.props),
|
||||
});
|
||||
} else {
|
||||
await pbAdmin.createClientEvent({
|
||||
name: event.kind === "vital" ? `vital.${event.metric}` : event.name,
|
||||
player: base.playerId,
|
||||
session_id: base.sessionId,
|
||||
path: event.path,
|
||||
route_id: event.routeId,
|
||||
value: event.value,
|
||||
props:
|
||||
event.kind === "vital"
|
||||
? event.rating
|
||||
? { rating: event.rating }
|
||||
: undefined
|
||||
: redactArguments(event.props),
|
||||
user_agent: base.userAgent,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error("Failed to persist beacon event", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const Route = createFileRoute("/api/telemetry/beacon")({
|
||||
server: {
|
||||
middleware: [superTokensOptionalRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const player = (context as unknown as { player?: Player | null }).player ?? undefined;
|
||||
|
||||
const raw = await request.text();
|
||||
if (raw.length > MAX_BEACON_BYTES) {
|
||||
return new Response(null, { status: 413 });
|
||||
}
|
||||
|
||||
let parsed: unknown;
|
||||
try {
|
||||
parsed = JSON.parse(raw);
|
||||
} catch {
|
||||
return new Response(null, { status: 400 });
|
||||
}
|
||||
|
||||
const result = beaconPayloadSchema.safeParse(parsed);
|
||||
if (!result.success) {
|
||||
return new Response(null, { status: 400 });
|
||||
}
|
||||
|
||||
const key = player ? `p:${player.id}` : `ip:${clientIp(request)}`;
|
||||
if (!takeTokens(key, result.data.events.length)) {
|
||||
return new Response(null, { status: 429 });
|
||||
}
|
||||
|
||||
void writeEvents(result.data.events, {
|
||||
sessionId: result.data.sessionId,
|
||||
playerId: player?.id,
|
||||
userAgent: request.headers.get("user-agent") ?? undefined,
|
||||
}).catch((error) => logger.error("Beacon write batch failed", error));
|
||||
|
||||
return new Response(null, { status: 204 });
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { msg } from "@lingui/core/macro";
|
||||
import { superTokensRequestMiddleware } from "@/utils/supertokens";
|
||||
import { apiLoggingMiddleware } from "@/lib/telemetry/api-logging.server";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { localizedFor } from "@/lib/i18n/server-messages";
|
||||
@@ -12,7 +13,7 @@ const uploadSchema = z.object({
|
||||
|
||||
export const Route = createFileRoute("/api/tournaments/upload-logo")({
|
||||
server: {
|
||||
middleware: [superTokensRequestMiddleware],
|
||||
middleware: [apiLoggingMiddleware, superTokensRequestMiddleware],
|
||||
handlers: {
|
||||
POST: async ({ request, context }) => {
|
||||
const i18n = localizedFor(context.metadata);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createCsrfMiddleware, createStart } from "@tanstack/react-start";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
|
||||
const csrfMiddleware = createCsrfMiddleware({
|
||||
filter: (ctx) => ctx.handlerType === "serverFn",
|
||||
});
|
||||
|
||||
export const startInstance = createStart(() => ({
|
||||
requestMiddleware: [csrfMiddleware],
|
||||
functionMiddleware: [serverFnLoggingMiddleware],
|
||||
}));
|
||||
@@ -22,6 +22,7 @@ import { useDisclosure } from '@mantine/hooks'
|
||||
import { useEffect } from 'react'
|
||||
import toast from '@/lib/sonner'
|
||||
import { logger } from '@/lib/logger'
|
||||
import { captureBoundaryError } from '@/lib/telemetry/client'
|
||||
import { XCircleIcon, WarningIcon } from '@phosphor-icons/react'
|
||||
import { Trans, useLingui } from '@lingui/react/macro'
|
||||
import Button from './button'
|
||||
@@ -41,6 +42,7 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
|
||||
|
||||
useEffect(() => {
|
||||
logger.error('DefaultCatchBoundary | ', error)
|
||||
captureBoundaryError(error)
|
||||
|
||||
if (errorMessage.toLowerCase().includes('unauthenticated')) {
|
||||
toast.error(t`You've been logged out`)
|
||||
|
||||
@@ -53,12 +53,14 @@ export function Countdown({ date, label, color }: CountdownProps) {
|
||||
return (
|
||||
<Group gap="xs">
|
||||
{label && <Text size='sm' fw={500}>{label}:</Text>}
|
||||
{/* Server and client render different seconds; the first client tick corrects it. */}
|
||||
<Text
|
||||
size='sm'
|
||||
fw={600}
|
||||
c={isFinalStretch ? 'red' : color}
|
||||
ff="monospace"
|
||||
className={classes.time}
|
||||
suppressHydrationWarning
|
||||
>
|
||||
{prefix}
|
||||
<span
|
||||
@@ -66,6 +68,7 @@ export function Countdown({ date, label, color }: CountdownProps) {
|
||||
className={`${classes.seconds} ${
|
||||
isFinalStretch ? classes.finalTick : classes.tick
|
||||
}`}
|
||||
suppressHydrationWarning
|
||||
>
|
||||
{pad(timeLeft.seconds)}
|
||||
</span>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { track } from '@/lib/telemetry/client'
|
||||
import { Box, Paper, Group, Text, ActionIcon } from '@mantine/core'
|
||||
import { DownloadIcon, XIcon } from '@phosphor-icons/react'
|
||||
import { Trans, useLingui } from '@lingui/react/macro'
|
||||
@@ -26,13 +27,17 @@ export function IOSInstallPrompt() {
|
||||
|
||||
if ((isIOS || isAndroid) && !isInStandaloneMode && !hasBeenDismissed) {
|
||||
setPlatform(isIOS ? 'ios' : 'android')
|
||||
const timer = setTimeout(() => setShow(true), 3000)
|
||||
const timer = setTimeout(() => {
|
||||
setShow(true)
|
||||
track('pwa_ios_prompt_shown')
|
||||
}, 3000)
|
||||
return () => clearTimeout(timer)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleDismiss = () => {
|
||||
localStorage.setItem('pwa-install-prompt-dismissed', 'true')
|
||||
track('pwa_ios_prompt_dismissed')
|
||||
setShow(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Text, UnstyledButton } from "@mantine/core";
|
||||
import { Icon } from "@phosphor-icons/react";
|
||||
import classes from "./nav-tile.module.css";
|
||||
|
||||
interface NavTileProps {
|
||||
label: string;
|
||||
Icon: Icon;
|
||||
onClick?: () => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
/** A single square-ish nav tile with icon-over-label and press feedback. */
|
||||
export const NavTile = ({ label, Icon, onClick, disabled }: NavTileProps) => (
|
||||
<UnstyledButton
|
||||
className={`${classes.tile} flxn-tile`}
|
||||
onClick={onClick}
|
||||
disabled={disabled}
|
||||
>
|
||||
<span className={`${classes.icon} flxn-tile-icon`}>
|
||||
<Icon size={22} weight="bold" />
|
||||
</span>
|
||||
<Text size="xs" fw={600} lineClamp={2} lh={1.2}>
|
||||
{label}
|
||||
</Text>
|
||||
</UnstyledButton>
|
||||
);
|
||||
|
||||
export default NavTile;
|
||||
@@ -0,0 +1,43 @@
|
||||
.tile {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 14px 8px;
|
||||
border-radius: var(--mantine-radius-md);
|
||||
border: 1px solid var(--mantine-color-default-border);
|
||||
background-color: var(--mantine-color-body);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.icon {
|
||||
color: var(--mantine-primary-color-filled);
|
||||
display: flex;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
.tile:hover:not(:disabled) {
|
||||
background-color: var(--mantine-color-default-hover);
|
||||
}
|
||||
}
|
||||
|
||||
.tile:active:not(:disabled) {
|
||||
background-color: var(--mantine-color-default-hover);
|
||||
}
|
||||
|
||||
.tile:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.tile {
|
||||
transition: background-color 120ms ease-out, transform 120ms cubic-bezier(0.32, 0.72, 0, 1);
|
||||
}
|
||||
|
||||
.tile:active:not(:disabled) {
|
||||
transform: scale(0.97);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import { useIsMobile } from "@/hooks/use-is-mobile";
|
||||
import Drawer from "./drawer";
|
||||
import Modal from "./modal";
|
||||
import { ScrollArea, Flex, Loader } from "@mantine/core";
|
||||
import { Box, Flex, Loader } from "@mantine/core";
|
||||
|
||||
interface SheetProps extends PropsWithChildren {
|
||||
title?: string;
|
||||
@@ -60,14 +60,19 @@ const Sheet: React.FC<SheetProps> = ({ title, children, opened, onChange }) => {
|
||||
<Loader size='lg' />
|
||||
</Flex>
|
||||
}>
|
||||
<ScrollArea.Autosize
|
||||
style={{ flex: 1, maxHeight: '75dvh' }}
|
||||
scrollbarSize={8}
|
||||
scrollbars="y"
|
||||
type="scroll"
|
||||
{/* Native overflow, not ScrollArea: vaul's drag-vs-scroll detection
|
||||
only recognizes natively scrollable elements. */}
|
||||
<Box
|
||||
style={{
|
||||
flex: 1,
|
||||
maxHeight: "75dvh",
|
||||
overflowY: "auto",
|
||||
overscrollBehavior: "contain",
|
||||
WebkitOverflowScrolling: "touch",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</ScrollArea.Autosize>
|
||||
</Box>
|
||||
</Suspense>
|
||||
</SheetComponent>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Box, Group, Paper, Skeleton } from "@mantine/core";
|
||||
import type { MantineRadius } from "@mantine/core";
|
||||
|
||||
export interface CardSkeletonProps {
|
||||
withAvatar?: boolean;
|
||||
avatarSize?: number;
|
||||
withBadge?: boolean;
|
||||
radius?: MantineRadius;
|
||||
opacity?: number;
|
||||
}
|
||||
|
||||
export const CardSkeleton = ({
|
||||
withAvatar = true,
|
||||
avatarSize = 32,
|
||||
withBadge = true,
|
||||
radius = "md",
|
||||
opacity = 1,
|
||||
}: CardSkeletonProps) => {
|
||||
return (
|
||||
<Paper p="sm" withBorder radius={radius} style={{ opacity }}>
|
||||
<Group gap="sm" align="center" wrap="nowrap">
|
||||
{withAvatar && (
|
||||
<Skeleton height={avatarSize} width={avatarSize} radius="sm" />
|
||||
)}
|
||||
<Box style={{ flex: 1 }}>
|
||||
<Skeleton height={16} width="70%" mb={4} />
|
||||
<Skeleton height={12} width="40%" />
|
||||
</Box>
|
||||
{withBadge && <Skeleton height={20} width={60} radius="xl" />}
|
||||
</Group>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
export default CardSkeleton;
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from "./list-skeleton";
|
||||
export * from "./card-skeleton";
|
||||
export * from "./stat-tile-skeleton";
|
||||
@@ -0,0 +1,76 @@
|
||||
import { Box, Divider, Group, Skeleton, Stack } from "@mantine/core";
|
||||
import type { MantineSpacing } from "@mantine/core";
|
||||
|
||||
export interface ListSkeletonProps {
|
||||
rows?: number;
|
||||
withSearch?: boolean;
|
||||
withAvatar?: boolean;
|
||||
avatarSize?: number;
|
||||
withSubtitle?: boolean;
|
||||
withTrailing?: boolean | "double" | "text";
|
||||
titleWidth?: string | number;
|
||||
padding?: MantineSpacing;
|
||||
fadeStep?: number;
|
||||
fadeFloor?: number;
|
||||
}
|
||||
|
||||
export const ListSkeleton = ({
|
||||
rows = 6,
|
||||
withSearch = false,
|
||||
withAvatar = false,
|
||||
avatarSize = 40,
|
||||
withSubtitle = false,
|
||||
withTrailing = false,
|
||||
titleWidth = "45%",
|
||||
padding = "md",
|
||||
fadeStep = 0.1,
|
||||
fadeFloor = 0.35,
|
||||
}: ListSkeletonProps) => {
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
{withSearch && (
|
||||
<Box px={padding} pb="sm">
|
||||
<Skeleton height={42} radius="sm" />
|
||||
</Box>
|
||||
)}
|
||||
{Array.from({ length: rows }).map((_, index) => (
|
||||
<div
|
||||
key={index}
|
||||
style={{ opacity: Math.max(1 - index * fadeStep, fadeFloor) }}
|
||||
>
|
||||
<Group
|
||||
p={padding}
|
||||
wrap="nowrap"
|
||||
w="100%"
|
||||
justify={withTrailing === "text" ? "space-between" : undefined}
|
||||
>
|
||||
{withAvatar && (
|
||||
<Skeleton height={avatarSize} width={avatarSize} radius="sm" />
|
||||
)}
|
||||
{withSubtitle ? (
|
||||
<Stack gap={6}>
|
||||
<Skeleton height={14} width={160} radius="sm" />
|
||||
<Skeleton height={10} width={100} radius="sm" />
|
||||
</Stack>
|
||||
) : (
|
||||
<Skeleton height={16} width={titleWidth} radius="sm" />
|
||||
)}
|
||||
{withTrailing === "double" ? (
|
||||
<Stack ml="auto" gap={6} align="flex-end">
|
||||
<Skeleton height={10} width={90} radius="sm" />
|
||||
<Skeleton height={10} width={70} radius="sm" />
|
||||
</Stack>
|
||||
) : withTrailing === "text" ? (
|
||||
<Skeleton height={10} width={60} radius="sm" />
|
||||
) : withTrailing ? (
|
||||
<Skeleton ml="auto" height={20} width={20} radius="sm" />
|
||||
) : null}
|
||||
</Group>
|
||||
<Divider />
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default ListSkeleton;
|
||||
@@ -0,0 +1,42 @@
|
||||
import { Card, Group, Skeleton, Stack } from "@mantine/core";
|
||||
|
||||
export interface StatTileSkeletonProps {
|
||||
withCard?: boolean;
|
||||
align?: "row" | "column";
|
||||
numberWidth?: number;
|
||||
numberHeight?: number;
|
||||
labelWidth?: number;
|
||||
labelHeight?: number;
|
||||
}
|
||||
|
||||
export const StatTileSkeleton = ({
|
||||
withCard = false,
|
||||
align = "column",
|
||||
numberWidth = align === "row" ? 36 : 48,
|
||||
numberHeight = 28,
|
||||
labelWidth = align === "row" ? 110 : 80,
|
||||
labelHeight = align === "row" ? 14 : 12,
|
||||
}: StatTileSkeletonProps) => {
|
||||
const content =
|
||||
align === "row" ? (
|
||||
<Group gap="xs" align="baseline">
|
||||
<Skeleton height={numberHeight} width={numberWidth} radius="sm" />
|
||||
<Skeleton height={labelHeight} width={labelWidth} radius="sm" />
|
||||
</Group>
|
||||
) : (
|
||||
<Stack gap={4} align="center">
|
||||
<Skeleton height={numberHeight} width={numberWidth} radius="sm" />
|
||||
<Skeleton height={labelHeight} width={labelWidth} radius="sm" />
|
||||
</Stack>
|
||||
);
|
||||
|
||||
if (!withCard) return content;
|
||||
|
||||
return (
|
||||
<Card withBorder radius="md" p="md">
|
||||
{content}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default StatTileSkeleton;
|
||||
@@ -18,6 +18,7 @@ interface AuthData {
|
||||
theme?: string;
|
||||
locale?: string;
|
||||
seenThemesHint?: boolean;
|
||||
telemetryAlerts?: boolean;
|
||||
};
|
||||
roles: string[];
|
||||
phone: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createContext, useCallback, useEffect, useMemo, useState, PropsWithChildren } from 'react';
|
||||
import { useLingui } from '@lingui/react/macro';
|
||||
import { SpotifyAuth } from '@/lib/spotify/auth';
|
||||
import { useAuth } from './auth-context';
|
||||
import { useIsAdmin } from '@/features/core/hooks/use-is-admin';
|
||||
import { useConfig } from '@/hooks/use-config';
|
||||
import type {
|
||||
SpotifyContextType,
|
||||
@@ -40,8 +40,7 @@ const deepEqual = (a: unknown, b: unknown): boolean => {
|
||||
};
|
||||
|
||||
export const SpotifyProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
||||
const { roles } = useAuth();
|
||||
const isAdmin = roles?.includes('Admin') || false;
|
||||
const isAdmin = useIsAdmin();
|
||||
const config = useConfig();
|
||||
const { t } = useLingui();
|
||||
|
||||
|
||||
@@ -1,268 +1,32 @@
|
||||
import { useState, useMemo, memo } from "react";
|
||||
import { useState, useMemo } from "react";
|
||||
import { Trans, Plural, useLingui } from "@lingui/react/macro";
|
||||
import {
|
||||
Text,
|
||||
TextInput,
|
||||
Stack,
|
||||
Group,
|
||||
Box,
|
||||
Container,
|
||||
Divider,
|
||||
UnstyledButton,
|
||||
Select,
|
||||
Pagination,
|
||||
Code,
|
||||
Alert,
|
||||
ThemeIcon,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import {
|
||||
MagnifyingGlassIcon,
|
||||
CaretUpIcon,
|
||||
CaretDownIcon,
|
||||
CheckIcon,
|
||||
XIcon,
|
||||
ChecksIcon,
|
||||
PulseIcon,
|
||||
} from "@phosphor-icons/react";
|
||||
import { Alert, Code, Container, Group, Stack, Text } from "@mantine/core";
|
||||
import { CheckIcon, XIcon } from "@phosphor-icons/react";
|
||||
import { Activity, ActivitySearchParams } from "../types";
|
||||
import { useActivities } from "../queries";
|
||||
import Sheet from "@/components/sheet/sheet";
|
||||
import { usePlayers } from "@/features/players/queries";
|
||||
import { useSheet } from "@/hooks/use-sheet";
|
||||
import {
|
||||
DetailSheet,
|
||||
PaginatedList,
|
||||
SearchFilterBar,
|
||||
TelemetryListItem,
|
||||
} from "@/features/telemetry/components/shared";
|
||||
|
||||
interface ActivityListItemProps {
|
||||
activity: Activity;
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
const ActivityListItem = memo(({ activity, onClick }: ActivityListItemProps) => {
|
||||
const { t, i18n } = useLingui();
|
||||
const playerName = typeof activity.player === "object" && activity.player
|
||||
? `${activity.player.first_name} ${activity.player.last_name}`
|
||||
: t`System`;
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleString(i18n.locale);
|
||||
};
|
||||
|
||||
return (
|
||||
<UnstyledButton
|
||||
w="100%"
|
||||
p="md"
|
||||
onClick={onClick}
|
||||
style={{
|
||||
borderRadius: 0,
|
||||
transition: "background-color 0.15s ease",
|
||||
}}
|
||||
styles={{
|
||||
root: {
|
||||
'&:hover': {
|
||||
backgroundColor: 'var(--mantine-color-gray-0)',
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Group justify="space-between" align="flex-start" w="100%">
|
||||
<Stack gap={4} flex={1}>
|
||||
<Group gap="xs">
|
||||
<Text size="sm" fw={600}>
|
||||
{activity.name}
|
||||
</Text>
|
||||
{activity.success ? (
|
||||
<CheckIcon size={16} color="var(--mantine-color-green-6)" />
|
||||
) : (
|
||||
<XIcon size={16} color="var(--mantine-color-red-6)" />
|
||||
)}
|
||||
</Group>
|
||||
<Group gap="md">
|
||||
<Text size="xs" c="dimmed">
|
||||
{playerName}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
<Trans>{activity.duration}ms</Trans>
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
{formatDate(activity.created)}
|
||||
</Text>
|
||||
</Group>
|
||||
{activity.error && (
|
||||
<Text size="xs" c="red" lineClamp={1}>
|
||||
{activity.error}
|
||||
</Text>
|
||||
)}
|
||||
</Stack>
|
||||
</Group>
|
||||
</UnstyledButton>
|
||||
);
|
||||
});
|
||||
|
||||
interface ActivityDetailsSheetProps {
|
||||
activity: Activity | null;
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const ActivityDetailsSheet = memo(({ activity, isOpen, onClose }: ActivityDetailsSheetProps) => {
|
||||
const { t, i18n } = useLingui();
|
||||
if (!activity) return null;
|
||||
|
||||
const playerName = typeof activity.player === "object" && activity.player
|
||||
? `${activity.player.first_name} ${activity.player.last_name}`
|
||||
: t`System`;
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleString(i18n.locale);
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet title={t`Activity Details`} opened={isOpen} onChange={onClose}>
|
||||
<Stack gap="md" p="md">
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Function Name</Trans>
|
||||
</Text>
|
||||
<Text size="sm">{activity.name}</Text>
|
||||
</Stack>
|
||||
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Status</Trans>
|
||||
</Text>
|
||||
<Group gap="xs">
|
||||
{activity.success ? (
|
||||
<>
|
||||
<CheckIcon size={16} color="var(--mantine-color-green-6)" />
|
||||
<Text size="sm" c="green">
|
||||
<Trans>Success</Trans>
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<XIcon size={16} color="var(--mantine-color-red-6)" />
|
||||
<Text size="sm" c="red">
|
||||
<Trans>Failed</Trans>
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Player</Trans>
|
||||
</Text>
|
||||
<Text size="sm">{playerName}</Text>
|
||||
</Stack>
|
||||
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Duration</Trans>
|
||||
</Text>
|
||||
<Text size="sm"><Trans>{activity.duration}ms</Trans></Text>
|
||||
</Stack>
|
||||
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Created</Trans>
|
||||
</Text>
|
||||
<Text size="sm">{formatDate(activity.created)}</Text>
|
||||
</Stack>
|
||||
|
||||
{activity.user_agent && (
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>User Agent</Trans>
|
||||
</Text>
|
||||
<Text size="xs" style={{ wordBreak: "break-word" }}>
|
||||
{activity.user_agent}
|
||||
</Text>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{activity.error && (
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Error Message</Trans>
|
||||
</Text>
|
||||
<Alert color="red" variant="light">
|
||||
<Text size="sm" style={{ wordBreak: "break-word" }}>
|
||||
{activity.error}
|
||||
</Text>
|
||||
</Alert>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{activity.arguments && (
|
||||
<Stack gap="xs">
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
<Trans>Arguments</Trans>
|
||||
</Text>
|
||||
<Code block style={{ fontSize: "11px" }}>
|
||||
{JSON.stringify(activity.arguments, null, 2)}
|
||||
</Code>
|
||||
</Stack>
|
||||
)}
|
||||
</Stack>
|
||||
</Sheet>
|
||||
);
|
||||
});
|
||||
|
||||
const ActivitiesResults = ({ searchParams, page, setPage, onActivityClick }: any) => {
|
||||
const { data: result } = useActivities(searchParams);
|
||||
return (
|
||||
<>
|
||||
<Stack gap={0}>
|
||||
{result.items.map((activity: Activity, index: number) => (
|
||||
<Box key={activity.id}>
|
||||
<ActivityListItem
|
||||
activity={activity}
|
||||
onClick={() => onActivityClick(activity)}
|
||||
/>
|
||||
{index < result.items.length - 1 && <Divider />}
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
{result.items.length === 0 && (
|
||||
<Stack align="center" gap="md" py="xl">
|
||||
<ThemeIcon size="xl" variant="light" radius="md">
|
||||
<PulseIcon size={32} />
|
||||
</ThemeIcon>
|
||||
<Title order={3} c="dimmed">
|
||||
<Trans>No Activities Found</Trans>
|
||||
</Title>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{result.totalPages > 1 && (
|
||||
<Group justify="center" py="md">
|
||||
<Pagination
|
||||
total={result.totalPages}
|
||||
value={page}
|
||||
onChange={setPage}
|
||||
size="sm"
|
||||
/>
|
||||
</Group>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
const SLOW_THRESHOLD_MS = 1000;
|
||||
|
||||
export const ActivitiesTable = () => {
|
||||
const { t } = useLingui();
|
||||
const { t, i18n } = useLingui();
|
||||
const [page, setPage] = useState(1);
|
||||
const [search, setSearch] = useState("");
|
||||
const [successFilter, setSuccessFilter] = useState<string | null>(null);
|
||||
const [playerFilter, setPlayerFilter] = useState<string | null>(null);
|
||||
const [slowOnly, setSlowOnly] = useState(false);
|
||||
const [sortBy, setSortBy] = useState("-created");
|
||||
const [selectedActivity, setSelectedActivity] = useState<Activity | null>(null);
|
||||
const { isOpen: detailsOpened, open: openDetails, close: closeDetails } = useSheet();
|
||||
|
||||
const {
|
||||
isOpen: detailsOpened,
|
||||
open: openDetails,
|
||||
close: closeDetails,
|
||||
} = useSheet();
|
||||
const { data: players } = usePlayers();
|
||||
|
||||
const searchParams: ActivitySearchParams = useMemo(
|
||||
() => ({
|
||||
@@ -270,13 +34,24 @@ export const ActivitiesTable = () => {
|
||||
perPage: 100,
|
||||
name: search || undefined,
|
||||
success: successFilter === "success" ? true : successFilter === "failure" ? false : undefined,
|
||||
player: playerFilter || undefined,
|
||||
sortBy,
|
||||
}),
|
||||
[page, search, successFilter, sortBy]
|
||||
[page, search, successFilter, playerFilter, sortBy]
|
||||
);
|
||||
|
||||
const { data: result } = useActivities(searchParams);
|
||||
|
||||
const items = useMemo(
|
||||
() => (slowOnly ? result.items.filter((a) => a.duration > SLOW_THRESHOLD_MS) : result.items),
|
||||
[result.items, slowOnly]
|
||||
);
|
||||
|
||||
const playerName = (activity: Activity) =>
|
||||
typeof activity.player === "object" && activity.player
|
||||
? `${activity.player.first_name} ${activity.player.last_name}`
|
||||
: t`System`;
|
||||
|
||||
const handleSort = (field: string) => {
|
||||
setSortBy((prev) => {
|
||||
if (prev === field) return `-${field}`;
|
||||
@@ -285,12 +60,6 @@ export const ActivitiesTable = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const getSortIcon = (field: string) => {
|
||||
if (sortBy === field) return <CaretUpIcon size={14} />;
|
||||
if (sortBy === `-${field}`) return <CaretDownIcon size={14} />;
|
||||
return null;
|
||||
};
|
||||
|
||||
const handleActivityClick = (activity: Activity) => {
|
||||
setSelectedActivity(activity);
|
||||
openDetails();
|
||||
@@ -304,90 +73,163 @@ export const ActivitiesTable = () => {
|
||||
return (
|
||||
<Container size="100%" px={0}>
|
||||
<Stack gap="xs">
|
||||
<Stack gap="xs" px="md">
|
||||
<TextInput
|
||||
placeholder={t`serverFn name`}
|
||||
value={search}
|
||||
onChange={(e) => {
|
||||
setSearch(e.currentTarget.value);
|
||||
setPage(1);
|
||||
}}
|
||||
leftSection={<MagnifyingGlassIcon size={16} />}
|
||||
size="md"
|
||||
/>
|
||||
|
||||
<Group>
|
||||
<Select
|
||||
placeholder={t`Status`}
|
||||
value={successFilter}
|
||||
onChange={(value) => {
|
||||
<SearchFilterBar
|
||||
searchValue={search}
|
||||
onSearchChange={(value) => {
|
||||
setSearch(value);
|
||||
setPage(1);
|
||||
}}
|
||||
searchPlaceholder={t`serverFn name`}
|
||||
filters={[
|
||||
{
|
||||
placeholder: t`Status`,
|
||||
value: successFilter,
|
||||
onChange: (value) => {
|
||||
setSuccessFilter(value);
|
||||
setPage(1);
|
||||
}}
|
||||
data={[
|
||||
},
|
||||
data: [
|
||||
{ value: "all", label: t`All` },
|
||||
{ value: "success", label: t`Success` },
|
||||
{ value: "failure", label: t`Failure` },
|
||||
]}
|
||||
clearable
|
||||
size="sm"
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
</Group>
|
||||
</Stack>
|
||||
|
||||
<Group px="md" justify="space-between" align="center">
|
||||
<Text size="10px" lh={0} c="dimmed">
|
||||
],
|
||||
},
|
||||
{
|
||||
placeholder: t`Player`,
|
||||
value: playerFilter,
|
||||
onChange: (value) => {
|
||||
setPlayerFilter(value);
|
||||
setPage(1);
|
||||
},
|
||||
data: players.map((player) => ({
|
||||
value: player.id,
|
||||
label: `${player.first_name} ${player.last_name}`,
|
||||
})),
|
||||
searchable: true,
|
||||
},
|
||||
]}
|
||||
chips={[
|
||||
{
|
||||
label: t`Slow >1s (this page)`,
|
||||
checked: slowOnly,
|
||||
onChange: setSlowOnly,
|
||||
},
|
||||
]}
|
||||
sortFields={[
|
||||
{ field: "created", label: <Trans>Date</Trans> },
|
||||
{ field: "duration", label: <Trans>Duration</Trans> },
|
||||
]}
|
||||
sortBy={sortBy}
|
||||
onSort={handleSort}
|
||||
summary={
|
||||
<Plural value={result.totalItems} one="# total activity" other="# total activities" />
|
||||
</Text>
|
||||
<Group gap="xs">
|
||||
<Text size="xs" c="dimmed">
|
||||
<Trans>Sort:</Trans>
|
||||
</Text>
|
||||
<UnstyledButton
|
||||
onClick={() => handleSort("created")}
|
||||
style={{ display: "flex", alignItems: "center", gap: 4 }}
|
||||
>
|
||||
<Text
|
||||
size="xs"
|
||||
fw={sortBy.includes("created") ? 600 : 400}
|
||||
c={sortBy.includes("created") ? "var(--mantine-color-text)" : "dimmed"}
|
||||
>
|
||||
<Trans>Date</Trans>
|
||||
</Text>
|
||||
{getSortIcon("created")}
|
||||
</UnstyledButton>
|
||||
<Text size="xs" c="dimmed">
|
||||
•
|
||||
</Text>
|
||||
<UnstyledButton
|
||||
onClick={() => handleSort("duration")}
|
||||
style={{ display: "flex", alignItems: "center", gap: 4 }}
|
||||
>
|
||||
<Text
|
||||
size="xs"
|
||||
fw={sortBy.includes("duration") ? 600 : 400}
|
||||
c={sortBy.includes("duration") ? "var(--mantine-color-text)" : "dimmed"}
|
||||
>
|
||||
<Trans>Duration</Trans>
|
||||
</Text>
|
||||
{getSortIcon("duration")}
|
||||
</UnstyledButton>
|
||||
</Group>
|
||||
</Group>
|
||||
}
|
||||
/>
|
||||
|
||||
<ActivitiesResults
|
||||
searchParams={searchParams}
|
||||
<PaginatedList
|
||||
items={items}
|
||||
keyOf={(activity) => activity.id}
|
||||
empty={t`No Activities Found`}
|
||||
page={page}
|
||||
setPage={setPage}
|
||||
onActivityClick={handleActivityClick}
|
||||
totalPages={result.totalPages}
|
||||
onPageChange={setPage}
|
||||
renderItem={(activity) => (
|
||||
<TelemetryListItem
|
||||
title={activity.name}
|
||||
icon={
|
||||
activity.success ? (
|
||||
<CheckIcon size={16} color="var(--mantine-color-green-6)" />
|
||||
) : (
|
||||
<XIcon size={16} color="var(--mantine-color-red-6)" />
|
||||
)
|
||||
}
|
||||
meta={[
|
||||
playerName(activity),
|
||||
<Trans>{activity.duration}ms</Trans>,
|
||||
new Date(activity.created).toLocaleString(i18n.locale),
|
||||
]}
|
||||
error={activity.error}
|
||||
onClick={() => handleActivityClick(activity)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<ActivityDetailsSheet
|
||||
activity={selectedActivity}
|
||||
isOpen={detailsOpened}
|
||||
<DetailSheet
|
||||
title={t`Activity Details`}
|
||||
opened={detailsOpened}
|
||||
onClose={handleCloseDetails}
|
||||
fields={
|
||||
selectedActivity
|
||||
? [
|
||||
{ label: <Trans>Function Name</Trans>, value: selectedActivity.name },
|
||||
{
|
||||
label: <Trans>Status</Trans>,
|
||||
value: (
|
||||
<Group gap="xs">
|
||||
{selectedActivity.success ? (
|
||||
<>
|
||||
<CheckIcon size={16} color="var(--mantine-color-green-6)" />
|
||||
<Text size="sm" c="green">
|
||||
<Trans>Success</Trans>
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<XIcon size={16} color="var(--mantine-color-red-6)" />
|
||||
<Text size="sm" c="red">
|
||||
<Trans>Failed</Trans>
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
</Group>
|
||||
),
|
||||
},
|
||||
{ label: <Trans>Player</Trans>, value: playerName(selectedActivity) },
|
||||
{
|
||||
label: <Trans>Duration</Trans>,
|
||||
value: (
|
||||
<Text size="sm">
|
||||
<Trans>{selectedActivity.duration}ms</Trans>
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
label: <Trans>Created</Trans>,
|
||||
value: new Date(selectedActivity.created).toLocaleString(i18n.locale),
|
||||
},
|
||||
...(selectedActivity.user_agent
|
||||
? [{ label: <Trans>User Agent</Trans>, value: selectedActivity.user_agent }]
|
||||
: []),
|
||||
...(selectedActivity.error
|
||||
? [
|
||||
{
|
||||
label: <Trans>Error Message</Trans>,
|
||||
value: (
|
||||
<Alert color="red" variant="light">
|
||||
<Text size="sm" style={{ wordBreak: "break-word" }}>
|
||||
{selectedActivity.error}
|
||||
</Text>
|
||||
</Alert>
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
...(selectedActivity.arguments
|
||||
? [
|
||||
{
|
||||
label: <Trans>Arguments</Trans>,
|
||||
value: (
|
||||
<Code block style={{ fontSize: "11px" }}>
|
||||
{JSON.stringify(selectedActivity.arguments, null, 2)}
|
||||
</Code>
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]
|
||||
: []
|
||||
}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { Box, Card, Text, Select, Button, Group, Stack, Badge, Divider } from "@mantine/core";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { awardManualBadge } from "@/features/badges/server";
|
||||
import useAwardManualBadge from "@/features/badges/hooks/use-award-manual-badge";
|
||||
import { useAllBadges } from "@/features/badges/queries";
|
||||
import toast from "@/lib/sonner";
|
||||
import { usePlayers } from "@/features/players/queries";
|
||||
@@ -13,35 +13,29 @@ const AwardBadges = () => {
|
||||
|
||||
const [selectedPlayerId, setSelectedPlayerId] = useState<string | null>(null);
|
||||
const [selectedBadgeId, setSelectedBadgeId] = useState<string | null>(null);
|
||||
const [isAwarding, setIsAwarding] = useState(false);
|
||||
|
||||
const awardBadge = useAwardManualBadge();
|
||||
|
||||
const manualBadges = allBadges.filter((badge) => badge.type === "manual");
|
||||
|
||||
const handleAwardBadge = async () => {
|
||||
const handleAwardBadge = () => {
|
||||
if (!selectedPlayerId || !selectedBadgeId) return;
|
||||
|
||||
setIsAwarding(true);
|
||||
try {
|
||||
await awardManualBadge({
|
||||
data: {
|
||||
playerId: selectedPlayerId,
|
||||
badgeId: selectedBadgeId,
|
||||
awardBadge.mutate(
|
||||
{ playerId: selectedPlayerId, badgeId: selectedBadgeId },
|
||||
{
|
||||
onSuccess: () => {
|
||||
const selectedPlayer = players.find((p) => p.id === selectedPlayerId);
|
||||
const playerName = selectedPlayer
|
||||
? `${selectedPlayer.first_name} ${selectedPlayer.last_name}`
|
||||
: t`Player`;
|
||||
|
||||
toast.success(t`Badge awarded to ${playerName}`);
|
||||
|
||||
setSelectedPlayerId(null);
|
||||
},
|
||||
});
|
||||
|
||||
const selectedPlayer = players.find((p) => p.id === selectedPlayerId);
|
||||
const playerName = selectedPlayer
|
||||
? `${selectedPlayer.first_name} ${selectedPlayer.last_name}`
|
||||
: t`Player`;
|
||||
|
||||
toast.success(t`Badge awarded to ${playerName}`);
|
||||
|
||||
setSelectedPlayerId(null);
|
||||
} catch (error) {
|
||||
toast.error(t`Failed to award badge`);
|
||||
} finally {
|
||||
setIsAwarding(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const playerOptions = players.map((player) => ({
|
||||
@@ -98,7 +92,7 @@ const AwardBadges = () => {
|
||||
<Button
|
||||
onClick={handleAwardBadge}
|
||||
disabled={!selectedPlayerId}
|
||||
loading={isAwarding}
|
||||
loading={awardBadge.isPending}
|
||||
size="md"
|
||||
>
|
||||
<Trans>Award Badge</Trans>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { Suspense } from "react";
|
||||
import { SimpleGrid, Skeleton } from "@mantine/core";
|
||||
import QuietBoundary from "./quiet-boundary";
|
||||
import SectionBox from "./section-box";
|
||||
import TournamentSection from "./tournament-section";
|
||||
import ToolsList from "./tools-list";
|
||||
|
||||
const TournamentSkeleton = () => (
|
||||
<SectionBox>
|
||||
<Skeleton height={24} width={180} radius="sm" />
|
||||
<SimpleGrid cols={3} spacing="sm" mt="sm">
|
||||
<Skeleton height={72} radius="md" />
|
||||
<Skeleton height={72} radius="md" />
|
||||
<Skeleton height={72} radius="md" />
|
||||
</SimpleGrid>
|
||||
</SectionBox>
|
||||
);
|
||||
|
||||
export const AdminDashboard = () => (
|
||||
<>
|
||||
<QuietBoundary>
|
||||
<Suspense fallback={<TournamentSkeleton />}>
|
||||
<TournamentSection />
|
||||
</Suspense>
|
||||
</QuietBoundary>
|
||||
<ToolsList />
|
||||
</>
|
||||
);
|
||||
|
||||
export default AdminDashboard;
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Component, ReactNode } from "react";
|
||||
import { Text } from "@mantine/core";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
|
||||
interface QuietBoundaryProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
interface QuietBoundaryState {
|
||||
hasError: boolean;
|
||||
}
|
||||
|
||||
export class QuietBoundary extends Component<QuietBoundaryProps, QuietBoundaryState> {
|
||||
state: QuietBoundaryState = { hasError: false };
|
||||
|
||||
static getDerivedStateFromError(): QuietBoundaryState {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return (
|
||||
<Text size="sm" c="dimmed">
|
||||
<Trans>Unavailable right now</Trans>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export default QuietBoundary;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Box } from "@mantine/core";
|
||||
|
||||
export const SectionBox = ({ children }: { children: ReactNode }) => (
|
||||
<Box
|
||||
px="md"
|
||||
py="sm"
|
||||
style={{ borderBottom: "1px solid var(--mantine-color-default-border)" }}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
);
|
||||
|
||||
export default SectionBox;
|
||||
+9
-9
@@ -1,20 +1,20 @@
|
||||
import { List, Text } from "@mantine/core";
|
||||
import { Plural, Trans, useLingui } from "@lingui/react/macro";
|
||||
import ListLink from "@/components/list-link";
|
||||
import {
|
||||
DatabaseIcon,
|
||||
TreeStructureIcon,
|
||||
TrophyIcon,
|
||||
MedalIcon,
|
||||
CrownIcon,
|
||||
ListIcon,
|
||||
PulseIcon,
|
||||
} from "@phosphor-icons/react";
|
||||
import ListLink from "@/components/list-link";
|
||||
import ListButton from "@/components/list-button";
|
||||
import { getBadgeMigrationStatus, migrateBadgeProgress } from "@/features/badges/server";
|
||||
import { useServerQuery } from "@/lib/tanstack-query/hooks";
|
||||
import toast from "@/lib/sonner";
|
||||
|
||||
const AdminPage = () => {
|
||||
export const ToolsList = () => {
|
||||
const { t } = useLingui();
|
||||
|
||||
const { data: migrationStatus, refetch: refetchMigrationStatus } = useServerQuery({
|
||||
@@ -51,6 +51,11 @@ const AdminPage = () => {
|
||||
Icon={TrophyIcon}
|
||||
to="/admin/tournaments"
|
||||
/>
|
||||
<ListLink
|
||||
label={t`Telemetry`}
|
||||
Icon={PulseIcon}
|
||||
to="/admin/telemetry/usage"
|
||||
/>
|
||||
<ListLink
|
||||
label={t`Award Badges`}
|
||||
Icon={CrownIcon}
|
||||
@@ -86,11 +91,6 @@ const AdminPage = () => {
|
||||
<Trans>Badge recalculation failed. Check the server logs.</Trans>
|
||||
</Text>
|
||||
)}
|
||||
<ListLink
|
||||
label={t`Activities`}
|
||||
Icon={ListIcon}
|
||||
to="/admin/activities"
|
||||
/>
|
||||
<ListButton
|
||||
label={t`Open Pocketbase`}
|
||||
Icon={DatabaseIcon}
|
||||
@@ -107,4 +107,4 @@ const AdminPage = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default AdminPage;
|
||||
export default ToolsList;
|
||||
@@ -0,0 +1,48 @@
|
||||
import { SimpleGrid, Text, Title } from "@mantine/core";
|
||||
import { useLingui } from "@lingui/react/macro";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { GearIcon, PlayIcon, UsersThreeIcon } from "@phosphor-icons/react";
|
||||
import { useCurrentTournament } from "@/features/tournaments/queries";
|
||||
import { NavTile } from "@/components/nav-tile";
|
||||
import { Countdown } from "@/components/countdown";
|
||||
import SectionBox from "./section-box";
|
||||
|
||||
export const TournamentSection = () => {
|
||||
const { t } = useLingui();
|
||||
const navigate = useNavigate();
|
||||
const { data: tournament } = useCurrentTournament();
|
||||
|
||||
if (!tournament) return null;
|
||||
|
||||
const upcoming = !!tournament.start_time && Date.parse(tournament.start_time) > Date.now();
|
||||
|
||||
return (
|
||||
<SectionBox>
|
||||
<Title order={3}>{tournament.name}</Title>
|
||||
{upcoming && (
|
||||
<Text size="sm" c="dimmed" component="div">
|
||||
<Countdown date={new Date(tournament.start_time)} label={t`Starts in`} />
|
||||
</Text>
|
||||
)}
|
||||
<SimpleGrid cols={3} spacing="sm" mt="sm">
|
||||
<NavTile
|
||||
label={t`Run`}
|
||||
Icon={PlayIcon}
|
||||
onClick={() => navigate({ to: `/admin/tournaments/run/${tournament.id}` })}
|
||||
/>
|
||||
<NavTile
|
||||
label={t`Enrollment`}
|
||||
Icon={UsersThreeIcon}
|
||||
onClick={() => navigate({ to: `/admin/tournaments/${tournament.id}/enrollment` })}
|
||||
/>
|
||||
<NavTile
|
||||
label={t`Manage`}
|
||||
Icon={GearIcon}
|
||||
onClick={() => navigate({ to: `/admin/tournaments/${tournament.id}` })}
|
||||
/>
|
||||
</SimpleGrid>
|
||||
</SectionBox>
|
||||
);
|
||||
};
|
||||
|
||||
export default TournamentSection;
|
||||
@@ -2,4 +2,4 @@ import { Logger } from "@/lib/logger";
|
||||
|
||||
export const logger = new Logger("Admin");
|
||||
|
||||
export { default as AdminPage } from "./components/admin-page";
|
||||
export { default as AdminDashboard } from "./components/dashboard";
|
||||
|
||||
@@ -19,6 +19,7 @@ import PlayerList from '@/features/players/components/player-list';
|
||||
import { useAuth } from '@/contexts/auth-context';
|
||||
import { Player } from '@/features/players/types';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { track } from '@/lib/telemetry/client';
|
||||
|
||||
const BadgeStatsTable = () => {
|
||||
const { data: allBadges } = useAllBadges();
|
||||
@@ -141,7 +142,13 @@ const BadgeStatRow: React.FC<BadgeStatRowProps> = ({
|
||||
|
||||
return (
|
||||
<Box key={badge.id}>
|
||||
<UnstyledButton onClick={badgeSheet.open} w='100%'>
|
||||
<UnstyledButton
|
||||
onClick={() => {
|
||||
track("badge_viewed", { value: badge.key });
|
||||
badgeSheet.open();
|
||||
}}
|
||||
w='100%'
|
||||
>
|
||||
<Grid p={'xs'} align='center'>
|
||||
<Grid.Col span={2} style={{ display: 'flex', alignItems: 'center' }}>
|
||||
<BadgeIcon badge={badge} filled={true} />
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useServerMutation } from "@/lib/tanstack-query/hooks/use-server-mutation";
|
||||
import { awardManualBadge } from "@/features/badges/server";
|
||||
import { badgeKeys } from "@/features/badges/queries";
|
||||
|
||||
interface AwardManualBadgeInput {
|
||||
playerId: string;
|
||||
badgeId: string;
|
||||
}
|
||||
|
||||
export default function useAwardManualBadge() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useServerMutation({
|
||||
mutationFn: (data: AwardManualBadgeInput) => awardManualBadge({ data }),
|
||||
onSuccess: (_data, { playerId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: badgeKeys.playerBadges(playerId) });
|
||||
queryClient.invalidateQueries({ queryKey: badgeKeys.allEarnedBadges() });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
||||
import { superTokensAdminFunctionMiddleware, superTokensFunctionMiddleware } from "@/utils/supertokens";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
import { createServerFn } from "@tanstack/react-start";
|
||||
import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { z } from "zod";
|
||||
@@ -15,7 +14,7 @@ export const getPlayerBadges = createServerFn()
|
||||
);
|
||||
|
||||
export const migrateBadgeProgress = createServerFn()
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async () =>
|
||||
toServerResult(async () => startBadgeMigration())
|
||||
);
|
||||
@@ -41,7 +40,7 @@ export const awardManualBadge = createServerFn()
|
||||
playerId: z.string(),
|
||||
badgeId: z.string(),
|
||||
}))
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ data }) =>
|
||||
toServerResult(async () => {
|
||||
const result = await pbAdmin.awardManualBadge(data.playerId, data.badgeId);
|
||||
|
||||
@@ -399,7 +399,7 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
</Sheet>
|
||||
</Flex>
|
||||
|
||||
{!showControls && <MatchReport match={match} compact />}
|
||||
{!showControls && <MatchReport match={match} compact source="match_card" />}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ import { MatchReport } from "./match-report";
|
||||
import Sheet from "@/components/sheet/sheet";
|
||||
import { useSheet } from "@/hooks/use-sheet";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
const EASE: [number, number, number, number] = [0.32, 0.72, 0, 1];
|
||||
|
||||
@@ -155,7 +156,7 @@ const MatchDock = ({ match, onClose }: MatchDockProps) => {
|
||||
ended={ended}
|
||||
/>
|
||||
|
||||
<MatchReport match={match} />
|
||||
<MatchReport match={match} source="match_dock" />
|
||||
|
||||
<Group justify="space-between" wrap="nowrap" gap="sm">
|
||||
<Box style={{ flex: 1, minWidth: 0 }}>
|
||||
@@ -166,7 +167,7 @@ const MatchDock = ({ match, onClose }: MatchDockProps) => {
|
||||
</Center>
|
||||
}
|
||||
>
|
||||
<EmojiBar matchId={match.id} />
|
||||
<EmojiBar matchId={match.id} source="match_dock" />
|
||||
</Suspense>
|
||||
</Box>
|
||||
{!hasPrivate && (
|
||||
@@ -174,7 +175,15 @@ const MatchDock = ({ match, onClose }: MatchDockProps) => {
|
||||
<ActionIcon
|
||||
variant="subtle"
|
||||
size="sm"
|
||||
onClick={h2hSheet.open}
|
||||
onClick={() => {
|
||||
track("h2h_viewed", {
|
||||
source: "match_dock",
|
||||
context: [match?.home?.name, match?.away?.name]
|
||||
.filter(Boolean)
|
||||
.join(" v "),
|
||||
});
|
||||
h2hSheet.open();
|
||||
}}
|
||||
aria-label={t`View head-to-head`}
|
||||
w={40}
|
||||
style={{ flexShrink: 0 }}
|
||||
|
||||
@@ -13,6 +13,7 @@ import Sheet from "@/components/sheet/sheet";
|
||||
import { MatchForm } from "./match-form";
|
||||
import toast from "@/lib/sonner";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
const teamId = (t: Match["home"]): string | undefined =>
|
||||
!t ? undefined : typeof t === "string" ? t : t.id;
|
||||
@@ -26,9 +27,10 @@ const teamName = (t: Match["home"]): string | undefined =>
|
||||
interface MatchReportProps {
|
||||
match: Match;
|
||||
compact?: boolean;
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export const MatchReport: React.FC<MatchReportProps> = ({ match, compact }) => {
|
||||
export const MatchReport: React.FC<MatchReportProps> = ({ match, compact, source }) => {
|
||||
const { user } = useAuth();
|
||||
const formSheet = useSheet();
|
||||
const { t } = useLingui();
|
||||
@@ -129,8 +131,9 @@ export const MatchReport: React.FC<MatchReportProps> = ({ match, compact }) => {
|
||||
|
||||
const openForm = useCallback(() => {
|
||||
setAcknowledgedReport(pendingSignature);
|
||||
track("score_report_opened", source ? { source } : undefined);
|
||||
formSheet.open();
|
||||
}, [pendingSignature, formSheet.open]);
|
||||
}, [pendingSignature, formSheet.open, source]);
|
||||
|
||||
const dismissTakeover = useCallback(() => {
|
||||
setAcknowledgedReport(pendingSignature);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { isAdminRole } from "../utils/roles";
|
||||
|
||||
export const useIsAdmin = (): boolean => {
|
||||
const { roles } = useAuth();
|
||||
return isAdminRole(roles);
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HouseIcon, RankingIcon, ShieldIcon, TrophyIcon, UserCircleIcon } from "@phosphor-icons/react";
|
||||
import { useMemo } from "react";
|
||||
import { useLingui } from "@lingui/react/macro";
|
||||
import { isAdminRole } from "../utils/roles";
|
||||
|
||||
export const useLinks = (userId: string | undefined, roles: string[]) => {
|
||||
const { t } = useLingui();
|
||||
@@ -31,7 +32,7 @@ export const useLinks = (userId: string | undefined, roles: string[]) => {
|
||||
}
|
||||
]
|
||||
|
||||
if (roles.includes('Admin')) {
|
||||
if (isAdminRole(roles)) {
|
||||
links.push({
|
||||
label: t`Admin`,
|
||||
href: '/admin',
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export const ADMIN_ROLE = "Admin";
|
||||
|
||||
export const isAdminRole = (roles?: string[] | null): boolean =>
|
||||
!!roles?.includes(ADMIN_ROLE);
|
||||
@@ -10,6 +10,7 @@ import Sheet from "@/components/sheet/sheet";
|
||||
import TeamHeadToHeadSheet from "./team-head-to-head-sheet";
|
||||
import AnimatedScore from "./animated-score";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
interface MatchCardProps {
|
||||
match: Match;
|
||||
@@ -41,6 +42,10 @@ const MatchCard = ({ match, hideH2H = false }: MatchCardProps) => {
|
||||
|
||||
const handleH2HClick = (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
track("h2h_viewed", {
|
||||
source: "match_card",
|
||||
context: [match.home?.name, match.away?.name].filter(Boolean).join(" v "),
|
||||
});
|
||||
h2hSheet.open();
|
||||
};
|
||||
|
||||
@@ -218,7 +223,7 @@ const MatchCard = ({ match, hideH2H = false }: MatchCardProps) => {
|
||||
}}
|
||||
>
|
||||
<Suspense>
|
||||
<EmojiBar matchId={match.id} />
|
||||
<EmojiBar matchId={match.id} source="match_card" />
|
||||
</Suspense>
|
||||
</Paper>
|
||||
</Box>
|
||||
|
||||
@@ -9,7 +9,6 @@ import { Match, MatchInput } from "@/features/matches/types";
|
||||
import { emitServerEvent } from "@/lib/events/emitter";
|
||||
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
|
||||
import { PlayerInfo } from "../players/types";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
|
||||
const orderedTeamsSchema = z.object({
|
||||
tournamentId: z.string(),
|
||||
@@ -18,7 +17,7 @@ const orderedTeamsSchema = z.object({
|
||||
|
||||
export const generateTournamentBracket = createServerFn()
|
||||
.validator(orderedTeamsSchema)
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ data: { tournamentId, orderedTeamIds } }) =>
|
||||
toServerResult(async () => {
|
||||
logger.info("Generating tournament bracket", {
|
||||
@@ -141,7 +140,7 @@ export const generateTournamentBracket = createServerFn()
|
||||
|
||||
export const startMatch = createServerFn()
|
||||
.validator(z.string())
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ data }) =>
|
||||
toServerResult(async () => {
|
||||
logger.info("Starting match", data);
|
||||
@@ -170,7 +169,7 @@ export const populateKnockoutBracket = createServerFn()
|
||||
.validator(z.object({
|
||||
tournamentId: z.string(),
|
||||
}))
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ data: { tournamentId } }) =>
|
||||
toServerResult(async () => {
|
||||
const tournament = await pbAdmin.getTournament(tournamentId);
|
||||
@@ -801,7 +800,7 @@ const endMatchSchema = z.object({
|
||||
});
|
||||
export const endMatch = createServerFn()
|
||||
.validator(endMatchSchema)
|
||||
.middleware([superTokensAdminFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ data: { matchId, home_cups, away_cups, ot_count } }) =>
|
||||
toServerResult(async () => {
|
||||
logger.info("Ending match", matchId);
|
||||
@@ -827,7 +826,7 @@ const reportScoreSchema = z.object({
|
||||
|
||||
export const reportMatchScore = createServerFn()
|
||||
.validator(reportScoreSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data: { matchId, home_cups, away_cups, ot_count }, context }) =>
|
||||
toServerResult(async () => {
|
||||
const player = await pbAdmin.getPlayerByAuthId(context.userAuthId);
|
||||
@@ -890,7 +889,7 @@ const matchIdSchema = z.object({ matchId: z.string() });
|
||||
|
||||
export const confirmMatchScore = createServerFn()
|
||||
.validator(matchIdSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data: { matchId }, context }) =>
|
||||
toServerResult(async () => {
|
||||
const player = await pbAdmin.getPlayerByAuthId(context.userAuthId);
|
||||
@@ -929,7 +928,7 @@ export const confirmMatchScore = createServerFn()
|
||||
|
||||
export const clearMatchReport = createServerFn()
|
||||
.validator(matchIdSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data: { matchId }, context }) =>
|
||||
toServerResult(async () => {
|
||||
const player = await pbAdmin.getPlayerByAuthId(context.userAuthId);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { matchInputSchema } from "./types";
|
||||
|
||||
describe("matchInputSchema.partial()", () => {
|
||||
it("does not inject keys the caller did not send", () => {
|
||||
const parsed = matchInputSchema.partial().parse({ home_cups: 7 });
|
||||
expect(parsed).toEqual({ home_cups: 7 });
|
||||
});
|
||||
});
|
||||
@@ -42,20 +42,20 @@ export interface Match {
|
||||
export const matchInputSchema = z.object({
|
||||
order: z.number().int().min(1).optional(),
|
||||
lid: z.number().int().min(1),
|
||||
reset: z.boolean().optional().default(false),
|
||||
reset: z.boolean().optional(),
|
||||
round: z.number().int().min(1),
|
||||
home_cups: z.number().int().min(0).optional().default(0),
|
||||
away_cups: z.number().int().min(0).optional().default(0),
|
||||
ot_count: z.number().int().min(0).optional().default(0),
|
||||
home_cups: z.number().int().min(0).optional(),
|
||||
away_cups: z.number().int().min(0).optional(),
|
||||
ot_count: z.number().int().min(0).optional(),
|
||||
start_time: z.iso.datetime().optional(),
|
||||
end_time: z.iso.datetime().optional(),
|
||||
bye: z.boolean().optional().default(false),
|
||||
bye: z.boolean().optional(),
|
||||
home_from_lid: z.number().int().min(1).optional(),
|
||||
away_from_lid: z.number().int().min(1).optional(),
|
||||
home_from_loser: z.boolean().optional().default(false),
|
||||
away_from_loser: z.boolean().optional().default(false),
|
||||
is_losers_bracket: z.boolean().optional().default(false),
|
||||
status: z.enum(["tbd", "ready", "started", "ended"]).optional().default("tbd"),
|
||||
home_from_loser: z.boolean().optional(),
|
||||
away_from_loser: z.boolean().optional(),
|
||||
is_losers_bracket: z.boolean().optional(),
|
||||
status: z.enum(["tbd", "ready", "started", "ended"]).optional(),
|
||||
tournament: z.string().min(1),
|
||||
home: z.string().min(1).nullable().optional(),
|
||||
away: z.string().min(1).nullable().optional(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Stack, Text, TextInput, Box, Paper, Group, Divider, ActionIcon, Button } from "@mantine/core";
|
||||
import { useState, useMemo } from "react";
|
||||
import { useState, useMemo, useRef } from "react";
|
||||
import { MagnifyingGlassIcon, XIcon, ArrowRightIcon, PlusIcon } from "@phosphor-icons/react";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { useAllPlayerStats } from "../queries";
|
||||
@@ -8,6 +8,7 @@ import { useSheet } from "@/hooks/use-sheet";
|
||||
import Sheet from "@/components/sheet/sheet";
|
||||
import PlayerHeadToHeadSheet from "./player-head-to-head-sheet";
|
||||
import PlayerAvatar from "@/components/player-avatar";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
const LeagueHeadToHead = () => {
|
||||
const { t } = useLingui();
|
||||
@@ -15,6 +16,7 @@ const LeagueHeadToHead = () => {
|
||||
const [player1Id, setPlayer1Id] = useState<string | null>(null);
|
||||
const [player2Id, setPlayer2Id] = useState<string | null>(null);
|
||||
const [search, setSearch] = useState("");
|
||||
const searchedRef = useRef(false);
|
||||
const { data: allPlayerStats } = useAllPlayerStats();
|
||||
const h2hSheet = useSheet();
|
||||
|
||||
@@ -51,6 +53,12 @@ const LeagueHeadToHead = () => {
|
||||
setPlayer1Id(playerId);
|
||||
} else {
|
||||
setPlayer2Id(playerId);
|
||||
const opponent =
|
||||
allPlayerStats?.find((p) => p.player_id === playerId)?.player_name || "";
|
||||
track("h2h_viewed", {
|
||||
source: "stats",
|
||||
context: [player1Name, opponent].filter(Boolean).join(" v "),
|
||||
});
|
||||
h2hSheet.open();
|
||||
}
|
||||
};
|
||||
@@ -128,7 +136,14 @@ const LeagueHeadToHead = () => {
|
||||
<TextInput
|
||||
placeholder={t`Search players`}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.currentTarget.value)}
|
||||
onChange={(e) => {
|
||||
const value = e.currentTarget.value;
|
||||
if (value && !searchedRef.current) {
|
||||
searchedRef.current = true;
|
||||
track("player_searched");
|
||||
}
|
||||
setSearch(value);
|
||||
}}
|
||||
leftSection={<MagnifyingGlassIcon size={16} />}
|
||||
size="md"
|
||||
px="md"
|
||||
|
||||
@@ -28,6 +28,7 @@ import { useNavigate } from "@tanstack/react-router";
|
||||
import { useAllPlayerStats } from "../queries";
|
||||
import { PlayerListItemSkeleton } from "./player-stats-table-skeleton";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
type SortKey = keyof PlayerStats | "mmr";
|
||||
type SortDirection = "asc" | "desc";
|
||||
@@ -177,6 +178,7 @@ const PlayerStatsTable = ({ viewType = 'all' }: PlayerStatsTableProps) => {
|
||||
const navigate = useNavigate();
|
||||
const [search, setSearch] = useState("");
|
||||
const deferredSearch = useDeferredValue(search);
|
||||
const searchedRef = useRef(false);
|
||||
const [sortConfig, setSortConfig] = useState<SortConfig>({
|
||||
key: "mmr" as SortKey,
|
||||
direction: "desc",
|
||||
@@ -291,10 +293,10 @@ const PlayerStatsTable = ({ viewType = 'all' }: PlayerStatsTableProps) => {
|
||||
}, [navigate]);
|
||||
|
||||
const handleSort = (key: SortKey) => {
|
||||
setSortConfig((prev) => ({
|
||||
key,
|
||||
direction: prev.key === key && prev.direction === "desc" ? "asc" : "desc",
|
||||
}));
|
||||
const direction =
|
||||
sortConfig.key === key && sortConfig.direction === "desc" ? "asc" : "desc";
|
||||
track("stats_sorted", { value: key, context: direction });
|
||||
setSortConfig({ key, direction });
|
||||
};
|
||||
|
||||
const getSortIcon = (key: SortKey) => {
|
||||
@@ -328,7 +330,14 @@ const PlayerStatsTable = ({ viewType = 'all' }: PlayerStatsTableProps) => {
|
||||
<TextInput
|
||||
placeholder={t`Search players`}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.currentTarget.value)}
|
||||
onChange={(e) => {
|
||||
const value = e.currentTarget.value;
|
||||
if (value && !searchedRef.current) {
|
||||
searchedRef.current = true;
|
||||
track("player_searched");
|
||||
}
|
||||
setSearch(value);
|
||||
}}
|
||||
leftSection={<MagnifyingGlassIcon size={16} />}
|
||||
size="md"
|
||||
px="md"
|
||||
|
||||
@@ -9,6 +9,7 @@ import PlayerAvatar from "@/components/player-avatar";
|
||||
import { useSheet } from "@/hooks/use-sheet";
|
||||
import { Player } from "../../types";
|
||||
import PlayerHeadToHeadSheet from "../player-head-to-head-sheet";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
interface HeaderProps {
|
||||
player: Player;
|
||||
@@ -53,7 +54,13 @@ const Header = ({ player }: HeaderProps) => {
|
||||
variant="subtle"
|
||||
size="sm"
|
||||
radius="xl"
|
||||
onClick={h2hSheet.open}
|
||||
onClick={() => {
|
||||
track("h2h_viewed", {
|
||||
source: "profile",
|
||||
context: [player.first_name, player.last_name].filter(Boolean).join(" "),
|
||||
});
|
||||
h2hSheet.open();
|
||||
}}
|
||||
w={40}
|
||||
display={!owner ? 'block' : 'none'}
|
||||
>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Box, Stack, Text, Divider, Group, Button } from "@mantine/core";
|
||||
import { Suspense, useState, useDeferredValue } from "react";
|
||||
import { Suspense, useState, useDeferredValue, useRef } from "react";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
import Header from "./header";
|
||||
@@ -10,6 +10,7 @@ import StatsOverview, { StatsSkeleton } from "@/components/stats-overview";
|
||||
import MatchList from "@/features/matches/components/match-list";
|
||||
import BadgeShowcase from "@/features/badges/components/badge-showcase";
|
||||
import BadgeShowcaseSkeleton from "@/features/badges/components/badge-showcase-skeleton";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
interface ProfileProps {
|
||||
id: string;
|
||||
@@ -20,14 +21,22 @@ const StatsWithFilter = ({ id }: { id: string }) => {
|
||||
const deferredViewType = useDeferredValue(viewType);
|
||||
const isStale = viewType !== deferredViewType;
|
||||
|
||||
const viewTypeRef = useRef(viewType);
|
||||
const changeViewType = (next: typeof viewType) => {
|
||||
if (viewTypeRef.current === next) return;
|
||||
viewTypeRef.current = next;
|
||||
track("stats_filtered", { value: next, source: "profile" });
|
||||
setViewType(next);
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Group gap="xs" px="md" justify="space-between" align="center">
|
||||
<Text size="md" fw={700}><Trans>Statistics</Trans></Text>
|
||||
<Group gap="xs">
|
||||
<Button variant={viewType === 'all' ? 'filled' : 'light'} size="compact-xs" onClick={() => setViewType('all')}><Trans>All</Trans></Button>
|
||||
<Button variant={viewType === 'mainline' ? 'filled' : 'light'} size="compact-xs" onClick={() => setViewType('mainline')}><Trans>Mainline</Trans></Button>
|
||||
<Button variant={viewType === 'regional' ? 'filled' : 'light'} size="compact-xs" onClick={() => setViewType('regional')}><Trans>Regional</Trans></Button>
|
||||
<Button variant={viewType === 'all' ? 'filled' : 'light'} size="compact-xs" onClick={() => changeViewType('all')}><Trans>All</Trans></Button>
|
||||
<Button variant={viewType === 'mainline' ? 'filled' : 'light'} size="compact-xs" onClick={() => changeViewType('mainline')}><Trans>Mainline</Trans></Button>
|
||||
<Button variant={viewType === 'regional' ? 'filled' : 'light'} size="compact-xs" onClick={() => changeViewType('regional')}><Trans>Regional</Trans></Button>
|
||||
</Group>
|
||||
</Group>
|
||||
<Box style={{ opacity: isStale ? 0.6 : 1, transition: 'opacity 150ms' }}>
|
||||
@@ -90,7 +99,12 @@ const Profile = ({ id }: ProfileProps) => {
|
||||
<>
|
||||
<Header player={player} />
|
||||
<Box mt="lg">
|
||||
<SwipeableTabs tabs={tabs} />
|
||||
<SwipeableTabs
|
||||
tabs={tabs}
|
||||
onTabChange={(_, tab) => {
|
||||
if (tab.value === "matches") track("match_history_viewed", { source: "profile" });
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -7,7 +7,6 @@ import { z } from "zod";
|
||||
import { Logger } from "@/lib/logger";
|
||||
import { getRequest } from "@tanstack/react-start/server";
|
||||
import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
|
||||
const logger = new Logger('Players');
|
||||
|
||||
@@ -52,7 +51,7 @@ export const getPlayer = createServerFn()
|
||||
|
||||
export const updatePlayer = createServerFn()
|
||||
.validator(playerUpdateSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) =>
|
||||
toServerResult(async () => {
|
||||
const userAuthId = context.userAuthId;
|
||||
@@ -84,7 +83,7 @@ export const updatePlayer = createServerFn()
|
||||
|
||||
export const createPlayer = createServerFn()
|
||||
.validator(playerInputSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) =>
|
||||
toServerResult(async () => {
|
||||
const userAuthId = context.userAuthId;
|
||||
@@ -117,7 +116,7 @@ export const createPlayer = createServerFn()
|
||||
|
||||
export const associatePlayer = createServerFn()
|
||||
.validator(z.string())
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) =>
|
||||
toServerResult(async () => {
|
||||
const userAuthId = context.userAuthId;
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
import { PredictionBracket } from "./prediction-bracket";
|
||||
import { MatchupSheet } from "./matchup-sheet";
|
||||
import { WinnerSelector } from "./winner-selector";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
|
||||
interface PredictionEditorProps {
|
||||
tournament: Tournament;
|
||||
@@ -215,7 +216,15 @@ export const PredictionEditor: React.FC<PredictionEditorProps> = ({
|
||||
variant="default"
|
||||
size="lg"
|
||||
radius="md"
|
||||
onClick={matchupSheet.open}
|
||||
onClick={() => {
|
||||
if (activeResolved?.home && activeResolved?.away) {
|
||||
track("h2h_viewed", {
|
||||
source: "predictions",
|
||||
context: `${activeResolved.home.name} v ${activeResolved.away.name}`,
|
||||
});
|
||||
}
|
||||
matchupSheet.open();
|
||||
}}
|
||||
disabled={!activeResolved?.home && !activeResolved?.away}
|
||||
aria-label={t`Matchup details`}
|
||||
>
|
||||
|
||||
@@ -4,7 +4,6 @@ import { pbAdmin } from "@/lib/pocketbase/client";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
||||
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
import { Tournament } from "@/features/tournaments/types";
|
||||
import {
|
||||
MyPrediction,
|
||||
@@ -56,7 +55,7 @@ const submitPredictionSchema = z.object({
|
||||
|
||||
export const submitPrediction = createServerFn()
|
||||
.validator(submitPredictionSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data: { tournamentId, picks }, context }) =>
|
||||
toServerResult(async (): Promise<Prediction> => {
|
||||
const player = await pbAdmin.getPlayerByAuthId(context.userAuthId);
|
||||
|
||||
@@ -17,11 +17,13 @@ import EmojiPicker from "./emoji-picker";
|
||||
import { useMatchReactions, useToggleMatchReaction } from "../queries";
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { Reaction } from "@/features/matches/server";
|
||||
import { track } from "@/lib/telemetry/client";
|
||||
import classes from "./emoji-bar.module.css";
|
||||
|
||||
interface EmojiBarProps {
|
||||
matchId: string;
|
||||
onReactionPress?: (emoji: string) => void;
|
||||
source?: string;
|
||||
}
|
||||
|
||||
const EASE: [number, number, number, number] = [0.32, 0.72, 0, 1];
|
||||
@@ -56,6 +58,7 @@ const TickingCount = ({ value, ...textProps }: TickingCountProps) => {
|
||||
const EmojiBar = ({
|
||||
matchId,
|
||||
onReactionPress,
|
||||
source,
|
||||
}: EmojiBarProps) => {
|
||||
const { user } = useAuth();
|
||||
const { t } = useLingui();
|
||||
@@ -85,6 +88,7 @@ const EmojiBar = ({
|
||||
if (onReactionPress) {
|
||||
onReactionPress(emoji);
|
||||
} else {
|
||||
if (!userReactions.includes(emoji)) track("reaction_sent", { emoji, source });
|
||||
toggleReaction.mutate({ data: { matchId, emoji } });
|
||||
}
|
||||
};
|
||||
@@ -198,7 +202,7 @@ const EmojiBar = ({
|
||||
</AnimatePresence>
|
||||
</Group>
|
||||
<EmojiPicker
|
||||
onSelect={onReactionPress || ((emoji) => toggleReaction.mutate({ data: { matchId, emoji } }))}
|
||||
onSelect={handleReactionClick}
|
||||
userReactions={userReactions}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
@@ -1,11 +1,46 @@
|
||||
import { useState } from "react";
|
||||
import { Box, Title, Stack, Switch, Button, Text, Group } from "@mantine/core";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { useWebPush } from "@/hooks/use-web-push";
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { useIsAdmin } from "@/features/core/hooks/use-is-admin";
|
||||
import { updateUserTelemetryAlerts } from "@/features/settings/server";
|
||||
import toast from "@/lib/sonner";
|
||||
|
||||
const TelemetryAlertsSwitch = () => {
|
||||
const { t } = useLingui();
|
||||
const { metadata, set } = useAuth();
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const handleToggle = async (checked: boolean) => {
|
||||
setSaving(true);
|
||||
try {
|
||||
const result = await updateUserTelemetryAlerts({ data: checked });
|
||||
if (result?.metadata) {
|
||||
set({ metadata: result.metadata });
|
||||
}
|
||||
} catch {
|
||||
toast.error(t`Couldn't update telemetry alerts`);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Switch
|
||||
checked={metadata?.telemetryAlerts === true}
|
||||
onChange={(e) => handleToggle(e.currentTarget.checked)}
|
||||
disabled={saving}
|
||||
label={t`Telemetry alerts`}
|
||||
description={t`Error spikes and failing functions, pushed to this account`}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export function NotificationsSection() {
|
||||
const { supported, configured, permission, subscribed, busy, enable, disable, sendTest } =
|
||||
useWebPush();
|
||||
const isAdmin = useIsAdmin();
|
||||
const { t } = useLingui();
|
||||
|
||||
if (!supported || !configured) {
|
||||
@@ -64,6 +99,7 @@ export function NotificationsSection() {
|
||||
disabled={busy}
|
||||
label={t`Enable notifications on this device`}
|
||||
/>
|
||||
{subscribed && isAdmin && <TelemetryAlertsSwitch />}
|
||||
{subscribed && (
|
||||
<Group>
|
||||
<Button
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { createServerFn } from "@tanstack/react-start";
|
||||
import { superTokensFunctionMiddleware } from "@/utils/supertokens";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
import {
|
||||
superTokensAdminFunctionMiddleware,
|
||||
superTokensFunctionMiddleware,
|
||||
} from "@/utils/supertokens";
|
||||
|
||||
// Whitelists: these values flow into Mantine's primaryColor / the
|
||||
// data-mantine-color-scheme attribute — an unknown value crash-loops or
|
||||
@@ -19,7 +21,7 @@ const COLOR_SCHEMES = ["light", "dark", "auto"];
|
||||
|
||||
export const updateUserColorScheme = createServerFn({ method: "POST" })
|
||||
.validator((data: string) => data)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
@@ -43,7 +45,7 @@ export const updateUserColorScheme = createServerFn({ method: "POST" })
|
||||
|
||||
export const updateUserLocale = createServerFn({ method: "POST" })
|
||||
.validator((data: string) => data)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
@@ -69,7 +71,7 @@ export const updateUserLocale = createServerFn({ method: "POST" })
|
||||
|
||||
export const updateUserTheme = createServerFn({ method: "POST" })
|
||||
.validator((data: string) => data)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
@@ -96,7 +98,7 @@ export const updateUserTheme = createServerFn({ method: "POST" })
|
||||
});
|
||||
|
||||
export const updateUserSeenThemesHint = createServerFn({ method: "POST" })
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
@@ -119,7 +121,7 @@ export const updateUserSeenThemesHint = createServerFn({ method: "POST" })
|
||||
|
||||
export const updateUserAccentColor = createServerFn({ method: "POST" })
|
||||
.validator((data: string) => data)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ context, data }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
@@ -140,3 +142,26 @@ export const updateUserAccentColor = createServerFn({ method: "POST" })
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const updateUserTelemetryAlerts = createServerFn({ method: "POST" })
|
||||
.validator((data: boolean) => data === true)
|
||||
.middleware([superTokensAdminFunctionMiddleware])
|
||||
.handler(async ({ context, data }) => {
|
||||
const { userAuthId, metadata } = context;
|
||||
if (!userAuthId) return;
|
||||
|
||||
const { updateUserMetadataFields } = await import(
|
||||
"@/utils/supertokens-core.server"
|
||||
);
|
||||
|
||||
await updateUserMetadataFields(userAuthId, {
|
||||
telemetryAlerts: data,
|
||||
});
|
||||
|
||||
return {
|
||||
metadata: {
|
||||
...metadata,
|
||||
telemetryAlerts: data,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -12,12 +12,11 @@ import {
|
||||
} from '@phosphor-icons/react';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useSpotify } from '@/lib/spotify/hooks';
|
||||
import { useAuth } from '@/contexts/auth-context';
|
||||
import { useIsAdmin } from '@/features/core/hooks/use-is-admin';
|
||||
import SpotifySheet from './spotify-sheet';
|
||||
|
||||
const SpotifyControlsBar = () => {
|
||||
const { roles } = useAuth();
|
||||
const isAdmin = roles?.includes('Admin') || false;
|
||||
const isAdmin = useIsAdmin();
|
||||
const [sheetOpened, { open: openSheet, close: closeSheet }] = useDisclosure(false);
|
||||
const { t } = useLingui();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from '@phosphor-icons/react';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
import { useSpotify } from '@/lib/spotify/hooks';
|
||||
import { useAuth } from '@/contexts/auth-context';
|
||||
import { useIsAdmin } from '@/features/core/hooks/use-is-admin';
|
||||
import Sheet from '@/components/sheet/sheet';
|
||||
|
||||
interface SpotifySheetProps {
|
||||
@@ -26,8 +26,7 @@ interface SpotifySheetProps {
|
||||
}
|
||||
|
||||
const SpotifySheet: React.FC<SpotifySheetProps> = ({ opened, onClose }) => {
|
||||
const { roles } = useAuth();
|
||||
const isAdmin = roles?.includes('Admin') || false;
|
||||
const isAdmin = useIsAdmin();
|
||||
const spotify = useSpotify();
|
||||
const { t } = useLingui();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SlidePanelField } from "@/components/sheet/slide-panel";
|
||||
import { useAuth } from "@/contexts/auth-context";
|
||||
import { useIsAdmin } from "@/features/core/hooks/use-is-admin";
|
||||
import { useUnenrolledPlayers } from "@/features/players/queries";
|
||||
import { Autocomplete, Stack, Text, TextInput } from "@mantine/core";
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
@@ -15,8 +16,8 @@ interface PlayersPickerProps {
|
||||
|
||||
const PlayersPicker = ({ tournamentId, value = [], onChange, disabled, error }: PlayersPickerProps) => {
|
||||
const { t } = useLingui();
|
||||
const { roles, user } = useAuth();
|
||||
const isAdmin = roles.includes("Admin");
|
||||
const { user } = useAuth();
|
||||
const isAdmin = useIsAdmin();
|
||||
|
||||
const { data } = useUnenrolledPlayers(tournamentId);
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import { toServerResult } from "@/lib/tanstack-query/utils/to-server-result";
|
||||
import { teamInputSchema, teamUpdateSchema } from "./types";
|
||||
import { logger } from "@/lib/logger";
|
||||
import { Match } from "../matches/types";
|
||||
import { serverFnLoggingMiddleware } from "@/utils/activities";
|
||||
import { emitServerEvent } from "@/lib/events/emitter";
|
||||
|
||||
|
||||
@@ -32,7 +31,7 @@ export const getTeamInfo = createServerFn()
|
||||
|
||||
export const createTeam = createServerFn()
|
||||
.validator(teamInputSchema)
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data, context }) =>
|
||||
toServerResult(async () => {
|
||||
const userId = context.userAuthId;
|
||||
@@ -54,7 +53,7 @@ export const updateTeam = createServerFn()
|
||||
id: z.string(),
|
||||
updates: teamUpdateSchema
|
||||
}))
|
||||
.middleware([superTokensFunctionMiddleware, serverFnLoggingMiddleware])
|
||||
.middleware([superTokensFunctionMiddleware])
|
||||
.handler(async ({ data: { id, updates }, context }) =>
|
||||
toServerResult(async () => {
|
||||
const userId = context.userAuthId;
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Box, Group, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
|
||||
export interface BarListItem {
|
||||
label: ReactNode;
|
||||
value: number;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
interface BarListProps {
|
||||
items: BarListItem[];
|
||||
formatValue?: (value: number) => string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
const BarRow = ({
|
||||
item,
|
||||
max,
|
||||
formatValue,
|
||||
color,
|
||||
}: {
|
||||
item: BarListItem;
|
||||
max: number;
|
||||
formatValue: (value: number) => string;
|
||||
color: string;
|
||||
}) => {
|
||||
const content = (
|
||||
<Stack gap={4} w="100%">
|
||||
<Group justify="space-between" wrap="nowrap" gap="md">
|
||||
<Text size="sm" truncate style={{ minWidth: 0 }}>
|
||||
{item.label}
|
||||
</Text>
|
||||
<Text size="sm" c="dimmed" style={{ fontVariantNumeric: "tabular-nums" }}>
|
||||
{formatValue(item.value)}
|
||||
</Text>
|
||||
</Group>
|
||||
<Box
|
||||
h={8}
|
||||
w={`${max > 0 ? Math.max((item.value / max) * 100, 1) : 0}%`}
|
||||
bg={color}
|
||||
style={{ borderRadius: "0 4px 4px 0" }}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
if (!item.onClick) {
|
||||
return <Box py={6}>{content}</Box>;
|
||||
}
|
||||
|
||||
return (
|
||||
<UnstyledButton w="100%" py={6} onClick={item.onClick}>
|
||||
{content}
|
||||
</UnstyledButton>
|
||||
);
|
||||
};
|
||||
|
||||
export const BarList = ({
|
||||
items,
|
||||
formatValue = (value) => value.toLocaleString(),
|
||||
color = "var(--mantine-color-anchor)",
|
||||
}: BarListProps) => {
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<Text c="dimmed" size="sm">
|
||||
—
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
const max = Math.max(...items.map((item) => item.value));
|
||||
|
||||
return (
|
||||
<Stack gap={2}>
|
||||
{items.map((item, index) => (
|
||||
<BarRow
|
||||
key={index}
|
||||
item={item}
|
||||
max={max}
|
||||
formatValue={formatValue}
|
||||
color={color}
|
||||
/>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default BarList;
|
||||
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { niceExtent, pointsToPath } from "./chart-path";
|
||||
|
||||
describe("pointsToPath", () => {
|
||||
it("returns an empty string for an empty series", () => {
|
||||
expect(pointsToPath([], 100, 40)).toBe("");
|
||||
});
|
||||
|
||||
it("renders a single point as a horizontal segment without NaN", () => {
|
||||
const path = pointsToPath([5], 100, 40, 2);
|
||||
expect(path).not.toContain("NaN");
|
||||
expect(path).toBe("M2,20 L98,20");
|
||||
});
|
||||
|
||||
it("centers a flat series vertically without NaN", () => {
|
||||
const path = pointsToPath([3, 3, 3], 100, 40);
|
||||
expect(path).not.toContain("NaN");
|
||||
expect(path).toBe("M0,20 L50,20 L100,20");
|
||||
});
|
||||
|
||||
it("maps min to the bottom and max to the top", () => {
|
||||
const path = pointsToPath([0, 10], 100, 40);
|
||||
expect(path).toBe("M0,40 L100,0");
|
||||
});
|
||||
|
||||
it("respects padding", () => {
|
||||
const path = pointsToPath([0, 10], 100, 40, 4);
|
||||
expect(path).toBe("M4,36 L96,4");
|
||||
});
|
||||
|
||||
it("uses a shared extent when provided", () => {
|
||||
const path = pointsToPath([0, 5], 100, 40, 0, [0, 10]);
|
||||
expect(path).toBe("M0,40 L100,20");
|
||||
});
|
||||
});
|
||||
|
||||
describe("niceExtent", () => {
|
||||
it("handles an empty series", () => {
|
||||
expect(niceExtent([])).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
it("handles an all-zero series", () => {
|
||||
expect(niceExtent([0, 0, 0])).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
it("spreads a flat non-zero series", () => {
|
||||
const [lo, hi] = niceExtent([10, 10]);
|
||||
expect(lo).toBeLessThan(10);
|
||||
expect(hi).toBeGreaterThan(10);
|
||||
expect(Number.isNaN(lo)).toBe(false);
|
||||
expect(Number.isNaN(hi)).toBe(false);
|
||||
});
|
||||
|
||||
it("covers the data with rounded bounds", () => {
|
||||
const [lo, hi] = niceExtent([3, 47, 12]);
|
||||
expect(lo).toBeLessThanOrEqual(3);
|
||||
expect(hi).toBeGreaterThanOrEqual(47);
|
||||
});
|
||||
|
||||
it("never dips below zero for non-negative data", () => {
|
||||
const [lo] = niceExtent([1, 2, 3]);
|
||||
expect(lo).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
export function pointsToPath(
|
||||
values: number[],
|
||||
width: number,
|
||||
height: number,
|
||||
pad = 0,
|
||||
extent?: [number, number]
|
||||
): string {
|
||||
if (values.length === 0) return "";
|
||||
|
||||
const [lo, hi] = extent ?? [Math.min(...values), Math.max(...values)];
|
||||
const span = hi - lo;
|
||||
const innerWidth = Math.max(width - pad * 2, 0);
|
||||
const innerHeight = Math.max(height - pad * 2, 0);
|
||||
|
||||
const yFor = (value: number) =>
|
||||
span === 0
|
||||
? pad + innerHeight / 2
|
||||
: pad + innerHeight - ((value - lo) / span) * innerHeight;
|
||||
|
||||
if (values.length === 1) {
|
||||
const y = yFor(values[0]);
|
||||
return `M${pad},${y} L${pad + innerWidth},${y}`;
|
||||
}
|
||||
|
||||
const step = innerWidth / (values.length - 1);
|
||||
return values
|
||||
.map((value, index) => {
|
||||
const command = index === 0 ? "M" : "L";
|
||||
return `${command}${pad + step * index},${yFor(value)}`;
|
||||
})
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
export function niceExtent(values: number[]): [number, number] {
|
||||
if (values.length === 0) return [0, 1];
|
||||
|
||||
let min = Math.min(...values);
|
||||
let max = Math.max(...values);
|
||||
|
||||
if (min === max) {
|
||||
if (min === 0) return [0, 1];
|
||||
const spread = Math.abs(min) / 2;
|
||||
min -= spread;
|
||||
max += spread;
|
||||
}
|
||||
|
||||
const step = niceStep((max - min) / 4);
|
||||
let lo = Math.floor(min / step) * step;
|
||||
const hi = Math.ceil(max / step) * step;
|
||||
if (min >= 0 && lo < 0) lo = 0;
|
||||
return [lo, hi];
|
||||
}
|
||||
|
||||
function niceStep(rough: number): number {
|
||||
const power = 10 ** Math.floor(Math.log10(rough));
|
||||
const fraction = rough / power;
|
||||
if (fraction <= 1) return power;
|
||||
if (fraction <= 2) return 2 * power;
|
||||
if (fraction <= 5) return 5 * power;
|
||||
return 10 * power;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export { pointsToPath, niceExtent } from "./chart-path";
|
||||
export { Sparkline } from "./sparkline";
|
||||
export { BarList } from "./bar-list";
|
||||
export type { BarListItem } from "./bar-list";
|
||||
export { StatTile } from "./stat-tile";
|
||||
@@ -0,0 +1,110 @@
|
||||
import { Group, Text } from "@mantine/core";
|
||||
import { niceExtent, pointsToPath } from "./chart-path";
|
||||
|
||||
const VIEW_WIDTH = 240;
|
||||
const PAD = 3;
|
||||
|
||||
export interface SparklineScale {
|
||||
start?: string;
|
||||
end?: string;
|
||||
formatValue?: (value: number) => string;
|
||||
}
|
||||
|
||||
interface SparklineProps {
|
||||
data: number[];
|
||||
series2?: number[];
|
||||
height?: number;
|
||||
showArea?: boolean;
|
||||
label?: string;
|
||||
color?: string;
|
||||
series2Color?: string;
|
||||
scale?: SparklineScale;
|
||||
}
|
||||
|
||||
export const Sparkline = ({
|
||||
data,
|
||||
series2,
|
||||
height = 48,
|
||||
showArea = false,
|
||||
label,
|
||||
color = "var(--mantine-color-anchor)",
|
||||
series2Color = "var(--mantine-color-dimmed)",
|
||||
scale,
|
||||
}: SparklineProps) => {
|
||||
if (data.length === 0) {
|
||||
return (
|
||||
<Text c="dimmed" size="sm" aria-label={label}>
|
||||
—
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
const extent = niceExtent(series2?.length ? [...data, ...series2] : data);
|
||||
const path = pointsToPath(data, VIEW_WIDTH, height, PAD, extent);
|
||||
const secondPath = series2?.length
|
||||
? pointsToPath(series2, VIEW_WIDTH, height, PAD, extent)
|
||||
: null;
|
||||
const areaPath = showArea && !secondPath
|
||||
? `${path} L${VIEW_WIDTH - PAD},${height - PAD} L${PAD},${height - PAD} Z`
|
||||
: null;
|
||||
|
||||
const allValues = series2?.length ? [...data, ...series2] : data;
|
||||
const max = Math.max(...allValues);
|
||||
const formatValue = scale?.formatValue ?? ((value: number) => value.toLocaleString());
|
||||
|
||||
const svg = (
|
||||
<svg
|
||||
viewBox={`0 0 ${VIEW_WIDTH} ${height}`}
|
||||
preserveAspectRatio="none"
|
||||
width="100%"
|
||||
height={height}
|
||||
role="img"
|
||||
aria-label={label}
|
||||
style={{ display: "block" }}
|
||||
>
|
||||
{areaPath && <path d={areaPath} fill={color} fillOpacity={0.1} stroke="none" />}
|
||||
<path
|
||||
d={path}
|
||||
fill="none"
|
||||
stroke={color}
|
||||
strokeWidth={2}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
{secondPath && (
|
||||
<path
|
||||
d={secondPath}
|
||||
fill="none"
|
||||
stroke={series2Color}
|
||||
strokeWidth={2}
|
||||
strokeDasharray="4 3"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
)}
|
||||
</svg>
|
||||
);
|
||||
|
||||
if (!scale) return svg;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{svg}
|
||||
<Group justify="space-between" gap="xs" mt={2}>
|
||||
<Text size="xs" c="dimmed">
|
||||
{scale.start}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed" style={{ fontVariantNumeric: "tabular-nums" }}>
|
||||
↑{formatValue(max)}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
{scale.end}
|
||||
</Text>
|
||||
</Group>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sparkline;
|
||||
@@ -0,0 +1,60 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Box, Group, Stack, Text, UnstyledButton } from "@mantine/core";
|
||||
import Sparkline, { SparklineScale } from "./sparkline";
|
||||
|
||||
interface StatTileProps {
|
||||
label: ReactNode;
|
||||
value: ReactNode;
|
||||
valueColor?: string;
|
||||
delta?: number;
|
||||
spark?: number[];
|
||||
sparkScale?: SparklineScale;
|
||||
caption?: ReactNode;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export const StatTile = ({
|
||||
label,
|
||||
value,
|
||||
valueColor,
|
||||
delta,
|
||||
spark,
|
||||
sparkScale,
|
||||
caption,
|
||||
onClick,
|
||||
}: StatTileProps) => {
|
||||
const content = (
|
||||
<Stack gap={2}>
|
||||
<Group gap="xs" align="baseline" wrap="nowrap">
|
||||
<Text fz="xl" fw={700} lh={1.2} c={valueColor}>
|
||||
{value}
|
||||
</Text>
|
||||
{delta !== undefined && delta !== 0 && (
|
||||
<Text size="xs" c={delta > 0 ? "green" : "red"}>
|
||||
{delta > 0 ? "+" : ""}
|
||||
{delta.toLocaleString()}
|
||||
</Text>
|
||||
)}
|
||||
</Group>
|
||||
<Text size="xs" c="dimmed">
|
||||
{label}
|
||||
</Text>
|
||||
{caption && <Box>{caption}</Box>}
|
||||
{spark && spark.length > 0 && (
|
||||
<Sparkline data={spark} height={28} scale={sparkScale} />
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
|
||||
if (onClick) {
|
||||
return (
|
||||
<UnstyledButton className="flxn-press" onClick={onClick} w="100%">
|
||||
{content}
|
||||
</UnstyledButton>
|
||||
);
|
||||
}
|
||||
|
||||
return content;
|
||||
};
|
||||
|
||||
export default StatTile;
|
||||
@@ -0,0 +1,69 @@
|
||||
import { Suspense, useMemo, useState } from "react";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import { Container, Divider, Group, Stack, Switch, Text } from "@mantine/core";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { useClientErrorGroups } from "../../queries";
|
||||
import { lastNDays } from "../../range";
|
||||
import { ErrorGroupRow } from "./error-group-row";
|
||||
|
||||
const ErrorGroupList = ({
|
||||
from,
|
||||
to,
|
||||
includeResolved,
|
||||
}: {
|
||||
from: string;
|
||||
to: string;
|
||||
includeResolved: boolean;
|
||||
}) => {
|
||||
const { data: groups } = useClientErrorGroups({ from, to, includeResolved });
|
||||
|
||||
if (groups.length === 0) {
|
||||
return (
|
||||
<Text size="sm" c="dimmed" px="md" py="xl" ta="center">
|
||||
<Trans>No unresolved errors</Trans>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
{groups.map((group, index) => (
|
||||
<div key={group.group_hash}>
|
||||
<ErrorGroupRow group={group} />
|
||||
{index < groups.length - 1 && <Divider />}
|
||||
</div>
|
||||
))}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export const ErrorBrowser = () => {
|
||||
const { t } = useLingui();
|
||||
const [includeResolved, setIncludeResolved] = useState(false);
|
||||
const range = useMemo(() => lastNDays(30), []);
|
||||
|
||||
return (
|
||||
<Container size="100%" px={0}>
|
||||
<Stack gap="xs">
|
||||
<Group px="md" justify="flex-end">
|
||||
<Switch
|
||||
size="sm"
|
||||
label={t`Include resolved`}
|
||||
checked={includeResolved}
|
||||
onChange={(event) => setIncludeResolved(event.currentTarget.checked)}
|
||||
/>
|
||||
</Group>
|
||||
|
||||
<Suspense fallback={<ListSkeleton rows={6} withSubtitle />}>
|
||||
<ErrorGroupList
|
||||
from={range.from}
|
||||
to={range.to}
|
||||
includeResolved={includeResolved}
|
||||
/>
|
||||
</Suspense>
|
||||
</Stack>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorBrowser;
|
||||
@@ -0,0 +1,111 @@
|
||||
import { useState } from "react";
|
||||
import { Trans, useLingui } from "@lingui/react/macro";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Code,
|
||||
Collapse,
|
||||
Group,
|
||||
Stack,
|
||||
Text,
|
||||
UnstyledButton,
|
||||
} from "@mantine/core";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useServerMutation } from "@/lib/tanstack-query/hooks";
|
||||
import { resolveClientErrorGroup } from "../../server";
|
||||
import { telemetryKeys } from "../../queries";
|
||||
import type { ClientErrorGroup } from "../../types";
|
||||
import { RelativeTime } from "../shared";
|
||||
|
||||
export const ErrorGroupRow = ({ group }: { group: ClientErrorGroup }) => {
|
||||
const { t } = useLingui();
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const resolveMutation = useServerMutation({
|
||||
mutationFn: (variables: { groupHash: string; resolved: boolean }) =>
|
||||
resolveClientErrorGroup({ data: variables }),
|
||||
successMessage: group.resolved ? t`Error group reopened` : t`Error group resolved`,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: telemetryKeys.all });
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<UnstyledButton
|
||||
w="100%"
|
||||
p="md"
|
||||
onClick={() => setExpanded((prev) => !prev)}
|
||||
style={{ borderRadius: 0 }}
|
||||
>
|
||||
<Stack gap={4}>
|
||||
<Group gap="xs" wrap="nowrap">
|
||||
<Text
|
||||
size="sm"
|
||||
fw={700}
|
||||
c={group.resolved ? "dimmed" : "red"}
|
||||
style={{ flexShrink: 0, fontVariantNumeric: "tabular-nums" }}
|
||||
>
|
||||
{group.count.toLocaleString()}×
|
||||
</Text>
|
||||
<Text size="sm" fw={600} lineClamp={2} style={{ minWidth: 0 }}>
|
||||
{group.sample.message}
|
||||
</Text>
|
||||
</Group>
|
||||
<Group gap="md">
|
||||
{group.sample.source && (
|
||||
<Text size="xs" c="dimmed">
|
||||
{group.sample.source}
|
||||
</Text>
|
||||
)}
|
||||
<Text size="xs" c="dimmed">
|
||||
<RelativeTime date={group.lastSeen} />
|
||||
</Text>
|
||||
{group.resolved && (
|
||||
<Text size="xs" c="dimmed">
|
||||
<Trans>Resolved</Trans>
|
||||
</Text>
|
||||
)}
|
||||
</Group>
|
||||
</Stack>
|
||||
</UnstyledButton>
|
||||
|
||||
<Collapse in={expanded} transitionDuration={200}>
|
||||
<Stack gap="sm" px="md" pb="md">
|
||||
{group.sample.path && (
|
||||
<Text size="xs" c="dimmed">
|
||||
{group.sample.path}
|
||||
</Text>
|
||||
)}
|
||||
{group.sample.stack && (
|
||||
<Code
|
||||
block
|
||||
style={{ fontSize: "11px", maxHeight: 240, overflow: "auto" }}
|
||||
>
|
||||
{group.sample.stack}
|
||||
</Code>
|
||||
)}
|
||||
<Group justify="flex-end">
|
||||
<Button
|
||||
size="xs"
|
||||
variant="subtle"
|
||||
color={group.resolved ? "yellow" : "green"}
|
||||
loading={resolveMutation.isPending}
|
||||
onClick={() =>
|
||||
resolveMutation.mutate({
|
||||
groupHash: group.group_hash,
|
||||
resolved: !group.resolved,
|
||||
})
|
||||
}
|
||||
>
|
||||
{group.resolved ? <Trans>Reopen</Trans> : <Trans>Mark resolved</Trans>}
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Collapse>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorGroupRow;
|
||||
@@ -0,0 +1,2 @@
|
||||
export { ErrorBrowser } from "./error-browser";
|
||||
export { ErrorGroupRow } from "./error-group-row";
|
||||
@@ -0,0 +1,105 @@
|
||||
import { Fragment } from "react";
|
||||
import { Box, Group, Stack, Text } from "@mantine/core";
|
||||
import { Plural, useLingui } from "@lingui/react/macro";
|
||||
import { useSessionTimeline } from "../../queries";
|
||||
import type { TimelineEntry } from "../../types";
|
||||
|
||||
const GAP_MARKER_MS = 5 * 60 * 1000;
|
||||
|
||||
const parseTs = (ts: string) => Date.parse(ts.replace(" ", "T"));
|
||||
|
||||
const dotColor = (entry: TimelineEntry): string => {
|
||||
if (entry.kind === "error" || entry.success === false) return "var(--mantine-color-red-6)";
|
||||
if (entry.kind === "server_fn") return "var(--mantine-color-green-6)";
|
||||
return "var(--mantine-color-dimmed)";
|
||||
};
|
||||
|
||||
const Dot = ({ color }: { color: string }) => (
|
||||
<Box
|
||||
w={6}
|
||||
h={6}
|
||||
style={{ borderRadius: "50%", backgroundColor: color, flexShrink: 0 }}
|
||||
/>
|
||||
);
|
||||
|
||||
export const SessionTimelineView = ({ sessionId }: { sessionId: string }) => {
|
||||
const { i18n } = useLingui();
|
||||
const { data } = useSessionTimeline(sessionId);
|
||||
|
||||
const clock = (ts: string) =>
|
||||
i18n.date(new Date(parseTs(ts)), { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
||||
|
||||
return (
|
||||
<Stack gap={0}>
|
||||
<Group gap="md" pb="sm">
|
||||
<Text size="xs" c="dimmed">
|
||||
{i18n.date(new Date(parseTs(data.session.started)), {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
})}
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
<Plural value={data.session.pageViews} one="# page" other="# pages" />
|
||||
</Text>
|
||||
{data.session.errors > 0 && (
|
||||
<Text size="xs" c="red">
|
||||
<Plural value={data.session.errors} one="# error" other="# errors" />
|
||||
</Text>
|
||||
)}
|
||||
</Group>
|
||||
|
||||
{data.entries.map((entry, index) => {
|
||||
const prev = data.entries[index - 1];
|
||||
const gapMs = prev ? parseTs(entry.ts) - parseTs(prev.ts) : 0;
|
||||
return (
|
||||
<Fragment key={`${entry.ts}-${index}`}>
|
||||
{gapMs > GAP_MARKER_MS && (
|
||||
<Text size="xs" c="dimmed" py={4} pl={46}>
|
||||
+{Math.round(gapMs / 60000)}m
|
||||
</Text>
|
||||
)}
|
||||
<Group gap="xs" py={5} wrap="nowrap" align="center">
|
||||
<Text
|
||||
size="xs"
|
||||
c="dimmed"
|
||||
w={64}
|
||||
style={{ flexShrink: 0, fontVariantNumeric: "tabular-nums" }}
|
||||
>
|
||||
{clock(entry.ts)}
|
||||
</Text>
|
||||
<Dot color={dotColor(entry)} />
|
||||
<Text
|
||||
size="sm"
|
||||
lineClamp={1}
|
||||
c={entry.kind === "error" ? "red" : undefined}
|
||||
style={{ minWidth: 0, flex: 1 }}
|
||||
>
|
||||
{entry.label}
|
||||
{entry.detail && entry.kind !== "error" && (
|
||||
<Text component="span" size="sm" c="dimmed">
|
||||
{" "}
|
||||
· {entry.detail}
|
||||
</Text>
|
||||
)}
|
||||
</Text>
|
||||
{entry.kind === "server_fn" && entry.success === false && (
|
||||
<Text size="xs" c="red" style={{ flexShrink: 0 }}>
|
||||
✗
|
||||
</Text>
|
||||
)}
|
||||
{entry.kind === "server_fn" && typeof entry.duration === "number" && entry.duration > 0 && (
|
||||
<Text size="xs" c="dimmed" style={{ flexShrink: 0, fontVariantNumeric: "tabular-nums" }}>
|
||||
{entry.duration}ms
|
||||
</Text>
|
||||
)}
|
||||
</Group>
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default SessionTimelineView;
|
||||
@@ -0,0 +1,81 @@
|
||||
import { Suspense, useState } from "react";
|
||||
import { Plural, Trans, useLingui } from "@lingui/react/macro";
|
||||
import { Text } from "@mantine/core";
|
||||
import Sheet from "@/components/sheet/sheet";
|
||||
import { ListSkeleton } from "@/components/skeletons";
|
||||
import { useSessions } from "../../queries";
|
||||
import type { SessionSummary } from "../../types";
|
||||
import { PaginatedList, RelativeTime, TelemetryListItem } from "../shared";
|
||||
import SessionTimelineView from "./session-timeline";
|
||||
|
||||
export const defaultSessionParams = { days: 7, page: 1 } as const;
|
||||
|
||||
const playerName = (player?: SessionSummary["player"]): string | null => {
|
||||
if (!player) return null;
|
||||
return [player.first_name, player.last_name].filter(Boolean).join(" ") || null;
|
||||
};
|
||||
|
||||
const durationLabel = (session: SessionSummary): string => {
|
||||
const ms =
|
||||
Date.parse(session.lastSeen.replace(" ", "T")) -
|
||||
Date.parse(session.started.replace(" ", "T"));
|
||||
const minutes = Math.round(ms / 60000);
|
||||
return minutes < 1 ? "<1m" : `${minutes}m`;
|
||||
};
|
||||
|
||||
export const SessionsList = () => {
|
||||
const { t } = useLingui();
|
||||
const [page, setPage] = useState(1);
|
||||
const [selected, setSelected] = useState<SessionSummary | null>(null);
|
||||
|
||||
const { data } = useSessions({ days: 7, page });
|
||||
|
||||
return (
|
||||
<>
|
||||
<PaginatedList
|
||||
items={data.items}
|
||||
keyOf={(session) => session.session_id}
|
||||
empty={t`No sessions yet`}
|
||||
page={data.page}
|
||||
totalPages={data.totalPages}
|
||||
onPageChange={setPage}
|
||||
renderItem={(session) => (
|
||||
<TelemetryListItem
|
||||
title={playerName(session.player) ?? t`Anonymous`}
|
||||
meta={[
|
||||
<RelativeTime key="time" date={session.lastSeen} />,
|
||||
<Plural key="pages" value={session.pageViews} one="# page" other="# pages" />,
|
||||
durationLabel(session),
|
||||
]}
|
||||
error={
|
||||
session.errors > 0 ? (
|
||||
<Plural value={session.errors} one="# error" other="# errors" />
|
||||
) : undefined
|
||||
}
|
||||
onClick={() => setSelected(session)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
<Sheet
|
||||
title={selected ? (playerName(selected.player) ?? t`Anonymous`) : ""}
|
||||
opened={selected !== null}
|
||||
onChange={() => setSelected(null)}
|
||||
>
|
||||
{selected && (
|
||||
<Suspense fallback={<ListSkeleton rows={8} />}>
|
||||
<SessionTimelineView sessionId={selected.session_id} />
|
||||
</Suspense>
|
||||
)}
|
||||
</Sheet>
|
||||
|
||||
{data.totalItems > 0 && (
|
||||
<Text size="xs" c="dimmed" px="md" py="sm">
|
||||
<Trans>Last 7 days</Trans>
|
||||
</Text>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SessionsList;
|
||||
@@ -0,0 +1,38 @@
|
||||
import { ReactNode, memo } from "react";
|
||||
import { Stack, Text } from "@mantine/core";
|
||||
import Sheet from "@/components/sheet/sheet";
|
||||
|
||||
export interface DetailField {
|
||||
label: ReactNode;
|
||||
value: ReactNode;
|
||||
}
|
||||
|
||||
interface DetailSheetProps {
|
||||
title: string;
|
||||
opened: boolean;
|
||||
onClose: () => void;
|
||||
fields: DetailField[];
|
||||
}
|
||||
|
||||
export const DetailSheet = memo(({ title, opened, onClose, fields }: DetailSheetProps) => (
|
||||
<Sheet title={title} opened={opened} onChange={onClose}>
|
||||
<Stack gap="md" p="md">
|
||||
{fields.map((field, index) => (
|
||||
<Stack gap="xs" key={index}>
|
||||
<Text size="xs" fw={700} c="dimmed">
|
||||
{field.label}
|
||||
</Text>
|
||||
{typeof field.value === "string" || typeof field.value === "number" ? (
|
||||
<Text size="sm" style={{ wordBreak: "break-word" }}>
|
||||
{field.value}
|
||||
</Text>
|
||||
) : (
|
||||
field.value
|
||||
)}
|
||||
</Stack>
|
||||
))}
|
||||
</Stack>
|
||||
</Sheet>
|
||||
));
|
||||
|
||||
export default DetailSheet;
|
||||
@@ -0,0 +1,7 @@
|
||||
export { TelemetryListItem } from "./telemetry-list-item";
|
||||
export { DetailSheet } from "./detail-sheet";
|
||||
export type { DetailField } from "./detail-sheet";
|
||||
export { SearchFilterBar } from "./search-filter-bar";
|
||||
export type { FilterSelectConfig, FilterChipConfig, SortFieldConfig } from "./search-filter-bar";
|
||||
export { PaginatedList } from "./paginated-list";
|
||||
export { RelativeTime } from "./relative-time";
|
||||
@@ -0,0 +1,47 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Box, Divider, Group, Pagination, Stack, Text } from "@mantine/core";
|
||||
|
||||
interface PaginatedListProps<T> {
|
||||
items: T[];
|
||||
renderItem: (item: T) => ReactNode;
|
||||
keyOf: (item: T) => string;
|
||||
empty: string;
|
||||
page?: number;
|
||||
totalPages?: number;
|
||||
onPageChange?: (page: number) => void;
|
||||
}
|
||||
|
||||
export const PaginatedList = <T,>({
|
||||
items,
|
||||
renderItem,
|
||||
keyOf,
|
||||
empty,
|
||||
page = 1,
|
||||
totalPages = 1,
|
||||
onPageChange,
|
||||
}: PaginatedListProps<T>) => (
|
||||
<>
|
||||
<Stack gap={0}>
|
||||
{items.map((item, index) => (
|
||||
<Box key={keyOf(item)}>
|
||||
{renderItem(item)}
|
||||
{index < items.length - 1 && <Divider />}
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
|
||||
{items.length === 0 && (
|
||||
<Text size="sm" c="dimmed" px="md" py="xl" ta="center">
|
||||
{empty}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{totalPages > 1 && onPageChange && (
|
||||
<Group justify="center" py="md">
|
||||
<Pagination total={totalPages} value={page} onChange={onPageChange} size="sm" />
|
||||
</Group>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
export default PaginatedList;
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useLingui } from "@lingui/react/macro";
|
||||
|
||||
export const RelativeTime = ({ date }: { date?: string }) => {
|
||||
const { t, i18n } = useLingui();
|
||||
|
||||
if (!date) return <>{t`Never`}</>;
|
||||
|
||||
const then = new Date(date);
|
||||
const diffMs = Date.now() - then.getTime();
|
||||
const diffMins = Math.floor(diffMs / 60000);
|
||||
const diffHours = Math.floor(diffMins / 60);
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffMins < 1) return <>{t`Just now`}</>;
|
||||
if (diffMins < 60) return <>{t`${diffMins}m ago`}</>;
|
||||
if (diffHours < 24) return <>{t`${diffHours}h ago`}</>;
|
||||
if (diffDays < 30) return <>{t`${diffDays}d ago`}</>;
|
||||
return <>{then.toLocaleString(i18n.locale)}</>;
|
||||
};
|
||||
|
||||
export default RelativeTime;
|
||||
@@ -0,0 +1,134 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Chip, Group, Select, Stack, Text, TextInput, UnstyledButton } from "@mantine/core";
|
||||
import { CaretDownIcon, CaretUpIcon, MagnifyingGlassIcon } from "@phosphor-icons/react";
|
||||
import { Trans } from "@lingui/react/macro";
|
||||
|
||||
export interface FilterSelectConfig {
|
||||
placeholder: string;
|
||||
value: string | null;
|
||||
onChange: (value: string | null) => void;
|
||||
data: { value: string; label: string }[];
|
||||
searchable?: boolean;
|
||||
}
|
||||
|
||||
export interface FilterChipConfig {
|
||||
label: ReactNode;
|
||||
checked: boolean;
|
||||
onChange: (checked: boolean) => void;
|
||||
}
|
||||
|
||||
export interface SortFieldConfig {
|
||||
field: string;
|
||||
label: ReactNode;
|
||||
}
|
||||
|
||||
interface SearchFilterBarProps {
|
||||
searchValue: string;
|
||||
onSearchChange: (value: string) => void;
|
||||
searchPlaceholder: string;
|
||||
filters?: FilterSelectConfig[];
|
||||
chips?: FilterChipConfig[];
|
||||
sortFields?: SortFieldConfig[];
|
||||
sortBy?: string;
|
||||
onSort?: (field: string) => void;
|
||||
summary?: ReactNode;
|
||||
}
|
||||
|
||||
export const SearchFilterBar = ({
|
||||
searchValue,
|
||||
onSearchChange,
|
||||
searchPlaceholder,
|
||||
filters,
|
||||
chips,
|
||||
sortFields,
|
||||
sortBy = "",
|
||||
onSort,
|
||||
summary,
|
||||
}: SearchFilterBarProps) => {
|
||||
const getSortIcon = (field: string) => {
|
||||
if (sortBy === field) return <CaretUpIcon size={14} />;
|
||||
if (sortBy === `-${field}`) return <CaretDownIcon size={14} />;
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack gap="xs" px="md">
|
||||
<TextInput
|
||||
placeholder={searchPlaceholder}
|
||||
value={searchValue}
|
||||
onChange={(e) => onSearchChange(e.currentTarget.value)}
|
||||
leftSection={<MagnifyingGlassIcon size={16} />}
|
||||
size="md"
|
||||
/>
|
||||
|
||||
{filters && filters.length > 0 && (
|
||||
<Group>
|
||||
{filters.map((filter, index) => (
|
||||
<Select
|
||||
key={index}
|
||||
placeholder={filter.placeholder}
|
||||
value={filter.value}
|
||||
onChange={filter.onChange}
|
||||
data={filter.data}
|
||||
searchable={filter.searchable}
|
||||
clearable
|
||||
size="sm"
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
))}
|
||||
</Group>
|
||||
)}
|
||||
|
||||
{chips && chips.length > 0 && (
|
||||
<Group gap="xs">
|
||||
{chips.map((chip, index) => (
|
||||
<Chip key={index} size="xs" checked={chip.checked} onChange={chip.onChange}>
|
||||
{chip.label}
|
||||
</Chip>
|
||||
))}
|
||||
</Group>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
{(summary || (sortFields && sortFields.length > 0)) && (
|
||||
<Group px="md" justify="space-between" align="center">
|
||||
<Text size="10px" lh={0} c="dimmed" component="div">
|
||||
{summary}
|
||||
</Text>
|
||||
{sortFields && sortFields.length > 0 && onSort && (
|
||||
<Group gap="xs">
|
||||
<Text size="xs" c="dimmed">
|
||||
<Trans>Sort:</Trans>
|
||||
</Text>
|
||||
{sortFields.map((sortField, index) => (
|
||||
<Group gap="xs" key={sortField.field}>
|
||||
{index > 0 && (
|
||||
<Text size="xs" c="dimmed">
|
||||
•
|
||||
</Text>
|
||||
)}
|
||||
<UnstyledButton
|
||||
onClick={() => onSort(sortField.field)}
|
||||
style={{ display: "flex", alignItems: "center", gap: 4 }}
|
||||
>
|
||||
<Text
|
||||
size="xs"
|
||||
fw={sortBy.includes(sortField.field) ? 600 : 400}
|
||||
c={sortBy.includes(sortField.field) ? "var(--mantine-color-text)" : "dimmed"}
|
||||
>
|
||||
{sortField.label}
|
||||
</Text>
|
||||
{getSortIcon(sortField.field)}
|
||||
</UnstyledButton>
|
||||
</Group>
|
||||
))}
|
||||
</Group>
|
||||
)}
|
||||
</Group>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchFilterBar;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user