@adventurelabs/scout-core 1.4.49 → 1.4.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -117,38 +117,42 @@ export function useScoutRefresh(options = {}) {
|
|
|
117
117
|
// Background fetch fresh data without blocking
|
|
118
118
|
(async () => {
|
|
119
119
|
try {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
120
|
+
const userPromise = (async () => {
|
|
121
|
+
const start = Date.now();
|
|
122
|
+
const { data } = await supabase.auth.getUser();
|
|
123
|
+
const duration = Date.now() - start;
|
|
124
|
+
timingRefs.current.userApiDuration = duration;
|
|
125
|
+
dispatch(setUserApiDuration(duration));
|
|
126
|
+
if (data.user) {
|
|
127
|
+
dispatch(setUser(data.user));
|
|
128
|
+
}
|
|
129
|
+
return data.user ?? null;
|
|
130
|
+
})();
|
|
131
|
+
let backgroundHerdModulesResult;
|
|
132
|
+
try {
|
|
133
|
+
const start = Date.now();
|
|
134
|
+
const result = await server_load_herd_modules();
|
|
135
|
+
const totalDuration = Date.now() - start;
|
|
136
|
+
const serverDuration = result.server_processing_time_ms || totalDuration;
|
|
137
|
+
const clientOverhead = totalDuration - serverDuration;
|
|
138
|
+
console.log(`[useScoutRefresh] Background API timing breakdown:`);
|
|
139
|
+
console.log(` - Server processing: ${serverDuration}ms`);
|
|
140
|
+
console.log(` - Client overhead: ${clientOverhead}ms`);
|
|
141
|
+
console.log(` - Total request: ${totalDuration}ms`);
|
|
142
|
+
timingRefs.current.herdModulesDuration = serverDuration;
|
|
143
|
+
dispatch(setHerdModulesApiServerProcessingDuration(serverDuration));
|
|
144
|
+
dispatch(setHerdModulesApiTotalRequestDuration(totalDuration));
|
|
145
|
+
backgroundHerdModulesResult = result;
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
await userPromise.catch(() => { });
|
|
149
|
+
throw e;
|
|
150
|
+
}
|
|
151
|
+
const backgroundUserResult = await userPromise;
|
|
147
152
|
// Validate background responses
|
|
148
153
|
if (backgroundHerdModulesResult.data &&
|
|
149
154
|
Array.isArray(backgroundHerdModulesResult.data) &&
|
|
150
|
-
backgroundUserResult
|
|
151
|
-
backgroundUserResult.data) {
|
|
155
|
+
backgroundUserResult) {
|
|
152
156
|
// Update cache with fresh data
|
|
153
157
|
try {
|
|
154
158
|
await scoutCache.setHerdModules(backgroundHerdModulesResult.data, cacheTtlMs);
|
|
@@ -164,10 +168,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
164
168
|
// Update store with fresh data from background request
|
|
165
169
|
console.log(`[useScoutRefresh] Updating store with background herd modules`);
|
|
166
170
|
dispatch(setHerdModules(backgroundHerdModulesResult.data));
|
|
167
|
-
if (backgroundUserResult && backgroundUserResult.data) {
|
|
168
|
-
console.log(`[useScoutRefresh] Updating store with background user data`);
|
|
169
|
-
dispatch(setUser(backgroundUserResult.data));
|
|
170
|
-
}
|
|
171
171
|
// Update data source to DATABASE
|
|
172
172
|
dispatch(setDataSource(EnumDataSource.DATABASE));
|
|
173
173
|
dispatch(setDataSourceInfo({
|
|
@@ -226,35 +226,41 @@ export function useScoutRefresh(options = {}) {
|
|
|
226
226
|
lastQueryAtRef.current = Date.now();
|
|
227
227
|
return;
|
|
228
228
|
}
|
|
229
|
-
// Step 2: Load fresh data from API
|
|
229
|
+
// Step 2: Load fresh data from API (user resolves independently; Redux gets user as soon as getUser returns)
|
|
230
230
|
const parallelStartTime = Date.now();
|
|
231
|
-
const
|
|
232
|
-
|
|
231
|
+
const userPromise = (async () => {
|
|
232
|
+
const start = Date.now();
|
|
233
|
+
const { data } = await supabase.auth.getUser();
|
|
234
|
+
const duration = Date.now() - start;
|
|
235
|
+
timingRefs.current.userApiDuration = duration;
|
|
236
|
+
dispatch(setUserApiDuration(duration));
|
|
237
|
+
if (!data.user) {
|
|
238
|
+
throw new Error("Invalid user response");
|
|
239
|
+
}
|
|
240
|
+
dispatch(setUser(data.user));
|
|
241
|
+
return data.user;
|
|
242
|
+
})();
|
|
243
|
+
let herdModulesResult;
|
|
244
|
+
try {
|
|
245
|
+
herdModulesResult = await (async () => {
|
|
233
246
|
const start = Date.now();
|
|
234
247
|
const result = await server_load_herd_modules();
|
|
235
248
|
const totalDuration = Date.now() - start;
|
|
236
249
|
const serverDuration = result.server_processing_time_ms || totalDuration;
|
|
237
250
|
return { result, totalDuration, serverDuration, start };
|
|
238
|
-
})()
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
duration,
|
|
246
|
-
start,
|
|
247
|
-
};
|
|
248
|
-
})(),
|
|
249
|
-
]);
|
|
251
|
+
})();
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
await userPromise.catch(() => { });
|
|
255
|
+
throw e;
|
|
256
|
+
}
|
|
257
|
+
await userPromise;
|
|
250
258
|
const parallelDuration = Date.now() - parallelStartTime;
|
|
251
|
-
console.log(`[useScoutRefresh]
|
|
259
|
+
console.log(`[useScoutRefresh] API requests completed in ${parallelDuration}ms`);
|
|
252
260
|
// Extract results and timing
|
|
253
261
|
const herdModulesResponse = herdModulesResult.result;
|
|
254
|
-
const res_new_user = userResult.result;
|
|
255
262
|
const herdModulesServerDuration = herdModulesResult.serverDuration;
|
|
256
263
|
const herdModulesTotalDuration = herdModulesResult.totalDuration;
|
|
257
|
-
const userApiDuration = userResult.duration;
|
|
258
264
|
const clientOverhead = herdModulesTotalDuration - herdModulesServerDuration;
|
|
259
265
|
console.log(`[useScoutRefresh] Fresh API timing breakdown:`);
|
|
260
266
|
console.log(` - Server processing: ${herdModulesServerDuration}ms`);
|
|
@@ -262,20 +268,15 @@ export function useScoutRefresh(options = {}) {
|
|
|
262
268
|
console.log(` - Total request: ${herdModulesTotalDuration}ms`);
|
|
263
269
|
// Store timing values
|
|
264
270
|
timingRefs.current.herdModulesDuration = herdModulesServerDuration;
|
|
265
|
-
timingRefs.current.userApiDuration = userApiDuration;
|
|
266
271
|
// Dispatch timing actions
|
|
267
272
|
dispatch(setHerdModulesApiServerProcessingDuration(herdModulesServerDuration));
|
|
268
273
|
dispatch(setHerdModulesApiTotalRequestDuration(herdModulesTotalDuration));
|
|
269
|
-
dispatch(setUserApiDuration(userApiDuration));
|
|
270
274
|
// Validate API responses
|
|
271
275
|
const validationStartTime = Date.now();
|
|
272
276
|
if (!herdModulesResponse.data ||
|
|
273
277
|
!Array.isArray(herdModulesResponse.data)) {
|
|
274
278
|
throw new Error("Invalid herd modules response");
|
|
275
279
|
}
|
|
276
|
-
if (!res_new_user || !res_new_user.data) {
|
|
277
|
-
throw new Error("Invalid user response");
|
|
278
|
-
}
|
|
279
280
|
const validationDuration = Date.now() - validationStartTime;
|
|
280
281
|
console.log(`[useScoutRefresh] Data validation took: ${validationDuration}ms`);
|
|
281
282
|
// Use the validated data
|
|
@@ -305,8 +306,6 @@ export function useScoutRefresh(options = {}) {
|
|
|
305
306
|
// Update store with new data
|
|
306
307
|
console.log(`[useScoutRefresh] Updating store with fresh herd modules`);
|
|
307
308
|
dispatch(setHerdModules(compatible_new_herd_modules));
|
|
308
|
-
console.log(`[useScoutRefresh] Updating store with fresh user data`);
|
|
309
|
-
dispatch(setUser(res_new_user.data));
|
|
310
309
|
dispatch(setHerdModulesLoadingState(EnumHerdModulesLoadingState.SUCCESSFULLY_LOADED));
|
|
311
310
|
const dataProcessingDuration = Date.now() - dataProcessingStartTime;
|
|
312
311
|
timingRefs.current.dataProcessingDuration = dataProcessingDuration;
|
|
@@ -700,6 +700,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
700
700
|
};
|
|
701
701
|
herds: {
|
|
702
702
|
Row: {
|
|
703
|
+
auto_delete_media_with_humans: boolean | null;
|
|
704
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
703
705
|
created_by: string;
|
|
704
706
|
description: string;
|
|
705
707
|
earthranger_domain: string | null;
|
|
@@ -714,6 +716,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
714
716
|
video_subscriber_token: string | null;
|
|
715
717
|
};
|
|
716
718
|
Insert: {
|
|
719
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
720
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
717
721
|
created_by: string;
|
|
718
722
|
description: string;
|
|
719
723
|
earthranger_domain?: string | null;
|
|
@@ -728,6 +732,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
728
732
|
video_subscriber_token?: string | null;
|
|
729
733
|
};
|
|
730
734
|
Update: {
|
|
735
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
736
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
731
737
|
created_by?: string;
|
|
732
738
|
description?: string;
|
|
733
739
|
earthranger_domain?: string | null;
|
|
@@ -1615,6 +1621,10 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
1615
1621
|
isSetofReturn: true;
|
|
1616
1622
|
};
|
|
1617
1623
|
};
|
|
1624
|
+
auto_assign_session_post_approver: {
|
|
1625
|
+
Args: never;
|
|
1626
|
+
Returns: number;
|
|
1627
|
+
};
|
|
1618
1628
|
check_realtime_schema_status: {
|
|
1619
1629
|
Args: never;
|
|
1620
1630
|
Returns: {
|
|
@@ -2915,6 +2925,8 @@ export declare function useSupabase(): SupabaseClient<Database, "public", "publi
|
|
|
2915
2925
|
location: string | null;
|
|
2916
2926
|
latitude: number | null;
|
|
2917
2927
|
longitude: number | null;
|
|
2928
|
+
auto_delete_media_with_humans: boolean | null;
|
|
2929
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
2918
2930
|
};
|
|
2919
2931
|
pins_pretty_location: {
|
|
2920
2932
|
id: number | null;
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -733,6 +733,8 @@ export type Database = {
|
|
|
733
733
|
};
|
|
734
734
|
herds: {
|
|
735
735
|
Row: {
|
|
736
|
+
auto_delete_media_with_humans: boolean | null;
|
|
737
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
736
738
|
created_by: string;
|
|
737
739
|
description: string;
|
|
738
740
|
earthranger_domain: string | null;
|
|
@@ -747,6 +749,8 @@ export type Database = {
|
|
|
747
749
|
video_subscriber_token: string | null;
|
|
748
750
|
};
|
|
749
751
|
Insert: {
|
|
752
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
753
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
750
754
|
created_by: string;
|
|
751
755
|
description: string;
|
|
752
756
|
earthranger_domain?: string | null;
|
|
@@ -761,6 +765,8 @@ export type Database = {
|
|
|
761
765
|
video_subscriber_token?: string | null;
|
|
762
766
|
};
|
|
763
767
|
Update: {
|
|
768
|
+
auto_delete_media_with_humans?: boolean | null;
|
|
769
|
+
auto_delete_media_with_no_tracks?: boolean | null;
|
|
764
770
|
created_by?: string;
|
|
765
771
|
description?: string;
|
|
766
772
|
earthranger_domain?: string | null;
|
|
@@ -1700,6 +1706,10 @@ export type Database = {
|
|
|
1700
1706
|
isSetofReturn: true;
|
|
1701
1707
|
};
|
|
1702
1708
|
};
|
|
1709
|
+
auto_assign_session_post_approver: {
|
|
1710
|
+
Args: never;
|
|
1711
|
+
Returns: number;
|
|
1712
|
+
};
|
|
1703
1713
|
check_realtime_schema_status: {
|
|
1704
1714
|
Args: never;
|
|
1705
1715
|
Returns: {
|
|
@@ -3000,6 +3010,8 @@ export type Database = {
|
|
|
3000
3010
|
location: string | null;
|
|
3001
3011
|
latitude: number | null;
|
|
3002
3012
|
longitude: number | null;
|
|
3013
|
+
auto_delete_media_with_humans: boolean | null;
|
|
3014
|
+
auto_delete_media_with_no_tracks: boolean | null;
|
|
3003
3015
|
};
|
|
3004
3016
|
pins_pretty_location: {
|
|
3005
3017
|
id: number | null;
|