Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@standardnotes/analytics

Package Overview
Dependencies
Maintainers
6
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@standardnotes/analytics - npm Package Compare versions

Comparing version 1.18.1 to 1.19.0

dist/src/Domain/Statistics/StatisticsMeasure.d.ts

1

dist/src/Domain/index.d.ts
export * from './Analytics/AnalyticsActivity';
export * from './Analytics/AnalyticsStoreInterface';
export * from './Statistics/StatisticsMeasure';
export * from './Statistics/StatisticsStoreInterface';

@@ -4,0 +5,0 @@ export * from './Time/Period';

@@ -19,2 +19,3 @@ "use strict";

__exportStar(require("./Analytics/AnalyticsStoreInterface"), exports);
__exportStar(require("./Statistics/StatisticsMeasure"), exports);
__exportStar(require("./Statistics/StatisticsStoreInterface"), exports);

@@ -21,0 +22,0 @@ __exportStar(require("./Time/Period"), exports);

@@ -0,1 +1,3 @@

import { Period } from '../Time/Period';
import { StatisticsMeasure } from './StatisticsMeasure';
export interface StatisticsStoreInterface {

@@ -14,2 +16,5 @@ incrementSNJSVersionUsage(snjsVersion: string): Promise<void>;

getYesterdayOutOfSyncIncidents(): Promise<number>;
incrementMeasure(measure: StatisticsMeasure, value: number, periods: Period[]): Promise<void>;
getMeasureAverage(measure: StatisticsMeasure, period: Period): Promise<number>;
getMeasureTotal(measure: StatisticsMeasure, period: Period): Promise<number>;
}
import * as IORedis from 'ioredis';
import { PeriodKeyGeneratorInterface } from '../../Domain';
import { Period, PeriodKeyGeneratorInterface } from '../../Domain';
import { StatisticsMeasure } from '../../Domain/Statistics/StatisticsMeasure';
import { StatisticsStoreInterface } from '../../Domain/Statistics/StatisticsStoreInterface';

@@ -8,2 +9,5 @@ export declare class RedisStatisticsStore implements StatisticsStoreInterface {

constructor(periodKeyGenerator: PeriodKeyGeneratorInterface, redisClient: IORedis.Redis);
getMeasureTotal(measure: StatisticsMeasure, period: Period): Promise<number>;
incrementMeasure(measure: StatisticsMeasure, value: number, periods: Period[]): Promise<void>;
getMeasureAverage(measure: StatisticsMeasure, period: Period): Promise<number>;
getYesterdayOutOfSyncIncidents(): Promise<number>;

@@ -10,0 +14,0 @@ incrementOutOfSyncIncidents(): Promise<void>;

@@ -12,2 +12,25 @@ "use strict";

}
async getMeasureTotal(measure, period) {
const totalValue = await this.redisClient.get(`count:measure:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`);
if (totalValue === null) {
return 0;
}
return +totalValue;
}
async incrementMeasure(measure, value, periods) {
const pipeline = this.redisClient.pipeline();
for (const period of periods) {
pipeline.incrby(`count:measure:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`, value);
pipeline.incr(`count:increments:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`);
}
await pipeline.exec();
}
async getMeasureAverage(measure, period) {
const increments = await this.redisClient.get(`count:increments:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`);
if (increments === null) {
return 0;
}
const totalValue = await this.getMeasureTotal(measure, period);
return totalValue / +increments;
}
async getYesterdayOutOfSyncIncidents() {

@@ -14,0 +37,0 @@ const count = await this.redisClient.get(`count:action:out-of-sync:timespan:${this.periodKeyGenerator.getPeriodKey(Domain_1.Period.Yesterday)}`);

4

package.json
{
"name": "@standardnotes/analytics",
"version": "1.18.1",
"version": "1.19.0",
"engines": {

@@ -40,3 +40,3 @@ "node": ">=14.0.0 <17.0.0"

},
"gitHead": "4bb785c7f0e54fe160dba51d7c5d97197b8e8bae"
"gitHead": "e618f046ea906588d97f44e8f77212b96a0cd903"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc