Skip to content

Commit

Permalink
feat: 4 new analytics modules
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Jun 29, 2019
1 parent 2890d9c commit 9cd8657
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/helpers/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions server/models/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions server/modules/analytics/matomo/code.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 26 additions & 0 deletions server/modules/analytics/matomo/definition.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions server/modules/analytics/newrelic/code.yml

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions server/modules/analytics/newrelic/definition.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 12 additions & 0 deletions server/modules/analytics/statcounter/code.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 18 additions & 0 deletions server/modules/analytics/statcounter/definition.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 16 additions & 0 deletions server/modules/analytics/yandex/code.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 13 additions & 0 deletions server/modules/analytics/yandex/definition.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9cd8657

Please sign in to comment.