generated from nhcarrigan/template
Compare commits
3 Commits
v1.0.0
...
c997e83aa5
| Author | SHA1 | Date | |
|---|---|---|---|
| c997e83aa5 | |||
| f2f5d9b1b4 | |||
| b65f3a4d6d |
@@ -0,0 +1,34 @@
|
|||||||
|
name: Code Analysis
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sonar:
|
||||||
|
name: SonarQube
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Source Files
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: SonarCube Scan
|
||||||
|
uses: SonarSource/sonarqube-scan-action@v4
|
||||||
|
timeout-minutes: 10
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: "https://quality.nhcarrigan.com"
|
||||||
|
with:
|
||||||
|
args: >
|
||||||
|
-Dsonar.sources=.
|
||||||
|
-Dsonar.projectKey=logger
|
||||||
|
|
||||||
|
- name: SonarQube Quality Gate check
|
||||||
|
uses: sonarsource/sonarqube-quality-gate-action@v1
|
||||||
|
with:
|
||||||
|
pollingTimeoutSec: 600
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: "https://quality.nhcarrigan.com"
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhcarrigan/logger",
|
"name": "@nhcarrigan/logger",
|
||||||
"version": "1.0.0",
|
"version": "1.1.0",
|
||||||
"description": "Our custom logging package, which pipes logs to our alerts server.",
|
"description": "Our custom logging package, which pipes logs to our alerts server.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "prod/index.js",
|
"main": "prod/index.js",
|
||||||
|
|||||||
@@ -71,4 +71,34 @@ export class Logger {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a counter metric to the alerting service.
|
||||||
|
* The alerting service is configured to handle aggregation, so you can send
|
||||||
|
* summative counts or individual increments. (e.g. Send a count of all users, or send a count of 1 every time a user joins).
|
||||||
|
* @param name -- The name of the metric to track.
|
||||||
|
* @param value -- The value of the metric to insert.
|
||||||
|
* @param metadata -- Any metadata to attach to the metric.
|
||||||
|
*/
|
||||||
|
public async metric(
|
||||||
|
name: string,
|
||||||
|
value: number,
|
||||||
|
metadata: Record<string, string | number | boolean>,
|
||||||
|
): Promise<void> {
|
||||||
|
await fetch(`${this.url}/metric`, {
|
||||||
|
body: JSON.stringify({
|
||||||
|
application: this.application,
|
||||||
|
metadata: metadata,
|
||||||
|
name: name,
|
||||||
|
value: value,
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
|
||||||
|
"Authorization": this.token,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header name.
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
method: "POST",
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user