Skip to content

Commit 154f7aa

Browse files
authored
Merge pull request #1838 from 4dn-dcic/ga4_updates_2
GA4 Ecommerce + Minor UI Updates
2 parents fac097b + 502b187 commit 154f7aa

File tree

9 files changed

+6530
-1922
lines changed

9 files changed

+6530
-1922
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ fourfront
66
Change Log
77
----------
88

9+
6.2.2
10+
=====
11+
12+
`GA4 e-commerce + UI updates <https://github.com/4dn-dcic/fourfront/pull/1838>`_
13+
14+
* metadata.tsv and server side downloads events replaced
15+
* tooltip added when Select All button get disabled in browse and file view
16+
17+
918
6.2.1
1019
=====
1120

package-lock.json

Lines changed: 6483 additions & 1900 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"dependencies": {
108108
"@fortawesome/fontawesome-free": "^5.15.4",
109109
"@hms-dbmi-bgm/react-workflow-viz": "0.1.7",
110-
"@hms-dbmi-bgm/shared-portal-components": "git+https:github.com/4dn-dcic/shared-portal-components#0.1.68",
110+
"@hms-dbmi-bgm/shared-portal-components": "git+https:github.com/4dn-dcic/shared-portal-components#0.1.70",
111111
"auth0-lock": "^11.33.1",
112112
"d3": "^7.5.0",
113113
"date-fns": "^2.28.0",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tool.poetry]
22
# Note: Various modules refer to this system as "encoded", not "fourfront".
33
name = "encoded"
4-
version = "6.2.1"
4+
version = "6.2.2"
55
description = "4DN-DCIC Fourfront"
66
authors = ["4DN-DCIC Team <[email protected]>"]
77
license = "MIT"

src/encoded/static/components/browse/components/above-table-controls/SelectedFilesControls.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { uniqueFileCount, SelectedFilesController } from './../SelectedFilesCont
1919
// eslint-disable-next-line no-unused-vars
2020
const { Item } = typedefs;
2121

22-
22+
const SELECT_ALL_LIMIT = 8000;
2323

