diff --git a/package-lock.json b/package-lock.json index 4785c953bb71..65186daa3bc0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,6 @@ "papaparse": "5.4.1", "pdf-lib": "1.17.1", "pdfjs-dist": "4.8.69", - "posthog-js": "1.187.2", "rxjs": "7.8.1", "simple-statistics": "7.8.7", "smoothscroll-polyfill": "0.4.4", @@ -11695,12 +11694,6 @@ "bser": "2.1.1" } }, - "node_modules/fflate": { - "version": "0.4.8", - "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz", - "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==", - "license": "MIT" - }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -17538,28 +17531,6 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "license": "MIT" }, - "node_modules/posthog-js": { - "version": "1.187.2", - "resolved": "https://registry.npmjs.org/posthog-js/-/posthog-js-1.187.2.tgz", - "integrity": "sha512-IGKsZ7M4AYACm5I6gGGFrv9kR/MOnVYw11XFYCLk363n0nq+ghwenoW1jJVL9gZLGKiMsConUR8rG2DD2OMKyg==", - "license": "MIT", - "dependencies": { - "core-js": "^3.38.1", - "fflate": "^0.4.8", - "preact": "^10.19.3", - "web-vitals": "^4.2.0" - } - }, - "node_modules/preact": { - "version": "10.24.3", - "resolved": "https://registry.npmjs.org/preact/-/preact-10.24.3.tgz", - "integrity": "sha512-Z2dPnBnMUfyQfSQ+GBdsGa16hz35YmLmtTLhM169uW944hYL6xzTYkJjC07j+Wosz733pMWx0fgON3JNw1jJQA==", - "license": "MIT", - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/preact" - } - }, "node_modules/prebuild-install": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", @@ -21506,12 +21477,6 @@ "dev": true, "license": "MIT" }, - "node_modules/web-vitals": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-4.2.4.tgz", - "integrity": "sha512-r4DIlprAGwJ7YM11VZp4R884m0Vmgr6EAKe3P+kO0PPj3Unqyvv59rczf6UiGcb9Z8QxZVcqKNwv/g0WNdWwsw==", - "license": "Apache-2.0" - }, "node_modules/webcola": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/webcola/-/webcola-3.4.0.tgz", diff --git a/package.json b/package.json index 453215b959eb..e96395d0ca15 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "papaparse": "5.4.1", "pdf-lib": "1.17.1", "pdfjs-dist": "4.8.69", - "posthog-js": "1.187.2", "rxjs": "7.8.1", "simple-statistics": "7.8.7", "smoothscroll-polyfill": "0.4.4", diff --git a/src/main/webapp/app/core/posthog/analytics.service.ts b/src/main/webapp/app/core/posthog/analytics.service.ts deleted file mode 100644 index 3971f5748b0d..000000000000 --- a/src/main/webapp/app/core/posthog/analytics.service.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { Injectable } from '@angular/core'; -import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; -import { posthog } from 'posthog-js'; - -@Injectable({ providedIn: 'root' }) -export class AnalyticsService { - /** - * Initialize Analytics with profile information. - * @param profileInfo - */ - public async initAnalytics(profileInfo: ProfileInfo): Promise { - if (!profileInfo || !profileInfo.postHog) { - return; - } - - posthog.init(profileInfo.postHog.token, { - api_host: profileInfo.postHog.host, - }); - } -} diff --git a/src/main/webapp/app/shared/layouts/main/main.component.ts b/src/main/webapp/app/shared/layouts/main/main.component.ts index 46f7727ecae3..6563c998cdfa 100644 --- a/src/main/webapp/app/shared/layouts/main/main.component.ts +++ b/src/main/webapp/app/shared/layouts/main/main.component.ts @@ -5,7 +5,6 @@ import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { SentryErrorHandler } from 'app/core/sentry/sentry.error-handler'; import { ThemeService } from 'app/core/theme/theme.service'; import { DOCUMENT } from '@angular/common'; -import { AnalyticsService } from 'app/core/posthog/analytics.service'; import { Subscription } from 'rxjs'; import { ExamParticipationService } from 'app/exam/participate/exam-participation.service'; import { CourseManagementService } from 'app/course/manage/course-management.service'; @@ -41,7 +40,6 @@ export class JhiMainComponent implements OnInit, OnDestroy { private profileService: ProfileService, private examParticipationService: ExamParticipationService, private sentryErrorHandler: SentryErrorHandler, - private analyticsService: AnalyticsService, private themeService: ThemeService, @Inject(DOCUMENT) private document: Document, @@ -50,7 +48,6 @@ export class JhiMainComponent implements OnInit, OnDestroy { private ltiService: LtiService, ) { this.setupErrorHandling().then(undefined); - this.setupAnalytics().then(undefined); } private async setupErrorHandling() { @@ -60,13 +57,6 @@ export class JhiMainComponent implements OnInit, OnDestroy { }); } - private async setupAnalytics() { - this.profileService.getProfileInfo().subscribe((profileInfo) => { - // postHog is only activated if it was specified in the application.yml file - this.analyticsService.initAnalytics(profileInfo); - }); - } - private getPageTitle(routeSnapshot: ActivatedRouteSnapshot): string { const title: string = routeSnapshot.data['pageTitle'] ?? 'artemisApp'; if (routeSnapshot.firstChild) { diff --git a/src/main/webapp/app/shared/layouts/profiles/profile-info.model.ts b/src/main/webapp/app/shared/layouts/profiles/profile-info.model.ts index 7039c00dc27e..d00be9d99622 100644 --- a/src/main/webapp/app/shared/layouts/profiles/profile-info.model.ts +++ b/src/main/webapp/app/shared/layouts/profiles/profile-info.model.ts @@ -10,10 +10,6 @@ export class ProfileInfo { public inDevelopment: boolean; public openApiEnabled?: boolean; public sentry?: { dsn: string }; - public postHog?: { - host?: string; - token: string; - }; public features: ActiveFeatureToggles; public guidedTourMapping?: GuidedTourMapping; public buildPlanURLTemplate: string; diff --git a/src/main/webapp/app/shared/layouts/profiles/profile.service.ts b/src/main/webapp/app/shared/layouts/profiles/profile.service.ts index 14b5d5b2ce31..b6176a1d027e 100644 --- a/src/main/webapp/app/shared/layouts/profiles/profile.service.ts +++ b/src/main/webapp/app/shared/layouts/profiles/profile.service.ts @@ -50,7 +50,6 @@ export class ProfileService { profileInfo.ribbonEnv = profileInfo.ribbonEnv ?? ''; profileInfo.sentry = data.sentry; - profileInfo.postHog = data.postHog; profileInfo.features = data.features; profileInfo.buildPlanURLTemplate = data.buildPlanURLTemplate; profileInfo.commitHashURLTemplate = data.commitHashURLTemplate; diff --git a/src/test/javascript/spec/core/post-hog-analytics.service.spec.ts b/src/test/javascript/spec/core/post-hog-analytics.service.spec.ts deleted file mode 100644 index 13d03a36424d..000000000000 --- a/src/test/javascript/spec/core/post-hog-analytics.service.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AnalyticsService } from 'app/core/posthog/analytics.service'; -import { posthog } from 'posthog-js'; -import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; - -describe('AnalyticsService', () => { - let analyticsService: AnalyticsService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [], - providers: [], - }); - analyticsService = TestBed.inject(AnalyticsService); - }); - - afterEach(() => { - jest.restoreAllMocks(); - }); - - it('should init posthog', async () => { - const initSpy = jest.spyOn(posthog, 'init'); - await analyticsService.initAnalytics({ postHog: { token: 'token', host: 'host' } } as any as ProfileInfo); - expect(initSpy).toHaveBeenCalledOnce(); - }); - - it('should not init posthog', async () => { - const initSpy = jest.spyOn(posthog, 'init'); - await analyticsService.initAnalytics({} as any as ProfileInfo); - expect(initSpy).not.toHaveBeenCalled(); - }); -});