Browse Source

feat: 4 new analytics modules

pull/901/head
Nick 5 years ago
parent
commit
9cd8657ce6
10 changed files with 138 additions and 0 deletions
  1. 8
      server/helpers/error.js
  2. 5
      server/models/pages.js
  3. 17
      server/modules/analytics/matomo/code.yml
  4. 26
      server/modules/analytics/matomo/definition.yml
  5. 5
      server/modules/analytics/newrelic/code.yml
  6. 18
      server/modules/analytics/newrelic/definition.yml
  7. 12
      server/modules/analytics/statcounter/code.yml
  8. 18
      server/modules/analytics/statcounter/definition.yml
  9. 16
      server/modules/analytics/yandex/code.yml
  10. 13
      server/modules/analytics/yandex/definition.yml

8
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

5
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,

17
server/modules/analytics/matomo/code.yml

@ -0,0 +1,17 @@
head: |
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{{serverHost}}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{siteId}}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src='{{scriptUrl}}'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="{{serverHost}}/matomo.php?idsite=2&amp;rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->

26
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

5
server/modules/analytics/newrelic/code.yml
File diff suppressed because it is too large
View File

18
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

12
server/modules/analytics/statcounter/code.yml

@ -0,0 +1,12 @@
head: |
<!-- Statcounter Code -->
<script type="text/javascript">
var sc_project={{projectId}};
var sc_invisible=1;
var sc_security="{{securityToken}}";
var sc_https=1;
var sc_remove_link=1;
</script>
<script type="text/javascript" src="https://www.statcounter.com/counter/counter.js" async></script>
<noscript><div class="statcounter"><img class="statcounter" src="https://c.statcounter.com/{{projectId}}/0/{{securityToken}}/1/" alt="Web Analytics Made Easy - StatCounter"></div></noscript>
<!-- End of Statcounter Code -->

18
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

16
server/modules/analytics/yandex/code.yml

@ -0,0 +1,16 @@
head: |
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym({{tagNumber}}, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/{{tagNumber}}" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->

13
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
Loading…
Cancel
Save