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

@standardnotes/analytics

Package Overview
Dependencies
Maintainers
5
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.4.1 to 1.5.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.5.0](https://github.com/standardnotes/snjs/compare/@standardnotes/analytics@1.4.1...@standardnotes/analytics@1.5.0) (2022-06-01)
### Features
* add unmarking activities ([09cea1d](https://github.com/standardnotes/snjs/commit/09cea1d8e97dd83f2eaafaef5ff680aef8c5c3ff))
## [1.4.1](https://github.com/standardnotes/snjs/compare/@standardnotes/analytics@1.4.0...@standardnotes/analytics@1.4.1) (2022-06-01)

@@ -8,0 +19,0 @@

1

dist/Domain/Service/AnalyticsActivity.d.ts
export declare enum AnalyticsActivity {
EditingItems = "editing-items",
Login = "login",
EmailUnbackedUpData = "email-unbacked-up-data",
EmailBackup = "email-backup"
}

@@ -8,3 +8,4 @@ "use strict";

AnalyticsActivity["Login"] = "login";
AnalyticsActivity["EmailUnbackedUpData"] = "email-unbacked-up-data";
AnalyticsActivity["EmailBackup"] = "email-backup";
})(AnalyticsActivity = exports.AnalyticsActivity || (exports.AnalyticsActivity = {}));

@@ -15,3 +15,8 @@ import { AnalyticsActivity } from './AnalyticsActivity';

getYesterdayOutOfSyncIncidents(): Promise<number>;
markActivity(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
unmarkActivityForToday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
unmarkActivitiesForToday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
unmarkActivityForYesterday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
unmarkActivitiesForYesterday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
markActivityForToday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
markActivitiesForToday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
wasActivityDoneYesterday(activity: AnalyticsActivity, analyticsId: number): Promise<boolean>;

@@ -18,0 +23,0 @@ wasActivityDoneToday(activity: AnalyticsActivity, analyticsId: number): Promise<boolean>;

@@ -7,2 +7,8 @@ import * as IORedis from 'ioredis';

constructor(redisClient: IORedis.Redis);
unmarkActivityForToday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
unmarkActivitiesForToday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
unmarkActivityForYesterday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
unmarkActivitiesForYesterday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
markActivityForToday(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
markActivitiesForToday(activities: AnalyticsActivity[], analyticsId: number): Promise<void>;
calculateActivityTotalCountForYesterday(activity: AnalyticsActivity): Promise<number>;

@@ -16,3 +22,2 @@ calculateActivityTotalCountForLastWeek(activity: AnalyticsActivity): Promise<number>;

wasActivityDoneThisWeek(activity: AnalyticsActivity, analyticsId: number): Promise<boolean>;
markActivity(activity: AnalyticsActivity, analyticsId: number): Promise<void>;
getYesterdayOutOfSyncIncidents(): Promise<number>;

@@ -19,0 +24,0 @@ incrementOutOfSyncIncidents(): Promise<void>;

@@ -17,2 +17,62 @@ "use strict";

}
unmarkActivityForToday(activity, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey()}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey()}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey()}`, analyticsId, 0);
yield pipeline.exec();
});
}
unmarkActivitiesForToday(activities, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
for (const activity of activities) {
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey()}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey()}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey()}`, analyticsId, 0);
}
yield pipeline.exec();
});
}
unmarkActivityForYesterday(activity, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey(this.getYesterdayDate())}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey(this.getYesterdayDate())}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey(this.getYesterdayDate())}`, analyticsId, 0);
yield pipeline.exec();
});
}
unmarkActivitiesForYesterday(activities, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
for (const activity of activities) {
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey(this.getYesterdayDate())}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey(this.getYesterdayDate())}`, analyticsId, 0);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey(this.getYesterdayDate())}`, analyticsId, 0);
}
yield pipeline.exec();
});
}
markActivityForToday(activity, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey()}`, analyticsId, 1);
yield pipeline.exec();
});
}
markActivitiesForToday(activities, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
for (const activity of activities) {
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey()}`, analyticsId, 1);
}
yield pipeline.exec();
});
}
calculateActivityTotalCountForYesterday(activity) {

@@ -74,11 +134,2 @@ return __awaiter(this, void 0, void 0, function* () {

}
markActivity(activity, analyticsId) {
return __awaiter(this, void 0, void 0, function* () {
const pipeline = this.redisClient.pipeline();
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getMonthlyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getWeeklyKey()}`, analyticsId, 1);
pipeline.setbit(`bitmap:action:${activity}:timespan:${this.getDailyKey()}`, analyticsId, 1);
yield pipeline.exec();
});
}
getYesterdayOutOfSyncIncidents() {

@@ -143,4 +194,4 @@ return __awaiter(this, void 0, void 0, function* () {

}
getMonthlyKey() {
const date = new Date();
getMonthlyKey(date) {
date = date !== null && date !== void 0 ? date : new Date();
return `${this.getYear(date)}-${this.getMonth(date)}`;

@@ -147,0 +198,0 @@ }

@@ -90,6 +90,6 @@ "use strict";

}));
it('should set analytics activity', () => __awaiter(void 0, void 0, void 0, function* () {
it('should mark analytics activity for today', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().markActivity(Domain_1.AnalyticsActivity.EditingItems, 123);
yield createStore().markActivityForToday(Domain_1.AnalyticsActivity.EditingItems, 123);
jest.useRealTimers();

@@ -102,2 +102,66 @@ expect(pipeline.setbit).toBeCalledTimes(3);

}));
it('should mark analytics activities for today', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().markActivitiesForToday([Domain_1.AnalyticsActivity.EditingItems, Domain_1.AnalyticsActivity.EmailUnbackedUpData], 123);
jest.useRealTimers();
expect(pipeline.setbit).toBeCalledTimes(6);
expect(pipeline.setbit).toHaveBeenNthCalledWith(1, 'bitmap:action:editing-items:timespan:2022-5', 123, 1);
expect(pipeline.setbit).toHaveBeenNthCalledWith(2, 'bitmap:action:editing-items:timespan:2022-week-21', 123, 1);
expect(pipeline.setbit).toHaveBeenNthCalledWith(3, 'bitmap:action:editing-items:timespan:2022-5-24', 123, 1);
expect(pipeline.setbit).toHaveBeenNthCalledWith(4, 'bitmap:action:email-unbacked-up-data:timespan:2022-5', 123, 1);
expect(pipeline.setbit).toHaveBeenNthCalledWith(5, 'bitmap:action:email-unbacked-up-data:timespan:2022-week-21', 123, 1);
expect(pipeline.setbit).toHaveBeenNthCalledWith(6, 'bitmap:action:email-unbacked-up-data:timespan:2022-5-24', 123, 1);
expect(pipeline.exec).toHaveBeenCalled();
}));
it('should unmark analytics activity for today', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().unmarkActivityForToday(Domain_1.AnalyticsActivity.EditingItems, 123);
jest.useRealTimers();
expect(pipeline.setbit).toBeCalledTimes(3);
expect(pipeline.setbit).toHaveBeenNthCalledWith(1, 'bitmap:action:editing-items:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(2, 'bitmap:action:editing-items:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(3, 'bitmap:action:editing-items:timespan:2022-5-24', 123, 0);
expect(pipeline.exec).toHaveBeenCalled();
}));
it('should unmark analytics activities for today', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().unmarkActivitiesForToday([Domain_1.AnalyticsActivity.EditingItems, Domain_1.AnalyticsActivity.EmailUnbackedUpData], 123);
jest.useRealTimers();
expect(pipeline.setbit).toBeCalledTimes(6);
expect(pipeline.setbit).toHaveBeenNthCalledWith(1, 'bitmap:action:editing-items:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(2, 'bitmap:action:editing-items:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(3, 'bitmap:action:editing-items:timespan:2022-5-24', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(4, 'bitmap:action:email-unbacked-up-data:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(5, 'bitmap:action:email-unbacked-up-data:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(6, 'bitmap:action:email-unbacked-up-data:timespan:2022-5-24', 123, 0);
expect(pipeline.exec).toHaveBeenCalled();
}));
it('should unmark analytics activity for yesterday', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().unmarkActivityForYesterday(Domain_1.AnalyticsActivity.EditingItems, 123);
jest.useRealTimers();
expect(pipeline.setbit).toBeCalledTimes(3);
expect(pipeline.setbit).toHaveBeenNthCalledWith(1, 'bitmap:action:editing-items:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(2, 'bitmap:action:editing-items:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(3, 'bitmap:action:editing-items:timespan:2022-5-23', 123, 0);
expect(pipeline.exec).toHaveBeenCalled();
}));
it('should unmark analytics activities for yesterday', () => __awaiter(void 0, void 0, void 0, function* () {
jest.useFakeTimers('modern');
jest.setSystemTime(1653395155000);
yield createStore().unmarkActivitiesForYesterday([Domain_1.AnalyticsActivity.EditingItems, Domain_1.AnalyticsActivity.EmailUnbackedUpData], 123);
jest.useRealTimers();
expect(pipeline.setbit).toBeCalledTimes(6);
expect(pipeline.setbit).toHaveBeenNthCalledWith(1, 'bitmap:action:editing-items:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(2, 'bitmap:action:editing-items:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(3, 'bitmap:action:editing-items:timespan:2022-5-23', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(4, 'bitmap:action:email-unbacked-up-data:timespan:2022-5', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(5, 'bitmap:action:email-unbacked-up-data:timespan:2022-week-21', 123, 0);
expect(pipeline.setbit).toHaveBeenNthCalledWith(6, 'bitmap:action:email-unbacked-up-data:timespan:2022-5-23', 123, 0);
expect(pipeline.exec).toHaveBeenCalled();
}));
it('should get yesterday out of sync incidents', () => __awaiter(void 0, void 0, void 0, function* () {

@@ -104,0 +168,0 @@ redisClient.get = jest.fn().mockReturnValue(1);

4

package.json
{
"name": "@standardnotes/analytics",
"version": "1.4.1",
"version": "1.5.0",
"engines": {

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

},
"gitHead": "f7cc42b1b141fa52826613e1ad84de7082270354"
"gitHead": "c6682f600bbc40cff3af130dfde5085e2c8aef22"
}
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