Skip to content

Commit

Permalink
Only collect states for platform browser (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling authored Aug 16, 2023
1 parent 1219fa7 commit 1cf8fea
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/core/service/stats.service.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import { Inject, Injectable } from '@angular/core';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Params } from '@angular/router';
import { Observable } from 'rxjs';
import { AppConfig, APP_CONFIG } from 'src/app/app.config';
import { RestService } from './rest.service';
import { isPlatformBrowser } from '@angular/common';

@Injectable()
export class StatsService {

constructor(@Inject(APP_CONFIG) private appConfig: AppConfig, private rest: RestService) {
constructor(
@Inject(APP_CONFIG) private appConfig: AppConfig,
@Inject(PLATFORM_ID) private platformId: string,
private rest: RestService
) {

}

public collect(queryParams: Params): Observable<any> {
return new Observable((observer) => {
if (this.appConfig.collectSearchStats) {
if (isPlatformBrowser(this.platformId) && this.appConfig.collectSearchStats) {
this.rest.get('https://php.library.tamu.edu/utilities/vivo_page_info.php').toPromise().then((data: any) => {
data.queryParams = queryParams;
this.rest.post('https://scholars.library.tamu.edu/vivo_editor/insert_stat.php', data, {
Expand Down

0 comments on commit 1cf8fea

Please sign in to comment.