From 9cd8657ce68e894290a06ff4c1abfebab71d6f5d Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 29 Jun 2019 16:45:27 -0400 Subject: [PATCH] feat: 4 new analytics modules --- server/helpers/error.js | 8 ++++++ server/models/pages.js | 5 ++++ server/modules/analytics/matomo/code.yml | 17 ++++++++++++ .../modules/analytics/matomo/definition.yml | 26 +++++++++++++++++++ server/modules/analytics/newrelic/code.yml | 5 ++++ .../modules/analytics/newrelic/definition.yml | 18 +++++++++++++ server/modules/analytics/statcounter/code.yml | 12 +++++++++ .../analytics/statcounter/definition.yml | 18 +++++++++++++ server/modules/analytics/yandex/code.yml | 16 ++++++++++++ .../modules/analytics/yandex/definition.yml | 13 ++++++++++ 10 files changed, 138 insertions(+) create mode 100644 server/modules/analytics/matomo/code.yml create mode 100644 server/modules/analytics/matomo/definition.yml create mode 100644 server/modules/analytics/newrelic/code.yml create mode 100644 server/modules/analytics/newrelic/definition.yml create mode 100644 server/modules/analytics/statcounter/code.yml create mode 100644 server/modules/analytics/statcounter/definition.yml create mode 100644 server/modules/analytics/yandex/code.yml create mode 100644 server/modules/analytics/yandex/definition.yml diff --git a/server/helpers/error.js b/server/helpers/error.js index 551207fd..a5918e0e 100644 --- a/server/helpers/error.js +++ b/server/helpers/error.js @@ -117,6 +117,14 @@ module.exports = { message: 'Mail template failed to load.', code: 3003 }), + PageGenericError: CustomError('PageGenericError', { + message: 'An unexpected error occured during a page operation.', + code: 6001 + }), + PageDuplicateCreate: CustomError('PageDuplicateCreate', { + message: 'Cannot create this page because an entry already exists at the same path.', + code: 6002 + }), SearchActivationFailed: CustomError('SearchActivationFailed', { message: 'Search Engine activation failed.', code: 4002 diff --git a/server/models/pages.js b/server/models/pages.js index f1ce213a..9411bbd0 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -177,6 +177,11 @@ module.exports = class Page extends Model { } static async createPage(opts) { + const dupCheck = await WIKI.models.pages.query().select('id').where('localeCode', opts.locale).where('path', opts.path).first() + if (dupCheck) { + throw new WIKI.Error.PageDuplicateCreate() + } + await WIKI.models.pages.query().insert({ authorId: opts.authorId, content: opts.content, diff --git a/server/modules/analytics/matomo/code.yml b/server/modules/analytics/matomo/code.yml new file mode 100644 index 00000000..10c753b1 --- /dev/null +++ b/server/modules/analytics/matomo/code.yml @@ -0,0 +1,17 @@ +head: | + + + + diff --git a/server/modules/analytics/matomo/definition.yml b/server/modules/analytics/matomo/definition.yml new file mode 100644 index 00000000..5d99ace1 --- /dev/null +++ b/server/modules/analytics/matomo/definition.yml @@ -0,0 +1,26 @@ +key: matomo +title: Matomo +description: Take back control with Matomo Analytics – a powerful web analytics platform that gives you and your business 100% data ownership and user privacy protection. +author: requarks.io +logo: https://static.requarks.io/logo/matomo.svg +website: https://matomo.org/ +isAvailable: true +props: + siteId: + type: String + title: Site ID + hint: The number index representing your site ID + default: 1 + order: 1 + serverHost: + type: String + title: Server Host + hint: Including https:// and optionally the port. Without trailing slash. (e.g. https://example.matomo.cloud) + default: https://example.matomo.cloud + order: 2 + scriptUrl: + type: String + title: Tracking Script URL + hint: The full URL of the Matomo tracking script. + default: //cdn.matomo.cloud/EXAMPLE.matomo.cloud/matomo.js + order: 3 diff --git a/server/modules/analytics/newrelic/code.yml b/server/modules/analytics/newrelic/code.yml new file mode 100644 index 00000000..366e4b19 --- /dev/null +++ b/server/modules/analytics/newrelic/code.yml @@ -0,0 +1,5 @@ +head: | + diff --git a/server/modules/analytics/newrelic/definition.yml b/server/modules/analytics/newrelic/definition.yml new file mode 100644 index 00000000..e8dd2d45 --- /dev/null +++ b/server/modules/analytics/newrelic/definition.yml @@ -0,0 +1,18 @@ +key: newrelic +title: New Relic Browser +description: New Relic Browser provides deep visibility and insight into how your users are interacting with your application or website. +author: requarks.io +logo: https://static.requarks.io/logo/newrelic.svg +website: https://newrelic.com/products/browser-monitoring +isAvailable: true +props: + licenseKey: + type: String + title: License Key + hint: Found at the very end of the code snippet provided by New Relic Browser + order: 1 + appId: + type: String + title: Application ID + hint: Found at the very end of the code snippet provided by New Relic Browser + order: 2 diff --git a/server/modules/analytics/statcounter/code.yml b/server/modules/analytics/statcounter/code.yml new file mode 100644 index 00000000..51bd6996 --- /dev/null +++ b/server/modules/analytics/statcounter/code.yml @@ -0,0 +1,12 @@ +head: | + + + + + diff --git a/server/modules/analytics/statcounter/definition.yml b/server/modules/analytics/statcounter/definition.yml new file mode 100644 index 00000000..9747f0c8 --- /dev/null +++ b/server/modules/analytics/statcounter/definition.yml @@ -0,0 +1,18 @@ +key: statcounter +title: StatCounter +description: See how Statcounter's easy-to-use features give you everything you need to understand your visitors and increase your website traffic. +author: requarks.io +logo: https://static.requarks.io/logo/statcountr.svg +website: https://statcounter.com/ +isAvailable: true +props: + projectId: + type: String + title: Project ID + hint: Unique Project ID, found in the code snippet provided by StatCounter + order: 1 + securityToken: + type: String + title: Security Token + hint: Security token, found in the code snippet provided by StatCounter + order: 2 diff --git a/server/modules/analytics/yandex/code.yml b/server/modules/analytics/yandex/code.yml new file mode 100644 index 00000000..9f6ae1fc --- /dev/null +++ b/server/modules/analytics/yandex/code.yml @@ -0,0 +1,16 @@ +head: | + + + + diff --git a/server/modules/analytics/yandex/definition.yml b/server/modules/analytics/yandex/definition.yml new file mode 100644 index 00000000..e0e26445 --- /dev/null +++ b/server/modules/analytics/yandex/definition.yml @@ -0,0 +1,13 @@ +key: yandex +title: Yandex Metrica +description: From traffic trends to mouse movements – get a comprehensive understanding of your online audience and drive business growth. +author: requarks.io +logo: https://static.requarks.io/logo/yandex.svg +website: https://metrica.yandex.com +isAvailable: true +props: + tagNumber: + type: String + title: Tag Number + hint: When creating the tag, select "CMS and website builders" and copy the provided Tag Number + order: 1