mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
hotfix: wrapped analytics into try/catch to prevent failing on firefox
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { trackError } from "@/features/analytics";
|
import { track, trackError } from "@/features/analytics";
|
||||||
import { collectionCount, getCollections, saveCollections } from "@/features/collectionStorage";
|
import { collectionCount, getCollections, saveCollections } from "@/features/collectionStorage";
|
||||||
import { migrateStorage } from "@/features/migration";
|
import { migrateStorage } from "@/features/migration";
|
||||||
import { showWelcomeDialog } from "@/features/v3welcome/utils/showWelcomeDialog";
|
import { showWelcomeDialog } from "@/features/v3welcome/utils/showWelcomeDialog";
|
||||||
@@ -31,7 +31,7 @@ export default defineBackground(() =>
|
|||||||
browser.runtime.onInstalled.addListener(async ({ reason, previousVersion }) =>
|
browser.runtime.onInstalled.addListener(async ({ reason, previousVersion }) =>
|
||||||
{
|
{
|
||||||
logger("onInstalled", reason, previousVersion);
|
logger("onInstalled", reason, previousVersion);
|
||||||
analytics.track("extension_installed", { reason, previousVersion: previousVersion ?? "none" });
|
track("extension_installed", { reason, previousVersion: previousVersion ?? "none" });
|
||||||
|
|
||||||
const previousMajor: number = previousVersion ? parseInt(previousVersion.split(".")[0]) : 0;
|
const previousMajor: number = previousVersion ? parseInt(previousVersion.split(".")[0]) : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { getCollectionTitle } from "@/entrypoints/sidepanel/utils/getCollectionTitle";
|
import { getCollectionTitle } from "@/entrypoints/sidepanel/utils/getCollectionTitle";
|
||||||
|
import { track } from "@/features/analytics";
|
||||||
import { useGroupColors } from "@/hooks/useGroupColors";
|
import { useGroupColors } from "@/hooks/useGroupColors";
|
||||||
import { CollectionItem, GroupItem } from "@/models/CollectionModels";
|
import { CollectionItem, GroupItem } from "@/models/CollectionModels";
|
||||||
import * as fui from "@fluentui/react-components";
|
import * as fui from "@fluentui/react-components";
|
||||||
@@ -27,9 +28,9 @@ export default function EditDialog(props: GroupEditDialogProps): ReactElement
|
|||||||
const handleSave = () =>
|
const handleSave = () =>
|
||||||
{
|
{
|
||||||
if (props.type === "collection" ? props.collection !== null : props.group !== null)
|
if (props.type === "collection" ? props.collection !== null : props.group !== null)
|
||||||
analytics.track("item_edited", { type: props.type });
|
track("item_edited", { type: props.type });
|
||||||
else
|
else
|
||||||
analytics.track("item_created", { type: props.type });
|
track("item_created", { type: props.type });
|
||||||
|
|
||||||
if (props.type === "collection")
|
if (props.type === "collection")
|
||||||
props.onSave({
|
props.onSave({
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import CloudIssueMessages from "@/entrypoints/sidepanel/layouts/collections/mess
|
|||||||
import CtaMessage from "@/entrypoints/sidepanel/layouts/collections/messages/CtaMessage";
|
import CtaMessage from "@/entrypoints/sidepanel/layouts/collections/messages/CtaMessage";
|
||||||
import filterCollections, { CollectionFilterType } from "@/entrypoints/sidepanel/utils/filterCollections";
|
import filterCollections, { CollectionFilterType } from "@/entrypoints/sidepanel/utils/filterCollections";
|
||||||
import sortCollections from "@/entrypoints/sidepanel/utils/sortCollections";
|
import sortCollections from "@/entrypoints/sidepanel/utils/sortCollections";
|
||||||
|
import { track } from "@/features/analytics";
|
||||||
import useSettings from "@/hooks/useSettings";
|
import useSettings from "@/hooks/useSettings";
|
||||||
import { CollectionItem } from "@/models/CollectionModels";
|
import { CollectionItem } from "@/models/CollectionModels";
|
||||||
import { DndContext, DragEndEvent, DragOverlay, DragStartEvent, MouseSensor, TouchSensor, useSensor, useSensors } from "@dnd-kit/core";
|
import { DndContext, DragEndEvent, DragOverlay, DragStartEvent, MouseSensor, TouchSensor, useSensor, useSensors } from "@dnd-kit/core";
|
||||||
@@ -65,7 +66,7 @@ export default function CollectionListView(): ReactElement
|
|||||||
if (sortMode !== "custom")
|
if (sortMode !== "custom")
|
||||||
setSortMode("custom");
|
setSortMode("custom");
|
||||||
|
|
||||||
analytics.track("used_drag_and_drop");
|
track("used_drag_and_drop");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BuyMeACoffee20Regular } from "@/assets/BuyMeACoffee20";
|
import { BuyMeACoffee20Regular } from "@/assets/BuyMeACoffee20";
|
||||||
import { buyMeACoffeeLink, storeLink } from "@/data/links";
|
import { buyMeACoffeeLink, storeLink } from "@/data/links";
|
||||||
|
import { track } from "@/features/analytics";
|
||||||
import { useBmcStyles } from "@/hooks/useBmcStyles";
|
import { useBmcStyles } from "@/hooks/useBmcStyles";
|
||||||
import extLink from "@/utils/extLink";
|
import extLink from "@/utils/extLink";
|
||||||
import { Button, Link, MessageBar, MessageBarActions, MessageBarBody, MessageBarProps, MessageBarTitle } from "@fluentui/react-components";
|
import { Button, Link, MessageBar, MessageBarActions, MessageBarBody, MessageBarProps, MessageBarTitle } from "@fluentui/react-components";
|
||||||
@@ -29,9 +30,9 @@ export default function CtaMessage(props: MessageBarProps): ReactElement
|
|||||||
setCounter(counter);
|
setCounter(counter);
|
||||||
|
|
||||||
if (counter === -1)
|
if (counter === -1)
|
||||||
analytics.track("bmc_clicked");
|
track("bmc_clicked");
|
||||||
else
|
else
|
||||||
analytics.track("cta_dismissed");
|
track("cta_dismissed");
|
||||||
};
|
};
|
||||||
|
|
||||||
if (counter < 50)
|
if (counter < 50)
|
||||||
@@ -41,7 +42,7 @@ export default function CtaMessage(props: MessageBarProps): ReactElement
|
|||||||
<MessageBar layout="multiline" icon={ <HeartFilled color="red" /> } { ...props }>
|
<MessageBar layout="multiline" icon={ <HeartFilled color="red" /> } { ...props }>
|
||||||
<MessageBarBody>
|
<MessageBarBody>
|
||||||
<MessageBarTitle>{ i18n.t("cta_message.title") }</MessageBarTitle>
|
<MessageBarTitle>{ i18n.t("cta_message.title") }</MessageBarTitle>
|
||||||
{ i18n.t("cta_message.message") } <Link { ...extLink(storeLink) } onClick={ () => analytics.track("feedback_clicked") }>{ i18n.t("cta_message.feedback") }</Link>
|
{ i18n.t("cta_message.message") } <Link { ...extLink(storeLink) } onClick={ () => track("feedback_clicked") }>{ i18n.t("cta_message.feedback") }</Link>
|
||||||
</MessageBarBody>
|
</MessageBarBody>
|
||||||
<MessageBarActions
|
<MessageBarActions
|
||||||
containerAction={
|
containerAction={
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BuyMeACoffee20Filled, BuyMeACoffee20Regular } from "@/assets/BuyMeACoffee20";
|
import { BuyMeACoffee20Filled, BuyMeACoffee20Regular } from "@/assets/BuyMeACoffee20";
|
||||||
import { buyMeACoffeeLink, githubLinks, storeLink } from "@/data/links";
|
import { buyMeACoffeeLink, githubLinks, storeLink } from "@/data/links";
|
||||||
|
import { track } from "@/features/analytics";
|
||||||
import useSettings from "@/hooks/useSettings";
|
import useSettings from "@/hooks/useSettings";
|
||||||
import extLink from "@/utils/extLink";
|
import extLink from "@/utils/extLink";
|
||||||
import sendNotification from "@/utils/sendNotification";
|
import sendNotification from "@/utils/sendNotification";
|
||||||
@@ -41,10 +42,10 @@ export default function MoreButton(): ReactElement
|
|||||||
|
|
||||||
<fui.MenuDivider />
|
<fui.MenuDivider />
|
||||||
|
|
||||||
<fui.MenuItemLink icon={ <BmcIcon /> } { ...extLink(buyMeACoffeeLink) } onClick={ () => analytics.track("feedback_clicked") }>
|
<fui.MenuItemLink icon={ <BmcIcon /> } { ...extLink(buyMeACoffeeLink) } onClick={ () => track("feedback_clicked") }>
|
||||||
{ i18n.t("common.cta.sponsor") }
|
{ i18n.t("common.cta.sponsor") }
|
||||||
</fui.MenuItemLink>
|
</fui.MenuItemLink>
|
||||||
<fui.MenuItemLink icon={ <FeedbackIcon /> } { ...extLink(storeLink) } onClick={ () => analytics.track("bmc_clicked") }>
|
<fui.MenuItemLink icon={ <FeedbackIcon /> } { ...extLink(storeLink) } onClick={ () => track("bmc_clicked") }>
|
||||||
{ i18n.t("common.cta.feedback") }
|
{ i18n.t("common.cta.feedback") }
|
||||||
</fui.MenuItemLink>
|
</fui.MenuItemLink>
|
||||||
<fui.MenuItemLink icon={ <LearnIcon /> } { ...extLink(githubLinks.release) } >
|
<fui.MenuItemLink icon={ <LearnIcon /> } { ...extLink(githubLinks.release) } >
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export { default as userPropertiesStorage } from "./utils/userPropertiesStorage";
|
export { default as userPropertiesStorage } from "./utils/userPropertiesStorage";
|
||||||
export { default as trackError } from "./utils/trackError";
|
export { default as trackError } from "./utils/trackError";
|
||||||
|
export { default as track } from "./utils/track";
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
export default function track(eventName: string, eventProperties?: Record<string, string>): void
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
analytics.track(eventName, eventProperties);
|
||||||
|
}
|
||||||
|
catch (ex)
|
||||||
|
{
|
||||||
|
console.error("Failed to send analytics event", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
export default function trackError(name: string, error: Error): void
|
export default function trackError(name: string, error: Error): void
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
analytics.track(name, {
|
analytics.track(name, {
|
||||||
name: error.name,
|
name: error.name,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
stack: error.stack ?? "no_stack"
|
stack: error.stack ?? "no_stack"
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
catch (ex)
|
||||||
|
{
|
||||||
|
console.error("Failed to send error report", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useTheme } from "@/contexts/ThemeProvider";
|
import { useTheme } from "@/contexts/ThemeProvider";
|
||||||
import { v3blogPost } from "@/data/links";
|
import { v3blogPost } from "@/data/links";
|
||||||
|
import { track } from "@/features/analytics";
|
||||||
import extLink from "@/utils/extLink";
|
import extLink from "@/utils/extLink";
|
||||||
import * as fui from "@fluentui/react-components";
|
import * as fui from "@fluentui/react-components";
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ export default function WelcomeDialog(): React.ReactElement
|
|||||||
<fui.DialogTrigger disableButtonEnhancement>
|
<fui.DialogTrigger disableButtonEnhancement>
|
||||||
<fui.Button
|
<fui.Button
|
||||||
appearance="primary" as="a" { ...extLink(v3blogPost) }
|
appearance="primary" as="a" { ...extLink(v3blogPost) }
|
||||||
onClick={ () => analytics.track("visit_blog_button_click") }
|
onClick={ () => track("visit_blog_button_click") }
|
||||||
>
|
>
|
||||||
{ i18n.t("features.v3welcome.actions.visit_blog") }
|
{ i18n.t("features.v3welcome.actions.visit_blog") }
|
||||||
</fui.Button>
|
</fui.Button>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { track } from "@/features/analytics";
|
||||||
import { CollectionItem, GroupItem } from "@/models/CollectionModels";
|
import { CollectionItem, GroupItem } from "@/models/CollectionModels";
|
||||||
import { Tabs } from "wxt/browser";
|
import { Tabs } from "wxt/browser";
|
||||||
import { settings } from "./settings";
|
|
||||||
import sendNotification from "./sendNotification";
|
import sendNotification from "./sendNotification";
|
||||||
|
import { settings } from "./settings";
|
||||||
|
|
||||||
export default async function saveTabsToCollection(closeTabs: boolean): Promise<CollectionItem>
|
export default async function saveTabsToCollection(closeTabs: boolean): Promise<CollectionItem>
|
||||||
{
|
{
|
||||||
@@ -24,7 +25,7 @@ export default async function saveTabsToCollection(closeTabs: boolean): Promise<
|
|||||||
if (closeTabs)
|
if (closeTabs)
|
||||||
await browser.tabs.remove(tabsToClose.map(i => i.id!));
|
await browser.tabs.remove(tabsToClose.map(i => i.id!));
|
||||||
|
|
||||||
analytics.track(closeTabs ? "set_aside" : "save");
|
track(closeTabs ? "set_aside" : "save");
|
||||||
|
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user