@@ -14,7 +14,7 @@ import { apiUrl } from '@/config.js';
14
14
import { waiting , popup , popupMenu , success , alert } from '@/os.js' ;
15
15
import { generateClientTransactionId , misskeyApi } from '@/scripts/misskey-api.js' ;
16
16
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' ;
18
18
import { instance } from '@/instance.js' ;
19
19
20
20
// TODO: 他のタブと永続化されたstateを同期
@@ -53,6 +53,7 @@ export async function signout() {
53
53
const registration = await navigator . serviceWorker . ready ;
54
54
const push = await registration . pushManager . getSubscription ( ) ;
55
55
if ( push ) {
56
+ const initiateTime = Date . now ( ) ;
56
57
await window . fetch ( `${ apiUrl } /sw/unregister` , {
57
58
method : 'POST' ,
58
59
body : JSON . stringify ( {
@@ -63,6 +64,14 @@ export async function signout() {
63
64
'Content-Type' : 'application/json' ,
64
65
'X-Client-Transaction-Id' : generateClientTransactionId ( 'misskey' ) ,
65
66
} ,
67
+ } ) . then ( ( ) => {
68
+ if ( instance . googleAnalyticsId ) {
69
+ gtagTime ( {
70
+ name : 'api' ,
71
+ event_category : '/sw/unregister' ,
72
+ value : Date . now ( ) - initiateTime ,
73
+ } ) ;
74
+ }
66
75
} ) ;
67
76
}
68
77
}
@@ -105,6 +114,7 @@ export async function removeAccount(idOrToken: Account['id']) {
105
114
106
115
function fetchAccount ( token : string , id ?: string , forceShowDialog ?: boolean ) : Promise < Account > {
107
116
return new Promise ( ( done , fail ) => {
117
+ const initiateTime = Date . now ( ) ;
108
118
window . fetch ( `${ apiUrl } /i` , {
109
119
method : 'POST' ,
110
120
body : JSON . stringify ( {
@@ -115,6 +125,16 @@ function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Pr
115
125
'X-Client-Transaction-Id' : generateClientTransactionId ( 'misskey' ) ,
116
126
} ,
117
127
} )
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
+ } )
118
138
. then ( res => new Promise < Account | { error : Record < string , any > } > ( ( done2 , fail2 ) => {
119
139
if ( res . status >= 500 && res . status < 600 ) {
120
140
// サーバーエラー(5xx)の場合をrejectとする
0 commit comments