2424
export class SelectAllFilesButton extends React.PureComponent {
2525

@@ -64,7 +64,7 @@ export class SelectAllFilesButton extends React.PureComponent {
6464
isEnabled(){
6565
const { totalFilesCount } = this.props;
6666
if (!totalFilesCount) return true;
67-
if (totalFilesCount > 8000) return false;
67+
if (totalFilesCount > SELECT_ALL_LIMIT) return false;
6868
return true;
6969
}
7070

@@ -140,12 +140,13 @@ export class SelectAllFilesButton extends React.PureComponent {
140140
"mr-05 icon icon-fw icon-" + (selecting ? 'circle-notch icon-spin fas' : (isAllSelected ? 'square far' : 'check-square far'))
141141
);
142142
const cls = "btn " + (isAllSelected ? "btn-outline-primary" : "btn-primary");
143+
const tooltip = (!isAllSelected && !isEnabled) ? `"Select All" is disabled since the total file count exceeds the upper limit: ${SELECT_ALL_LIMIT}` : null;
143144

144145
return (
145146
<div className="pull-left box selection-buttons">
146147
<div className="btn-group">
147148
<button type="button" id="select-all-files-button" disabled={selecting || (!isAllSelected && !isEnabled)}
148-
className={cls} onClick={this.handleSelectAll}>
149+
className={cls} onClick={this.handleSelectAll} data-tip={tooltip}>
149150
<i className={iconClassName}/>
150151
<span className="d-none d-md-inline text-400">{ isAllSelected ? 'Deselect' : 'Select' } </span>
151152
<span className="text-600">All</span>

src/encoded/static/components/browse/components/above-table-controls/SelectedFilesDownloadButton.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ const SelectedFilesDownloadStartButton = React.memo(function SelectedFilesDownlo
319319
});
320320

321321
/**
322-
* We're going to consider download of metadata.tsv file to be akin to adding something to shopping cart.
322+
* We're going to consider download of metadata.tsv file to be akin to one step before the purchasing.
323323
* Something they might download later...
324324
*/
325325
function onClick(evt){
@@ -333,12 +333,13 @@ const SelectedFilesDownloadStartButton = React.memo(function SelectedFilesDownlo
333333
};
334334
const products = analytics.transformItemsToProducts(fileList, extData);
335335
analytics.event(
336-
"purchase",
336+
"add_payment_info",
337337
"SelectedFilesDownloadModal",
338338
"Download metadata.tsv Button Pressed",
339339
function() { console.info(`Will download metadata.tsv having ${productsLength} items in the cart.`); },
340340
{
341341
items: Array.isArray(products) ? products : null,
342+
payment_type: "Metadata.tsv Download",
342343
list_name: extData.item_list_name,
343344
value: filenameAccessions.size || 0,
344345
filters: analytics.getStringifiedCurrentFilters((context && context.filters) || null)

src/encoded/static/components/static-pages/components/StatisticsPageViewBody.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ const aggregationsToChartData = {
458458
if (!resp || !resp['@graph']) return null;
459459
const { countBy : { file_downloads : countBy } } = props;
460460

461-
let useReport = 'file_downloads_by_experiment_type';
462-
let groupingKey = "ga:dimension5"; // Experiment Type
461+
let useReport = 'file_downloads_by_filetype';
462+
let groupingKey = "ga:productVariant"; // File Type
463463
const countKey = 'ga:metric2'; // Download Count
464464

465-
if (countBy === 'filetype'){
466-
useReport = 'file_downloads_by_filetype';
467-
groupingKey = 'ga:productVariant'; // File Type
465+
if (countBy === 'experiment_type'){
466+
useReport = 'file_downloads_by_experiment_type';
467+
groupingKey = 'ga:dimension5'; // Experiment Type
468468
} else if (countBy === 'geo_country'){
469469
useReport = 'file_downloads_by_country';
470470
groupingKey = 'ga:country';
@@ -573,7 +573,7 @@ export class UsageStatsViewController extends React.PureComponent {
573573

574574
Object.keys(usageAggsToChartData).forEach(function(k){
575575
if (k === 'file_downloads'){
576-
countBy[k] = 'experiment_type'; // For file_downloads, countBy is treated as 'groupBy'.
576+
countBy[k] = 'filetype'; // For file_downloads, countBy is treated as 'groupBy'.
577577
// Not high enough priority to spend much time improving this file, albeit much straightforward room for it exists.
578578
} else {
579579
countBy[k] = 'views';

src/encoded/static/components/util/file.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import { File } from './typedefs';
1414
/**
1515
* Generate analytics "add product to cart" event.
1616
* We don't create an actual "download file" event here
17-
* because this is done server-side.
17+
* because this is done server-side. (instead we use add_payment_info that
18+
* is the final step just before the purchase in GA4.)
1819
*
1920
* `context` and `fileItem` are likely to be same unless is
2021
* detailpane on another page showing file info.
@@ -26,12 +27,13 @@ export function downloadFileButtonClick(fileItem, context = null){
2627
const parameters = {
2728
items: Array.isArray(products) ? products : null,
2829
value: !isNaN(fileItem.file_size) ? fileItem.file_size : 0,
29-
filters: getStringifiedCurrentFilters((context && context.filters) || null)
30+
filters: getStringifiedCurrentFilters((context && context.filters) || null),
31+
payment_type: 'File Download'
3032
};
31-
// add_to_cart-begin_checkout-purchase conversions
33+
// add_to_cart-begin_checkout-add_payment_info conversions
3234
event("add_to_cart", "FileDownloadButton", "Click", null, parameters, false);
3335
event("begin_checkout", "FileDownloadButton", "Select", null, parameters, false);
34-
event("purchase", "FileDownloadButton", "Download", null, parameters, false);
36+
event("add_payment_info", "FileDownloadButton", "Download", null, parameters, false);
3537
}, 0);
3638
}
3739

src/encoded/types/file.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,16 +1477,16 @@ def update_google_analytics(context, request, ga_config, filename, file_size_dow
14771477
if ga_tid is None:
14781478
raise Exception("No valid tracker id found in ga_config.json > hostnameTrackerIDMapping")
14791479

1480-
file_extension = file_extension = os.path.splitext(filename)[1][1:]
1480+
file_extension = os.path.splitext(filename)[1][1:]
1481+
item_types = [ty for ty in reversed(context.jsonld_type()[:-1])]
14811482

14821483
ga_payload = {
14831484
"client_id": ga_cid,
14841485
"timestamp_micros": str(int(datetime.datetime.now().timestamp() * 1000000)),
14851486
"non_personalized_ads": False,
1486-
# "user_agent": request.user_agent,
14871487
"events": [
14881488
{
1489-
"name": "file_download",
1489+
"name": "purchase",
14901490
"params": {
14911491
"name": filename,
14921492
"source": "Serverside File Download",
@@ -1499,12 +1499,24 @@ def update_google_analytics(context, request, ga_config, filename, file_size_dow
14991499
"experiment_type": file_experiment_type or None,
15001500
"lab": lab.get("display_title"),
15011501
# Product Category from @type, e.g. "File/FileProcessed"
1502-
"file_classification": "/".join([ty for ty in reversed(context.jsonld_type()[:-1])]),
1503-
"file_type": file_type
1502+
"file_classification": "/".join(item_types),
1503+
"file_type": file_type,
1504+
"items": [
1505+
{
1506+
"item_id": file_at_id,
1507+
"item_name": filename,
1508+
"item_category": item_types[0] if len(item_types) >= 1 else "Unknown",
1509+
"item_category2": item_types[1] if len(item_types) >= 2 else "Unknown",
1510+
"item_brand": lab.get("display_title"),
1511+
"item_variant": file_type,
1512+
"quantity": 1
1513+
}
1514+
]
15041515
}
15051516
}
15061517
]
15071518
}
1519+
# import pdb;pdb.set_trace()
15081520

15091521
if user_uuid:
15101522
ga_payload['events'][0]['params']['user_uuid'] = user_uuid

0 commit comments

Comments
 (0)