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.23.0 to 1.24.0

6

dist/src/Domain/Analytics/AnalyticsStoreInterface.d.ts

@@ -8,2 +8,8 @@ import { Period } from '../Time/Period';

calculateActivityRetention(activity: AnalyticsActivity, firstPeriod: Period, secondPeriod: Period): Promise<number>;
calculateActivitiesRetention(parameters: {
firstActivity: AnalyticsActivity;
firstActivityPeriodKey: string;
secondActivity: AnalyticsActivity;
secondActivityPeriodKey: string;
}): Promise<number>;
calculateActivityTotalCount(activity: AnalyticsActivity, period: Period): Promise<number>;

@@ -10,0 +16,0 @@ calculateActivityChangesTotalCount(activity: AnalyticsActivity, period: Period): Promise<Array<{

@@ -18,4 +18,10 @@ import * as IORedis from 'ioredis';

wasActivityDone(activity: AnalyticsActivity, analyticsId: number, period: Period): Promise<boolean>;
calculateActivitiesRetention(parameters: {
firstActivity: AnalyticsActivity;
firstActivityPeriodKey: string;
secondActivity: AnalyticsActivity;
secondActivityPeriodKey: string;
}): Promise<number>;
calculateActivityRetention(activity: AnalyticsActivity, firstPeriod: Period, secondPeriod: Period): Promise<number>;
calculateActivityTotalCount(activity: AnalyticsActivity, period: Period): Promise<number>;
}

18

dist/src/Infra/Redis/RedisAnalyticsStore.js

@@ -57,12 +57,18 @@ "use strict";

}
async calculateActivityRetention(activity, firstPeriod, secondPeriod) {
const initialPeriodKey = this.periodKeyGenerator.getPeriodKey(firstPeriod);
const subsequentPeriodKey = this.periodKeyGenerator.getPeriodKey(secondPeriod);
const diffKey = `bitmap:action:${activity}:timespan:${initialPeriodKey}-${subsequentPeriodKey}`;
await this.redisClient.bitop('AND', diffKey, `bitmap:action:${activity}:timespan:${initialPeriodKey}`, `bitmap:action:${activity}:timespan:${subsequentPeriodKey}`);
async calculateActivitiesRetention(parameters) {
const diffKey = `bitmap:action:${parameters.firstActivity}-${parameters.secondActivity}:timespan:${parameters.secondActivityPeriodKey}`;
await this.redisClient.bitop('AND', diffKey, `bitmap:action:${parameters.firstActivity}:timespan:${parameters.firstActivityPeriodKey}`, `bitmap:action:${parameters.secondActivity}:timespan:${parameters.secondActivityPeriodKey}`);
await this.redisClient.expire(diffKey, 3600);
const retainedTotalInActivity = await this.redisClient.bitcount(diffKey);
const initialTotalInActivity = await this.redisClient.bitcount(`bitmap:action:${activity}:timespan:${initialPeriodKey}`);
const initialTotalInActivity = await this.redisClient.bitcount(`bitmap:action:${parameters.firstActivity}:timespan:${parameters.firstActivityPeriodKey}`);
return Math.ceil((retainedTotalInActivity * 100) / initialTotalInActivity);
}
async calculateActivityRetention(activity, firstPeriod, secondPeriod) {
return this.calculateActivitiesRetention({
firstActivity: activity,
firstActivityPeriodKey: this.periodKeyGenerator.getPeriodKey(firstPeriod),
secondActivity: activity,
secondActivityPeriodKey: this.periodKeyGenerator.getPeriodKey(secondPeriod),
});
}
async calculateActivityTotalCount(activity, period) {

@@ -69,0 +75,0 @@ return this.redisClient.bitcount(`bitmap:action:${activity}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`);

{
"name": "@standardnotes/analytics",
"version": "1.23.0",
"version": "1.24.0",
"engines": {

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

},
"gitHead": "686e4f8ddf8a268722b8a8bce4367413db7b2d75"
"gitHead": "c5fdd59eb1fe4f7cea990d09c17e54e3c858db48"
}
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