This starter kit should provide a quick jumping off point to creating your own MyDataHelps Custom Views.
This repository uses the components from MyDataHelpsUI, which contains many pre-built and localized React components that are commonly useful in custom views. It is bootstrapped with Vite.
You will normally start by developing and testing your custom view in a local environment.
- Clone/fork the code in this repository to your local machine.
- Run
npm install. - Get a participant access token - see below for details.
- Copy the file
dotenvto create a file named.env.development. - Edit the environment file to specify your participant access token.
- Run
npm run dev.
You should see the default project home page appear and populate itself with data from your participant. src/main.tsx contains other routes. Navigate to them in your browser to see other pre-build views in action.
You can use or edit one of the existing views, or build your own using MyDataHelpsUI and/or the MyDataHelps SDK!
Normally, participant authentication is managed by MyDataHelps. When running in development mode, you must manually configure an access token so the custom view can get and show participant data. This simulates a participant accessing the view through MyDataHelps.
First, identify the participant you want to test with. Ideally this will be a fake participant from your test/dry-run project.
Second, choose which scopes you will need, depending on which features your test participant will need to access. See Participant Tokens - Scopes for details. The default dashboard screen requires the following scopes: Participant:read SurveyTasks:read SurveyAnswers:read Notifications:read DataCollectionSettings:read ExternalAccounts:connect ExternalAccounts:read Project:read.
Finally, obtain the token for the test participant. Choose any of the following methods:
- Log in to mydatahelps.org using that participant. Use the browser developer tools to examine the request to
https://mydatahelps.org/identityserver/connect/token. The access token will be in the response. - Use the MyDataHelps REST API NodeJS Quickstart or MyDataHelps REST API Python Quickstart apps to generate a token for your test participant.
- Use the MyDataHelps REST API to generate a token for your test participant.
Once you have the token, store it in the .env.development file as explained above, then run the app.
IMPORTANT NOTES:
- Take care not to commit the token to source control.
- Use the
.env.developmentfile (not.env) so the token is not deployed in production. - The starter kit will only use the token from the environment file when running in development mode. When the custom view is displayed within MyDataHelps, the system will automatically provide a token for the current participant.
Your custom view must be hosted on the internet before MyDataHelps can use it. We recommend using a CI/CD process to automatically build and deploy your view. See the hosting guide for recommendations and best practices.
- Use
npm run buildto build the view for production, then deploy it to your chosen host. - Once your view is deployed, create a new tab in your project app layout and point it to your custom view URL. See Using Views for details.
- Before you can use your custom view in a production project, it will have to pass a security review. Learn about the security review process.
A handful of views have been set up already to walk you through various use cases that you may encounter when building your custom view.
The "ConnectEhr" view just includes pre-built views from MyDataHelpsUI
"Home" and "DeviceData" views show you how to import specific components into your view
"TaskProgress" is a custom view with a custom component (inside src/components/TaskProgress)
To edit a component, you may wish to build a new custom component that models the logic used to build the original component in MyDataHelpsUI