Skip to content

Commit

Permalink
handle export button being clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
constantology committed Sep 13, 2017
1 parent 1eea87b commit 41b3045
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/js/republishing.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { init as initDownloadModal } from './modal-download';
import {
ATTR_TRACKABLE,
CSS_SELECTOR_REPUBLISHING_HEADER_LINK,
CSS_SELECTOR_TRACKABLE,
TRACKING
} from './config';

Expand Down Expand Up @@ -51,29 +52,30 @@ function track (flags, user) {
contractID: user.contract_id
});

addEventListener('click', (evt) => {
if (evt.target.matches(CSS_SELECTOR_REPUBLISHING_HEADER_LINK)) {
broadcast('oTracking.event', {
category: TRACKING.CATEGORY,
action: evt.target.getAttribute(ATTR_TRACKABLE),
app: TRACKING.DATA.context.app,
appVersion: user.app.version,
contractID: user.contract_id
});
document.addEventListener('submit', (evt) => broadcastClick(evt, user), true);
addEventListener('click', (evt) => broadcastClick(evt, user), true);
}

function broadcastClick (evt, user) {
let publish = false;
if (evt.target.matches(CSS_SELECTOR_REPUBLISHING_HEADER_LINK)) {
publish = true;
}
else if (location.pathname.includes('/save') || location.pathname.includes('/download')) {
if (evt.target.matches(CSS_SELECTOR_TRACKABLE)) {
publish = true;
}
}, true);
}

// tracking.init({
// server: TRACKING.URI
// });
//
// tracking.page({
// app: `${TRACKING.DATA.context.app}.simple`,
// appVersion: user.app.version,
// contractID: user.contract_id
// }, () => {});
//
// tracking.page(config, () => {});
if (publish === true) {
broadcast('oTracking.event', {
category: TRACKING.CATEGORY,
action: evt.target.getAttribute(ATTR_TRACKABLE),
app: TRACKING.DATA.context.app,
appVersion: user.app.version,
contractID: user.contract_id
});
}
}

export { init, track };

0 comments on commit 41b3045

Please sign in to comment.