Skip to content

Commit

Permalink
add option to track user id (fix #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
sualko committed Oct 28, 2018
1 parent 6e348e4 commit f971a91
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js/track.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var _paq = _paq || [];
_paq.push(['setCustomVariable', '1', 'App', app, 'page']);
}

if (OC && OC.currentUser) {
if (OC && OC.currentUser && options.trackUser) {
// set user id
_paq.push(['setUserId', OC.currentUser]);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Controller/JavaScriptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function tracking()
'url' => $this->config->getAppValue('url'),
'siteId' => $this->config->getAppValue('siteId'),
'trackDir' => $this->config->getBooleanAppValue('trackDir'),
'trackUser' => $this->config->getBooleanAppValue('trackUser'),
];

$script = "var cloudPiwikOptions = '".json_encode($options)."';";
Expand Down
2 changes: 1 addition & 1 deletion lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function index()

public function update($key)
{
if (!in_array($key, ['url', 'siteId', 'trackDir'])) {
if (!in_array($key, ['url', 'siteId', 'trackDir', 'trackUser'])) {
return [
'result' => 'error',
'message' => 'Tried to update not allowed param.',
Expand Down
1 change: 1 addition & 0 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function getForm()
'url' => $this->config->getAppValue('piwik', 'url'),
'siteId' => $this->config->getAppValue('piwik', 'siteId'),
'trackDir' => $this->config->getAppValue('piwik', 'trackDir'),
'trackUser' => $this->config->getAppValue('piwik', 'trackUser'),
];

return new TemplateResponse('piwik', 'settings/admin', $parameters);
Expand Down
8 changes: 7 additions & 1 deletion templates/settings/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
<tr>
<td colspan="2">
<input type="checkbox" name="trackDir" id="piwikTrackDir" class="checkbox" <?php if ($_['trackDir']): ?> checked="checked"<?php endif; ?> />
<label for="piwikTrackDir">Track file browsing </label>
<label for="piwikTrackDir">Track file browsing</label>
</td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="trackUser" id="piwikTrackUser" class="checkbox" <?php if ($_['trackUser']): ?> checked="checked"<?php endif; ?> />
<label for="piwikTrackUser">Track user id</label>
</td>
</tr>
</table>
Expand Down

0 comments on commit f971a91

Please sign in to comment.