Commit Graph

41 Commits

Author SHA1 Message Date
Kevin Ansfield
5e40a03336 Published new versions
- @tryghost/custom-theme-settings-service@0.0.5
 - @tryghost/email-analytics-provider-mailgun@1.0.2
 - @tryghost/email-analytics-service@1.0.2
2021-09-28 15:51:13 +01:00
Kevin Ansfield
bc31453dde Added .updateSettings() to custom theme settings service
refs https://github.com/TryGhost/Team/issues/1070

- receives settings array as provided by through Ghost's API
- errors if a provided setting key does not already exist in the database (settings are only created when syncing with a theme)
- errors if a provided select setting value does not match the theme-provided options
- providing there were no errors, updates each value in the database if it's changed along with the internal cache of full setting objects and the public key/value cache
- returns the same list of settings as `.listSettings()` for API consistency
2021-09-28 15:50:46 +01:00
Kevin Ansfield
2bb5a9cb6e Fixed cache.populate() leaving behind old settings
refs https://github.com/TryGhost/Team/issues/1070

- if the cache is repopulated, keys that already existed in the cache but that don't exist in the new group of settings were left in the cache
- added a `.clear()` method that removes all items from the cache and call it when populating so the cache only contains what it was last populated with
  - deletes properties on the internal content object so that references aren't lost
2021-09-28 15:50:46 +01:00
Renovate Bot
372e89f8ce Update dependency mocha to v9.1.2 2021-09-28 08:59:37 +00:00
Kevin Ansfield
d3e8033b1f Published new versions
- @tryghost/custom-theme-settings-service@0.0.4
2021-09-23 23:42:04 +01:00
Kevin Ansfield
6c526bfee2 Fixed missing await in async method
refs https://github.com/TryGhost/Team/issues/1070

- missing await was resulting in setting caches not being populated
2021-09-23 23:41:44 +01:00
Kevin Ansfield
1733041c8f Published new versions
- @tryghost/custom-theme-settings-service@0.0.3
2021-09-23 20:35:36 +01:00
Kevin Ansfield
e28415abf4 Added CustomThemeSettingsService.listSettings()
refs https://github.com/TryGhost/Team/issues/1070

- return re-fetched settings after sync so they can be used in later activation steps
- added internal `activeThemeSettings` cache that stores full setting data along with saved values for use in API output
- added `listSettings()` that converts internal cache object into a settings array that matches API format
2021-09-23 20:34:35 +01:00
Kevin Ansfield
e98b9d764d Published new versions
- @tryghost/custom-theme-settings-service@0.0.2
2021-09-23 09:17:25 +01:00
Kevin Ansfield
c4f364996b Removed model dependency in custom theme settings cache
refs https://github.com/TryGhost/Team/issues/1070

- having a dependency on a model in the cache service meant that Ghost had to know about that and pre-initialize the cache during boot, even though that didn't actually do anything except create a cache instance
- by making the cache a simple key/value store able to be populated from the cache settings service when a theme is activated it means that Ghost doesn't need to perform any extra initialization when the cache is initialized via `require`
2021-09-23 09:16:59 +01:00
Kevin Ansfield
0f5ccb7131 Published new versions
- @tryghost/custom-theme-settings-service@0.0.1
 - @tryghost/email-analytics-provider-mailgun@1.0.1
 - @tryghost/email-analytics-service@1.0.1
2021-09-22 22:00:51 +01:00
Kevin Ansfield
cf9cee0208 First pass at custom-theme-settings-service functionality
refs https://github.com/TryGhost/Team/issues/1070

- added `bread` util that acts as a wrapper for the provided model, if we have any business functionality needed when settings are added/removed then it will go here
- added primary "server" service that handles syncing of custom theme data extracted from a theme with the settings that are in the database and exported as "Service". Syncing rules on theme activation:
    - if a new setting is seen, create it with the default value
    - if a setting has it's type changed, remove it and create a new setting with the default value
    - if a select setting's value is not a valid option, reset it to the default value
- added shared "frontend/server" service that exposes an in-memory cache of key/value pairs for the currently active theme
2021-09-22 21:56:45 +01:00
Kevin Ansfield
56012f5f21 slimer new custom-theme-settings-service 2021-09-21 17:21:52 +01:00
Renovate Bot
e80bb79139 Update dependency mocha to v9.1.1 2021-08-31 08:26:23 +00:00
Renovate Bot
7bdd78c0de Update dependency mocha to v9.1.0 2021-08-23 04:54:43 +00:00
Renovate Bot
d13bd19e93 Update dependency sinon to v11.1.2 2021-07-28 15:01:32 +00:00
Renovate Bot
55cfcb0b1c Update dependency mocha to v9.0.3 2021-07-27 03:57:19 +00:00
Renovate Bot
055eede197 Update Test & linting packages 2021-07-06 04:34:39 +00:00
Renovate Bot
ec977273e3 Update dependency mocha to v9 2021-06-23 11:53:59 +00:00
Renovate Bot
e9accde2dd Update dependency sinon to v11 2021-05-27 19:34:33 +00:00
Renovate Bot
1e8e9b9beb Update Test & linting packages 2021-05-11 02:08:58 +00:00
Renovate Bot
33d44e089c Update dependency sinon to v10 2021-03-23 21:47:42 +00:00
Renovate Bot
de19b1487e Update Test & linting packages 2021-03-15 03:56:46 +00:00
Kevin Ansfield
7ae5ac5c0e Published new versions
- @tryghost/email-analytics-provider-mailgun@1.0.0
 - @tryghost/email-analytics-service@1.0.0
