@hmcts/rpx-xui-common-lib 2.0.11 → 2.0.12

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.
@@ -10,7 +10,7 @@ import { combineLatest, BehaviorSubject, Subject, of as of$1, forkJoin, zip, iif
10
10
  import * as i2$1 from '@angular/router';
11
11
  import { NavigationEnd, RouterModule } from '@angular/router';
12
12
  import { map, filter, distinctUntilChanged, delay, skipWhile, shareReplay, catchError, take, tap, debounceTime, switchMap, mergeMap } from 'rxjs/operators';
13
- import * as LDClient from 'launchdarkly-js-client-sdk';
13
+ import { initialize } from 'launchdarkly-js-client-sdk';
14
14
  import * as i1$1 from '@angular/common/http';
15
15
  import { HttpParams } from '@angular/common/http';
16
16
  import { of } from 'rxjs/internal/observable/of';
@@ -999,6 +999,10 @@ class FeatureToggleService {
999
999
  getValueOnce(_key, _defaultValue) {
1000
1000
  throw new Error('Not implemented');
1001
1001
  }
1002
+ // tslint:disable-next-line: variable-name
1003
+ getValueSync(feature, defaultValue) {
1004
+ throw new Error(`Not implemented ${feature}:${defaultValue}`);
1005
+ }
1002
1006
  }
1003
1007
  FeatureToggleService.ɵfac = function FeatureToggleService_Factory(t) { return new (t || FeatureToggleService)(); };
1004
1008
  FeatureToggleService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: FeatureToggleService, factory: FeatureToggleService.ɵfac, providedIn: 'root' });
@@ -1046,17 +1050,18 @@ class LaunchDarklyService {
1046
1050
  this.ready.next(false);
1047
1051
  this.user = user;
1048
1052
  this.clientId = clientId;
1049
- this.client = LDClient.initialize(this.clientId, this.user, {});
1053
+ this.client = initialize(this.clientId, this.user, {});
1050
1054
  this.client.on('ready', () => {
1051
1055
  this.client.identify(this.user).then(() => this.ready.next(true));
1052
1056
  });
1053
1057
  }
1054
- isEnabled(feature) {
1055
- return this.getValue(feature, false);
1058
+ isEnabled(feature, defaultValue = false) {
1059
+ return this.getValue(feature, defaultValue);
1056
1060
  }
1057
1061
  getArray(feature) {
1058
1062
  return this.getValue(feature, []);
1059
1063
  }
1064
+ // Note that this function always emits its default value first, which can lead to unexpected results
1060
1065
  getValue(feature, defaultValue) {
1061
1066
  if (!this.features.hasOwnProperty(feature)) {
1062
1067
  this.features[feature] = new BehaviorSubject(defaultValue);
@@ -1081,6 +1086,9 @@ class LaunchDarklyService {
1081
1086
  getValueOnce(feature, defaultValue) {
1082
1087
  return this.ready.pipe(filter(ready => ready), map(() => this.client.variation(feature, defaultValue)));
1083
1088
  }
1089
+ getValueSync(feature, defaultValue) {
1090
+ return this.client.variation(feature, defaultValue);
1091
+ }
1084
1092
  }
1085
1093
  LaunchDarklyService.ɵfac = function LaunchDarklyService_Factory(t) { return new (t || LaunchDarklyService)(); };
1086
1094
  LaunchDarklyService.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: LaunchDarklyService, factory: LaunchDarklyService.ɵfac, providedIn: 'root' });
@@ -7263,9 +7271,9 @@ function CookieBannerComponent_div_0_Template(rf, ctx) { if (rf & 1) {
7263
7271
  i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(24, 20, "View cookies"));
7264
7272
  } }
