1111import { Action } from "@ngrx/store" ;
1212
1313// App dependencies
14+ import { TrackingAction } from "../analytics/tracking.action" ;
1415import { FileFacetName } from "../../facet/file-facet/file-facet-name.model" ;
1516import { SearchTerm } from "../../search/search-term.model" ;
1617import { SearchEntity } from "../../search/search-entity.model" ;
1718import { SelectSearchTermAction } from "./select-search-term.action" ;
19+ import { GAEvent } from "../../../shared/analytics/ga-event.model" ;
20+ import { GADimension } from "../../../shared/analytics/ga-dimension.model" ;
21+ import { GAAction } from "../../../shared/analytics/ga-action.model" ;
22+ import { GAEntityType } from "../../../shared/analytics/ga-entity-type.model" ;
23+ import { GACategory } from "../../../shared/analytics/ga-category.model" ;
24+ import { GASource } from "../../../shared/analytics/ga-source.model" ;
1825
19- export class SelectProjectIdAction implements Action , SelectSearchTermAction {
26+ export class SelectProjectIdAction implements Action , SelectSearchTermAction , TrackingAction {
2027
2128 public static ACTION_TYPE = "FILE.SEARCH.SELECT_PROJECT_ID" ;
2229 public readonly type = SelectProjectIdAction . ACTION_TYPE ;
@@ -27,11 +34,36 @@ export class SelectProjectIdAction implements Action, SelectSearchTermAction {
2734 * @param {string } projectId
2835 * @param {string } projectShortname
2936 * @param {boolean } selected
37+ * @param {GASource } source
3038 */
3139 constructor (
3240 public readonly projectId : string ,
3341 public readonly projectShortname : string ,
34- public readonly selected = true ) { }
42+ public readonly selected = true ,
43+ public readonly source : GASource ) { }
44+
45+ /**
46+ * Return the cleared age range action as a GA event.
47+ *
48+ * @param {string } currentQuery
49+ * @returns {GAEvent }
50+ */
51+ public asEvent ( currentQuery : string ) : GAEvent {
52+
53+ return {
54+ category : GACategory . SEARCH ,
55+ action : this . selected ? GAAction . SELECT : GAAction . DESELECT ,
56+ label : this . projectShortname ,
57+ dimensions : {
58+ [ GADimension . CURRENT_QUERY ] : currentQuery ,
59+ [ GADimension . ENTITY_ID ] : this . projectId ,
60+ [ GADimension . ENTITY_TYPE ] : GAEntityType . FACET ,
61+ [ GADimension . FACET ] : this . facetName ,
62+ [ GADimension . SOURCE ] : this . source ,
63+ [ GADimension . TERM ] : this . projectShortname
64+ }
65+ } ;
66+ }
3567
3668 /**
3769 * Returns selected project in search term format.
0 commit comments