Skip to content

Commit

Permalink
Merge pull request #563 from NASA-IMPACT/enhance/ga
Browse files Browse the repository at this point in the history
Enhance collected metrics (atdb edits, template download)
  • Loading branch information
wrynearson authored Oct 17, 2023
2 parents 21880c1 + 5d65d48 commit 51c7e6b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { confirmDeleteDocumentVersion } from '../common/confirmation-prompt';
import toasts from '../common/toasts';
import ReactGA from 'react-ga4';

/**
* Convenience method to delete an atbd version and show a toast notification.
Expand All @@ -24,6 +25,7 @@ export async function documentDeleteVersionConfirmAndToast({
if (result.error) {
toasts.error(`An error occurred: ${result.error.message}`);
} else {
ReactGA.event('atbd_version_deleted');
toasts.success('Document version successfully deleted');
history.push('/dashboard');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback } from 'react';
import { useHistory } from 'react-router';
import ReactGA from 'react-ga4';

import { useAtbds } from '../../../context/atbds-list';
import { documentEdit } from '../../../utils/url-creator';
Expand Down Expand Up @@ -33,6 +34,10 @@ export function useDocumentCreate(title, alias, isPdfType) {
processToast.error(`An error occurred: ${result.error.message}`);
}
} else {
ReactGA.event('atbd_created', {
type: isPdfType ? 'pdf' : 'regular'
});

processToast.success('Document successfully created');
// To trigger the modals to open from other pages, we use the history
// state as the user is sent from one page to another. See explanation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback } from 'react';
import { useHistory } from 'react-router';
import ReactGA from 'react-ga4';

import { documentEdit } from '../../../utils/url-creator';
import { createProcessToast } from '../../common/toasts';
Expand All @@ -22,6 +23,7 @@ export function useSubmitForMetaAndVersionData(updateAtbd, atbd, step) {
if (result.error) {
processToast.error(`An error occurred: ${result.error.message}`);
} else {
ReactGA.event('atbd_updated');
resetForm({ values });
processToast.success('Changes saved');
// Update the path in case the alias changed.
Expand Down Expand Up @@ -81,6 +83,7 @@ export function useSubmitForVersionData(updateAtbd, atbd, hook) {
if (result.error) {
processToast.error(`An error occurred: ${result.error.message}`);
} else {
ReactGA.event('atbd_updated');
formBag.resetForm({ values });
processToast.success('Changes saved');

Expand Down Expand Up @@ -300,6 +303,7 @@ export function useSubmitForAtbdContacts({
`An error occurred: ${result.error.message}. Please try again`
);
} else {
ReactGA.event('atbd_updated');
resetForm({
values: {
...values,
Expand Down
18 changes: 17 additions & 1 deletion app/assets/scripts/components/new-atbd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import styled from 'styled-components';
import { themeVal, glsp } from '@devseed-ui/theme-provider';
import { Button } from '@devseed-ui/button';
import ReactGA from 'react-ga4';

import {
FaFileAlt,
Expand Down Expand Up @@ -232,6 +233,11 @@ function NewAtbd() {
href='https://docs.google.com/document/d/1T4q56qZrRN5L6MGXA1UJLMgDgS-Fde9Fo4R4bwVQDF8/edit?usp=sharing'
target='_blank'
rel='noopener noreferrer'
onClick={() => {
ReactGA.event('atbd_template_download', {
template_format: 'Google Docs'
});
}}
>
<span>
<FaFileAlt />
Expand All @@ -242,6 +248,11 @@ function NewAtbd() {
href='https://docs.google.com/document/d/1Jh3htOiivNIG_ZqhbN5nEK1TAVB6BjRY/edit?usp=share_link&ouid=102031143611308171378&rtpof=true&sd=true'
target='_blank'
rel='noopener noreferrer'
onClick={() => {
ReactGA.event('atbd_template_download', {
template_format: 'Microsoft Word'
});
}}
>
<span>
<FaFileWord />
Expand All @@ -251,7 +262,12 @@ function NewAtbd() {
<TemplateLink
href='https://drive.google.com/file/d/1AusZOxIpkBiA0QJAB3AtSXSBUU5tWwlJ/view?usp=share_link'
target='_blank'
rel='noopener'
rel='noopener noreferrer'
onClick={() => {
ReactGA.event('atbd_template_download', {
template_format: 'Latex'
});
}}
>
<span>
<SiLatex />
Expand Down

0 comments on commit 51c7e6b

Please sign in to comment.