Skip to content

Commit

Permalink
docs: set correct package name in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LabEG committed Mar 11, 2024
1 parent fefde7d commit efdf4ca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/LabEG/reca/blob/main/LICENSE)

# WebMon - Realtime user WebMonitoring
# Bretrics - Realtime user Browser Monitoring

Monitor the performance of the user's browser and code for real users. Allows you to collect WebVitals metrics, performance and business metrics through the Prometheuse monitoring system.

Expand Down Expand Up @@ -36,10 +36,10 @@ yarn add @mts-pjsc/bretrics
The package has a pre-configured monitoring mode that includes the necessary webvitals metrics.

``` typescript
import {webmon} from "@mts-pjsc/bretrics";
import {bretrics} from "@mts-pjsc/bretrics";

webmon
.setup({apiPath: "/webmon"}) // <-- microservice deploy location
bretrics
.setup({apiPath: "/bretrics"}) // <-- microservice deploy location
.useDefaultMonitoring()
.sendMetrics({my_metric: 5}); // <-- custom metrics
```
Expand All @@ -51,10 +51,10 @@ If you need to send custom metric, you must use the `sendMetrics` method.
Prometheus labels can be set as default for all metrics, or individually for each value.

``` typescript
import {webmon} from "@mts-pjsc/bretrics";
import {bretrics} from "@mts-pjsc/bretrics";

webmon
.setup({apiPath: "/webmon"})
bretrics
.setup({apiPath: "/bretrics"})
.useDefaultMonitoring()
.setLabels({stage: "beta", path: location.pathname})
.sendMetrics({
Expand All @@ -67,14 +67,14 @@ webmon

The default labels will be added to the metrics if you didn't pass them in the `sendMetrics` method.

### Example WebMonitoring customization
### Example Bretrics customization

The library exports the web monitoring constructor class, so you can inherit from it and implement logic according to OOP principles.

``` typescript
import {WebMonitoring} from "@mts-pjsc/bretrics";
import {Bretrics} from "@mts-pjsc/bretrics";

export class WebMonitoringService extends WebMonitoring {
export class BretricsService extends Bretrics {

public override sendMetrics (metric: Record<string, number>): this {
super.sendMetrics(metric);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mts-pjsc/bretrics",
"version": "1.0.0",
"version": "1.0.1",
"description": "Web Monitoring",
"main": "dist/index.js",
"type": "module",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type {Metric} from "web-vitals";
import {onLCP, onFID, onCLS, onFCP, onINP, onTTFB} from "web-vitals";
import type {IMetric} from "./interfaces/IMetric";

export class WebMonitoring {
export class Bretrics {

public apiPath: string = "/webmon";
public apiPath: string = "/bretrics";

public labels: Record<string, number | string> = {};

Expand Down Expand Up @@ -120,6 +120,7 @@ export class WebMonitoring {
return sendMetrics;
}

// eslint-disable-next-line @typescript-eslint/class-methods-use-this
protected getDeviceType (): string {
const ua = navigator.userAgent;
if ((/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/iu).test(ua)) {
Expand All @@ -135,5 +136,4 @@ export class WebMonitoring {

}

export const webmonitoring = new WebMonitoring();
export const webmon = webmonitoring;
export const bretrics = new Bretrics();

0 comments on commit efdf4ca

Please sign in to comment.