Skip to content

Commit

Permalink
Merge pull request #1948 from Gauravjeetsingh/beta-9.2.1-fixes
Browse files Browse the repository at this point in the history
Update the Aptabase analytics
  • Loading branch information
Gauravjeetsingh committed May 21, 2024
2 parents 585a0ec + 111ac95 commit c966329
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
29 changes: 12 additions & 17 deletions analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@ require('dotenv').config();

class Analytics {
trackEvent({ category, action, label, value }) {
if (process.env.NODE_ENV !== 'development') {
// TODO: need to add variable that stops statistics collection
isOnline().then((online) => {
// TODO: for offline users, come up with a way of storing and send when online.
if (online) {
trackEvent(action, {
category,
label,
value,
});
}
});
} else {
console.log(
`Tracking Event suppressed for development ec: ${category}, ea: ${action}, el: ${label}, ev: ${value}`,
);
}
// TODO: need to add variable that stops statistics collection
isOnline().then((online) => {
// TODO: for offline users, come up with a way of storing and send when online.
if (online) {
console.log('action', action, 'options', { category, label, value });
trackEvent(action, {
category,
label,
value,
});
}
});
}
}

Expand Down
7 changes: 6 additions & 1 deletion www/main/addons/announcement/components/Annoucement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ const Announcement = ({ isGurmukhi }) => {
const HandleKeyboardToggle = () => {
setKeyboardOpenStatus(!keyboardOpenStatus);

analytics.trackEvent('display', 'announcement-slide', 'announcement-in-gurmukhi', isGurmukhi);
analytics.trackEvent({
category: 'display',
action: 'announcement-slide',
label: 'announcement-in-gurmukhi',
value: isGurmukhi,
});
};

const addMiscSlide = (givenText) => {
Expand Down
14 changes: 12 additions & 2 deletions www/main/addons/announcement/components/DhanGuru.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,20 @@ export const DhanGuru = ({ isGurmukhi }) => {
}
if (typeof e === 'object') {
addMiscSlide(e.target.value);
analytics.trackEvent('display', 'dhanguru-slide', e.target.value);
analytics.trackEvent({
category: 'display',
action: 'dhanguru-slide',
label: 'Dhan guru slide',
value: e.target.value,
});
} else {
addMiscSlide(e);
analytics.trackEvent('display', 'dhanguru-slide', e);
analytics.trackEvent({
category: 'display',
action: 'dhanguru-slide',
label: 'Dhan guru slide',
value: e,
});
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ const getBaniControllerItems = ({
code,
});
setMiscSlideText(syncString);
analytics.trackEvent('controller', 'codePresented', true);
analytics.trackEvent({
category: 'controller',
action: 'codePresented',
label: 'present code',
value: true,
});
analytics.trackEvent({
category: 'controller',
action: 'codePresented',
Expand Down
1 change: 0 additions & 1 deletion www/main/workspace-bar/components/WorkspaceBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const WorkspaceBar = () => {
if (currentWorkspace !== workspace) {
setCurrentWorkspace(workspace);
}
analytics.trackEvent('changed workspace', workspace);
analytics.trackEvent({
category: 'workspace',
action: 'changed',
Expand Down

0 comments on commit c966329

Please sign in to comment.