@molecule/api-activity-capture

Utility · activity · API (Node) · v1.1.1 · Apache-2.0

Records the email, SMS, push, webhook and channel messages your API sends in the molecule.dev Activity panel: captured in the dev sandbox, delivered and recorded in production.

npm install @molecule/api-activity-capture

npm · Source on GitHub

How it works

@molecule/api-activity-capture is a utility package for the API (Node) side (activity).

Works with: @molecule/api-bond, @molecule/api-logger, @molecule/api-secrets

Reference

Records the email, SMS, push, webhook and channel messages your API sends in the molecule.dev Activity panel.

In the molecule.dev dev sandbox each send is recorded and not delivered. In a production deploy it is delivered by your own provider and recorded with its outcome. Anywhere else (your machine, another host) the call does nothing and your providers send as usual.

Call it last in setupBonds(), after every provider is bonded, so it can wrap them. mlcl add @molecule/api-activity-capture --inject writes the call for you, and projects created on molecule.dev come with it.

import { setupActivityCapture } from '@molecule/api-activity-capture'

import { setupEmailsMailgun } from './emails-mailgun.js'

export async function setupBonds(): Promise<void> {
  setupEmailsMailgun()
  await setupActivityCapture()
}

The platform turns it on with MOLECULE_ACTIVITY_URL (where events go) and MOLECULE_ACTIVITY_MODE (tee delivers and records; anything else records only). A category whose capture package cannot be loaded keeps its real provider.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Type

utility

Installation

npm install @molecule/api-activity-capture @molecule/api-activity @molecule/api-activity-http @molecule/api-bond @molecule/api-channel-capture @molecule/api-emails-capture @molecule/api-logger @molecule/api-push-capture @molecule/api-secrets @molecule/api-sms-capture @molecule/api-webhook-capture

API

Functions

setupActivityCapture()

Record what the app sends in the molecule.dev Activity panel.

Call it last in setupBonds(), after every provider is bonded. It does nothing unless MOLECULE_ACTIVITY_URL is set, which molecule.dev does for the apps it runs. Then it bonds the HTTP activity sink and, for each capturable category the app has bonded:

  • with MOLECULE_ACTIVITY_MODE=tee (a production deploy), wraps the real provider: the send is delivered and recorded with its outcome;
  • otherwise (the dev sandbox), replaces it: the send is recorded and not delivered.

A category whose capture package cannot be loaded, or (in tee mode) has no wrapping factory, keeps its real provider: delivering always wins over recording.

function setupActivityCapture(): Promise<void>

Returns: Once every bonded category is routed.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/api-bond ^1.0.1
  • @molecule/api-logger ^1.0.1
  • @molecule/api-secrets ^1.0.1

Runtime Dependencies

  • @molecule/api-activity
  • @molecule/api-activity-http
  • @molecule/api-bond
  • @molecule/api-channel-capture
  • @molecule/api-emails-capture
  • @molecule/api-logger
  • @molecule/api-push-capture
  • @molecule/api-secrets
  • @molecule/api-sms-capture
  • @molecule/api-webhook-capture