Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: google analytics #15451

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
4 changes: 3 additions & 1 deletion packages/frontend/src/components/MkPageWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ SPDX-License-Identifier: AGPL-3.0-only
import { computed, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
import { url } from '@@/js/config.js';
import { getScrollContainer } from '@@/js/scroll.js';
import type { PageMetadata } from '@/scripts/page-metadata.js';
import RouterView from '@/components/global/RouterView.vue';
import MkWindow from '@/components/MkWindow.vue';
import { popout as _popout } from '@/scripts/popout.js';
import { copyToClipboard } from '@/scripts/copy-to-clipboard.js';
import { useScrollPositionManager } from '@/nirax.js';
import { i18n } from '@/i18n.js';
import { provideMetadataReceiver, provideReactiveMetadata } from '@/scripts/page-metadata.js';
import type { PageMetadata } from '@/scripts/page-metadata.js';
import { openingWindowsCount } from '@/os.js';
import { claimAchievement } from '@/scripts/achievements.js';
import { useRouterFactory } from '@/router/supplier.js';
Expand Down Expand Up @@ -92,6 +92,8 @@ const reloadCount = ref(0);

windowRouter.addListener('push', ctx => {
history.value.push({ path: ctx.path, key: ctx.key });

// ga
});

windowRouter.addListener('replace', ctx => {
Expand Down
5 changes: 5 additions & 0 deletions packages/frontend/src/router/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EventEmitter } from 'eventemitter3';
import type { IRouter, Resolved, RouteDef, RouterEvent, RouterFlag } from '@/nirax.js';

import type { App, ShallowRef } from 'vue';
import { analytics } from '@/analytics.js';

/**
* {@link Router}による画面遷移を可能とするために{@link mainRouter}をセットアップする。
Expand All @@ -23,6 +24,10 @@ export function setupRouter(app: App, routerFactory: ((path: string) => IRouter)

mainRouter.addListener('push', ctx => {
window.history.pushState({ key: ctx.key }, '', ctx.path);

analytics.page({
path: ctx.path,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaceに反応しないのでchangeイベントで取ったほうがいいかも

});

mainRouter.addListener('replace', ctx => {
Expand Down
Loading