Add frontend reporting of "usp" URL parameter

Change-Id: Iecfbf93b359382acd518194129e8e79a7e32163f
This commit is contained in:
Ben Rohlfs
2021-03-12 09:24:26 +01:00
parent a35fbbcc1a
commit 6fb09dd0e0
2 changed files with 4 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ export enum LifeCycle {
VISIBILILITY_VISIBLE = 'Visibility changed to visible', VISIBILILITY_VISIBLE = 'Visibility changed to visible',
EXTENSION_DETECTED = 'Extension detected', EXTENSION_DETECTED = 'Extension detected',
PLUGINS_INSTALLED = 'Plugins installed', PLUGINS_INSTALLED = 'Plugins installed',
USER_REFERRED_FROM = 'User referred from',
} }
export enum Execution { export enum Execution {

View File

@@ -74,7 +74,7 @@ import {
toPathname, toPathname,
toSearchParams, toSearchParams,
} from '../../../utils/url-util'; } from '../../../utils/url-util';
import {Execution} from '../../../constants/reporting'; import {Execution, LifeCycle} from '../../../constants/reporting';
const RoutePattern = { const RoutePattern = {
ROOT: '/', ROOT: '/',
@@ -861,6 +861,8 @@ export class GrRouter extends LegacyElementMixin(PolymerElement) {
const pathname = toPathname(ctx.canonicalPath); const pathname = toPathname(ctx.canonicalPath);
const searchParams = toSearchParams(ctx.canonicalPath); const searchParams = toSearchParams(ctx.canonicalPath);
if (searchParams.has('usp')) { if (searchParams.has('usp')) {
const usp = searchParams.get('usp');
this.reporting.reportLifeCycle(LifeCycle.USER_REFERRED_FROM, {usp});
searchParams.delete('usp'); searchParams.delete('usp');
this._redirect(toPath(pathname, searchParams)); this._redirect(toPath(pathname, searchParams));
return; return;