Skip to content

Commit

Permalink
DON-950: WIP replacing matomo library
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsl committed Mar 25, 2024
1 parent 817f2a7 commit edfbacb
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 86 deletions.
11 changes: 5 additions & 6 deletions src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { MatSelectModule } from '@angular/material/select';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { RecaptchaModule } from 'ng-recaptcha';
import { MatomoModule } from 'ngx-matomo';
import {NgxMatomoModule, provideMatomo, withRouter} from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { AppComponent } from './app.component';
import { TBG_DONATE_STORAGE } from './donation.service';
import { TBG_DONATE_ID_STORAGE } from './identity.service'
import {environment} from "../environments/environment";

describe('AppComponent', () => {
beforeEach(waitForAsync(() => {
Expand All @@ -28,12 +29,9 @@ describe('AppComponent', () => {
MatIconModule,
MatInputModule,
MatListModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
MatSelectModule,
NoopAnimationsModule,
Expand All @@ -47,6 +45,7 @@ describe('AppComponent', () => {
// Inject in-memory storage for tests, in place of local storage.
{ provide: TBG_DONATE_STORAGE, useExisting: InMemoryStorageService },
{ provide: TBG_DONATE_ID_STORAGE, useExisting: InMemoryStorageService },
provideMatomo({ trackerUrl: '', siteId: ''}, withRouter()),
],
}).compileComponents();
}));
Expand Down
11 changes: 3 additions & 8 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RouterModule, RouterOutlet } from '@angular/router';
import { ComponentsModule } from '@biggive/components-angular';
import { TransferHttpCacheModule } from '@nguniversal/common';
import {RECAPTCHA_BASE_URL, RECAPTCHA_NONCE} from 'ng-recaptcha';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { LOCAL_STORAGE } from 'ngx-webstorage-service';

import { AppComponent } from './app.component';
Expand Down Expand Up @@ -42,14 +42,9 @@ const matomoTrackers = environment.matomoSiteId ? [
BrowserModule,
ComponentsModule,
HttpClientModule,
// Matomo module always imported, but with 0 trackers set if site ID omitted for the env.
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `${matomoBaseUri}/matomo.js`,
trackers: matomoTrackers,
routeTracking: {
enable: true,
},
requireCookieConsent: true,
}),
RouterModule.forRoot(routes, {
bindToComponentInputs: true,
Expand Down Expand Up @@ -81,7 +76,7 @@ const matomoTrackers = environment.matomoSiteId ? [
provide: RECAPTCHA_BASE_URL,
useValue: 'https://recaptcha.net/recaptcha/api.js' // using this URL instead of default google.com means we avoid google.com cookies.
},
provideMatomo({ trackerUrl: `${matomoBaseUri}/matomo.php`, siteId: environment.matomoSiteId}, withRouter())
provideMatomo({ trackerUrl: `${matomoBaseUri}/matomo.php`, siteId: environment.matomoSiteId}, withRouter()),
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
bootstrap: [AppComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Component} from "@angular/core";
import {ComponentFixture, TestBed} from '@angular/core/testing';
import { MatDialogModule } from '@angular/material/dialog';
import {ActivatedRoute} from "@angular/router";
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import {InMemoryStorageService} from "ngx-webstorage-service";
import {of} from "rxjs";

Expand Down Expand Up @@ -38,12 +38,9 @@ describe('DonationStartContainer', () => {
imports: [
HttpClientTestingModule,
MatDialogModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {ActivatedRoute, Router} from '@angular/router';
import {RouterTestingModule} from '@angular/router/testing';
import {RecaptchaModule} from 'ng-recaptcha';
import {MatomoModule, MatomoTracker} from 'ngx-matomo';
import {MatomoTracker} from 'ngx-matomo-client';
import {InMemoryStorageService} from 'ngx-webstorage-service';
import {of} from 'rxjs';

Expand All @@ -32,6 +32,7 @@ import {PostcodeService} from "../../postcode.service";
import {StripeService} from "../../stripe.service";
import {Donation} from "../../donation.model";
import {MatSnackBar} from '@angular/material/snack-bar';
import {NgxMatomoModule} from "ngx-matomo-client";

function makeDonationStartFormComponent(donationService: DonationService,) {
const mockIdentityService = TestBed.inject(IdentityService);
Expand Down Expand Up @@ -108,6 +109,10 @@ describe('DonationStartNewPrimaryComponent', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [{siteId: '', trackerUrl: ''}],
}),
],
providers: [
TimeLeftPipe,
Expand Down Expand Up @@ -206,13 +211,9 @@ describe('DonationStartNewPrimaryComponent', () => {
MatDialogModule,
MatIconModule,
MatInputModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
}),
trackers: [{siteId: '', trackerUrl: ''}], }),
MatRadioModule,
MatProgressSpinnerModule,
MatSelectModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {MatSnackBar} from '@angular/material/snack-bar';
import {MatStepper} from '@angular/material/stepper';
import {ActivatedRoute, Router} from '@angular/router';
import {RecaptchaComponent} from 'ng-recaptcha';
import {MatomoTracker} from 'ngx-matomo';
import {MatomoTracker} from 'ngx-matomo-client';
import {debounceTime, distinctUntilChanged, retryWhen, startWith, switchMap, tap} from 'rxjs/operators';
import {
PaymentIntent,
Expand Down
9 changes: 3 additions & 6 deletions src/app/donation-thanks/donation-thanks.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {MatDialogModule} from '@angular/material/dialog';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {ActivatedRoute} from '@angular/router';
import {RouterTestingModule} from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import {InMemoryStorageService} from 'ngx-webstorage-service';
import {of} from 'rxjs';

Expand All @@ -25,12 +25,9 @@ describe('DonationThanksComponent', () => {
HttpClientTestingModule,
MatButtonModule,
MatDialogModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
MatProgressSpinnerModule,
RouterTestingModule.withRoutes([
Expand Down
2 changes: 1 addition & 1 deletion src/app/donation-thanks/donation-thanks.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core';
import {DomSanitizer, SafeHtml} from "@angular/platform-browser";
import { MatDialog } from '@angular/material/dialog';
import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
import { MatomoTracker } from 'ngx-matomo';
import { MatomoTracker } from 'ngx-matomo-client';
import { RecaptchaComponent } from 'ng-recaptcha';

import { Campaign } from '../campaign.model';
Expand Down
9 changes: 3 additions & 6 deletions src/app/donation.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import {InMemoryStorageService, SESSION_STORAGE} from 'ngx-webstorage-service';

import { Donation } from './donation.model';
Expand Down Expand Up @@ -44,12 +44,9 @@ describe('DonationService', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '-', trackerUrl: ''}],
}),
RouterTestingModule,
],
Expand Down
2 changes: 1 addition & 1 deletion src/app/donation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Donation} from './donation.model';
import {DonationCreatedResponse} from './donation-created-response.model';
import {environment} from '../environments/environment';
import {Person} from "./person.model";
import {MatomoTracker} from 'ngx-matomo';
import {MatomoTracker} from 'ngx-matomo-client';

export const TBG_DONATE_STORAGE = new InjectionToken<StorageService>('TBG_DONATE_STORAGE');

Expand Down
9 changes: 3 additions & 6 deletions src/app/identity.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { inject, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { IdentityService, TBG_DONATE_ID_STORAGE } from './identity.service';
Expand All @@ -20,12 +20,9 @@ describe('IdentityService', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
RouterTestingModule,
],
Expand Down
2 changes: 1 addition & 1 deletion src/app/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {HttpClient, HttpHeaders} from '@angular/common/http';
import {EventEmitter, Inject, Injectable, InjectionToken} from '@angular/core';
import jwtDecode from 'jwt-decode';
import {CookieService} from 'ngx-cookie-service';
import {MatomoTracker} from 'ngx-matomo';
import {MatomoTracker} from 'ngx-matomo-client';
import {StorageService} from 'ngx-webstorage-service';
import {Observable, of} from 'rxjs';
import {delay, retry, tap} from 'rxjs/operators';
Expand Down
9 changes: 3 additions & 6 deletions src/app/login-modal/login-modal.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ActivatedRoute } from '@angular/router';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { LoginModalComponent } from './login-modal.component';
Expand All @@ -23,12 +23,9 @@ describe('LoginModalComponent', () => {
HttpClientTestingModule,
MatButtonModule,
MatDialogModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
NoopAnimationsModule,
ReactiveFormsModule,
Expand Down
9 changes: 3 additions & 6 deletions src/app/my-account/my-account.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import {HttpClientModule} from "@angular/common/http";
import {NO_ERRORS_SCHEMA} from "@angular/core";
import {MatDialogModule} from "@angular/material/dialog";
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import {InMemoryStorageService} from "ngx-webstorage-service";
import {of} from "rxjs";
import {PaymentMethod} from "@stripe/stripe-js";
Expand All @@ -26,12 +26,9 @@ describe('MyAccountComponent', () => {
imports: [
HttpClientModule,
MatDialogModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
],
providers: [
Expand Down
9 changes: 3 additions & 6 deletions src/app/register-modal/register-modal.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { RegisterModalComponent } from './register-modal.component';
Expand All @@ -23,12 +23,9 @@ describe('RegisterModalComponent', () => {
HttpClientTestingModule,
MatButtonModule,
MatDialogModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
NoopAnimationsModule,
ReactiveFormsModule,
Expand Down
9 changes: 3 additions & 6 deletions src/app/reset-password/reset-password.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MatInputModule } from '@angular/material/input';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { TBG_DONATE_STORAGE } from '../donation.service';
Expand All @@ -29,12 +29,9 @@ describe('ResetPasswordComponent', () => {
MatButtonModule,
MatDialogModule,
MatInputModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
MatProgressSpinnerModule,
NoopAnimationsModule,
Expand Down
9 changes: 3 additions & 6 deletions src/app/stripe.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { TBG_DONATE_STORAGE } from './donation.service';
Expand All @@ -14,12 +14,9 @@ describe('StripeService', () => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
RouterTestingModule,
],
Expand Down
9 changes: 3 additions & 6 deletions src/app/transfer-funds/transfer-funds.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MatSelectModule } from '@angular/material/select';
import { MatStepperModule } from '@angular/material/stepper';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { MatomoModule } from 'ngx-matomo';
import { NgxMatomoModule } from 'ngx-matomo-client';
import { InMemoryStorageService } from 'ngx-webstorage-service';

import { TBG_DONATE_STORAGE } from '../donation.service';
Expand All @@ -34,12 +34,9 @@ describe('TransferFundsComponent', () => {
MatDialogModule,
MatIconModule,
MatInputModule,
MatomoModule.forRoot({
NgxMatomoModule.forRoot({
scriptUrl: `https://example.com/matomo.js`,
trackers: [],
routeTracking: {
enable: true,
}
trackers: [{siteId: '', trackerUrl: ''}],
}),
MatRadioModule,
MatProgressSpinnerModule,
Expand Down
Loading

0 comments on commit edfbacb

Please sign in to comment.