Skip to content

Commit

Permalink
Wrap sendBeacon call
Browse files Browse the repository at this point in the history
  • Loading branch information
zoontek committed Apr 8, 2024
1 parent 9e4e547 commit e4bdd9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
20 changes: 8 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// const { dependencies } = require("./package.json");
const path = require("pathe");

const errorOnCI = process.env.CI === "true" ? "error" : "warn";

module.exports = {
plugins: ["@typescript-eslint", "react", "react-hooks", "react-native", "swan"],

Expand All @@ -26,9 +24,6 @@ module.exports = {
overrides: [
{
files: ["**/__{mocks,tests}__/**/*.{ts,tsx}"],
rules: {
"no-empty": ["error", { allowEmptyCatch: true }],
},
},
{
files: ["*.d.ts"],
Expand All @@ -47,15 +42,16 @@ module.exports = {
],

rules: {
curly: errorOnCI,
curly: "error",

"no-implicit-coercion": "error",
"no-param-reassign": "error",
"no-var": "error",
"object-shorthand": errorOnCI,
"object-shorthand": "error",
"prefer-const": "error",

"no-extra-boolean-cast": "off",
"no-empty": ["error", { allowEmptyCatch: true }],

"@typescript-eslint/no-unused-vars": [
"error",
Expand Down Expand Up @@ -87,12 +83,12 @@ module.exports = {
"react-hooks/exhaustive-deps": "warn",

// https://github.com/intellicode/eslint-plugin-react-native
"react-native/no-color-literals": errorOnCI,
"react-native/no-inline-styles": errorOnCI,
"react-native/no-single-element-style-arrays": errorOnCI,
"react-native/no-unused-styles": errorOnCI,
"react-native/no-color-literals": "error",
"react-native/no-inline-styles": "error",
"react-native/no-single-element-style-arrays": "error",
"react-native/no-unused-styles": "error",

"swan/jsx-newline": errorOnCI,
"swan/jsx-newline": "error",
"swan/no-template-in-t": "error",
},
};
6 changes: 5 additions & 1 deletion clients/onboarding/src/utils/matomo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export const sendMatomoEvent = (
.otherwise(() => ({})),
};

navigator.sendBeacon(API_URL + encodeSearch(params));
if ("sendBeacon" in navigator) {
try {
navigator.sendBeacon(API_URL + encodeSearch(params));
} catch {}
}
};

export const useSessionTracking = (projectId: string | undefined) => {
Expand Down

0 comments on commit e4bdd9f

Please sign in to comment.