@abi-software/mapintegratedvuer 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/mapintegratedvuer",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "Apache-2.0",
5
5
  "scripts": {
6
6
  "serve": "vite --host --force",
@@ -48,8 +48,8 @@
48
48
  "*.js"
49
49
  ],
50
50
  "dependencies": {
51
- "@abi-software/flatmapvuer": "1.0.1",
52
- "@abi-software/map-side-bar": "2.0.1",
51
+ "@abi-software/flatmapvuer": "1.0.2",
52
+ "@abi-software/map-side-bar": "2.1.0",
53
53
  "@abi-software/plotvuer": "1.0.0",
54
54
  "@abi-software/scaffoldvuer": "1.0.1",
55
55
  "@abi-software/simulationvuer": "1.0.0",
@@ -19,6 +19,7 @@
19
19
 
20
20
  <script>
21
21
  /* eslint-disable no-alert, no-console */
22
+ import Tagging from '../services/tagging.js';
22
23
  import SplitFlow from './SplitFlow.vue';
23
24
  import EventBus from './EventBus';
24
25
  import { mapStores } from 'pinia';
@@ -26,6 +27,7 @@ import { useSettingsStore } from '../stores/settings';
26
27
  import { findSpeciesKey } from './scripts/utilities.js';
27
28
  import { MapSvgSpriteColor} from '@abi-software/svg-sprite';
28
29
  import { initialState } from "./scripts/utilities.js";
30
+ import RetrieveContextCardMixin from "../mixins/RetrieveContextCardMixin.js"
29
31
  import {
30
32
  ElLoading as Loading
31
33
  } from "element-plus";
@@ -40,6 +42,7 @@ export default {
40
42
  Loading,
41
43
  SplitFlow,
42
44
  },
45
+ mixins: [RetrieveContextCardMixin],
43
46
  props: {
44
47
  /**
45
48
  * A link (URL) to share.
@@ -158,7 +161,7 @@ export default {
158
161
  * instead change the current entry by setting the state.
159
162
  * @arg state
160
163
  */
161
- setCurrentEntry: function(state) {
164
+ setCurrentEntry: async function(state) {
162
165
  if (state && state.type) {
163
166
  if (state.type === "Scaffold" && state.url) {
164
167
  //State for scaffold containing the following items:
@@ -167,7 +170,7 @@ export default {
167
170
  // resource - the url to metadata
168
171
  // state - state to restore (viewport)
169
172
  // viewUrl - relative path of the view file to metadata
170
- const newView = {
173
+ let newView = {
171
174
  type: state.type,
172
175
  label: state.label,
173
176
  region: state.region,
@@ -175,6 +178,9 @@ export default {
175
178
  state: state.state,
176
179
  viewUrl: state.viewUrl
177
180
  };
181
+ // Add content from scicrunch for the context card
182
+ const contextCardInfo = await this.retrieveContextCardFromUrl(state.url);
183
+ newView = {...newView, ...contextCardInfo};
178
184
  this.$refs.flow.createNewEntry(newView);
179
185
  } else if (state.type === "MultiFlatmap") {
180
186
  //State for scaffold containing the following items:
@@ -246,6 +252,15 @@ export default {
246
252
  * This event emit when the component is mounted.
247
253
  */
248
254
  this.$emit("isReady");
255
+
256
+ // GA Tagging
257
+ // Page view tracking for maps' buttons click on portal
258
+ // category: AC | FC | WholeBody
259
+ Tagging.sendEvent({
260
+ 'event': 'interaction_event',
261
+ 'event_name': 'portal_maps_page_view',
262
+ 'category': this.startingMap
263
+ });
249
264
  },
250
265
  },
251
266
  computed: {
@@ -29,6 +29,7 @@
29
29
  @tabClicked="tabClicked"
30
30
  @search-changed="searchChanged($event)"
31
31
  @contextUpdate="contextUpdate($event)"
32
+ @datalink-clicked="datalinkClicked($event)"
32
33
  />
33
34
  <SplitDialog
34
35
  :entries="entries"
@@ -42,12 +43,18 @@
42
43
 
43
44
  <script>
44
45
  /* eslint-disable no-alert, no-console */
46
+ import Tagging from '../services/tagging.js';
45
47
  import DialogToolbarContent from "./DialogToolbarContent.vue";
46
48
  import EventBus from "./EventBus";
47
49
  import SplitDialog from "./SplitDialog.vue";
48
50
  // import contextCards from './context-cards'
49
51
  import { SideBar } from "@abi-software/map-side-bar";
50
- import { capitalise, getNewMapEntry, initialDefaultState } from "./scripts/utilities.js";
52
+ import {
53
+ capitalise,
54
+ getNewMapEntry,
55
+ initialDefaultState,
56
+ intersectArrays,
57
+ } from "./scripts/utilities.js";
51
58
  import { mapStores } from 'pinia';
52
59
  import { useEntriesStore } from '../stores/entries';
53
60
  import { useSettingsStore } from '../stores/settings';
@@ -85,6 +92,8 @@ export default {
85
92
  startUp: true,
86
93
  search: '',
87
94
  activeDockedId : 1,
95
+ filterTriggered: false,
96
+ availableFacets: [],
88
97
  }
89
98
  },
90
99
  watch: {
@@ -109,12 +118,34 @@ export default {
109
118
  this.openSearch([action.filter], action.label);
110
119
  } else {
111
120
  this.openSearch([], action.term);
121
+ // GA Tagging
122
+ // Event tracking for map action search/filter data
123
+ const eventName = action.featuredDataset
124
+ ? 'portal_maps_featured_dataset_search'
125
+ : 'portal_maps_action_search';
126
+ Tagging.sendEvent({
127
+ 'event': 'interaction_event',
128
+ 'event_name': eventName,
129
+ 'category': action.term || 'filter',
130
+ 'location': 'map_location_pin'
131
+ });
132
+ this.filterTriggered = true;
112
133
  }
113
134
  } else if (action.type == "URL") {
114
135
  window.open(action.resource, "_blank");
115
136
  } else if (action.type == "Facet") {
116
137
  if (this.$refs.sideBar) {
117
138
  this.$refs.sideBar.addFilter(action);
139
+ const { facet } = action;
140
+ // GA Tagging
141
+ // Event tracking for map action search/filter data
142
+ Tagging.sendEvent({
143
+ 'event': 'interaction_event',
144
+ 'event_name': 'portal_maps_action_filter',
145
+ 'category': facet || 'filter',
146
+ 'location': 'map_location_pin'
147
+ });
148
+ this.filterTriggered = true;
118
149
  }
119
150
  } else if (action.type == "Facets") {
120
151
  const facets = [];
@@ -140,12 +171,51 @@ export default {
140
171
  );
141
172
  if (this.$refs.sideBar) {
142
173
  this.$refs.sideBar.openSearch(facets, "");
174
+
175
+ const filterValuesArray = intersectArrays(this.availableFacets, action.labels);
176
+ const filterValues = filterValuesArray.join(', ');
177
+ // GA Tagging
178
+ // Event tracking for map action search/filter data
179
+ Tagging.sendEvent({
180
+ 'event': 'interaction_event',
181
+ 'event_name': 'portal_maps_action_filter',
182
+ 'category': filterValues || 'filter',
183
+ 'location': 'map_popup_button'
184
+ });
143
185
  }
144
186
  } else {
187
+ this.trackGalleryClick(action);
145
188
  this.createNewEntry(action);
146
189
  }
147
190
  }
148
191
  },
192
+ trackGalleryClick: function (action) {
193
+ const categoryValues = [];
194
+ const { label, type, datasetId, discoverId, resource } = action;
195
+ let filePath = '';
196
+ let id = datasetId ? datasetId : discoverId;
197
+ if (label) categoryValues.push(label);
198
+ if (type) categoryValues.push(type);
199
+ if (datasetId) categoryValues.push('(' + id + ')');
200
+ if (resource) {
201
+ if (type === "Plot") {
202
+ filePath = resource.dataSource.url;
203
+ } else {
204
+ filePath = typeof resource === 'string' ? resource : resource.share_link;
205
+ }
206
+ }
207
+
208
+ // GA Tagging
209
+ // Event tracking for map sidebar gallery click
210
+ Tagging.sendEvent({
211
+ 'event': 'interaction_event',
212
+ 'event_name': 'portal_maps_gallery_click',
213
+ 'category': categoryValues.join(' '),
214
+ 'location': 'map_sidebar_gallery',
215
+ 'dataset_id': id ? id + '' : '', // change to string format
216
+ 'file_path': filePath,
217
+ });
218
+ },
149
219
  onDisplaySearch: function (payload) {
150
220
  let searchFound = false;
151
221
  //Search all active viewers when global callback is on
@@ -159,6 +229,15 @@ export default {
159
229
  });
160
230
  }
161
231
  this.$refs.dialogToolbar.setFailedSearch(searchFound ? undefined : payload.term);
232
+
233
+ // GA Tagging
234
+ // Event tracking for map on display search
235
+ Tagging.sendEvent({
236
+ 'event': 'interaction_event',
237
+ 'event_name': 'portal_maps_display_search',
238
+ 'category': payload.term,
239
+ 'location': 'map_toolbar'
240
+ });
162
241
  },
163
242
  fetchSuggestions: function(payload) {
164
243
  const suggestions = [];
@@ -177,14 +256,46 @@ export default {
177
256
  searchChanged: function (data) {
178
257
  if (data && data.type == "query-update") {
179
258
  this.search = data.value;
259
+ if (this.search && !this.filterTriggered) {
260
+ // GA Tagging
261
+ // Event tracking for map action search/filter data
262
+ Tagging.sendEvent({
263
+ 'event': 'interaction_event',
264
+ 'event_name': 'portal_maps_action_search',
265
+ 'category': this.search,
266
+ 'location': 'map_sidebar_search'
267
+ });
268
+ }
269
+ this.filterTriggered = false; // reset for next action
180
270
  }
181
271
  if (data && data.type == "filter-update") {
182
272
  this.settingsStore.updateFacets(data.value);
273
+
274
+ // Remove filter event from maps' popup
275
+ if (!this.filterTriggered) {
276
+ const { value } = data;
277
+ const filterValuesArray = value.filter((val) =>
278
+ val.facet && val.facet.toLowerCase() !== 'show all'
279
+ ).map((val) => val.facet);
280
+ const filterValues = filterValuesArray.join(', ');
281
+
282
+ // GA Tagging
283
+ // Event tracking for map action search/filter data
284
+ Tagging.sendEvent({
285
+ 'event': 'interaction_event',
286
+ 'event_name': 'portal_maps_action_filter',
287
+ 'category': filterValues || 'filter',
288
+ 'location': 'map_sidebar_filter'
289
+ });
290
+ }
291
+ this.filterTriggered = false; // reset for next action
183
292
  }
184
293
  if (data && data.type == "available-facets") {
185
294
  this.settingsStore.updateFacetLabels(data.value.labels);
186
295
  this.settingsStore.updateMarkers(data.value.uberons);
187
296
  EventBus.emit("markerUpdate");
297
+
298
+ this.availableFacets = data.value.labels
188
299
  }
189
300
  },
190
301
  getNewEntryId: function() {
@@ -323,7 +434,27 @@ export default {
323
434
  },
324
435
  contextUpdate: function (payload) {
325
436
  EventBus.emit("contextUpdate", payload);
326
- }
437
+ },
438
+ datalinkClicked: function (payload) {
439
+ // payload is dataset URL
440
+ const datasetURL = payload || '';
441
+ const substringA = 'datasets/';
442
+ const substringB = '?type=dataset';
443
+ const datasetId = datasetURL.substring(
444
+ datasetURL.indexOf(substringA) + substringA.length,
445
+ datasetURL.indexOf(substringB)
446
+ );
447
+
448
+ // GA Tagging
449
+ // Event tracking for map sidebar gallery dataset click
450
+ Tagging.sendEvent({
451
+ 'event': 'interaction_event',
452
+ 'event_name': 'portal_maps_gallery_click',
453
+ 'category': datasetURL,
454
+ 'location': 'map_sidebar_gallery',
455
+ 'dataset_id': datasetId || ''
456
+ });
457
+ },
327
458
  },
328
459
  created: function () {
329
460
  this._facets = [];
@@ -162,12 +162,36 @@ const getBodyScaffoldInfo = async (sparcApi, species) => {
162
162
  return {url, datasetInfo};
163
163
  }
164
164
 
165
- export {
165
+ // Array intersection
166
+ const intersectArrays = (arr1, arr2) => {
167
+ return arr1.filter((x) => arr2.includes(x));
168
+ };
169
+
170
+ // Not using URLSearchParams to avoid encoding spaces
171
+ const transformObjToString = (obj) => {
172
+ return Object.keys(obj)
173
+ .map((key) => `${key}=${obj[key]}`)
174
+ .join('&');
175
+ };
176
+
177
+ const transformStringToObj = (str) => {
178
+ const params = new URLSearchParams(str);
179
+ const obj = {};
180
+ for (const [key, value] of params) {
181
+ obj[key] = value;
182
+ }
183
+ return obj;
184
+ };
185
+
186
+ export {
166
187
  availableSpecies,
167
188
  capitalise,
168
189
  findSpeciesKey,
169
190
  initialState,
170
191
  initialDefaultState,
171
192
  getBodyScaffoldInfo,
172
- getNewMapEntry
193
+ getNewMapEntry,
194
+ intersectArrays,
195
+ transformObjToString,
196
+ transformStringToObj,
173
197
  }
@@ -17,6 +17,7 @@
17
17
  :flatmapAPI="flatmapAPI"
18
18
  :sparcAPI="apiLocation"
19
19
  @open-map="openMap"
20
+ @pathway-selection-changed="onPathwaySelectionChanged"
20
21
  />
21
22
  </template>
22
23
 
@@ -26,6 +27,7 @@ import { FlatmapVuer } from "@abi-software/flatmapvuer";
26
27
  import EventBus from "../EventBus";
27
28
  import ContentMixin from "../../mixins/ContentMixin";
28
29
  import DynamicMarkerMixin from "../../mixins/DynamicMarkerMixin";
30
+ import { transformObjToString } from '../scripts/utilities';
29
31
  import "@abi-software/flatmapvuer/dist/style.css";
30
32
 
31
33
  export default {
@@ -50,6 +52,24 @@ export default {
50
52
  flatmaprResourceSelected: function (type, resource) {
51
53
  this.$refs.flatmap.resourceSelected(
52
54
  type, resource, (this.$refs.map.viewingMode === "Exploration"));
55
+
56
+ if (resource.eventType === 'click' && resource.feature.type === 'feature') {
57
+ const eventData = {
58
+ label: resource.label || '',
59
+ id: resource.feature.id || '',
60
+ featureId: resource.feature.featureId || '',
61
+ taxonomy: resource.taxonomy || '',
62
+ resources: resource.resource.join(', ')
63
+ };
64
+ const paramString = transformObjToString(eventData);
65
+ // `transformStringToObj` function can be used to change it back to object
66
+ Tagging.sendEvent({
67
+ 'event': 'interaction_event',
68
+ 'event_name': 'portal_maps_connectivity',
69
+ 'category': paramString,
70
+ "location": type + ' ' + this.$refs.map.viewingMode
71
+ });
72
+ }
53
73
  },
54
74
  flatmapReadyCall: function (flatmap) {
55
75
  let provClone = {id: this.entry.id, prov: this.getFlatmapImp().provenance}; //create clone of provenance and add id
@@ -60,6 +80,17 @@ export default {
60
80
  this.flatmapReadyForMarkerUpdates(flatmap);
61
81
  }
62
82
  },
83
+ onPathwaySelectionChanged: function (data) {
84
+ const { label, property, checked, selectionsTitle } = data;
85
+ // GA Tagging
86
+ // Event tracking for maps' pathway selection change
87
+ Tagging.sendEvent({
88
+ 'event': 'interaction_event',
89
+ 'event_name': 'portal_maps_pathway_change',
90
+ 'category': label + ' [' + property + '] ' + checked,
91
+ 'location': selectionsTitle
92
+ });
93
+ },
63
94
  highlightFeatures: function(info) {
64
95
  let name = info.name;
65
96
  const flatmap = this.$refs.flatmap.mapImp;
@@ -17,16 +17,22 @@
17
17
  :sparcAPI="apiLocation"
18
18
  @pan-zoom-callback="flatmapPanZoomCallback"
19
19
  @open-map="openMap"
20
+ @pathway-selection-changed="onPathwaySelectionChanged"
21
+ @open-pubmed-url="onOpenPubmedUrl"
20
22
  />
21
23
  </template>
22
24
 
23
25
  <script>
24
26
  /* eslint-disable no-alert, no-console */
25
- import { availableSpecies } from "../scripts/utilities.js";
27
+ import Tagging from '../../services/tagging.js';
26
28
  import { MultiFlatmapVuer } from "@abi-software/flatmapvuer";
27
29
  import ContentMixin from "../../mixins/ContentMixin";
28
30
  import EventBus from "../EventBus";
29
- import { getBodyScaffoldInfo } from "../scripts/utilities";
31
+ import {
32
+ availableSpecies,
33
+ getBodyScaffoldInfo,
34
+ transformObjToString
35
+ } from "../scripts/utilities";
30
36
  import DyncamicMarkerMixin from "../../mixins/DynamicMarkerMixin";
31
37
 
32
38
  import "@abi-software/flatmapvuer/dist/style.css";
@@ -160,6 +166,45 @@ export default {
160
166
  flatmaprResourceSelected: function (type, resource) {
161
167
  const map = this.$refs.multiflatmap.getCurrentFlatmap();
162
168
  this.resourceSelected(type, resource, (map.viewingMode === "Exploration"));
169
+
170
+ if (resource.eventType === 'click' && resource.feature.type === 'feature') {
171
+ const eventData = {
172
+ label: resource.label || '',
173
+ id: resource.feature.id || '',
174
+ featureId: resource.feature.featureId || '',
175
+ taxonomy: resource.taxonomy || '',
176
+ resources: resource.resource.join(', ')
177
+ };
178
+ const paramString = transformObjToString(eventData);
179
+ // `transformStringToObj` function can be used to change it back to object
180
+ Tagging.sendEvent({
181
+ 'event': 'interaction_event',
182
+ 'event_name': 'portal_maps_connectivity',
183
+ 'category': paramString,
184
+ "location": type + ' ' + map.viewingMode
185
+ });
186
+ }
187
+ },
188
+ onPathwaySelectionChanged: function (data) {
189
+ const { label, property, checked, selectionsTitle } = data;
190
+ // GA Tagging
191
+ // Event tracking for maps' pathway selection change
192
+ Tagging.sendEvent({
193
+ 'event': 'interaction_event',
194
+ 'event_name': 'portal_maps_pathway_change',
195
+ 'category': label + ' [' + property + '] ' + checked,
196
+ 'location': selectionsTitle
197
+ });
198
+ },
199
+ onOpenPubmedUrl: function (url) {
200
+ // GA Tagging
201
+ // Event tracking for open pubmed url from popup
202
+ Tagging.sendEvent({
203
+ 'event': 'interaction_event',
204
+ 'event_name': 'portal_maps_pubmed_url',
205
+ 'file_path': url,
206
+ 'location': 'map_popup_button',
207
+ });
163
208
  },
164
209
  /**
165
210
  * Handle sync pan zoom event
@@ -245,6 +290,14 @@ export default {
245
290
  await this.toggleSyncMode();
246
291
  }
247
292
  this.updateProvCard();
293
+
294
+ // GA Tagging
295
+ // Event tracking for maps' species change
296
+ Tagging.sendEvent({
297
+ 'event': 'interaction_event',
298
+ 'event_name': 'portal_maps_species_change',
299
+ 'category': this.activeSpecies
300
+ });
248
301
  },
249
302
  multiFlatmapReady: function (flatmap) {
250
303
  if (flatmap) {
@@ -9,6 +9,7 @@ import markerZoomLevels from "../components/markerZoomLevelsHardCoded.js";
9
9
  import { mapStores } from 'pinia';
10
10
  import { useSettingsStore } from '../stores/settings';
11
11
  import { useSplitFlowStore } from '../stores/splitFlow';
12
+ import Tagging from '../services/tagging.js';
12
13
 
13
14
  function capitalise(text) {
14
15
  return text[0].toUpperCase() + text.substring(1)
@@ -52,10 +53,22 @@ export default {
52
53
  openMap: function (type) {
53
54
  if (type === "SYNC") {
54
55
  this.toggleSyncMode();
56
+ this.trackOpenMap('toggle_map_sync_mode');
55
57
  } else {
56
58
  EventBus.emit("OpenNewMap", type);
59
+ this.trackOpenMap(`open_new_${type}_map`);
57
60
  }
58
61
  },
62
+ trackOpenMap: function (category) {
63
+ // GA Tagging
64
+ // Open map tracking
65
+ Tagging.sendEvent({
66
+ 'event': 'interaction_event',
67
+ 'event_name': 'portal_maps_open_map',
68
+ 'category': category,
69
+ 'location': 'open_new_map'
70
+ });
71
+ },
59
72
  updateWithViewUrl: function() {
60
73
  return;
61
74
  },
@@ -113,6 +126,7 @@ export default {
113
126
  term: this.settingsStore.featuredMarkerDoi(
114
127
  resource.feature.id
115
128
  ),
129
+ featuredDataset: true,
116
130
  };
117
131
  } else if (hardcodedAnnotation.filter(h => h.keyword).length > 0) {
118
132
  // if it matches our stored keywords, it is a keyword search
@@ -0,0 +1,83 @@
1
+
2
+ /* eslint-disable no-alert, no-console */
3
+ export default {
4
+ // Note that the setting store is included in MapContent.vue
5
+ methods: {
6
+ retrieveContextCardFromUrl: async function (url) {
7
+ // split the url to get the datasetId
8
+ const [datasetId, basePath, scaffoldPath, s3uri] = this.splitInfoFromUrl(url);
9
+
10
+ // get the context file from scicrunch
11
+ const sciResults = await this.getContextFileFromScicrunch(datasetId, scaffoldPath);
12
+ if (!sciResults.success){
13
+ return {} // return empty object if no context file is found (the empty object will be added to the entry)
14
+ }
15
+
16
+ // return the context file
17
+ const fullPath = basePath + sciResults.contextFile + s3uri;
18
+ return {
19
+ s3uri: sciResults.s3uri,
20
+ contextCardUrl: fullPath,
21
+ }
22
+ },
23
+ splitInfoFromUrl: function (url) {
24
+ // example url: "https://mapcore-demo.org/current/sparc-api-v2/s3-resource/221/3/files/derivative/Scaffolds/mouse_colon_metadata.json",
25
+ // find the part after 's3-resource'
26
+ let s3path = url.split('s3-resource')[1];
27
+ let basePath = url.split('files/')[0] + 'files/' // This gives us the base path for our relative path we will get from scicrunch
28
+ let scaffoldPath = url.split('files/')[1].split('?')[0] // This gives us the relative path to the file we want to get from scicrunch
29
+ let s3uri = '?' + url.split('?')[1] // This gives us the uri needed to get the file from s3
30
+
31
+ // split the url by '/'
32
+ const parts = s3path.split('/');
33
+ // remove the first part
34
+ parts.shift();
35
+ // return the datasetId which is the first part
36
+ const datasetId = parts[0];
37
+
38
+ return [datasetId, basePath, scaffoldPath, s3uri];
39
+ },
40
+ getContextFileFromScicrunch: async function (datasetId, scaffoldPath) {
41
+ // get the context file from scicrunch
42
+ let results = await fetch(`${this.settingsStore.sparcApi}/dataset_info/using_multiple_discoverIds/?discoverIds=${datasetId}`)
43
+ .then(response => response.json())
44
+ .then(data => {
45
+ // get the context info from the response
46
+ if (data.numberOfHits === 1) { // check if there is only one hit (We don't want to use the data if there are multiple hits)
47
+ const contextFile = data.results[0]['abi-contextual-information']
48
+
49
+ // check if there is only one context file and if so return it
50
+ if ( contextFile && contextFile.length === 1) {
51
+ return {
52
+ success: true,
53
+ contextFile: contextFile[0],
54
+ s3uri: data.results[0]['s3uri']
55
+ }
56
+ }
57
+
58
+ // If there are multiple context files, find the one that matches the scaffold path
59
+ else if (contextFile && contextFile.length > 1) {
60
+ let search = this.findContextInforForFilePath(data.results[0]['abi-context-file'], scaffoldPath);
61
+ if (search) {
62
+ return {
63
+ success: true,
64
+ contextFile: search,
65
+ s3uri: data.results[0]['s3uri']
66
+ }
67
+ }
68
+ }
69
+ }
70
+ return {success: false};
71
+ }).catch(error => {
72
+ console.error('Error:', error);
73
+ return {success: false};
74
+ });
75
+ return results;
76
+ },
77
+ findContextInforForFilePath: function (dataciteInfo, filePath) {
78
+ // find the context file that matches the scaffold path
79
+ let result = dataciteInfo.find((info) => info.datacite.isDerivedFrom.path.includes(filePath))
80
+ return result?.dataset?.path
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,28 @@
1
+ export default {
2
+ sendEvent: function(data) {
3
+ const taggingData = {
4
+ event: data.event || '',
5
+ event_name: data.event_name || '',
6
+ files: data.files || '',
7
+ file_name: data.file_name || '',
8
+ file_path: data.file_path || '',
9
+ file_type: data.file_type || '',
10
+ category: data.category || '',
11
+ dataset_id: data.dataset_id || '',
12
+ version_id: data.version_id || '',
13
+ doi: data.doi || '',
14
+ citation_type: data.citation_type || '',
15
+ location: data.location || ''
16
+ };
17
+
18
+ // set debugging mode
19
+ if (localStorage.getItem('debugTagging') === 'yes') {
20
+ console.table(taggingData);
21
+ }
22
+
23
+ // push to dataLayer for GTM
24
+ if (typeof dataLayer !== 'undefined') {
25
+ dataLayer.push(taggingData);
26
+ }
27
+ }
28
+ }