PR Time Tracker
PR Time Tracker automates invoice generation processes and tracks core developer activity related to PRs and issues.
Contributing
If you want to contribute, please follow Holdex Developer Guidelines.
Possible issues docs
- Cannot submit time: see docs
Installing application
- Access the App public page
- Install the App under your organization
- Invite the @pr-time-tracker into your organization and make him an owner
- To customize the included repositories, go to "Settings" -> "GitHub Apps"
Connect the installed organization with the Tracker flow
- Add a record of your organization info in the Vercel env
APP_INTEGRATIONS_LIST
{ "id": "org_id", "name": "org_slug", "nodeId": "oracle_project_id"}
Where:
id
is the identifier used for defining jobs (can be any string)
name
- the GitHub organization slug
nodeId
- Holdex Oracle project ID, if no project is defined, use explicit value 337c06eb
for HX project column
- Re-deploy the current production build so changes can take effect.
Scripts
- postinstall: Sets up Husky for Git hooks.
- pre-dev: Executes a script to pull environment variables before starting development.
- dev: Starts the development server on port 3000 after executing the
pre-dev
script.
- build: Builds the project.
- preview: Previews the build.
- format: Formats the code using Prettier with plugins for Svelte and Pug.
- lint: Lints the codebase using ESLint with support for JavaScript, TypeScript, Svelte, and CommonJS.
check: Syncs Svelte kit and checks the TypeScript configuration.
- type-check: type checks the TypeScript files without emitting any output.
- check:watch: Watches for changes and syncs Svelte kit while checking TypeScript.
- proxy: Sets up ngrok to proxy requests to the development server with a specific domain.
Local Development Setup
Requirements
git
https://git-scm.com/downloads
docker
https://docs.docker.com/
nodejs
https://nodejs.org/en/download/package-manager
pnpm
https://pnpm.io/installation
Steps and Setups
-
Clone this repository
-
Make GitHub Access Token for installing some of the hosted dependencies:
-
Copy .npmrc.example
to .npmrc
in the root folder and replace the NPM_TOKEN
with your generated GitHub access token.
-
Install the dependencies pnpm install
You should have this if you setup your token properly with proper permission
![Project Dependencies Installation](./docs/images/local-development-setup/dependencies-installations.png)
-
Setup Telebit https://telebit.cloud/
Following the telebit setup you will have these, take note of your own unique telebit address.
![Telebit Setup 1](./docs/images/local-development-setup/telebit-setup-1.png)
![Telebit Setup 2](./docs/images/local-development-setup/telebit-setup-2.png)
-
Setup your Supabase Project for Trigger.dev v2 based on this guide: https://v2docs.trigger.dev/documentation/guides/self-hosting/supabase (Optional)
You can skip this step if you don't need to run your own supabase for Trigger.dev v2. We provide a shared supabase project for development purpose that you can use.
But for some reason you have a problem when running with the shared supabase project, you can follow this guide to create your own supabase project.
-
You can follow this setup guide https://v2docs.trigger.dev/documentation/guides/self-hosting/supabase#create-a-supabase-db
-
Create your supabase project for trigger.dev
When creating the project, take note of your Supabase DB uri and password.
![Supabase DB Setup 1](./docs/images/local-development-setup/supabase-db-setup-1.png)
![Supabase DB Setup 2](./docs/images/local-development-setup/supabase-db-setup-2.png)
-
Go to the /container
folder
-
Duplicate the .env.example
to .env
-
In the .env
file change the DATABASE_URL
and DIRECT_URL
you created in the Supabase DB creation step (don't forget to adjust with your own password).
# From this
DATABASE_URL=postgresql://postgres.phtaofoaormwpxwrwtkw:YZHPcdhJEwOUcK05@aws-0-eu-central-1.pooler.supabase.com:6543/postgres?schema=triggerdotdev&pgbouncer=true
DIRECT_URL=postgresql://postgres.phtaofoaormwpxwrwtkw:YZHPcdhJEwOUcK05@aws-0-eu-central-1.pooler.supabase.com:5432/postgres?schema=triggerdotdev
# To this (EXAMPLE)
DATABASE_URL=postgresql://postgres.arnehavoxpuewazwvpph:YOUR-PASSWORD@aws-0-ap-southeast-1.pooler.supabase.com:6543/postgres?schema=triggerdotdev&pgbouncer=true
DIRECT_URL=postgresql://postgres.arnehavoxpuewazwvpph:YOUR-PASSWORD@aws-0-ap-southeast-1.pooler.supabase.com:5432/postgres?schema=triggerdotdev
-
Setup Local Trigger.dev v2
-
Start proxy server for localhost:3030
to Telebit pnpm trigger-dev:proxy
![Telebit Proxy](./docs/images/local-development-setup/telebit-proxy.png)
-
Go to the /container
folder
-
Duplicate the .env.example
to .env
-
In the .env
file change the LOGIN_ORIGIN
and API_ORIGIN
with the forwarding URL from telebit above, e.g:
# From this
LOGIN_ORIGIN=https://alert-seemingly-moccasin.telebit.io
APP_ORIGIN=https://alert-seemingly-moccasin.telebit.io
# To this (EXAMPLE)
LOGIN_ORIGIN=https://shaggy-termite-71.telebit.io
APP_ORIGIN=https://shaggy-termite-71.telebit.io
-
Run docker compose up
within the container. Make sure you don't have running redis that use port 0.0.0.0:6379
. If you fail to run this see Possible issues on the bottom.
You should see this successful docker compose
![Docker Compose Success](./docs/images/local-development-setup/docker-compose-up-success.png)
-
You should be able to access your local Trigger.dev using the forwarding URL from pnpm trigger-dev:proxy
above e.g: https://shaggy-termite-71.telebit.io/
You should see this successful docker compose
![Docker Compose Success](./docs/images/local-development-setup/docker-compose-up-success.png)
-
Setup your local account and triggerdotdev project
Register your email here
![Local Triggerdotdev 2](./docs/images/local-development-setup/local-triggerdotdev-2.png)
You'll get a login url from `docker` container
![Local Triggerdotdev 3](./docs/images/local-development-setup/local-triggerdotdev-3.png)
Copy and paste to browser to access, and you'll be redirected to your project.
![Local Triggerdotdev 4](./docs/images/local-development-setup/local-triggerdotdev-4.png)
-
Go to the root path and download the environment variables using pnpm pre-dev
and you will see a new file .env
on root
-
Take note of the Trigger.dev API Keys in Trigger dev UI (Environment & API Keys) and change the TRIGGER_API_KEY
and TRIGGER_API_URL
in the .env
file, and the endpointId
in your package.json
file.
# .env
# API Key from triggerdotdev UI
TRIGGER_API_KEY="tr_dev_YIHNyqRKaKYt7lJ7hwF2"
# URL from telebit forwarding proxy for accessing local triggerdotdev
TRIGGER_API_URL="https://shaggy-termite-71.telebit.io"
# slug for your created project in triggerdotdev (you can find this in the URL)
TRIGGER_PROJECT_ID="pr-time-tracker-lmz0"
// package.json
{
// ...
"trigger.dev": {
"endpointId": "pr-time-tracker-lmz0"
}
}
![Local Triggerdotdev 7](./docs/images/local-development-setup/local-triggerdotdev-7.png)
-
Run local dev of the project pnpm dev-only
-
Run ngrok proxy for the local dev project using pnpm proxy
![Local Triggerdotdev 8](./docs/images/local-development-setup/local-triggerdotdev-8.png)
-
In the Trigger dev UI (Environment & API Keys), set a development endpoint with the following URL:
https://alert-seemingly-moccasin.ngrok-free.app/api/trigger
![Local Triggerdotdev 5](./docs/images/local-development-setup/local-triggerdotdev-5.png)
![Local Triggerdotdev 6](./docs/images/local-development-setup/local-triggerdotdev-6.png)
![Local Triggerdotdev 9](./docs/images/local-development-setup/local-triggerdotdev-9.png)
-
After the process is done, you should be able to see a new entry in Runs
sidebar. Congrats! you have registered your local trigger.dev proxy url to github webhooks 🎉
You should see this successful run
![Local Triggerdotdev 10](./docs/images/local-development-setup/local-triggerdotdev-10.png)
![Local Triggerdotdev 11](./docs/images/local-development-setup/local-triggerdotdev-11.png)
-
Database Connection:
- Use
MongoDB Compass
to connect to the database using the MONGODB_URI
environment variable.
Possible issues
-
Telebit can't run. You might find this issue when running pnpm trigger-dev:proxy
.
```shell
pnpm trigger-dev:proxy
> pr-time-tracker@0.0.3 trigger-dev:proxy /home/ubuntu/Developer/pr-time-tracker
> ~/telebit http 3030
/home/ubuntu/Applications/telebit/bin/telebit-remote.js:643
var verstrd = [ pkg.name + ' daemon v' + state.config.version ];
^
TypeError: Cannot read property 'version' of undefined
at handleConfig (/home/ubuntu/Applications/telebit/bin/telebit-remote.js:643:57)
at /home/ubuntu/Applications/telebit/bin/telebit-remote.js:359:22
at /home/ubuntu/Applications/telebit/usr/share/install-launcher.js:241:26
at ChildProcess.exithandler (child_process.js:280:7)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
ELIFECYCLE Command failed with exit code 1.
```
Try to reinstall telebit
```shell
curl https://get.telebit.io/ | bash
```
Then rerun `pnpm trigger-dev:proxy`
-
Trigger.dev local docker failed to run migration. You might face this issue when running docker compose up
in /container
folder.
```
triggerdotdev | 526 migrations found in prisma/migrations
triggerdotdev |
triggerdotdev | Error: P3009
triggerdotdev |
triggerdotdev | migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
triggerdotdev | The `20230616104937_remove_api_identifier` migration started at 2024-11-12 08:37:52.191805 UTC failed
triggerdotdev |
```
A fix mentioned in
Make new Supabase project and change the `DATABASE_URL` and `DIRECT_URL` accordingly
Add this to the `triggerdotdev` container within `docker-compose.yml`
```yaml
# This is the important bit!
command:
- sh
- -c
- sed -i s/public/triggerdotdev/ ./packages/database/prisma/migrations/20240130165343_add_composite_index_to_job_run_for_job_id_and_created_at/migration.sql && ./scripts/entrypoint.sh
```
-
Redis can't find addrinfo. You might face this issue when running docker compose up
in /container
folder.
```shell
triggerdotdev | [ioredis] Unhandled error event: Error: getaddrinfo ENOTFOUND host.docker.internal
triggerdotdev | at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
triggerdotdev | at GetAddrInfoReqWrap.callbackTrampoline (node:internal/async_hooks:130:17)
```
You might need to change the REDIS_HOST="host.docker.internal"
in the /container/.env
to docker specific ip address e.g: REDIS_HOST=172.17.0.1
-
After setting a development endpoint, no new Runs
entry made.
Make sure the root `.env` `TRIGGER_API_KEY`, `TRIGGER_API_URL`, and `TRIGGER_PROJECT_ID` points to the correct values.
If you have verified these settings but still don't see any new `Runs` entries, try creating a new project in your local trigger.dev and rerun the setup process using the new project data. You can also try to restart the whole docker container after changing the `.env` and `package.json` files.