From 2b54a909a808337b4b42b6613c091a9993bb5736 Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 16 Oct 2023 17:52:34 +0100 Subject: [PATCH 1/2] Track template download --- .../scripts/components/new-atbd/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/assets/scripts/components/new-atbd/index.js b/app/assets/scripts/components/new-atbd/index.js index 513c4cbd..12a801ac 100644 --- a/app/assets/scripts/components/new-atbd/index.js +++ b/app/assets/scripts/components/new-atbd/index.js @@ -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, @@ -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' + }); + }} > @@ -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' + }); + }} > @@ -251,7 +262,12 @@ function NewAtbd() { { + ReactGA.event('atbd_template_download', { + template_format: 'Latex' + }); + }} > From 5d65d48292df610a842170e2b62e16506dc9dc58 Mon Sep 17 00:00:00 2001 From: Vitor George Date: Mon, 16 Oct 2023 18:08:32 +0100 Subject: [PATCH 2/2] Track ATBD edits --- .../scripts/components/documents/document-delete-process.js | 2 ++ .../components/documents/single-edit/use-document-create.js | 5 +++++ .../scripts/components/documents/single-edit/use-submit.js | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/app/assets/scripts/components/documents/document-delete-process.js b/app/assets/scripts/components/documents/document-delete-process.js index 7b54b78e..ab2ab2e1 100644 --- a/app/assets/scripts/components/documents/document-delete-process.js +++ b/app/assets/scripts/components/documents/document-delete-process.js @@ -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. @@ -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'); } diff --git a/app/assets/scripts/components/documents/single-edit/use-document-create.js b/app/assets/scripts/components/documents/single-edit/use-document-create.js index 75378407..437f656c 100644 --- a/app/assets/scripts/components/documents/single-edit/use-document-create.js +++ b/app/assets/scripts/components/documents/single-edit/use-document-create.js @@ -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'; @@ -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 diff --git a/app/assets/scripts/components/documents/single-edit/use-submit.js b/app/assets/scripts/components/documents/single-edit/use-submit.js index ccc3ed36..757de42d 100644 --- a/app/assets/scripts/components/documents/single-edit/use-submit.js +++ b/app/assets/scripts/components/documents/single-edit/use-submit.js @@ -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'; @@ -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. @@ -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'); @@ -300,6 +303,7 @@ export function useSubmitForAtbdContacts({ `An error occurred: ${result.error.message}. Please try again` ); } else { + ReactGA.event('atbd_updated'); resetForm({ values: { ...values,