mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
chore(core): replace with new track impl (#7735)
This commit is contained in:
@@ -3,7 +3,7 @@ import {
|
||||
pushGlobalLoadingEventAtom,
|
||||
resolveGlobalLoadingEventAtom,
|
||||
} from '@affine/component/global-loading';
|
||||
import { mixpanel } from '@affine/core/mixpanel';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { apis } from '@affine/electron-api';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import type { PageRootService, RootBlockModel } from '@blocksuite/blocks';
|
||||
@@ -26,10 +26,8 @@ async function exportHandler({ page, type }: ExportHandlerOptions) {
|
||||
if (editorRoot) {
|
||||
pageService = editorRoot.spec.getService<PageRootService>('affine:page');
|
||||
}
|
||||
mixpanel.track('ShareCreated', {
|
||||
track.$.header.share.export({
|
||||
type,
|
||||
segment: 'sharing panel',
|
||||
module: 'export share',
|
||||
});
|
||||
switch (type) {
|
||||
case 'html':
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
PreconditionStrategy,
|
||||
registerAffineCommand,
|
||||
} from '@affine/core/commands';
|
||||
import { mixpanel } from '@affine/core/mixpanel';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||
import { WorkspaceFlavour } from '@affine/env/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
@@ -161,10 +161,8 @@ export function useRegisterBlocksuiteEditorCommands() {
|
||||
label: t['com.affine.header.option.duplicate'](),
|
||||
run() {
|
||||
duplicate(docId);
|
||||
mixpanel.track('DocCreated', {
|
||||
control: 'cmdk',
|
||||
type: 'doc duplicate',
|
||||
category: 'doc',
|
||||
track.$.cmdk.$.createDoc({
|
||||
control: 'duplicate',
|
||||
});
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { notify } from '@affine/component';
|
||||
import { mixpanel } from '@affine/core/mixpanel';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { getAffineCloudBaseUrl } from '@affine/core/modules/cloud/services/fetch';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import type { Disposable } from '@blocksuite/global/utils';
|
||||
@@ -68,9 +68,8 @@ export const useSharingUrl = ({
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
mixpanel.track('ShareLinkCopied', {
|
||||
module: urlType === 'share' ? 'public share' : 'private share',
|
||||
type: 'link',
|
||||
track.$.header.share.copyShareLink({
|
||||
type: urlType === 'share' ? 'public' : 'private',
|
||||
});
|
||||
} else {
|
||||
notify.error({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useUpgradeNotify } from '@affine/core/components/affine/subscription-landing/notify';
|
||||
import { mixpanel } from '@affine/core/mixpanel';
|
||||
import { track } from '@affine/core/mixpanel';
|
||||
import { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
@@ -129,11 +129,9 @@ export const useSubscriptionNotifyReader = () => {
|
||||
upgradeNotify(link);
|
||||
localStorage.removeItem(localStorageKey);
|
||||
|
||||
// mixpanel
|
||||
mixpanel.track('PlanChangeSucceeded', {
|
||||
category: recurring,
|
||||
type: plan,
|
||||
control: 'new subscription',
|
||||
track.$.$.$.checkout({
|
||||
plan,
|
||||
recurring,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to parse subscription callback link', err);
|
||||
|
||||
@@ -7,7 +7,7 @@ import { atomWithObservable, atomWithStorage } from 'jotai/utils';
|
||||
import { useCallback, useState } from 'react';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { mixpanel } from '../mixpanel';
|
||||
import { track } from '../mixpanel';
|
||||
import { popupWindow } from '../utils';
|
||||
import { useAsyncCallback } from './affine-async-hooks';
|
||||
|
||||
@@ -122,9 +122,7 @@ export const useAppUpdater = () => {
|
||||
);
|
||||
|
||||
const quitAndInstall = useCallback(() => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'QuitAndInstall',
|
||||
});
|
||||
track.$.navigationPanel.bottomButtons.quitAndInstall();
|
||||
if (updateReady) {
|
||||
setAppQuitting(true);
|
||||
apis?.updater.quitAndInstall().catch(err => {
|
||||
@@ -135,9 +133,7 @@ export const useAppUpdater = () => {
|
||||
}, [updateReady]);
|
||||
|
||||
const checkForUpdates = useCallback(async () => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'CheckForUpdates',
|
||||
});
|
||||
track.$.settingsPanel.about.checkUpdates();
|
||||
if (checkingForUpdates) {
|
||||
return;
|
||||
}
|
||||
@@ -154,9 +150,7 @@ export const useAppUpdater = () => {
|
||||
}, [checkingForUpdates, setCheckingForUpdates]);
|
||||
|
||||
const downloadUpdate = useCallback(() => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'DownloadUpdate',
|
||||
});
|
||||
track.$.settingsPanel.about.downloadUpdate();
|
||||
apis?.updater.downloadUpdate().catch(err => {
|
||||
console.error('Error downloading update:', err);
|
||||
});
|
||||
@@ -164,8 +158,8 @@ export const useAppUpdater = () => {
|
||||
|
||||
const toggleAutoDownload = useCallback(
|
||||
(enable: boolean) => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'ToggleAutoDownload',
|
||||
track.$.settingsPanel.about.changeAppSetting({
|
||||
key: 'autoDownload',
|
||||
value: enable,
|
||||
});
|
||||
setSetting({
|
||||
@@ -177,8 +171,8 @@ export const useAppUpdater = () => {
|
||||
|
||||
const toggleAutoCheck = useCallback(
|
||||
(enable: boolean) => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'ToggleAutoCheck',
|
||||
track.$.settingsPanel.about.changeAppSetting({
|
||||
key: 'autoCheckUpdates',
|
||||
value: enable,
|
||||
});
|
||||
setSetting({
|
||||
@@ -189,17 +183,13 @@ export const useAppUpdater = () => {
|
||||
);
|
||||
|
||||
const openChangelog = useAsyncCallback(async () => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'OpenChangelog',
|
||||
});
|
||||
track.$.navigationPanel.bottomButtons.openChangelog();
|
||||
popupWindow(runtimeConfig.changelogUrl);
|
||||
await setChangelogUnread(true);
|
||||
}, [setChangelogUnread]);
|
||||
|
||||
const dismissChangelog = useAsyncCallback(async () => {
|
||||
mixpanel.track('Button', {
|
||||
resolve: 'DismissChangelog',
|
||||
});
|
||||
track.$.navigationPanel.bottomButtons.dismissChangelog();
|
||||
await setChangelogUnread(true);
|
||||
}, [setChangelogUnread]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user