Skip to content

Commit

Permalink
Merge pull request #795 from update-host
Browse files Browse the repository at this point in the history
Update host
  • Loading branch information
u1-liquid authored Nov 7, 2024
2 parents 0a31e31 + 4466bcc commit ec4835f
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "2024.5.0-host.4",
"version": "2024.5.0-host.4a",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
27 changes: 24 additions & 3 deletions packages/backend/src/server/sso/SAMLIdentifyProviderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
22 changes: 21 additions & 1 deletion packages/frontend/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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を同期
Expand Down Expand Up @@ -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({
Expand All @@ -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,
});
}
});
}
}
Expand Down Expand Up @@ -105,6 +114,7 @@ export async function removeAccount(idOrToken: Account['id']) {

function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> {
return new Promise((done, fail) => {
const initiateTime = Date.now();
window.fetch(`${apiUrl}/i`, {
method: 'POST',
body: JSON.stringify({
Expand All @@ -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<Account | { error: Record<string, any> }>((done2, fail2) => {
if (res.status >= 500 && res.status < 600) {
// サーバーエラー(5xx)の場合をrejectとする
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/boot/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ export async function common(createVue: () => App<Element>) {
app.use(VueGtag, {
bootstrap: false,
appName: `Misskey v${version}`,
pageTrackerEnabled: true,
pageTrackerScreenviewEnabled: true,
config: {
id: instance.googleAnalyticsId,
params: {
Expand Down
19 changes: 18 additions & 1 deletion packages/frontend/src/components/MkPageWindow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { computed, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
import { computed, nextTick, onMounted, onUnmounted, provide, ref, shallowRef } from 'vue';
import RouterView from '@/components/global/RouterView.vue';
import MkWindow from '@/components/MkWindow.vue';
import { popout as _popout } from '@/scripts/popout.js';
Expand All @@ -43,6 +43,8 @@ import { claimAchievement } from '@/scripts/achievements.js';
import { getScrollContainer } from '@/scripts/scroll.js';
import { useRouterFactory } from '@/router/supplier.js';
import { mainRouter } from '@/router/main.js';
import { instance } from '@/instance.js';
import { pageview } from 'vue-gtag';
const props = defineProps<{
initialPath: string;
Expand Down Expand Up @@ -110,6 +112,21 @@ provide('shouldOmitHeaderTitle', true);
provide('shouldHeaderThin', true);
provide('forceSpacerMin', true);
if (instance.googleAnalyticsId) {
pageview({
page_title: pageMetadata.value?.title,
page_path: windowRouter.getCurrentPath(),
});
windowRouter.afterEach(() =>
nextTick(() =>
pageview({
page_title: pageMetadata.value?.title,
page_path: windowRouter.getCurrentPath(),
}),
),
);
}
const contextmenu = computed(() => ([{
icon: 'ti ti-player-eject',
text: i18n.ts.showInPage,
Expand Down
22 changes: 22 additions & 0 deletions packages/frontend/src/scripts/misskey-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { ref } from 'vue';
import { apiUrl } from '@/config.js';
import { $i } from '@/account.js';
import { miLocalStorage } from '@/local-storage.js';
import { time as gtagTime } from 'vue-gtag';
import { instance } from '@/instance.js';
export const pendingApiRequestsCount = ref(0);

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

// Send request
const initiateTime = Date.now();
window.fetch(`${apiUrl}/${endpoint}`, {
method: 'POST',
body: JSON.stringify(data),
Expand All @@ -76,6 +79,15 @@ export function misskeyApi<
'X-Client-Transaction-Id': generateClientTransactionId(initiator),
},
signal,
}).then(res => {
if (instance.googleAnalyticsId) {
gtagTime({
name: 'api',
event_category: `/${endpoint}`,
value: Date.now() - initiateTime,
});
}
return res;
}).then(handleResponse(resolve, reject)).catch(reject);
});

Expand Down Expand Up @@ -105,13 +117,23 @@ export function misskeyApiGet<

const promise = new Promise<_ResT>((resolve, reject) => {
// Send request
const initiateTime = Date.now();
window.fetch(`${apiUrl}/${endpoint}?${query}`, {
method: 'GET',
credentials: 'omit',
cache: 'default',
headers: {
'X-Client-Transaction-Id': generateClientTransactionId(initiator),
},
}).then(res => {
if (instance.googleAnalyticsId) {
gtagTime({
name: 'api-get',
event_category: `/${endpoint}?${query}`,
value: Date.now() - initiateTime,
});
}
return res;
}).then(handleResponse(resolve, reject)).catch(reject);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/scripts/usage-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/misskey-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "misskey-js",
"version": "2024.5.0-host.4",
"version": "2024.5.0-host.4a",
"description": "Misskey SDK for JavaScript",
"types": "./built/dts/index.d.ts",
"exports": {
Expand Down

0 comments on commit ec4835f

Please sign in to comment.