Skip to content

SDK and CLI

Michael Marras edited this page Jun 8, 2026 · 4 revisions

SDK Setup

Step 1 - Register your Project

Dashboard accounts are seeded by the team (no self-serve signup). Ask in the team channel to get a project_id for your app.

Step 2 - Install SDK

Add the Watchtower SDK to your html file with the following script

<script src="https://cdn.jsdelivr.net/gh/cse110-sp26-group7/Watchtower@main/client/watchtower.min.js" defer></script> 

Step 3 - Initialize SDK

Create and initialize a WatchTower object in in your code. Make sure to use your project id

const wt = new Watchtower({
  projectId: "your_project_id",
  endpoint: "https://watchtower-ingest.cse110piedpiper7.workers.dev/ingest",
  environment: "prod"
})
wt.init()

Step 4 - Test

Add this button to your html file to test your dashboard

<button id="trigger-error">Trigger Test Error</button>

<script>
  document
    .getElementById("trigger-error")
    .addEventListener("click", () => {
      // Simulate a runtime error
      throw new Error("Manual test error triggered");
    });
</script>

WatchTower CLI

Command line interface for interacting with WatchTower. Used in CI/CD pipelines and by power users.

Step 1 - Login

npx watchtower login

Opens a browser login prompt.

Step 2 - Create a Project

npx watchtower create

Outputs a unique PROJECT_ID. Store this as WT_PROJECT_ID in your environment variables or CI secrets.

Step 3 - Wire Up Deploys in CI

Notifies WatchTower that your project was deployed. Requires WT_PROJECT_ID.

npx watchtower deploy --environment <env> --gitSha <sha> --projectId <projectId>
Flag Short Required Description
--environment <environment> -e true Deployment environment (prod, staging, dev)
--gitSha <gitSha> -s true Release identifier (git SHA)
--projectId <projectId> -p true Your WatchTower project ID (e.g. wt_abcdabcd)
--set-version <version> -V false SemVer tag for this release (e.g. v1.2.0)

Example — GitHub Actions:

- name: Notify WatchTower
  run: npx watchtower deploy --environment prod --gitSha $GITHUB_SHA --projectId ${{ secrets.WT_PROJECT_ID }}

For tagged releases, add --set-version ${{ github.ref_name }}.

Clone this wiki locally