Skip to content

Commit

Permalink
added params x-page-url
Browse files Browse the repository at this point in the history
  • Loading branch information
howdysuraj committed Apr 16, 2024
1 parent de91efa commit 6025751
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/app/core/interceptors/httpInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ export class HttpConfigInterceptor implements HttpInterceptor {
);
}

getUrlWithoutQueryParam(url: string): string {
const queryIndex = Math.min(
url.indexOf('?') !== -1 ? url.indexOf('?') : url.length,
url.indexOf(';') !== -1 ? url.indexOf(';') : url.length
);
if (queryIndex !== url.length) {
url = url.substring(0, queryIndex);
}
if (url.length > 200) {
url = url.substring(0, 200);
}
return url;
}

intercept(request: HttpRequest<string>, next: HttpHandler): Observable<HttpEvent<string>> {
return forkJoin({
token: iif(() => this.secureUrl(request.url), this.getAccessToken(), of(null)),
Expand All @@ -128,7 +142,13 @@ export class HttpConfigInterceptor implements HttpInterceptor {
const osVersion = deviceInfo.osVersion;
const operatingSystem = deviceInfo.operatingSystem;
const mobileModifiedappVersion = `fyle-mobile::${appVersion}::${operatingSystem}::${osVersion}`;
request = request.clone({ headers: request.headers.set('X-App-Version', mobileModifiedappVersion) });
request = request.clone({
setHeaders: {
'X-App-Version': mobileModifiedappVersion,
'X-Page-Url': this.getUrlWithoutQueryParam(window.location.href),
'X-Source-Identifier': 'mobile_app',
},
});

return next.handle(request).pipe(
catchError((error) => {
Expand Down

0 comments on commit 6025751

Please sign in to comment.