Compare commits

..

2 Commits

Author SHA1 Message Date
standardci 006f1fccec chore(release): publish new version
- @standardnotes/analytics@1.51.0
 - @standardnotes/api-gateway@1.36.13
 - @standardnotes/auth-server@1.52.0
 - @standardnotes/domain-events-infra@1.9.12
 - @standardnotes/domain-events@2.78.0
 - @standardnotes/event-store@1.6.7
 - @standardnotes/files-server@1.8.7
 - @standardnotes/scheduler-server@1.13.8
 - @standardnotes/syncing-server@1.10.24
 - @standardnotes/websockets-server@1.4.7
 - @standardnotes/workspace-server@1.17.7
2022-11-07 09:16:03 +00:00
Karol Sójko c0f5817d47 feat(analytics): add handling subscription expired events 2022-11-07 10:14:12 +01:00
28 changed files with 149 additions and 11 deletions
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.51.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@1.50.0...@standardnotes/analytics@1.51.0) (2022-11-07)
### Features
* **analytics:** add handling subscription expired events ([c0f5817](https://github.com/standardnotes/server/commit/c0f5817d4753410ee5d997c1b94e340b400cb5d9))
# [1.50.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@1.49.0...@standardnotes/analytics@1.50.0) (2022-11-07)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "1.50.0",
"version": "1.51.0",
"engines": {
"node": ">=14.0.0 <17.0.0"
},
@@ -41,6 +41,7 @@ import { SubscriptionCancelledEventHandler } from '../Domain/Handler/Subscriptio
import { SubscriptionRenewedEventHandler } from '../Domain/Handler/SubscriptionRenewedEventHandler'
import { SubscriptionRefundedEventHandler } from '../Domain/Handler/SubscriptionRefundedEventHandler'
import { SubscriptionPurchasedEventHandler } from '../Domain/Handler/SubscriptionPurchasedEventHandler'
import { SubscriptionExpiredEventHandler } from '../Domain/Handler/SubscriptionExpiredEventHandler'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const newrelicFormatter = require('@newrelic/winston-enricher')
@@ -141,6 +142,9 @@ export class ContainerConfigLoader {
container
.bind<SubscriptionPurchasedEventHandler>(TYPES.SubscriptionPurchasedEventHandler)
.to(SubscriptionPurchasedEventHandler)
container
.bind<SubscriptionExpiredEventHandler>(TYPES.SubscriptionExpiredEventHandler)
.to(SubscriptionExpiredEventHandler)
// Services
container.bind<DomainEventFactory>(TYPES.DomainEventFactory).to(DomainEventFactory)
@@ -26,6 +26,7 @@ const TYPES = {
SubscriptionRenewedEventHandler: Symbol.for('SubscriptionRenewedEventHandler'),
SubscriptionRefundedEventHandler: Symbol.for('SubscriptionRefundedEventHandler'),
SubscriptionPurchasedEventHandler: Symbol.for('SubscriptionPurchasedEventHandler'),
SubscriptionExpiredEventHandler: Symbol.for('SubscriptionExpiredEventHandler'),
// Services
DomainEventPublisher: Symbol.for('DomainEventPublisher'),
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
@@ -0,0 +1,47 @@
import 'reflect-metadata'
import { SubscriptionName } from '@standardnotes/common'
import { SubscriptionExpiredEvent } from '@standardnotes/domain-events'
import { SubscriptionExpiredEventHandler } from './SubscriptionExpiredEventHandler'
import { GetUserAnalyticsId } from '../UseCase/GetUserAnalyticsId/GetUserAnalyticsId'
import { StatisticsStoreInterface } from '../Statistics/StatisticsStoreInterface'
import { AnalyticsStoreInterface } from '../Analytics/AnalyticsStoreInterface'
describe('SubscriptionExpiredEventHandler', () => {
let event: SubscriptionExpiredEvent
let getUserAnalyticsId: GetUserAnalyticsId
let analyticsStore: AnalyticsStoreInterface
let statisticsStore: StatisticsStoreInterface
const createHandler = () => new SubscriptionExpiredEventHandler(getUserAnalyticsId, analyticsStore, statisticsStore)
beforeEach(() => {
event = {} as jest.Mocked<SubscriptionExpiredEvent>
event.createdAt = new Date(1)
event.payload = {
subscriptionId: 1,
userEmail: 'test@test.com',
subscriptionName: SubscriptionName.PlusPlan,
timestamp: 1,
offline: false,
totalActiveSubscriptionsCount: 123,
}
getUserAnalyticsId = {} as jest.Mocked<GetUserAnalyticsId>
getUserAnalyticsId.execute = jest.fn().mockReturnValue({ analyticsId: 3 })
analyticsStore = {} as jest.Mocked<AnalyticsStoreInterface>
analyticsStore.markActivity = jest.fn()
statisticsStore = {} as jest.Mocked<StatisticsStoreInterface>
statisticsStore.setMeasure = jest.fn()
})
it('should update analytics and statistics', async () => {
await createHandler().handle(event)
expect(analyticsStore.markActivity).toHaveBeenCalled()
expect(statisticsStore.setMeasure).toHaveBeenCalled()
})
})
@@ -0,0 +1,34 @@
import { DomainEventHandlerInterface, SubscriptionExpiredEvent } from '@standardnotes/domain-events'
import { inject, injectable } from 'inversify'
import TYPES from '../../Bootstrap/Types'
import { AnalyticsActivity } from '../Analytics/AnalyticsActivity'
import { AnalyticsStoreInterface } from '../Analytics/AnalyticsStoreInterface'
import { StatisticsMeasure } from '../Statistics/StatisticsMeasure'
import { StatisticsStoreInterface } from '../Statistics/StatisticsStoreInterface'
import { Period } from '../Time/Period'
import { GetUserAnalyticsId } from '../UseCase/GetUserAnalyticsId/GetUserAnalyticsId'
@injectable()
export class SubscriptionExpiredEventHandler implements DomainEventHandlerInterface {
constructor(
@inject(TYPES.GetUserAnalyticsId) private getUserAnalyticsId: GetUserAnalyticsId,
@inject(TYPES.AnalyticsStore) private analyticsStore: AnalyticsStoreInterface,
@inject(TYPES.StatisticsStore) private statisticsStore: StatisticsStoreInterface,
) {}
async handle(event: SubscriptionExpiredEvent): Promise<void> {
const { analyticsId } = await this.getUserAnalyticsId.execute({ userEmail: event.payload.userEmail })
await this.analyticsStore.markActivity(
[AnalyticsActivity.SubscriptionExpired, AnalyticsActivity.ExistingCustomersChurn],
analyticsId,
[Period.Today, Period.ThisWeek, Period.ThisMonth],
)
await this.statisticsStore.setMeasure(
StatisticsMeasure.TotalCustomers,
event.payload.totalActiveSubscriptionsCount,
[Period.Today, Period.ThisWeek, Period.ThisMonth, Period.ThisYear],
)
}
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.36.13](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.36.12...@standardnotes/api-gateway@1.36.13) (2022-11-07)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.36.12](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.36.11...@standardnotes/api-gateway@1.36.12) (2022-11-07)
**Note:** Version bump only for package @standardnotes/api-gateway
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.36.12",
"version": "1.36.13",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.52.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.51.0...@standardnotes/auth-server@1.52.0) (2022-11-07)
### Features
* **analytics:** add handling subscription expired events ([c0f5817](https://github.com/standardnotes/server/commit/c0f5817d4753410ee5d997c1b94e340b400cb5d9))
# [1.51.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.50.0...@standardnotes/auth-server@1.51.0) (2022-11-07)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.51.0",
"version": "1.52.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -79,6 +79,7 @@ describe('SubscriptionExpiredEventHandler', () => {
subscriptionName: SubscriptionName.PlusPlan,
timestamp,
offline: false,
totalActiveSubscriptionsCount: 123,
}
getUserAnalyticsId = {} as jest.Mocked<GetUserAnalyticsId>
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.9.12](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.11...@standardnotes/domain-events-infra@1.9.12) (2022-11-07)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.9.11](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.9.10...@standardnotes/domain-events-infra@1.9.11) (2022-11-07)
**Note:** Version bump only for package @standardnotes/domain-events-infra
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.9.11",
"version": "1.9.12",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.78.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.77.0...@standardnotes/domain-events@2.78.0) (2022-11-07)
### Features
* **analytics:** add handling subscription expired events ([c0f5817](https://github.com/standardnotes/server/commit/c0f5817d4753410ee5d997c1b94e340b400cb5d9))
# [2.77.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.76.0...@standardnotes/domain-events@2.77.0) (2022-11-07)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.77.0",
"version": "2.78.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -6,4 +6,5 @@ export interface SubscriptionExpiredEventPayload {
subscriptionName: SubscriptionName
timestamp: number
offline: boolean
totalActiveSubscriptionsCount: number
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.6.7](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.6...@standardnotes/event-store@1.6.7) (2022-11-07)
**Note:** Version bump only for package @standardnotes/event-store
## [1.6.6](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.6.5...@standardnotes/event-store@1.6.6) (2022-11-07)
**Note:** Version bump only for package @standardnotes/event-store
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.6.6",
"version": "1.6.7",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.8.7](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.8.6...@standardnotes/files-server@1.8.7) (2022-11-07)
**Note:** Version bump only for package @standardnotes/files-server
## [1.8.6](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.8.5...@standardnotes/files-server@1.8.6) (2022-11-07)
**Note:** Version bump only for package @standardnotes/files-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.8.6",
"version": "1.8.7",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.13.8](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.13.7...@standardnotes/scheduler-server@1.13.8) (2022-11-07)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.13.7](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.13.6...@standardnotes/scheduler-server@1.13.7) (2022-11-07)
**Note:** Version bump only for package @standardnotes/scheduler-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.13.7",
"version": "1.13.8",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.10.24](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.10.23...@standardnotes/syncing-server@1.10.24) (2022-11-07)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.10.23](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.10.22...@standardnotes/syncing-server@1.10.23) (2022-11-07)
**Note:** Version bump only for package @standardnotes/syncing-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.10.23",
"version": "1.10.24",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.7](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.4.6...@standardnotes/websockets-server@1.4.7) (2022-11-07)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.4.6](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.4.5...@standardnotes/websockets-server@1.4.6) (2022-11-07)
**Note:** Version bump only for package @standardnotes/websockets-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.4.6",
"version": "1.4.7",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.17.7](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.17.6...@standardnotes/workspace-server@1.17.7) (2022-11-07)
**Note:** Version bump only for package @standardnotes/workspace-server
## [1.17.6](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.17.5...@standardnotes/workspace-server@1.17.6) (2022-11-07)
**Note:** Version bump only for package @standardnotes/workspace-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/workspace-server",
"version": "1.17.6",
"version": "1.17.7",
"engines": {
"node": ">=16.0.0 <17.0.0"
},