Monitoring and Logging

The javascript-gameshow project utilizes various mechanisms for monitoring and logging. This includes:

  • Console logging: The codebase leverages console.log, console.info, console.warn, and console.error for basic debugging and information outputs.

    Example:

    console.info(`There are ${QUESTIONS.length} questions.`)
              console.warn(`No questions remaining for difficulty ${difficulty}.`);
              
  • Error handling: The code includes try...catch blocks for handling potential errors.

    Example:

    try {
                // Code that may throw an error
              } catch (error) {
                console.error(error);
              }
              
  • Custom logging functions: The QuestionController utilizes custom functions (logQuestions) for specific logging needs.

    Example:

    logQuestions() {
                console.groupCollapsed("Question Integrity Check");
                // ... logging statements ...
                console.groupEnd();
              }
              
  • Storage: The QuestionController utilizes local storage (localStorage) for persistent storage of QuestionClaim records.

    Example:

    private getClaimRecords(): QuestionClaim[] {
                let usageRecords = JSON.parse(localStorage.getItem(STORAGE_KEY) || "[]");
                return usageRecords;
              }
              
              private saveClaimRecords(usageRecords: QuestionClaim[]): void {
                localStorage.setItem(STORAGE_KEY, JSON.stringify(usageRecords));
              }
              
  • Firebase: The project is deployed using Firebase. The audience-app and presenter-app are configured to use Firebase for hosting and potentially other services like authentication or data storage.

    Example:

    $ npm run deploy
              
  • Deployment: The project uses npm scripts for deployment.

    Example:

    $ npm run deploy
              

For detailed information regarding Firebase deployment, consult the README.md file for the project. README.md

  • Firebase Rules: The project uses Firebase rules to govern database access. The database.rules.json file defines these rules.

    Example:

    If you change your rules inside of the firebase console do not forget to copy them to the `database.rules.json` file otherwise when you deploy they will get blown away. The file is the law of the land.
              
  • Testing: The project utilizes Jest and Enzyme for testing. The README.md file outlines the testing commands and configuration.

    Example:

    $ npm run test
              

Top-Level Directory Explanations

audience-app/ - This directory contains the files for the audience-facing part of the application. It includes HTML files for different pages, static assets like images, and configuration files for Firebase and npm.

audience-app/public/ - This subdirectory holds the publicly accessible files of the audience app. It includes HTML files for specific pages, images, and other static assets.

presenter-app/ - This directory contains the files for the presenter-facing part of the application. It includes source code, static assets, and configuration files.

presenter-app/build/ - This subdirectory holds the compiled and bundled files for the presenter app. It includes HTML, CSS, JavaScript, and image files.

presenter-app/src/ - This subdirectory contains the source code for the presenter app. It includes components, controllers, routes, styles, and utility functions.

presenter-app/tests/ - This subdirectory contains test files for the presenter app. It includes mocks, controllers, and declarations.