Skip to content

Commit c18855d

Browse files
authored
HP-1696 add faro customized event (#1595)
* add faro customized event * fix import * fix study name * better error handling
1 parent fc33ca8 commit c18855d

File tree

6 files changed

+62
-23
lines changed

6 files changed

+62
-23
lines changed

package-lock.json

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"@fortawesome/react-fontawesome": "^0.2.0",
1616
"@gen3/guppy": "^0.18.1",
1717
"@gen3/ui-component": "^0.11.4",
18+
"@grafana/faro-core": "^1.9.1",
1819
"@grafana/faro-react": "^1.9.0",
1920
"@mantine/core": "^6.0.21",
2021
"@reactour/tour": "^2.12.0",

src/Discovery/DiscoveryActionBar/utils/checkDownloadStatus.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { datadogRum } from '@datadog/browser-rum';
3+
import { faro } from '@grafana/faro-core';
34
import {
45
JOB_POLLING_INTERVAL, DOWNLOAD_FAIL_STATUS, DOWNLOAD_SUCCEEDED_MESSAGE,
56
} from '../DiscoveryActionBarConstants';
@@ -66,19 +67,28 @@ const checkDownloadStatus = (
6667
});
6768
setTimeout(() => window.open(output), 2000);
6869
const projectNumber = selectedResources.map(
69-
(study) => study.project_number,
70+
(study) => study.project_number || [],
7071
);
7172
const studyName = selectedResources.map(
72-
(study) => study.study_name,
73+
(study) => study.study_metadata?.minimal_info?.study_name || [],
7374
);
7475
const repositoryName = selectedResources.map(
75-
(study) => study.commons,
76+
(study) => study.commons || [],
7677
);
7778
datadogRum.addAction('datasetDownload', {
7879
datasetDownloadProjectNumber: projectNumber,
7980
datasetDownloadStudyName: studyName,
8081
datasetDownloadRepositoryName: repositoryName,
8182
});
83+
faro.api.pushEvent(
84+
'datasetDownload',
85+
// Faro only accept string-string pairs in payload
86+
{
87+
datasetDownloadProjectNumber: projectNumber.join(','),
88+
datasetDownloadStudyName: studyName.join(','),
89+
datasetDownloadRepositoryName: repositoryName.join(','),
90+
},
91+
);
8292
} catch {
8393
// job output is not a url -> then it is an error message
8494
setDownloadStatus({

src/Discovery/DiscoveryActionBar/utils/handleDownloadManifestClick.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { datadogRum } from '@datadog/browser-rum';
2+
import { faro } from '@grafana/faro-core';
23
import FileSaver from 'file-saver';
34
import { DiscoveryConfig } from '../../DiscoveryConfig';
45
import assembleFileManifest from './assembleFileManifest';
@@ -20,14 +21,23 @@ const handleDownloadManifestClick = (
2021
}
2122
// combine manifests from all selected studies
2223
const manifest = assembleFileManifest(manifestFieldName, selectedResources);
23-
const projectNumber = selectedResources.map((study) => study.project_number);
24-
const studyName = selectedResources.map((study) => study.study_name);
25-
const repositoryName = selectedResources.map((study) => study.commons);
24+
const projectNumber = selectedResources.map((study) => study.project_number || []);
25+
const studyName = selectedResources.map((study) => study.study_metadata?.minimal_info?.study_name || []);
26+
const repositoryName = selectedResources.map((study) => study.commons || []);
2627
datadogRum.addAction('manifestDownload', {
2728
manifestDownloadProjectNumber: projectNumber,
2829
manifestDownloadStudyName: studyName,
2930
manifestDownloadRepositoryName: repositoryName,
3031
});
32+
faro.api.pushEvent(
33+
'manifestDownload',
34+
// Faro only accept string-string pairs in payload
35+
{
36+
manifestDownloadProjectNumber: projectNumber.join(','),
37+
manifestDownloadStudyName: studyName.join(','),
38+
manifestDownloadRepositoryName: repositoryName.join(','),
39+
},
40+
);
3141
// download the manifest
3242
const MANIFEST_FILENAME = 'manifest.json';
3343
const blob = new Blob([JSON.stringify(manifest, null, 2)], {

src/Discovery/DiscoveryActionBar/utils/handleExportToWorkspaceClick/handleExportToWorkspaceClick.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { datadogRum } from '@datadog/browser-rum';
2+
import { faro } from '@grafana/faro-core';
23
import { manifestServiceApiPath, hostname } from '../../../../localconf';
34
import { DiscoveryConfig } from '../../../DiscoveryConfig';
45
import { fetchWithCreds } from '../../../../actions';
@@ -66,14 +67,23 @@ const handleExportToWorkspaceClick = async (
6667
}
6768
});
6869

69-
const projectNumber = selectedResources.map((study) => study.project_number);
70-
const studyName = selectedResources.map((study) => study.study_name);
71-
const repositoryName = selectedResources.map((study) => study.commons);
70+
const projectNumber = selectedResources.map((study) => study.project_number || []);
71+
const studyName = selectedResources.map((study) => study.study_metadata?.minimal_info?.study_name || []);
72+
const repositoryName = selectedResources.map((study) => study.commons || []);
7273
datadogRum.addAction('exportToWorkspace', {
7374
exportToWorkspaceProjectNumber: projectNumber,
7475
exportToWorkspaceStudyName: studyName,
7576
exportToWorkspaceRepositoryName: repositoryName,
7677
});
78+
faro.api.pushEvent(
79+
'exportToWorkspace',
80+
// Faro only accept string-string pairs in payload
81+
{
82+
exportToWorkspaceProjectNumber: projectNumber.join(','),
83+
exportToWorkspaceStudyName: studyName.join(','),
84+
exportToWorkspaceRepositoryName: repositoryName.join(','),
85+
},
86+
);
7787

7888
// post exported manifest to manifestservice
7989
if (manifest.length) {

src/Workspace/index.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Menu, Dropdown, Button as Btn, Tooltip, Space,
88
} from 'antd';
99
import { datadogRum } from '@datadog/browser-rum';
10+
import { faro } from '@grafana/faro-core';
1011

1112
import {
1213
DownOutlined, UserOutlined, QuestionCircleOutlined, LoadingOutlined, ExclamationCircleOutlined,
@@ -320,6 +321,12 @@ class Workspace extends React.Component {
320321
datadogRum.addAction('workspaceLaunch', {
321322
workspaceName: workspace.name,
322323
});
324+
faro.api.pushEvent(
325+
'workspaceLaunch',
326+
{
327+
workspaceName: workspace.name,
328+
},
329+
);
323330
this.checkWorkspaceStatus();
324331
break;
325332
default:

0 commit comments

Comments
 (0)