# Gather Vue

Gather Vue is the Vue 3 customer referral widget used for referral campaigns,
pop-ups, and the campaign editor. It runs inside an iframe on merchant sites,
fetches campaign configuration from Gather Rails, and communicates with the
host page through `window.postMessage`.

## How it fits into Gather

```text
Merchant site
  -> gather-integration evaluates targeting and creates an iframe
  -> gather-vue renders the campaign inside the iframe
  -> gather-rails supplies campaign data and handles API requests
```

The built widget is published as an npm package for jsDelivr and is also
deployed to S3 behind CloudFront.

## Requirements

- [Node.js 24 LTS](https://nodejs.org/), pinned in `.nvmrc`
- [pnpm 10](https://pnpm.io/), matching the version used by GitHub Actions
- Gather Rails running locally if you need live API responses

## Setup

```sh
git clone git@github.com:gathercustomers/gather-vue.git
cd gather-vue
nvm install
nvm use
corepack enable
corepack prepare pnpm@10 --activate
cp .env.development.example .env.local
pnpm install
pnpm dev
```

The development example points `VITE_GATHER_URL` at a local Gather Rails
server on port 3000. Add any credentials needed for the integrations you are
testing to `.env.local`; the file is ignored by Git and must not be committed.

The Vite development server prints the local URL when it starts.

## Commands

| Task | Command |
|---|---|
| Start the development server | `pnpm dev` |
| Type-check | `pnpm type-check` |
| Lint and apply safe fixes | `pnpm lint` |
| Format | `pnpm format` |
| Run unit tests | `pnpm test:unit` |
| Run unit tests once | `pnpm test:unit --run` |
| Build the default bundle | `pnpm build` |
| Build for staging | `pnpm build:staging` |
| Build for production | `pnpm build:production` |
| Run end-to-end tests | `pnpm test:e2e` |

Before committing, run:

```sh
pnpm type-check
pnpm lint
pnpm test:unit --run
```

## End-to-end tests

Install the Playwright browsers once:

```sh
pnpm exec playwright install
```

Then build the app and run the suite:

```sh
pnpm build
pnpm test:e2e
```

Useful variants include:

```sh
pnpm test:e2e --project=chromium
pnpm test:e2e --debug
```

## Releases and deployment

Feature work merges into `develop`. Release commits are promoted to `staging`
for the staging npm/S3/CloudFront deployment, then to `master` for production.
npm publishing runs in GitHub Actions with OIDC trusted publishing; it does not
use a long-lived npm publish token.

Do not publish a release manually. Follow [`RELEASES.md`](RELEASES.md) for the
versioning, branch promotion, trusted-publisher configuration, and deployment
verification process.

## Further documentation

- [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) — application architecture,
  state, iframe communication, and build design
- [`RELEASES.md`](RELEASES.md) — release and deployment runbook
- [`docs/OBSERVABILITY.md`](docs/OBSERVABILITY.md) — frontend telemetry setup
- [`CUSTOMER_README.md`](CUSTOMER_README.md) — customer integration examples

## Recommended editor

[Visual Studio Code](https://code.visualstudio.com/) with
[Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
provides Vue and TypeScript language support. Disable Vetur if it is installed.
