From fcd75902ccef4fecfbe71ebe4f3fb923676ed98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:58:06 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat(analytics):=20=E3=82=A4=E3=83=99?= =?UTF-8?q?=E3=83=B3=E3=83=88=E3=81=AE=E9=87=8D=E8=A4=87=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=AB=E3=82=BF=E3=83=BC=E3=81=AE=E4=BF=AE=E6=AD=A3=20(Missk?= =?UTF-8?q?eyIO#791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/usage-report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/scripts/usage-report.ts b/packages/frontend/src/scripts/usage-report.ts index 4ad677da7281..55433ad50973 100644 --- a/packages/frontend/src/scripts/usage-report.ts +++ b/packages/frontend/src/scripts/usage-report.ts @@ -27,7 +27,7 @@ export function usageReport(data: UsageReport) { if (usageReportBuffer.length > 0) { const last = usageReportBuffer[usageReportBuffer.length - 1]; - if (last.t === data.t && last.e === data.e && last.a === data.a) return; + if (last.t === data.t && last.e === data.e && last.i === data.i && last.a === data.a) return; } usageReportBuffer.push(data); From 9559fbefe048b0069c39d35f957d2eb1c019e771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Thu, 7 Nov 2024 10:08:32 +0900 Subject: [PATCH 2/4] =?UTF-8?q?spec(SSO/SAML):=20Attribute=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=20(MisskeyIO#792)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/sso/SAMLIdentifyProviderService.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts b/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts index 60ce37d8eaa8..dbf004e27f0e 100644 --- a/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts +++ b/packages/backend/src/server/sso/SAMLIdentifyProviderService.ts @@ -495,14 +495,28 @@ export class SAMLIdentifyProviderService { '#text': user.id, }, }, - ...(user.name ? [{ + { + '@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn', + 'saml:AttributeValue': { + '@xsi:type': 'xs:string', + '#text': user.id, + }, + }, + { '@Name': 'firstName', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', 'saml:AttributeValue': { '@xsi:type': 'xs:string', - '#text': user.name, + '#text': user.name ? user.name : 'Misskey User', }, - }] : []), + }, + { + '@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname', + 'saml:AttributeValue': { + '@xsi:type': 'xs:string', + '#text': user.name ? user.name : 'Misskey User', + }, + }, { '@Name': 'lastName', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', @@ -511,6 +525,13 @@ export class SAMLIdentifyProviderService { '#text': `@${user.username}`, }, }, + { + '@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname', + 'saml:AttributeValue': { + '@xsi:type': 'xs:string', + '#text': `@${user.username}`, + }, + }, { '@Name': 'displayName', '@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic', From 122ed3c82dbcad02f2fe03ff5afee9f8cd4387d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:24:13 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat(analytics):=20=E3=83=87=E3=83=83?= =?UTF-8?q?=E3=82=ADUI=E3=81=AE=E3=83=9A=E3=83=BC=E3=82=B8=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=E3=81=A8API=E3=81=AE=E5=BF=9C=E7=AD=94=E6=99=82?= =?UTF-8?q?=E9=96=93=E3=81=AE=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E5=AE=9F?= =?UTF-8?q?=E8=A3=85=20(MisskeyIO#793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/account.ts | 22 ++++++++++++++++++- packages/frontend/src/boot/common.ts | 2 ++ .../frontend/src/components/MkPageWindow.vue | 19 +++++++++++++++- packages/frontend/src/scripts/misskey-api.ts | 22 +++++++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/account.ts b/packages/frontend/src/account.ts index c11e6e91257b..a34a70df0e10 100644 --- a/packages/frontend/src/account.ts +++ b/packages/frontend/src/account.ts @@ -14,7 +14,7 @@ import { apiUrl } from '@/config.js'; import { waiting, popup, popupMenu, success, alert } from '@/os.js'; import { generateClientTransactionId, misskeyApi } from '@/scripts/misskey-api.js'; import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js'; -import { set as gtagSet } from 'vue-gtag'; +import { set as gtagSet, time as gtagTime } from 'vue-gtag'; import { instance } from '@/instance.js'; // TODO: 他のタブと永続化されたstateを同期 @@ -53,6 +53,7 @@ export async function signout() { const registration = await navigator.serviceWorker.ready; const push = await registration.pushManager.getSubscription(); if (push) { + const initiateTime = Date.now(); await window.fetch(`${apiUrl}/sw/unregister`, { method: 'POST', body: JSON.stringify({ @@ -63,6 +64,14 @@ export async function signout() { 'Content-Type': 'application/json', 'X-Client-Transaction-Id': generateClientTransactionId('misskey'), }, + }).then(() => { + if (instance.googleAnalyticsId) { + gtagTime({ + name: 'api', + event_category: '/sw/unregister', + value: Date.now() - initiateTime, + }); + } }); } } @@ -105,6 +114,7 @@ export async function removeAccount(idOrToken: Account['id']) { function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise { return new Promise((done, fail) => { + const initiateTime = Date.now(); window.fetch(`${apiUrl}/i`, { method: 'POST', body: JSON.stringify({ @@ -115,6 +125,16 @@ function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Pr 'X-Client-Transaction-Id': generateClientTransactionId('misskey'), }, }) + .then(res => { + if (instance.googleAnalyticsId) { + gtagTime({ + name: 'api', + event_category: '/i', + value: Date.now() - initiateTime, + }); + } + return res; + }) .then(res => new Promise }>((done2, fail2) => { if (res.status >= 500 && res.status < 600) { // サーバーエラー(5xx)の場合をrejectとする diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 421619d928be..79ef7b3f2d67 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -270,6 +270,8 @@ export async function common(createVue: () => App) { app.use(VueGtag, { bootstrap: false, appName: `Misskey v${version}`, + pageTrackerEnabled: true, + pageTrackerScreenviewEnabled: true, config: { id: instance.googleAnalyticsId, params: { diff --git a/packages/frontend/src/components/MkPageWindow.vue b/packages/frontend/src/components/MkPageWindow.vue index aa4509b14b62..13d03abf30df 100644 --- a/packages/frontend/src/components/MkPageWindow.vue +++ b/packages/frontend/src/components/MkPageWindow.vue @@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only