In a constantly evolving product, it may be useful to conduct A/B testing.
This strategy allows trying new ideas with a small subset of the users, analyzing reception, iterating and improving before releasing them to everyone.
Routing
The frontend uses
React Router to declare routes and manage navigation between them.
You can use the <Route>
and <Switch>
components to declare routes, the useParams
hook to get the URL parameters, the <Link>
component for declarative navigation, and the useHistory
hook for imperative navigation.
Refer to React Router’s documentation for more details.
Styling
You can declare styled components with the styled
tag, reference tachyons classes, and also add custom CSS as needed.
Refer to styled-components and Tachyons’ documentation for more details.
Internationalization
The frontend uses
i18next to manage translations.
While we currently support only English, more languages may be added later on, making it a good idea to avoid hardcoding texts and having them instead as translations.
You can declare texts in the respective file for the language, at src/utils/translations
, and then, use the useTranslation
hook to access them in the component.
Refer to i18next’s documentation for more details.
Dependencies
The frontend uses
npm as its package manager.
When adding or updating dependencies, keep
this requirement in mind. Always make sure to pin the dependency to an exact version, as semantic versioning is often unreliable and may cause regressions due to unexpected incompatibilities.
Logging
You can use src/utils/logger.ts
, which sends errors and warnings to Bugsnag, the bug-tracking platform we currently use.
To access Bugsnag, sign in to your Okta account. If you can’t find the app, feel free to request access via
help@fluidattacks.com.
Design
Visual consistency is key to providing users with a good experience. This motivation led to the creation of the components library, a collection of UI components that can be easily used by developers and continuously refined by designers.
You can access it on:
- Production: design.fluidattacks.com
- Locally:
localhost:6006
, after running m . /designs run
Most of these components are implementations of the design guidelines defined by the Customer Experience team at Fluid Attacks. To learn more about the design component library, please refer to
Designs.
Resources
Our platform utilizes various media assets, including images, GIFs, and other media to enhance user experience. These resources are hosted and managed through Cloudinary. Our developers can access and manage these assets via our
Cloudinary media explorer.
API type safety
The
API features a fully typed schema. This frontend can leverage it by generating TypeScript types, ensuring accurate interactions with the backend.
To regenerate these types, execute views-types
.
Helpful tools that enhance development experience when working on the frontend:
- vscode gitlens
- react developer tools
- apollo client devtools
- vscode eslint
- vscode jest
- vscode prettier
- semver calculator
Troubleshooting
Helpful tips and tricks that have proven to be useful when diagnosing issues on the frontend:
- How do I do X?: Refer to the documentation of the core packages mentioned above. If that doesn’t solve it, feel free to reach out for help on the engineering chat.
- Why is X not working?: Look for error traces on the browser console or use breakpoints to inspect the code and variable values as it runs.
- Is the backend returning an error?: Use the network tab to view more details about the request and its response.
- Can’t find an element on a test?: Try increasing the print limit to view more details and suggestions or try a snippet on testing playground.
Frontend Testing
Frontend tests are classified into the following levels:
- Unit tests: From the test, start to create a function.
- End-to-end tests: These tests verify that the flows a user follows work as expected, for example: loading a web page, logging in, verifying email notifications, and online payments, validating that these flows are done and that they work correctly.