Skip to content

Commit 7a55109

Browse files
add metrics config
1 parent e580c42 commit 7a55109

5 files changed

Lines changed: 56 additions & 18 deletions

File tree

src/app/shared/cookies/browser-klaro.service.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ import { CAPTCHA_NAME } from '../../core/google-recaptcha/google-recaptcha.servi
1919
import isEqual from 'lodash/isEqual';
2020

2121
export interface CookieConsents {
22-
acknowledgement: boolean;
23-
authentication: boolean;
24-
preferences: boolean;
22+
[key: string]: boolean;
23+
}
24+
25+
export interface ThirdPartyMetric {
26+
key: string;
27+
enabled: boolean
2528
}
2629
/**
2730
* Metadata field to store a user's cookie consent preferences in
@@ -108,6 +111,20 @@ export class BrowserKlaroService extends KlaroService {
108111
this.klaroConfig.translations.zz.consentNotice.description = 'cookies.consent.content-notice.description.no-privacy';
109112
}
110113

114+
if(environment.metricsConsents) {
115+
environment.metricsConsents.forEach((metric) => {
116+
if(metric.enabled) {
117+
this.klaroConfig.services.push(
118+
{
119+
name: metric.key,
120+
purposes: ['thirdPartiesJs'],
121+
required: false,
122+
}
123+
)
124+
}
125+
})
126+
}
127+
111128
const hideGoogleAnalytics$ = this.configService.findByPropertyName(this.GOOGLE_ANALYTICS_KEY).pipe(
112129
getFirstCompletedRemoteData(),
113130
map(remoteData => !remoteData.hasSucceeded || !remoteData.payload || isEmpty(remoteData.payload.values)),

src/app/shared/cookies/klaro-configuration.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,6 @@ export const klaroConfiguration: any = {
135135
HAS_AGREED_END_USER
136136
]
137137
},
138-
{
139-
name: 'plumX',
140-
purposes: ['thirdPartiesJs'],
141-
required: false,
142-
},
143-
{
144-
name: 'altmetric',
145-
purposes: ['thirdPartiesJs'],
146-
required: false,
147-
},
148-
{
149-
name: 'dimensions',
150-
purposes: ['thirdPartiesJs'],
151-
required: false,
152-
},
153138
{
154139
name: GOOGLE_ANALYTICS_KLARO_KEY,
155140
purposes: ['statistical'],

src/config/app-config.interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import { FollowAuthorityMetadata } from './search-follow-metadata.interface';
3131
import { AdvancedAttachmentRenderingConfig } from './advanced-attachment-rendering.config';
3232
import { AttachmentRenderingConfig } from './attachment-rendering.config';
3333
import { SearchResultConfig } from './search-result-config.interface';
34+
import { CookieConsents, ThirdPartyMetric } from "../app/shared/cookies/browser-klaro.service";
3435

3536
interface AppConfig extends Config {
3637
ui: UIServerConfig;
@@ -68,6 +69,7 @@ interface AppConfig extends Config {
6869
attachmentRendering: AttachmentRenderingConfig;
6970
advancedAttachmentRendering: AdvancedAttachmentRenderingConfig;
7071
searchResult: SearchResultConfig;
72+
metricsConsents: ThirdPartyMetric[];
7173
}
7274

7375
/**

src/config/default-app-config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from './advanced-attachment-rendering.config';
3535
import { AttachmentRenderingConfig } from './attachment-rendering.config';
3636
import { SearchResultConfig } from './search-result-config.interface';
37+
import { CookieConsents, ThirdPartyMetric } from "../app/shared/cookies/browser-klaro.service";
3738

3839
export class DefaultAppConfig implements AppConfig {
3940
production = false;
@@ -735,4 +736,20 @@ export class DefaultAppConfig implements AppConfig {
735736
additionalMetadataFields: [],
736737
authorMetadata: ['dc.contributor.author', 'dc.creator', 'dc.contributor.*'],
737738
};
739+
740+
//Configuration for third-party metrics in Klaro
741+
metricsConsents: ThirdPartyMetric[] = [
742+
{
743+
key: 'plumX',
744+
enabled: true
745+
},
746+
{
747+
key: 'altmetric',
748+
enabled: true
749+
},
750+
{
751+
key: 'dimensions',
752+
enabled: true
753+
},
754+
];
738755
}

src/environments/environment.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BuildConfig } from 'src/config/build-config.interface';
33
import { RestRequestMethod } from '../app/core/data/rest-request-method';
44
import { NotificationAnimationsType } from '../app/shared/notifications/models/notification-animations-type';
55
import { AdvancedAttachmentElementType } from '../config/advanced-attachment-rendering.config';
6+
import { ThirdPartyMetric } from "../app/shared/cookies/browser-klaro.service";
67

78
export const environment: BuildConfig = {
89
production: false,
@@ -553,4 +554,20 @@ export const environment: BuildConfig = {
553554
],
554555
authorMetadata: ['dc.contributor.author', 'dc.contributor.editor', 'dc.contributor.contributor', 'dc.creator'],
555556
},
557+
558+
//Configuration for third-party metrics in Klaro
559+
metricsConsents: [
560+
{
561+
key: 'plumX',
562+
enabled: true
563+
},
564+
{
565+
key: 'altmetric',
566+
enabled: true
567+
},
568+
{
569+
key: 'dimensions',
570+
enabled: true
571+
},
572+
],
556573
};

0 commit comments

Comments
 (0)