@govuk-one-login/data-npm
v0.0.8
Published
Standardised logger for GOV.UK One Login data pod Lambda functions
Maintainers
Keywords
Readme
@govuk-one-login/data-npm
Standardised logger for GOV.UK One Login data pod Lambda functions, built on AWS Lambda Powertools and published to npm.
Install
npm install @govuk-one-login/data-npmUsage
import { DataLogger, LogEvents } from "@govuk-one-login/data-npm";
const logger = new DataLogger("my-service", "my-namespace");
// In your Lambda handler:
logger.initialise(context);
logger.infoWithMetrics("Started", LogEvents.StartedProcessing);Extending with service-specific log events
import { DataLogger } from "@govuk-one-login/data-npm";
enum MyLogEvents {
SomethingHappened = "Something Happened",
}
const logger = new DataLogger<MyLogEvents>("my-service");
logger.infoWithMetrics("msg", MyLogEvents.SomethingHappened);Generic log events
| Event | Value |
| --------------------------------- | -------------------------- |
| LogEvents.StartedProcessing | 'Started Processing' |
| LogEvents.SuccessfullyProcessed | 'Successfully Processed' |
| LogEvents.ErrorProcessing | 'Error Processing' |
Development
npm install
npm run build
npm testCode formatting
npm run formatPublishing
This package uses Changesets for version management and publishing. Publishing, git tags, and GitHub Releases are automated by the release workflow on merge to main.
1. Create a changeset
After making your code changes, create a changeset to describe what changed:
npx changesetFollow the prompts to select the bump type (patch, minor, or major) — this controls the version number. Then write a description — this becomes the changelog entry.
Alternatively, create the changeset file manually at .changeset/<any-name>.md:
Single change
---
"@govuk-one-login/data-npm": minor
---
Add support for custom metric dimensionsMultiple changes in one release
If you're making multiple changes that should ship under the same version number, list them in a single changeset. Run npx changeset once, or create the file manually:
---
"@govuk-one-login/data-npm": patch
---
- Automate release workflow with Changesets GitHub Action
- Align .npmrc auth token with setup-node
- Remove redundant registry-url from CI workflowThe frontmatter controls the version bump (patch, minor, or major). The body controls the changelog entry.
Changing the version type
If you need to change the bump type after creating the changeset, edit the frontmatter in the .changeset/*.md file before running changeset version.
2. Version the package
Run the version command to consume the changeset, bump package.json, and update CHANGELOG.md:
npx changeset version3. Commit and open a pull request
Commit your code changes together with the version bump and changelog update.
git add .
git commit -m "feat: add custom metric dimensions"
git push4. What happens on merge to main
Once your PR is merged to main, the release workflow automatically:
- Publishes the package to npm
- Creates a git tag (
v0.0.8, etc.) - Creates a GitHub Release
If the version is already published (e.g. a non-release PR), the workflow skips gracefully.
