Skip to content

Commit

Permalink
fix: remove google cross site tracking query params after load (#472)
Browse files Browse the repository at this point in the history
* fix: remove params

* fix: add removal of GA cross site tracking params in URL
  • Loading branch information
spaenleh authored Jan 22, 2024
1 parent 1bf323e commit 005221d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 56 deletions.
65 changes: 13 additions & 52 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"plugin:react-hooks/recommended",
"eslint:recommended"
],
"plugins": [
"@typescript-eslint",
"react-hooks"
],
"plugins": ["@typescript-eslint", "react-hooks"],
"env": {
"browser": true,
"node": true,
Expand Down Expand Up @@ -43,9 +40,7 @@
"react/react-in-jsx-scope": "off",
// note you must disable the base rule as it can report incorrect errors
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": [
"error"
],
"@typescript-eslint/no-use-before-define": ["error"],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
Expand All @@ -64,12 +59,7 @@
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
],
"import/no-named-as-default": 0,
Expand All @@ -86,16 +76,11 @@
}
],
"no-restricted-syntax": "off",
"react/state-in-constructor": [
"error",
"never"
],
"react/state-in-constructor": ["error", "never"],
"no-console": [
1,
{
"allow": [
"error"
]
"allow": ["error", "info"]
}
],
"import/no-extraneous-dependencies": [
Expand All @@ -107,15 +92,12 @@
"react/prop-types": "off", // Since we do not use prop-types
"react/require-default-props": "off", // Since we do not use prop-types
// disable the rule for all files
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-function-return-type": "off"
},
"overrides": [
{
// enable the rule specifically for TypeScript files
"files": [
"*.ts",
"*.tsx"
],
"files": ["*.ts", "*.tsx"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": [
"error",
Expand All @@ -127,46 +109,25 @@
},
{
// enable the rule specifically for src files
"files": [
"src/**/*.js",
"src/**/*.tsx",
"src/**/*.ts"
],
"files": ["src/**/*.js", "src/**/*.tsx", "src/**/*.ts"],
"rules": {
"no-restricted-syntax": [
"error"
]
"no-restricted-syntax": ["error"]
}
}
],
"settings": {
"import/extensions": [
".js",
".jsx",
".ts",
".tsx"
],
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
"import/parsers": {
"@typescript-eslint/parser": [
".ts",
".tsx"
]
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
},
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
},
"ignorePatterns": [
"node_modules/*"
]
"ignorePatterns": ["node_modules/*"]
}
27 changes: 23 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { useLocation } from 'react-router';
import { Navigate, Route, Routes } from 'react-router-dom';
import { useEffect } from 'react';
import {
Navigate,
Route,
Routes,
useLocation,
useSearchParams,
} from 'react-router-dom';

import { saveUrlForRedirection } from '@graasp/sdk';
import { CustomInitialLoader, withAuthorization } from '@graasp/ui';
Expand All @@ -12,9 +18,22 @@ import HomePage from '@/modules/pages/HomePage';
import ItemPage from '@/modules/pages/ItemPage';

export const App = (): JSX.Element => {
const { pathname } = useLocation();
const location = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const { data: currentMember, isLoading } = useCurrentMemberContext();

useEffect(
() => {
if (searchParams.get('_gl'))
// remove cross domain tracking query params
console.info('Removing cross site tracking params');
searchParams.delete('_gl');
setSearchParams(searchParams);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[searchParams],
);

if (isLoading) {
return <CustomInitialLoader />;
}
Expand All @@ -24,7 +43,7 @@ export const App = (): JSX.Element => {
redirectionLink: SIGN_IN_PATH,
onRedirect: () => {
// save current url for later redirection after sign in
saveUrlForRedirection(pathname, DOMAIN);
saveUrlForRedirection(location.pathname, DOMAIN);
},
};
const HomePageWithAuthorization = withAuthorization(HomePage, props);
Expand Down

0 comments on commit 005221d

Please sign in to comment.