refactor: Replace console logging with logger utility

- Add logger import across multiple view components
- Replace console.error/warn/log with logger methods
- Update error handling to use structured logging
- Improve type safety for error objects
- Add crypto-browserify polyfill for browser environment

The changes improve logging by:
1. Using consistent logging interface
2. Adding structured error logging
3. Improving error type safety
4. Centralizing logging configuration
5. Fixing browser compatibility issues

Affected files:
- Multiple view components
- vite.config.ts
- Build configuration
This commit is contained in:
Matthew Raymer
2025-03-11 09:35:55 +00:00
parent 8cae601148
commit e0aded04b4
1911 changed files with 88846 additions and 401 deletions

View File

@@ -159,7 +159,10 @@
<h3 class="text-sm uppercase font-semibold mt-3">
Projects That Contribute To This
</h3>
<!-- centering because long, wrapped project names didn't left align with blank or "text-left" -->
<!--
centering because long, wrapped project names didn't left align with blank
or "text-left"
-->
<div class="text-center">
<div v-for="plan in fulfillersToThis" :key="plan.handleId">
<button
@@ -181,7 +184,10 @@
<h3 class="text-sm uppercase font-semibold mb-3">
Projects Getting Contributions From This
</h3>
<!-- centering because long, wrapped project names didn't left align with blank or "text-left" -->
<!--
centering because long, wrapped project names didn't left align with blank
or "text-left"
-->
<div class="text-center">
<button
class="text-blue-500"
@@ -372,8 +378,8 @@
<span class="font-semibold mr-2 shrink-0">Totals</span>
<span class="whitespace-nowrap overflow-hidden text-ellipsis">
<a
@click="totalsExpanded = !totalsExpanded"
class="cursor-pointer text-blue-500"
@click="totalsExpanded = !totalsExpanded"
>
<!-- just show the hours, or alternatively whatever is first -->
<span v-if="givenTotalHours() > 0">
@@ -623,7 +629,7 @@ import * as libsUtil from "../libs/util";
import * as serverUtil from "../libs/endorserServer";
import { retrieveAccountDids } from "../libs/util";
import HiddenDidDialog from "../components/HiddenDidDialog.vue";
import { logger } from "../utils/logger";
/**
* Project View Component
* @author Matthew Raymer
@@ -702,6 +708,7 @@ export default class ProjectViewView extends Vue {
fulfillersToThis: Array<PlanSummaryRecord> = [];
/** Flag for fulfiller pagination */
fulfillersToHitLimit = false;
/** Gifts to this project */
givesToThis: Array<GiveSummaryRecord> = [];
givesHitLimit = false;
givesProvidedByThis: Array<GiveSummaryRecord> = [];
@@ -733,14 +740,6 @@ export default class ProjectViewView extends Vue {
// Interaction Data
/** Gifts to this project */
givesToThis: Array<GiveSummaryRecord> = [];
/** Flag for gifts pagination */
givesHitLimit = false;
/** Gifts from this project */
givesProvidedByThis: Array<GiveSummaryRecord> = [];
/** Flag for provided gifts pagination */
givesProvidedByHitLimit = false;
/** Offers to this project */
offersToThis: Array<OfferSummaryRecord> = [];
/** Flag for offers pagination */
offersHitLimit = false;
@@ -750,7 +749,7 @@ export default class ProjectViewView extends Vue {
checkingConfirmationForJwtId = "";
/** Recently checked unconfirmable JWTs */
recentlyCheckedAndUnconfirmableJwts: string[] = [];
startTime = "";
totalsExpanded = false;
truncatedDesc = "";
/** Truncation length */
@@ -806,12 +805,14 @@ export default class ProjectViewView extends Vue {
this.loadTotals();
}
onEditClick() {
const route = {
/**
* Navigates to project edit view with current project ID
*/
onEditClick(): void {
this.$router.push({
name: "new-edit-project",
query: { projectId: this.projectId },
};
(this.$router as Router).push(route);
});
}
// Isn't there a better way to make this available to the template?
@@ -869,7 +870,7 @@ export default class ProjectViewView extends Vue {
this.url = resp.data.claim?.url || "";
} else {
// actually, axios throws an error on 404 so we probably never get here
console.error("Error getting project:", resp);
logger.error("Error getting project:", resp);
this.$notify(
{
group: "alert",
@@ -881,7 +882,7 @@ export default class ProjectViewView extends Vue {
);
}
} catch (error: unknown) {
console.error("Error retrieving project:", error);
logger.error("Error retrieving project:", error);
this.$notify(
{
group: "alert",
@@ -958,7 +959,7 @@ export default class ProjectViewView extends Vue {
},
5000,
);
console.error(
logger.error(
"Something went wrong retrieving more gives to this project:",
serverError.message,
);
@@ -1017,7 +1018,7 @@ export default class ProjectViewView extends Vue {
},
5000,
);
console.error(
logger.error(
"Something went wrong retrieving gives that were provided by this project:",
serverError.message,
);
@@ -1073,7 +1074,7 @@ export default class ProjectViewView extends Vue {
},
5000,
);
console.error(
logger.error(
"Something went wrong retrieving more offers to this project:",
serverError.message,
);
@@ -1129,7 +1130,7 @@ export default class ProjectViewView extends Vue {
},
5000,
);
console.error(
logger.error(
"Something went wrong retrieving more plans that fulfill this project:",
serverError.message,
);
@@ -1176,30 +1177,13 @@ export default class ProjectViewView extends Vue {
},
5000,
);
console.error(
logger.error(
"Error retrieving plans fulfilled by this project:",
serverError.message,
);
}
}
onEditClick() {
const route = {
name: "new-edit-project",
query: { projectId: this.projectId },
};
this.$router.push(route);
}
// Isn't there a better way to make this available to the template?
expandText() {
this.expanded = true;
}
collapseText() {
this.expanded = false;
}
/**
* Handle clicking on a project entry found in the list
* @param id of the project
@@ -1437,7 +1421,7 @@ export default class ProjectViewView extends Vue {
give.jwtId,
];
} else {
console.error("Got error submitting the confirmation:", result);
logger.error("Got error submitting the confirmation:", result);
const message =
(result.error?.error as string) ||
"There was a problem submitting the confirmation.";
@@ -1493,7 +1477,7 @@ export default class ProjectViewView extends Vue {
);
}
} catch (error) {
console.error("Error loading totals:", error);
logger.error("Error loading totals:", error);
this.$notify(
{
group: "alert",