Skip to content

[WIP] Feature/olehs datacite usage tracker #2496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feature/datacite-usage-tracker
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/services/analytics.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import Metrics from 'ember-metrics/services/metrics';
import Session from 'ember-simple-auth/services/session';
import Toast from 'ember-toastr/services/toast';
import moment from 'moment-timezone';
import { DataCiteTracker } from '@datacite/datacite-tracker';
import { Tracker, MetricType } from 'datacite-tracker/src';

import CurrentUser from 'ember-osf-web/services/current-user';
import Ready from 'ember-osf-web/services/ready';
@@ -256,7 +256,7 @@ export default class Analytics extends Service {
async _trackDownloadTask(itemGuid: string, doi?: string) {
const _doi = doi || await this._getDoi(itemGuid);
if (_doi) {
this._sendDataciteUsage(_doi, DataCiteTracker.MetricType.Download);
this._sendDataciteUsage(_doi, MetricType.Download);
}
// TODO: this._sendCountedUsage(...) with itemGuid? (or don't)
}
@@ -429,16 +429,16 @@ export default class Analytics extends Service {
const { itemGuid } = this._getRouteMetricsMetadata();
if (itemGuid) {
const doi = await this._getDoi(itemGuid);
this._sendDataciteUsage(doi, DataCiteTracker.MetricType.View);
this._sendDataciteUsage(doi, MetricType.View);
}
}

_sendDataciteUsage(
doi: string,
metricType: DataCiteTracker.MetricType,
metricType: MetricType,
) {
if (dataciteTrackerRepoId && doi) {
const { trackMetric } = DataCiteTracker.Tracker({
const { trackMetric } = Tracker({
repoId: dataciteTrackerRepoId,
trackLocalhost: devMode,
// apiHost: 'https://analytics.datacite.org',
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -208,6 +208,7 @@
"ember-tooltips": "^3.6.0",
"ember-wormhole": "^0.6.0",
"eslint": "^7.32.0",
"datacite-tracker": "https://github.com/datacite/datacite-tracker",
"eslint-config-airbnb-base": "14.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ember": "^10.5.8",
@@ -269,6 +270,5 @@
]
},
"dependencies": {
"@datacite/datacite-tracker": "^0.0.5"
}
}
41 changes: 32 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -3483,11 +3483,6 @@
resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9"
integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==

"@datacite/datacite-tracker@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@datacite/datacite-tracker/-/datacite-tracker-0.0.5.tgz#7be86bbd02b39427eb87e43c5dc843f2fb9c637e"
integrity sha512-6F2YAHCLWnRiHEQdHz/0btRTlfgXIFbUEXAK0SyPV2+J2dVZK3fBCjXqsA1p/WAErRfIOvnH+eDqAT+9kNRb0w==

"@ember-data/[email protected]":
version "3.28.13"
resolved "https://registry.yarnpkg.com/@ember-data/adapter/-/adapter-3.28.13.tgz#3b921365046a329f3eb1c72fc4964c6aff06e53b"
@@ -10391,6 +10386,10 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

"datacite-tracker@https://github.com/datacite/datacite-tracker":
version "0.0.5"
resolved "https://github.com/datacite/datacite-tracker#f5345d4639f2bea4ed63c912e3872884717ecd69"

date-and-time@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/date-and-time/-/date-and-time-1.0.1.tgz#4959b7faf1ec5873e59d926d4528b9223a808a57"
@@ -21821,7 +21820,7 @@ string-template@~0.2.1:
resolved "https://registry.yarnpkg.com/string-template/-/string-template-0.2.1.tgz#42932e598a352d01fc22ec3367d9d84eec6c9add"
integrity sha1-QpMuWYo1LQH8IuwzZ9nYTuxsmt0=

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -21847,6 +21846,15 @@ string-width@^1.0.1:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^4.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^3.0.0, string-width@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
@@ -22017,7 +22025,7 @@ stringify-object@^3.2.2:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -22052,6 +22060,13 @@ strip-ansi@^6.0.0:
dependencies:
ansi-regex "^5.0.0"

strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -23855,8 +23870,7 @@ workerpool@^6.0.0, workerpool@^6.1.4:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.5.tgz#0f7cf076b6215fd7e1da903ff6f22ddd1886b581"
integrity sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -23882,6 +23896,15 @@ wrap-ansi@^5.1.0:
string-width "^3.0.0"
strip-ansi "^5.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"