Skip to content
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
5 changes: 5 additions & 0 deletions control/content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<!-- Import WYSIWYG -->
<script src="../../../../scripts/tinymce/tinymce.min.js"></script>

<script src="../../widget/js/analyticsKey.js"></script>

<!-- build:bundleCSSFiles -->
<!-- Sortable list css -->
<link rel="stylesheet" href="css/sortableList.css" />
Expand Down Expand Up @@ -291,6 +293,9 @@ <h1 class="section__title">Metrics</h1>
<script src="js/authManager.js"></script>
<script src="../settings/js/classes/settings.js"></script>
<script src="js/breadcrumb.js"></script>
<script>
Analytics.init();
</script>

<script src="app.js"></script>
<!-- endbuild -->
Expand Down
40 changes: 29 additions & 11 deletions control/content/js/classes/analytics.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
class Analytics {
constructor() {}
// Register plugin events for analytics
static registerEvent(title, key, description, silentNotification = true) {
buildfire.analytics.registerEvent(
{
title: title,
key: key,
description: description,
},
{ silentNotification }
);
}
static registerEvent = (event, options, callback) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version of lint that is used in this project is failing because it is not supporting arrow functions, please update the lint or use standard functions
you can see the error when running npm run build command

Error message:
\js\classes\analytics.js
4:24 error Parsing error: Unexpected token =

if (event.title && event.key) {
let _options = options.silentNotification || true;
buildfire.analytics.registerEvent(event, _options, (err, res) => {
if (err) return callback(err, null);
{
return callback(null, res)
};
});
}
};

static unregisterEvent(id) {
buildfire.analytics.unregisterEvent(`METRIC_${id}_HISTORY_UPDATE`);
}
}

static init = () => {
AnalyticsKey.eventType.forEach((e) => {
Analytics.registerEvent(
{
title: e.title,
key: e.key,
description: e.description,
},
{ silentNotification: false },
(err, res) => {
if (err) console.error(err);
else return res;
}
);
});
}
};
2 changes: 2 additions & 0 deletions widget/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ const checkIncreaseOrDecrease = (metrics) => {

percentage = percentage.toPrecision(3);

(percentage === "100") ? Analytics.trackAction(AnalyticsKey.eventType[1].key) : false;

summaryPreviousValueContainer.innerHTML = `
<i
class="material-icons mdc-button__icon ${situationClass} trending-icon">${situation}</i >
Expand Down
2 changes: 2 additions & 0 deletions widget/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
type="text/javascript"
></script>

<script src="js/analyticsKey.js"></script>

<!-- Material Icons -->
<link
href="https://fonts.googleapis.com/icon?family=Material+Icons"
Expand Down
14 changes: 14 additions & 0 deletions widget/js/analyticsKey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const AnalyticsKey = {
eventType: [
{
key: "Matrics_Viewed",
title: "Matrics Viewed",
description: "Occurs when a user view matrics",
},
{
key: "Matrics_Completed",
title: "Matrics Completed",
description: "Occurs when a user completed a matrics",
}
],
};
3 changes: 3 additions & 0 deletions widget/js/lib/listView.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class ListViewItem {
});
// local
else img.src = this.icon;
let data_title = this.title || "Metric"
img.setAttribute("alt",data_title);

ui.create("i", imgContainer, null, ["listViewItemIcon"]);
}
Expand Down Expand Up @@ -200,6 +202,7 @@ class ListViewItem {
]);

listViewItemToolbar.onclick = (e) => {
Analytics.trackAction(AnalyticsKey.eventType[0].key);
t.onToolbarClicked("btnBadge", t, e);
e.preventDefault();
e.stopPropagation();
Expand Down