2021-03-10 16:52:09 +00:00
Renovate Bot
125ffd3d12 Update Test & linting packages 2021-03-09 03:58:42 +00:00
Renovate Bot
3ad49f0852 Update dependency nock to v13.0.10 2021-03-04 00:16:49 +00:00
Renovate Bot
f2c584697b Update Test & linting packages 2021-03-02 01:44:56 +00:00
Renovate Bot
6e56cbcae9 Pin dependencies 2021-03-02 00:04:24 +00:00
Kevin Ansfield
52efb86667 Published new versions
- @tryghost/email-analytics-provider-mailgun@1.0.0-rc.1
 - @tryghost/email-analytics-service@1.0.0-rc.1
2021-03-01 21:36:35 +00:00
Kevin Ansfield
af7aff5352 Added email analytics service tests
no issue

- fixed destructuring error when  creating instances of `EmailAnalyticsService` or `EventProcessor` with no options object
- fixed unprocessable complained event incrementing complained count rather than unprocessable count
- fixed `fetchAll()` and `fetchLatest()` returning `undefined` instead of a blank EventProcessingResult
2021-03-01 21:31:07 +00:00
Kevin Ansfield
0145c925a0 Added email analytics mailgun provider tests 2021-02-25 20:04:17 +00:00
Kevin Ansfield
88c648636c Initial update of email analytics packages to work as external modules
refs https://github.com/TryGhost/Ghost/pull/12541

- make `EventProcessor` a super-class designed to be inherited from in consumer applications for application-level implementation
  - helps to keep application-level concerns for event handling (eg, what to do with spam complaints) and things like application database knowledge in the consumer
- removed all database knowledge from `EmailAnalyticsService`
  - requires a `queries` option to be passed in that lets the consuming application provide knowledge and define how fetched stats should be aggregated
2021-02-24 21:23:56 +00:00
Kevin Ansfield
2b1dc351d2 Added members.email_open_rate aggregation to email analytics (#12458)
refs https://github.com/TryGhost/Ghost/issues/12421
requires https://github.com/TryGhost/Ghost/pull/12457

- updates stats aggregator to calculate and store an open rate for each member
  - uses two queries because I couldn't find a reasonable approach to perform the update in a single query as per the email aggregation
  - benchmarked locally at <1sec/1000members
  - will not store an open rate unless the number of tracked emails sent to a member is above a certain threshold (defaults to 5) to avoid new members being heavily weighted
- fixes typo in EmailAnalytics that was stopping member stats from being aggregated
2021-02-24 21:03:29 +00:00
Kevin Ansfield
723218ee34 Added guard for page.items existing in Mailgun response
no issue

- it's possible to get Mailgun responses where the `items` array doesn't exist so we need to guard against that so we don't error
2021-02-24 21:03:29 +00:00
Kevin Ansfield
bef65aa8a2 Fixed email count check in email-analytics service
no issue

- raw knex `.count()` does not return a straight number, we need to handle an array of rowDataPacket objects
2021-02-24 21:03:29 +00:00
Kevin Ansfield
2b747e6b53 Fixed misleading emailAnalytics.fetchLatest debug statement 2021-02-24 21:03:29 +00:00
Kevin Ansfield
a84ec49854 Added no-emails guard check when fetching latest email events
no issue

- replicates the same guard used in `fetchLatest()` to prevent contacting Mailgun when there are no emails in the database
2021-02-24 21:03:29 +00:00
Kevin Ansfield
837334b536 Fixed linting 2021-02-24 21:03:29 +00:00
Kevin Ansfield
7bbf644d0d Added email analytics service (#12393)
no issue

- added `EmailAnalyticsService`
  - `.fetchAll()` grabs and processes all available events
  - `.fetchLatest()` grabs and processes all events since the last seen event timestamp
  - `EventProcessor` passed event objects and updates `email_recipients` or `members` records depending on the event being analytics or list hygiene
    - always returns a `EventProcessingResult` instance so that progress can be tracked and merged across individual events, batches (pages of events), and total runs
    - adds email_id and member_id to the returned result where appropriate so that the stats aggregator can limit processing to data that has changed
    - sets `email_recipients.{delivered_at, opened_at, failed_at}` for analytics events
    - sets `members.subscribed = false` for permanent failure/unsubscribed/complained list hygiene events
  - `StatsAggregator` takes an `EventProcessingResult`-like object containing arrays of email ids and member ids on which to aggregate statistics.
  - jobs for `fetch-latest` and `fetch-all` ready for use with the JobsService
- added `initialiseRecurringJobs()` function to Ghost bootup procedure that schedules the email analytics "fetch latest" job to run every minute
2021-02-24 21:03:29 +00:00
Kevin Ansfield
788676845d Added empty email analytics packages 2021-02-24 21:03:29 +00:00
Kevin Ansfield
2d12ab60ae Initial commit 2020-11-25 15:13:40 +00:00