Skip to content

Commit

Permalink
#17 Add advanced configuration options for tracking RC to multiple Pi…
Browse files Browse the repository at this point in the history
…wik Instances.
  • Loading branch information
ruKurz committed Jun 24, 2017
1 parent 69b7803 commit 337a08e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rocketchat-analytics/client/loadScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Template.body.onRendered(() => {
const piwikPrependDomain = piwikUrl && RocketChat.settings.get('PiwikAnalytics_prependDomain');
const piwikCookieDomain = piwikUrl && RocketChat.settings.get('PiwikAnalytics_cookieDomain');
const piwikDomains = piwikUrl && RocketChat.settings.get('PiwikAnalytics_domains');
const piwikAdditionalTracker = piwikUrl && RocketChat.settings.get('PiwikAdditionalTrackers');
const googleId = RocketChat.settings.get('GoogleAnalytics_enabled') && RocketChat.settings.get('GoogleAnalytics_ID');
if (piwikSiteId || googleId) {
c.stop();
Expand Down Expand Up @@ -37,6 +38,11 @@ Template.body.onRendered(() => {
window._paq.push(['setDomains', domains]);
}
(() => {
const addTrackers = JSON.parse(piwikAdditionalTracker);
for (let i = 0; i < addTrackers.length; i++) {
const tracker = addTrackers[i];
window._paq.push(['addTracker', `${ tracker['trackerURL'] }piwik.php`, tracker['siteId']]);
}
window._paq.push(['setTrackerUrl', `${ piwikUrl }piwik.php`]);
window._paq.push(['setSiteId', Number.parseInt(piwikSiteId)]);
const d = document;
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-analytics/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ RocketChat.settings.addGroup('Analytics', function addSettings() {
i18nLabel: 'Client_ID',
enableQuery
});
this.add('PiwikAdditionalTrackers', '', {
type: 'string',
multiline: true,
public: true,
i18nLabel: 'PiwikAdditionalTrackers',
enableQuery
});
this.add('PiwikAnalytics_prependDomain', false, {
type: 'boolean',
public: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,8 @@
"Pinned_a_message": "hat eine Nachricht angeheftet:",
"Pinned_Messages": "Fixierte Nachrichten",
"PiwikAnalytics_siteId_Description": "Die Website-ID zur Identifizierung dieser Website. Beispiel: 17",
"PiwikAdditionalTrackers" : "Zusätzliche Piwik Websites",
"PiwikAdditionalTrackers_Description" : "Geben Sie hier weitere Piwik Website URLs und SiteIDs in folgendem Format an, wenn Sie dieselben Daten in verschiedene Piwik Instanzen tracken möchten: [ { \"trackerURL\" : \"https://my.piwik.domain2/\", \"siteId\" : 42 }, { \"trackerURL\" : \"https://my.piwik.domain3/\", \"siteId\" : 15 } ]",
"PiwikAnalytics_prependDomain" : "Domain voranstellen",
"PiwikAnalytics_prependDomain_Description" : "Domain der Seite beim Tracken dem Seitentitel voranstellen",
"PiwikAnalytics_cookieDomain" : "Alle Subdomains",
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,8 @@
"Pinned_a_message": "Pinned a message:",
"Pinned_Messages": "Pinned Messages",
"PiwikAnalytics_siteId_Description": "The site id to use for identifying this site. Example: 17",
"PiwikAdditionalTrackers" : "Additional piwik sites",
"PiwikAdditionalTrackers_Description" : "Enter addtitional Piwik website URLs and SiteIDs in the following format, if you wnat to track the same data into different websites: [ { \"trackerURL\" : \"https://my.piwik.domain2/\", \"siteId\" : 42 }, { \"trackerURL\" : \"https://my.piwik.domain3/\", \"siteId\" : 15 } ]",
"PiwikAnalytics_prependDomain" : "Prepend domain",
"PiwikAnalytics_prependDomain_Description" : "Prepend the site domain to the page title when tracking",
"PiwikAnalytics_cookieDomain" : "All subdomains",
Expand Down

0 comments on commit 337a08e

Please sign in to comment.