Skip to content

Commit c02decc

Browse files
Added GA/GTM for matrix functionality. Resolves #1139. (#1150)
1 parent c64f0b0 commit c02decc

22 files changed

+316
-53
lines changed

spa/src/app/files/hca-get-data/hca-get-manifest/hca-get-manifest.component.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { FileTypeSummary } from "../../file-summary/file-type-summary";
2626
import { HCAGetManifestState } from "./hca-get-manifest.state";
2727
import { SearchTerm } from "../../search/search-term.model";
2828
import { FileManifestService } from "../../shared/file-manifest.service";
29-
import { GTMService } from "../../../shared/gtm/gtm.service";
3029
import { ManifestResponse } from "../../shared/manifest-response.model";
3130
import { ManifestStatus } from "../../shared/manifest-status.model";
3231

@@ -47,12 +46,10 @@ export class HCAGetManifestComponent implements OnDestroy, OnInit {
4746
/**
4847
* @param {ConfigService} configService
4948
* @param {FileManifestService} fileManifestService
50-
* @param {GTMService} gtmService
5149
* @param {Store<AppState>} store
5250
*/
5351
constructor(
5452
private configService: ConfigService,
55-
private gtmService: GTMService,
5653
private fileManifestService: FileManifestService,
5754
private store: Store<AppState>) {
5855

@@ -127,7 +124,7 @@ export class HCAGetManifestComponent implements OnDestroy, OnInit {
127124
/**
128125
* Track click on manifest data link.
129126
*
130-
* @param {SearchTerms[]} selectedSearchTerms
127+
* @param {SearchTerm[]} selectedSearchTerms
131128
* @param {string} manifestUrl
132129
*/
133130
public onDataLinkClicked(selectedSearchTerms: SearchTerm[], manifestUrl: string) {
@@ -138,7 +135,7 @@ export class HCAGetManifestComponent implements OnDestroy, OnInit {
138135
/**
139136
* Track click on copy of manifest data link.
140137
*
141-
* @param {SearchTerms[]} selectedSearchTerms
138+
* @param {SearchTerm[]} selectedSearchTerms
142139
* @param {string} manifestUrl
143140
*/
144141
public onDataLinkCopied(selectedSearchTerms: SearchTerm[], manifestUrl: string) {
@@ -148,6 +145,8 @@ export class HCAGetManifestComponent implements OnDestroy, OnInit {
148145

149146
/**
150147
* Dispatch action to generate manifest summary URL. Also track export action with GA.
148+
*
149+
* @param {SearchTerm[]} selectedSearchTerms
151150
*/
152151
public onRequestManifest(selectedSearchTerms: SearchTerm[]) {
153152

spa/src/app/files/hca-get-data/hca-get-matrix/hca-get-matrix.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<matrix-url-request-form [fileFormats]="getFileFormats(state.matrixFileFormats)"
66
[matrixPartialQueryMatch]="state.matrixPartialQueryMatch"
77
[matrixPartialQueryMatchCompleted]="state.matrixPartialQueryMatchCompleted"
8-
(matrixUrlRequested)="onMatrixUrlRequested($event)"></matrix-url-request-form>
8+
(matrixUrlRequested)="onMatrixUrlRequested(state.selectedSearchTerms, $event)"></matrix-url-request-form>
99
</ng-container>
1010
<!-- Matrix manifest in progress/in progress -->
1111
<ng-container
@@ -31,7 +31,9 @@ <h4 class="fontsize-m semi-bold">Your expression matrix is ready.</h4>
3131
</ng-container>
3232
</ng-container>
3333
<ng-container *ngFor="let matrixUrlRequest of state.matrixUrlRequests">
34-
<matrix-url-request-completed [matrixUrlRequest]="matrixUrlRequest">
34+
<matrix-url-request-completed [matrixUrlRequest]="matrixUrlRequest"
35+
(matrixDownloadUrlClicked)="onMatrixDownloadUrlClicked(state.selectedSearchTerms, $event)"
36+
(matrixDownloadUrlCopiedToClipboard)="onMatrixDownloadUrlCopiedToClipboard(state.selectedSearchTerms, $event)">
3537
<p class="fontsize-m semi-bold" *ngIf="isDisplayMultipleMatrixUrlRequests(state.matrixUrlRequests)">{{matrixUrlRequest.species}}</p>
3638
</matrix-url-request-completed>
3739
</ng-container>

spa/src/app/files/hca-get-data/hca-get-matrix/hca-get-matrix.component.spec.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,27 @@ import { of } from "rxjs";
1919

2020
// App components
2121
import { ConfigService } from "../../../config/config.service";
22+
import { DisplayDataLinkComponent } from "../display-data-link/display-data-link.component";
23+
import { HCAGetDataPanelComponent } from "../hca-get-data-panel/hca-get-data-panel.component";
24+
import { HCAGetMatrixComponent } from "./hca-get-matrix.component";
25+
import { MatrixPartialQueryMatchWarningComponent } from "../matrix-partial-query-match-warning/matrix-partial-query-match-warning.component";
26+
import { MatrixUrlRequestCompletedComponent } from "../matrix-url-request-completed/matrix-url-request-completed.component";
27+
import { MatrixUrlRequestFormComponent } from "../matrix-url-request-form/matrix-url-request-form.component";
28+
import { CancelFetchMatrixUrlRequestAction } from "../../_ngrx/matrix/cancel-fetch-matrix-url-request.action";
29+
import { ClearMatrixPartialQueryMatchAction } from "../../_ngrx/matrix/clear-matrix-partial-query-match.action";
30+
import { FetchMatrixUrlRequestAction } from "../../_ngrx/matrix/fetch-matrix-url-request.action";
2231
import { CopyToClipboardComponent } from "../../../shared/copy-to-clipboard/copy-to-clipboard.component";
23-
import { WarningComponent } from "../../../shared/warning/warning.component";
24-
import { WarningContentComponent } from "../../../shared/warning/warning-content.component";
25-
import { WarningTitleComponent } from "../../../shared/warning/warning-title.component";
26-
import { FileManifestService } from "../../shared/file-manifest.service";
2732
import { DEFAULT_FILE_SUMMARY } from "../../shared/file-summary.mock";
33+
import { FileManifestService } from "../../shared/file-manifest.service";
2834
import { GenusSpecies } from "../../shared/genus-species.model";
35+
import { GTMService } from "../../../shared/gtm/gtm.service";
2936
import { MatrixService } from "../../shared/matrix.service";
3037
import { MatrixFormat } from "../../shared/matrix-format.model";
3138
import { MatrixUrlRequestStatus } from "../../shared/matrix-url-request-status.model";
32-
import { CancelFetchMatrixUrlRequestAction } from "../../_ngrx/matrix/cancel-fetch-matrix-url-request.action";
33-
import { ClearMatrixPartialQueryMatchAction } from "../../_ngrx/matrix/clear-matrix-partial-query-match.action";
34-
import { FetchMatrixUrlRequestAction } from "../../_ngrx/matrix/fetch-matrix-url-request.action";
35-
import { DisplayDataLinkComponent } from "../display-data-link/display-data-link.component";
36-
import { HCAGetDataPanelComponent } from "../hca-get-data-panel/hca-get-data-panel.component";
37-
import { MatrixPartialQueryMatchWarningComponent } from "../matrix-partial-query-match-warning/matrix-partial-query-match-warning.component";
38-
import { MatrixUrlRequestCompletedComponent } from "../matrix-url-request-completed/matrix-url-request-completed.component";
39-
import { MatrixUrlRequestFormComponent } from "../matrix-url-request-form/matrix-url-request-form.component";
40-
import { HCAGetMatrixComponent } from "./hca-get-matrix.component";
39+
import { SearchTermService } from "../../shared/search-term.service";
40+
import { WarningComponent } from "../../../shared/warning/warning.component";
41+
import { WarningContentComponent } from "../../../shared/warning/warning-content.component";
42+
import { WarningTitleComponent } from "../../../shared/warning/warning-title.component";
4143

4244
describe("HCAGetMatrixComponent", () => {
4345

@@ -203,6 +205,17 @@ describe("HCAGetMatrixComponent", () => {
203205
useValue: jasmine.createSpyObj("FileManifestService", [
204206
"requestMatrixFileManifestUrl"
205207
])
208+
}, {
209+
provide: GTMService,
210+
useValue: jasmine.createSpyObj("GTMService", [
211+
"trackEvent"
212+
])
213+
}, {
214+
provide: SearchTermService,
215+
useValue: jasmine.createSpyObj("SearchTermService", [
216+
"bindSearchTerms",
217+
"marshallSearchTerms"
218+
])
206219
}, {
207220
provide: Store,
208221
useValue: testStore
@@ -333,7 +346,7 @@ describe("HCAGetMatrixComponent", () => {
333346
it("dispatches action to store, to fetch matrix URL request, when matrix URL is requested", () => {
334347

335348
// Confirm store dispatch is called
336-
component.onMatrixUrlRequested(MatrixFormat.loom);
349+
component.onMatrixUrlRequested([], MatrixFormat.loom);
337350
const fetchMatrixUrlRequestAction = new FetchMatrixUrlRequestAction(MatrixFormat.loom, component["ngDestroy$"]);
338351
expect(testStore.dispatch).toHaveBeenCalledWith(fetchMatrixUrlRequestAction);
339352
});

spa/src/app/files/hca-get-data/hca-get-matrix/hca-get-matrix.component.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ import {
2424
selectMatrixUrlRequestsBySpecies
2525
} from "../../_ngrx/matrix/matrix.selectors";
2626
import { selectSelectedSearchTerms } from "../../_ngrx/search/search.selectors";
27+
import { FetchMatrixPartialQueryMatchRequestAction } from "../../_ngrx/matrix/fetch-matrix-partial-query-match-request.action";
28+
import { ClearMatrixPartialQueryMatchAction } from "../../_ngrx/matrix/clear-matrix-partial-query-match.action";
29+
import { SearchTerm } from "../../search/search-term.model";
2730
import { MatrixFormat } from "../../shared/matrix-format.model";
2831
import { MatrixUrlRequest } from "../../shared/matrix-url-request.model";
2932
import { MatrixService } from "../../shared/matrix.service";
30-
import { FetchMatrixPartialQueryMatchRequestAction } from "../../_ngrx/matrix/fetch-matrix-partial-query-match-request.action";
31-
import { ClearMatrixPartialQueryMatchAction } from "../../_ngrx/matrix/clear-matrix-partial-query-match.action";
3233
import { MatrixUrlRequestStatus } from "../../shared/matrix-url-request-status.model";
3334

3435
@Component({
@@ -132,15 +133,39 @@ export class HCAGetMatrixComponent implements OnDestroy, OnInit {
132133
}
133134

134135
/**
135-
* Request matrix.
136+
* Request matrix, and also track request.
136137
*
138+
* @param {SearchTerm[]} selectedSearchTerms
137139
* @param {MatrixFormat} fileFormat
138140
*/
139-
public onMatrixUrlRequested(fileFormat: MatrixFormat) {
141+
public onMatrixUrlRequested(selectedSearchTerms: SearchTerm[], fileFormat: MatrixFormat) {
140142

143+
this.matrixService.trackRequestCohortMatrix(selectedSearchTerms, fileFormat);
141144
this.store.dispatch(new FetchMatrixUrlRequestAction(fileFormat, this.ngDestroy$));
142145
}
143146

147+
/**
148+
* Track click on matrix download URL.
149+
*
150+
* @param {SearchTerm[]} selectedSearchTerms
151+
* @param {string} matrixDownloadUrl
152+
*/
153+
public onMatrixDownloadUrlClicked(selectedSearchTerms: SearchTerm[], matrixDownloadUrl: string) {
154+
155+
this.matrixService.trackDownloadCohortMatrix(selectedSearchTerms, matrixDownloadUrl);
156+
}
157+
158+
/**
159+
* Track click on matrix download URL.
160+
*
161+
* @param {SearchTerm[]} selectedSearchTerms
162+
* @param {string} matrixDownloadUrl
163+
*/
164+
public onMatrixDownloadUrlCopiedToClipboard(selectedSearchTerms: SearchTerm[], matrixDownloadUrl: string) {
165+
166+
this.matrixService.trackCopyToClipboardCohortMatrixLink(selectedSearchTerms, matrixDownloadUrl);
167+
}
168+
144169
/**
145170
* Kill subscriptions on destroy of component.
146171
*/

spa/src/app/files/hca-get-data/matrix-url-request-completed/matrix-url-request-completed.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
“Save Link As...”.</p>
1212
<p class="fontsize-m">This link expires in 30 days.</p>
1313
<div class="download">
14-
<display-data-link [link]="getMatrixLink(matrixUrlRequest)"></display-data-link>
15-
<copy-to-clipboard [copyToClipboardLink]="getMatrixLink(matrixUrlRequest)"></copy-to-clipboard>
14+
<display-data-link [link]="getMatrixLink(matrixUrlRequest)"
15+
(dataLinkClicked)="onDataLinkClicked(getMatrixLink(matrixUrlRequest))"></display-data-link>
16+
<copy-to-clipboard [copyToClipboardLink]="getMatrixLink(matrixUrlRequest)"
17+
(copyClicked)="onDataLinkCopied(getMatrixLink(matrixUrlRequest))"></copy-to-clipboard>
1618
</div>
1719
</ng-container>

spa/src/app/files/hca-get-data/matrix-url-request-completed/matrix-url-request-completed.component.spec.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ import { ClipboardModule } from "ngx-clipboard";
1515

1616
// App components
1717
import { ConfigService } from "../../../config/config.service";
18+
import { DisplayDataLinkComponent } from "../display-data-link/display-data-link.component";
19+
import { HCAGetDataPanelComponent } from "../hca-get-data-panel/hca-get-data-panel.component";
20+
import { MatrixUrlRequestCompletedComponent } from "./matrix-url-request-completed.component";
1821
import { CopyToClipboardComponent } from "../../../shared/copy-to-clipboard/copy-to-clipboard.component";
22+
import { GTMService } from "../../../shared/gtm/gtm.service";
1923
import { FileManifestService } from "../../shared/file-manifest.service";
2024
import { MatrixService } from "../../shared/matrix.service";
2125
import { MatrixUrlRequestStatus } from "../../shared/matrix-url-request-status.model";
22-
import { DisplayDataLinkComponent } from "../display-data-link/display-data-link.component";
23-
import { HCAGetDataPanelComponent } from "../hca-get-data-panel/hca-get-data-panel.component";
24-
import { MatrixUrlRequestCompletedComponent } from "./matrix-url-request-completed.component";
26+
import { SearchTermService } from "../../shared/search-term.service";
2527

2628
describe("MatrixUrlRequestCompleted", () => {
2729

@@ -43,7 +45,7 @@ describe("MatrixUrlRequestCompleted", () => {
4345

4446
// Text values
4547
const SPECIES_HOMO = "Homo sapiens";
46-
const SPECIES_MUS = "Mus musculus";
48+
const SPECIES_MUS = "Mus musdisplays no species label when multiple matrix url requests are completed but only one request has datculus";
4749
const URL_DATA = "https://test.com";
4850
const URL_DATA_NULL = "";
4951

@@ -93,11 +95,22 @@ describe("MatrixUrlRequestCompleted", () => {
9395
useValue: jasmine.createSpyObj("HttpClient", [
9496
"get", "head", "post"
9597
])
98+
}, {
99+
provide: GTMService,
100+
useValue: jasmine.createSpyObj("GTMService", [
101+
"trackEvent"
102+
])
96103
}, {
97104
provide: FileManifestService,
98105
useValue: jasmine.createSpyObj("FileManifestService", [
99106
"requestMatrixFileManifestUrl"
100107
])
108+
}, {
109+
provide: SearchTermService,
110+
useValue: jasmine.createSpyObj("SearchTermService", [
111+
"bindSearchTerms",
112+
"marshallSearchTerms"
113+
])
101114
}, {
102115
provide: Store,
103116
useValue: testStore

spa/src/app/files/hca-get-data/matrix-url-request-completed/matrix-url-request-completed.component.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
// Core dependencies
9-
import { Component, Input } from "@angular/core";
9+
import { Component, EventEmitter, Input, Output } from "@angular/core";
1010

1111
// App dependencies
1212
import { MatrixService } from "../../shared/matrix.service";
@@ -21,7 +21,9 @@ export class MatrixUrlRequestCompletedComponent {
2121

2222
// Input/output
2323
@Input() matrixUrlRequest: MatrixUrlRequest;
24-
24+
@Output() matrixDownloadUrlClicked = new EventEmitter<string>();
25+
@Output() matrixDownloadUrlCopiedToClipboard = new EventEmitter<string>();
26+
2527
/**
2628
* @param {MatrixService} matrixService
2729
*/
@@ -71,4 +73,21 @@ export class MatrixUrlRequestCompletedComponent {
7173

7274
return this.matrixService.isMatrixUrlRequestFailed(request);
7375
}
76+
77+
/**
78+
* Let parent components know download link has been clicked.
79+
*/
80+
public onDataLinkClicked(matrixUrl: string) {
81+
82+
this.matrixDownloadUrlClicked.emit(matrixUrl);
83+
}
84+
85+
86+
/**
87+
* Let parent components know download link has been copied to clipboard.
88+
*/
89+
public onDataLinkCopied(matrixUrl: string) {
90+
91+
this.matrixDownloadUrlCopiedToClipboard.emit(matrixUrl);
92+
}
7493
}

spa/src/app/files/project-download-matrix-modal/project-download-matrix-modal.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
<ng-container title *ngIf="state.loaded">Download Project Expression Matrices</ng-container>
55
<ng-container subtitle *ngIf="state.loaded">{{state.project.projectTitle}}</ng-container>
66
<ng-container content *ngIf="state.loaded">
7-
<project-download-matrix [classFontName]="'fontsize-m'" [projectMatrixUrls]="state.projectMatrixUrls"></project-download-matrix>
7+
<project-download-matrix [classFontName]="'fontsize-m'"
8+
[projectMatrixUrls]="state.projectMatrixUrls"
9+
[projectTitle]="state.project.projectTitle"></project-download-matrix>
810
</ng-container>
911
</modal-layout>

spa/src/app/files/project-download-matrix/project-download-matrix.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
<ng-container *ngFor="let species of projectMatrixUrls.listSpeciesWithMatrixUrls()">
2020
<h3 class="fontsize-l">{{species}}</h3>
2121
<file-download *ngFor="let matrixUrl of projectMatrixUrls.listMatrixUrlsBySpecies(species)"
22-
[link]="matrixUrl"></file-download>
22+
[link]="matrixUrl"
23+
(linkClicked)="onMatrixDownloadUrlClicked(projectTitle, $event)"
24+
(linkCopiedToClipboard)="onMatrixDownloadUrlCopiedToClipboard(projectTitle, $event)"></file-download>
2325
</ng-container>
2426
</div>
2527
<left-bar>

spa/src/app/files/project-download-matrix/project-download-matrix.component.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ import { CopyToClipboardComponent } from "../../shared/copy-to-clipboard/copy-to
1919
import { FileDownloadComponent } from "../../shared/file-download/file-download.component";
2020
import { DataDownloadCitationComponent } from "../data-download-citation/data-download-citation.component";
2121
import { LeftBarComponent } from "../left-bar/left-bar.component";
22+
import { ProjectDownloadMatrixComponent } from "./project-download-matrix.component";
2223
import { GenusSpecies } from "../shared/genus-species.model";
2324
import { ProjectMatrixUrls } from "../shared/project-matrix-urls.model";
2425
import { SpeciesMatrixUrls } from "../shared/species-matrix-urls.model";
25-
import { ProjectDownloadMatrixComponent } from "./project-download-matrix.component";
26+
import { GTMService } from "../../shared/gtm/gtm.service";
27+
import { MatrixService } from "../shared/matrix.service";
2628

2729
describe("ProjectDownloadMatrixComponent", () => {
2830

@@ -79,6 +81,21 @@ describe("ProjectDownloadMatrixComponent", () => {
7981
],
8082
providers: [
8183
ConfigService,
84+
{
85+
provide: GTMService,
86+
useValue: jasmine.createSpyObj("GTMService", [
87+
"trackEvent"
88+
])
89+
},
90+
{
91+
provide: MatrixService,
92+
useValue: jasmine.createSpyObj("MatrixService", [
93+
"trackRequestCohortMatrix",
94+
"trackDownloadCohortMatrix",
95+
"trackCopyToClipboardCohortMatrixLink",
96+
97+
])
98+
},
8299
{
83100
provide: Store,
84101
useValue: testStore

0 commit comments

Comments
 (0)