Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions js/tracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/* global utag */

window.addEventListener('load', function() {
if (typeof utag === 'undefined' || !utag.view()) return
// Plus button in a breadcrumb
const plusBtnContainer = document.querySelector('.files-controls .actions.creatable')
plusBtnContainer?.addEventListener('click', function(event) {
const menuOption = event.target.closest('[data-action]')
if (menuOption) {
utag.view({
wt_link_id: `plus.button.${menuOption.attributes['data-action'].value}`,
page_content_id: 'files.breadcrumb',
page_type: 'files',
})
}
})

// Table head listener
const theadContainer = document.querySelector('#app-content-files table.files-filestable thead')
theadContainer?.addEventListener('mousedown', function(event) {
if (event.target.closest('.column-selection')) {
utag.view({
wt_link_id: 'checkbox.select-all',
page_content_id: 'files.tablehead',
page_type: 'files',
})
return
}
const menuOption = event.target.closest('[data-action]')
if (menuOption) {
utag.view({
wt_link_id: `button.${menuOption.attributes['data-action'].value}`,
page_content_id: 'files.tablehead',
page_type: 'files',
})
}
})

// Table body listener
const registerTableBodyEvent = function(event) {
if (event.target.closest('.action.action-share')) {
utag.view({
wt_link_id: 'button.shared',
page_content_id: 'files.tablebody',
page_type: 'files',
})
} else if (event.target.closest('td.selection')) {
utag.view({
wt_link_id: 'checkbox.select-file',
page_content_id: 'files.tablebody',
page_type: 'files',
})
} else if (event.target.closest('.fileActionsMenu.popovermenu')) {
const menuItem = event.target.closest('[data-action]')
menuItem && utag.view({
wt_link_id: `button.${menuItem.attributes['data-action'].value}`,
page_content_id: 'files.tablebody.more',
page_type: 'files',
})
}
}

const tbodyContainer = document.querySelector('#app-content-files table.files-filestable tbody')
tbodyContainer?.addEventListener('mousedown', (event) => registerTableBodyEvent(event))

// Files navigation container
const navContainer = document.querySelector('#app-navigation-vue')
navContainer?.addEventListener('mousedown', function(event) {
const navigation = event.target.closest('[data-cy-files-navigation-item]')
if (navigation) {
utag.view({
wt_link_id: `link.${navigation.attributes['data-cy-files-navigation-item'].value}`,
page_content_id: 'files.sidebarnav',
page_type: 'files',
})
}
})

// Photos navigation container
const navMediaContainer = document.querySelector('#app-navigation-vue')
navMediaContainer?.addEventListener('mousedown', function(event) {
const navigation = event.target.closest('[data-id-app-nav-item]')
if (navigation) {
utag.view({
wt_link_id: `link.${navigation.attributes['data-id-app-nav-item'].value}`,
page_content_id: 'photos.sidebarnav',
page_type: 'photos',
})
}
})

// Toggle grid/list view button listener
const toggleView = document.querySelector('#view-toggle')
toggleView?.addEventListener('click', function() {
utag.view({
wt_link_id: 'button.toggleview',
page_content_id: 'files.list',
page_type: 'files',
})
})

// Header - navigation
const headerLeft = document.querySelector('#header .header-left')
headerLeft?.addEventListener('mousedown', function(event) {
const navigation = event.target.closest('[data-app-id]')
if (navigation) {
utag.view({
wt_link_id: `link.${navigation.attributes['data-app-id'].value}`,
page_content_id: 'header.left',
page_type: 'header',
})
}
})

// Header - options
const headerRight = document.querySelector('#header .header-right')
headerRight?.addEventListener('mousedown', function(event) {
const navigation = event.target.closest('[id]')
if (navigation) {
utag.view({
wt_link_id: `link.${navigation.attributes.id.value}`,
page_content_id: 'header.right',
page_type: 'header',
})
}
})
})
1 change: 1 addition & 0 deletions lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ public function handle(Event $event): void {

// add marketing tracking magic
\OCP\Util::addScript("nmc_marketing", "consent");
\OCP\Util::addScript("nmc_marketing", "tracking");
}
}
Loading