Skip to content

Commit de062cb

Browse files
committed
Merge tag '2024.5.0-io.4a' into bun
2 parents ceea65b + 781f602 commit de062cb

File tree

8 files changed

+90
-8
lines changed

8 files changed

+90
-8
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "misskey",
3-
"version": "2024.5.0-io.4",
3+
"version": "2024.5.0-io.4a",
44
"codename": "nasubi",
55
"repository": {
66
"type": "git",

packages/backend/src/server/sso/SAMLIdentifyProviderService.ts

+24-3
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,28 @@ export class SAMLIdentifyProviderService {
495495
'#text': user.id,
496496
},
497497
},
498-
...(user.name ? [{
498+
{
499+
'@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn',
500+
'saml:AttributeValue': {
501+
'@xsi:type': 'xs:string',
502+
'#text': user.id,
503+
},
504+
},
505+
{
499506
'@Name': 'firstName',
500507
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
501508
'saml:AttributeValue': {
502509
'@xsi:type': 'xs:string',
503-
'#text': user.name,
510+
'#text': user.name ? user.name : 'Misskey User',
504511
},
505-
}] : []),
512+
},
513+
{
514+
'@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname',
515+
'saml:AttributeValue': {
516+
'@xsi:type': 'xs:string',
517+
'#text': user.name ? user.name : 'Misskey User',
518+
},
519+
},
506520
{
507521
'@Name': 'lastName',
508522
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',
@@ -511,6 +525,13 @@ export class SAMLIdentifyProviderService {
511525
'#text': `@${user.username}`,
512526
},
513527
},
528+
{
529+
'@Name': 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname',
530+
'saml:AttributeValue': {
531+
'@xsi:type': 'xs:string',
532+
'#text': `@${user.username}`,
533+
},
534+
},
514535
{
515536
'@Name': 'displayName',
516537
'@NameFormat': 'urn:oasis:names:tc:SAML:2.0:attrname-format:basic',

packages/frontend/src/account.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { apiUrl } from '@/config.js';
1414
import { waiting, popup, popupMenu, success, alert } from '@/os.js';
1515
import { generateClientTransactionId, misskeyApi } from '@/scripts/misskey-api.js';
1616
import { unisonReload, reloadChannel } from '@/scripts/unison-reload.js';
17-
import { set as gtagSet } from 'vue-gtag';
17+
import { set as gtagSet, time as gtagTime } from 'vue-gtag';
1818
import { instance } from '@/instance.js';
1919

2020
// TODO: 他のタブと永続化されたstateを同期
@@ -53,6 +53,7 @@ export async function signout() {
5353
const registration = await navigator.serviceWorker.ready;
5454
const push = await registration.pushManager.getSubscription();
5555
if (push) {
56+
const initiateTime = Date.now();
5657
await window.fetch(`${apiUrl}/sw/unregister`, {
5758
method: 'POST',
5859
body: JSON.stringify({
@@ -63,6 +64,14 @@ export async function signout() {
6364
'Content-Type': 'application/json',
6465
'X-Client-Transaction-Id': generateClientTransactionId('misskey'),
6566
},
67+
}).then(() => {
68+
if (instance.googleAnalyticsId) {
69+
gtagTime({
70+
name: 'api',
71+
event_category: '/sw/unregister',
72+
value: Date.now() - initiateTime,
73+
});
74+
}
6675
});
6776
}
6877
}
@@ -105,6 +114,7 @@ export async function removeAccount(idOrToken: Account['id']) {
105114

106115
function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> {
107116
return new Promise((done, fail) => {
117+
const initiateTime = Date.now();
108118
window.fetch(`${apiUrl}/i`, {
109119
method: 'POST',
110120
body: JSON.stringify({
@@ -115,6 +125,16 @@ function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Pr
115125
'X-Client-Transaction-Id': generateClientTransactionId('misskey'),
116126
},
117127
})
128+
.then(res => {
129+
if (instance.googleAnalyticsId) {
130+
gtagTime({
131+
name: 'api',
132+
event_category: '/i',
133+
value: Date.now() - initiateTime,
134+
});
135+
}
136+
return res;
137+
})
118138
.then(res => new Promise<Account | { error: Record<string, any> }>((done2, fail2) => {
119139
if (res.status >= 500 && res.status < 600) {
120140
// サーバーエラー(5xx)の場合をrejectとする

packages/frontend/src/boot/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ export async function common(createVue: () => App<Element>) {
270270
app.use(VueGtag, {
271271
bootstrap: false,
272272
appName: `Misskey v${version}`,
273+
pageTrackerEnabled: true,
274+
pageTrackerScreenviewEnabled: true,
273275
config: {
274276
id: instance.googleAnalyticsId,
275277
params: {

packages/frontend/src/components/MkPageWindow.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
2929
</template>
3030

3131
<script lang="ts" setup>
32-
import { computed, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
32+
import { computed, nextTick, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
3333
import RouterView from '@/components/global/RouterView.vue';
3434
import MkWindow from '@/components/MkWindow.vue';
3535
import { popout as _popout } from '@/scripts/popout.js';
@@ -43,6 +43,8 @@ import { claimAchievement } from '@/scripts/achievements.js';
4343
import { getScrollContainer } from '@/scripts/scroll.js';
4444
import { useRouterFactory } from '@/router/supplier.js';
4545
import { mainRouter } from '@/router/main.js';
46+
import { instance } from '@/instance.js';
47+
import { pageview } from 'vue-gtag';
4648

4749
const props = defineProps<{
4850
initialPath: string;
@@ -110,6 +112,21 @@ provide('shouldOmitHeaderTitle', true);
110112
provide('shouldHeaderThin', true);
111113
provide('forceSpacerMin', true);
112114

115+
if (instance.googleAnalyticsId) {
116+
pageview({
117+
page_title: pageMetadata.value?.title,
118+
page_path: windowRouter.getCurrentPath(),
119+
});
120+
windowRouter.afterEach(() =>
121+
nextTick(() =>
122+
pageview({
123+
page_title: pageMetadata.value?.title,
124+
page_path: windowRouter.getCurrentPath(),
125+
}),
126+
),
127+
);
128+
}
129+
113130
const contextmenu = computed(() => ([{
114131
icon: 'ti ti-player-eject',
115132
text: i18n.ts.showInPage,

packages/frontend/src/scripts/misskey-api.ts

+22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ref } from 'vue';
88
import { apiUrl } from '@/config.js';
99
import { $i } from '@/account.js';
1010
import { miLocalStorage } from '@/local-storage.js';
11+
import { time as gtagTime } from 'vue-gtag';
12+
import { instance } from '@/instance.js';
1113
export const pendingApiRequestsCount = ref(0);
1214

1315
let id: string | null = miLocalStorage.getItem('id');
@@ -66,6 +68,7 @@ export function misskeyApi<
6668
if (token !== undefined) (data as any).i = token;
6769

6870
// Send request
71+
const initiateTime = Date.now();
6972
window.fetch(`${apiUrl}/${endpoint}`, {
7073
method: 'POST',
7174
body: JSON.stringify(data),
@@ -76,6 +79,15 @@ export function misskeyApi<
7679
'X-Client-Transaction-Id': generateClientTransactionId(initiator),
7780
},
7881
signal,
82+
}).then(res => {
83+
if (instance.googleAnalyticsId) {
84+
gtagTime({
85+
name: 'api',
86+
event_category: `/${endpoint}`,
87+
value: Date.now() - initiateTime,
88+
});
89+
}
90+
return res;
7991
}).then(handleResponse(resolve, reject)).catch(reject);
8092
});
8193

@@ -105,13 +117,23 @@ export function misskeyApiGet<
105117

106118
const promise = new Promise<_ResT>((resolve, reject) => {
107119
// Send request
120+
const initiateTime = Date.now();
108121
window.fetch(`${apiUrl}/${endpoint}?${query}`, {
109122
method: 'GET',
110123
credentials: 'omit',
111124
cache: 'default',
112125
headers: {
113126
'X-Client-Transaction-Id': generateClientTransactionId(initiator),
114127
},
128+
}).then(res => {
129+
if (instance.googleAnalyticsId) {
130+
gtagTime({
131+
name: 'api-get',
132+
event_category: `/${endpoint}?${query}`,
133+
value: Date.now() - initiateTime,
134+
});
135+
}
136+
return res;
115137
}).then(handleResponse(resolve, reject)).catch(reject);
116138
});
117139

packages/frontend/src/scripts/usage-report.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function usageReport(data: UsageReport) {
2727

2828
if (usageReportBuffer.length > 0) {
2929
const last = usageReportBuffer[usageReportBuffer.length - 1];
30-
if (last.t === data.t && last.e === data.e && last.a === data.a) return;
30+
if (last.t === data.t && last.e === data.e && last.i === data.i && last.a === data.a) return;
3131
}
3232

3333
usageReportBuffer.push(data);

packages/misskey-js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "misskey-js",
4-
"version": "2024.5.0-io.4",
4+
"version": "2024.5.0-io.4a",
55
"description": "Misskey SDK for JavaScript",
66
"types": "./built/dts/index.d.ts",
77
"exports": {

0 commit comments

Comments
 (0)