7265
7273
  class CookieBannerComponent {
7266
- constructor(cookieService, featureToggleService, window) {
7274
+ constructor(cookieService, window) {
7267
7275
  this.cookieService = cookieService;
7268
- this.featureToggleService = featureToggleService;
7276
+ this.enableDynatrace = false;
7269
7277
  this.rejectionNotifier = new EventEmitter();
7270
7278
  this.acceptanceNotifier = new EventEmitter();
7271
7279
  this.isCookieBannerVisible = false;
@@ -7301,24 +7309,30 @@ class CookieBannerComponent {
7301
7309
  this.rejectionNotifier.emit();
7302
7310
  }
7303
7311
  notifyAcceptance() {
7304
- if (this.window.hasOwnProperty('dtrum')) {
7305
- // @ts-ignore
7306
- const dtrum = this.window['dtrum'];
7307
- if (dtrum) {
7308
- this.featureToggleService.isEnabled('xui-dynatrace-rum-enabled')
7309
- .subscribe((enabled) => {
7310
- if (enabled) {
7311
- try {
7312
- dtrum.enable();
7313
- dtrum.enableSessionReplay(true);
7314
- }
7315
- catch (e) {
7316
- console.error('Error enabling DynaTrace', e);
7317
- }
7312
+ if (this.enableDynatrace) {
7313
+ if (this.window.hasOwnProperty('dtrum')) {
7314
+ // @ts-ignore
7315
+ const dtrum = this.window['dtrum'];
7316
+ if (dtrum) {
7317
+ try {
7318
+ dtrum.enable();
7319
+ dtrum.enableSessionReplay(true);
7318
7320
  }
7319
- });
7321
+ catch (e) {
7322
+ console.error('Error enabling DynaTrace', e);
7323
+ }
7324
+ }
7325
+ else {
7326
+ console.info("DynaTrace not enabled on the server");
7327
+ }
7328
+ }
7329
+ else {
7330
+ console.info("DynaTrace not enabled on the server");
7320
7331
  }
7321
7332
  }
7333
+ else {
7334
+ console.info("Dyntrace RUM not enabled via component parameter");
7335
+ }
7322
7336
  this.acceptanceNotifier.emit();
7323
7337
  }
7324
7338
  getExpiryDate() {
@@ -7329,8 +7343,8 @@ class CookieBannerComponent {
7329
7343
  return now.toUTCString();
7330
7344
  }
7331
7345
  }
7332
- CookieBannerComponent.ɵfac = function CookieBannerComponent_Factory(t) { return new (t || CookieBannerComponent)(i0.ɵɵdirectiveInject(CookieService), i0.ɵɵdirectiveInject(FeatureToggleService), i0.ɵɵdirectiveInject(windowToken)); };
7333
- CookieBannerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CookieBannerComponent, selectors: [["xuilib-cookie-banner"]], inputs: { identifier: "identifier", appName: "appName" }, outputs: { rejectionNotifier: "rejectionNotifier", acceptanceNotifier: "acceptanceNotifier" }, decls: 1, vars: 1, consts: [["class", "govuk-cookie-banner ", "role", "region", 4, "ngIf"], ["role", "region", 1, "govuk-cookie-banner"], [1, "govuk-cookie-banner__message", "govuk-width-container"], [1, "govuk-grid-row"], [1, "govuk-grid-column-two-thirds"], [1, "govuk-cookie-banner__heading", "govuk-heading-m"], [1, "govuk-cookie-banner__content"], [1, "govuk-button-group"], ["value", "accept", "type", "button", "name", "cookies", "data-module", "govuk-button", 1, "govuk-button", 3, "click"], ["value", "reject", "type", "button", "name", "cookies", "data-module", "govuk-button", 1, "govuk-button", 3, "click"], ["routerLink", "/cookies", 1, "govuk-link"]], template: function CookieBannerComponent_Template(rf, ctx) { if (rf & 1) {
7346
+ CookieBannerComponent.ɵfac = function CookieBannerComponent_Factory(t) { return new (t || CookieBannerComponent)(i0.ɵɵdirectiveInject(CookieService), i0.ɵɵdirectiveInject(windowToken)); };
7347
+ CookieBannerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CookieBannerComponent, selectors: [["xuilib-cookie-banner"]], inputs: { identifier: "identifier", appName: "appName", enableDynatrace: "enableDynatrace" }, outputs: { rejectionNotifier: "rejectionNotifier", acceptanceNotifier: "acceptanceNotifier" }, decls: 1, vars: 1, consts: [["class", "govuk-cookie-banner ", "role", "region", 4, "ngIf"], ["role", "region", 1, "govuk-cookie-banner"], [1, "govuk-cookie-banner__message", "govuk-width-container"], [1, "govuk-grid-row"], [1, "govuk-grid-column-two-thirds"], [1, "govuk-cookie-banner__heading", "govuk-heading-m"], [1, "govuk-cookie-banner__content"], [1, "govuk-button-group"], ["value", "accept", "type", "button", "name", "cookies", "data-module", "govuk-button", 1, "govuk-button", 3, "click"], ["value", "reject", "type", "button", "name", "cookies", "data-module", "govuk-button", 1, "govuk-button", 3, "click"], ["routerLink", "/cookies", 1, "govuk-link"]], template: function CookieBannerComponent_Template(rf, ctx) { if (rf & 1) {
7334
7348
  i0.ɵɵtemplate(0, CookieBannerComponent_div_0_Template, 25, 22, "div", 0);
7335
7349
  } if (rf & 2) {
7336
7350
  i0.ɵɵproperty("ngIf", ctx.isCookieBannerVisible);
@@ -7338,13 +7352,15 @@ CookieBannerComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Cooki
7338
7352
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CookieBannerComponent, [{
7339
7353
  type: Component,
7340
7354
  args: [{ selector: 'xuilib-cookie-banner', template: "<div class=\"govuk-cookie-banner \" role=\"region\" attr.aria-label=\"'Cookies on {{appName}}'\" *ngIf=\"isCookieBannerVisible\">\n <div class=\"govuk-cookie-banner__message govuk-width-container\">\n\n <div class=\"govuk-grid-row\">\n <div class=\"govuk-grid-column-two-thirds\">\n <h2 class=\"govuk-cookie-banner__heading govuk-heading-m\">{{'Cookies on' | rpxTranslate}} {{appName | rpxTranslate}}</h2>\n\n <div class=\"govuk-cookie-banner__content\">\n <p>{{'We use some essential cookies to make this service work.' | rpxTranslate}}</p>\n <p>{{'We\\\u2019d also like to use analytics cookies so we can understand how you use the service and make improvements.' | rpxTranslate}}</p>\n </div>\n </div>\n </div>\n\n <div class=\"govuk-button-group\">\n <button value=\"accept\" type=\"button\" name=\"cookies\" class=\"govuk-button\" data-module=\"govuk-button\" (click)=\"acceptCookie()\">\n {{'Accept analytics cookies' | rpxTranslate}}\n </button>\n <button value=\"reject\" type=\"button\" name=\"cookies\" class=\"govuk-button\" data-module=\"govuk-button\" (click)=\"rejectCookie()\">\n {{'Reject analytics cookies' | rpxTranslate}}\n </button>\n <a class=\"govuk-link\" routerLink=\"/cookies\">{{'View cookies' | rpxTranslate}}</a>\n </div>\n </div>\n</div>\n" }]
7341
- }], function () { return [{ type: CookieService }, { type: FeatureToggleService }, { type: undefined, decorators: [{
7355
+ }], function () { return [{ type: CookieService }, { type: undefined, decorators: [{
7342
7356
  type: Inject,
7343
7357
  args: [windowToken]
7344
7358
  }] }]; }, { identifier: [{
7345
7359
  type: Input
7346
7360
  }], appName: [{
7347
7361
  type: Input
7362
+ }], enableDynatrace: [{
7363
+ type: Input
7348
7364
  }], rejectionNotifier: [{
7349
7365
  type: Output
7350
7366
  }], acceptanceNotifier: [{