Skip to content

Commit eff70a6

Browse files
Merge dev
2 parents e7a8dab + d44567b commit eff70a6

28 files changed

+1218
-893
lines changed

fission/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ dist-ssr
2828
*.sw?
2929

3030
yarn.lock
31+
32+
test-results
33+
src/test/**/__screenshots__

fission/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
33
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true, "defaultBranch": "dev" },
44
"files": { "ignoreUnknown": false },
55
"formatter": {

fission/bun.lock

Lines changed: 863 additions & 822 deletions
Large diffs are not rendered by default.

fission/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"colord": "^2.9.3",
3838
"framer-motion": "^10.18.0",
3939
"lygia": "^1.3.3",
40+
"msw": "^2.10.4",
4041
"notistack": "^3.0.2",
4142
"playwright": "^1.54.2",
4243
"postprocessing": "^6.37.6",

fission/src/GA.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ declare module "@haensl/google-analytics" {
77
function event(e: GaEvent)
88
function exception(e: GaException)
99
function setUserId({ id }: { id: string })
10-
function setUserProperty({ name, value }: { name: string; value: string })
10+
function setUserProperty({ name, value }: { name: string; value: unknown })
11+
function install()
1112
}

fission/src/Window.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare interface Window {
22
convertAuthToken(code: string): void
3-
gtag: () => void
3+
gtag?: (command: "config" | "set" | "get" | "event" | "consent", ...args: unknown[]) => void
4+
dataLayer?: unknown[][]
45
}

fission/src/mirabuf/MirabufLoader.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class MirabufCachingService {
143143
const miraBuff = await resp.arrayBuffer()
144144

145145
World.analyticsSystem?.event("Remote Download", {
146+
assemblyName: name ?? fetchLocation,
146147
type: miraType === MiraType.ROBOT ? "robot" : "field",
147148
fileSize: miraBuff.byteLength,
148149
})
@@ -283,6 +284,13 @@ class MirabufCachingService {
283284
}
284285
}
285286

287+
World.analyticsSystem?.event("Local Upload", {
288+
assemblyName: displayName,
289+
fileSize: buffer.byteLength,
290+
key,
291+
type: miraType == MiraType.ROBOT ? "robot" : "field",
292+
})
293+
286294
if (!target) {
287295
const cacheInfo = await MirabufCachingService.storeInCache(key, buffer, miraType, displayName)
288296
if (cacheInfo) {
@@ -517,7 +525,7 @@ class MirabufCachingService {
517525
window.localStorage.setItem(miraType == MiraType.ROBOT ? robotsDirName : fieldsDirName, JSON.stringify(map))
518526

519527
World.analyticsSystem?.event("Cache Store", {
520-
name: name ?? "-",
528+
assemblyName: name ?? "-",
521529
key: key,
522530
type: miraType == MiraType.ROBOT ? "robot" : "field",
523531
fileSize: miraBuff.byteLength,

fission/src/systems/analytics/AnalyticsSystem.ts

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const SAMPLE_INTERVAL = 60000 // 1 minute
88
const BETA_CODE_COOKIE_REGEX = /access_code=.*(;|$)/
99
const MOBILE_USER_AGENT_REGEX = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i
1010

11+
declare const GIT_COMMIT: string
12+
1113
export interface AccumTimes {
1214
frames: number
1315
physicsTime: number
@@ -16,6 +18,42 @@ export interface AccumTimes {
1618
simulationTime: number
1719
totalTime: number
1820
}
21+
type MiraEvent = {
22+
key?: string
23+
type?: "robot" | "field"
24+
assemblyName?: string
25+
/**
26+
* Size (in bytes) of the mirabuf file
27+
*/
28+
fileSize?: number
29+
}
30+
export interface AnalyticsEvents {
31+
"Performance Sample": {
32+
frames: number
33+
avgTotal: number
34+
avgPhysics: number
35+
avgScene: number
36+
avgInput: number
37+
avgSimulation: number
38+
}
39+
"APS Calls per Minute": unknown
40+
"APS Login": unknown
41+
"APS Download": MiraEvent
42+
43+
"Cache Get": MiraEvent
44+
"Cache Store": MiraEvent
45+
"Cache Remove": MiraEvent
46+
47+
"Remote Download": MiraEvent
48+
"Local Upload": MiraEvent
49+
50+
"Devtool Cache Persist": MiraEvent
51+
52+
"Scheme Applied": {
53+
isCustomized: boolean
54+
schemeName: string
55+
}
56+
}
1957

2058
class AnalyticsSystem extends WorldSystem {
2159
private _lastSampleTime = Date.now()
@@ -38,7 +76,7 @@ class AnalyticsSystem extends WorldSystem {
3876
this.sendMetaData()
3977
}
4078

41-
public event(name: string, params?: { [key: string]: string | number }) {
79+
public event<K extends keyof AnalyticsEvents>(name: K, params?: AnalyticsEvents[K]) {
4280
event({ name: name, params: params ?? {} })
4381
}
4482

@@ -50,7 +88,11 @@ class AnalyticsSystem extends WorldSystem {
5088
setUserId({ id: id })
5189
}
5290

53-
public setUserProperty(name: string, value: string) {
91+
public setUserProperty(name: string, value: unknown) {
92+
if (name.includes(" ")) {
93+
console.warn("GA user property names must not contain spaces")
94+
return
95+
}
5496
setUserProperty({ name: name, value: value })
5597
}
5698

@@ -62,9 +104,8 @@ class AnalyticsSystem extends WorldSystem {
62104
}
63105

64106
private sendMetaData() {
65-
if (import.meta.env.DEV) {
66-
this.setUserProperty("Internal Traffic", "true")
67-
}
107+
this.setUserProperty("isInternal", import.meta.env.DEV)
108+
this.setUserProperty("commit", GIT_COMMIT)
68109

69110
if (!this._consent) {
70111
return
@@ -73,15 +114,9 @@ class AnalyticsSystem extends WorldSystem {
73114
let betaCode = document.cookie.match(BETA_CODE_COOKIE_REGEX)?.[0]
74115
if (betaCode) {
75116
betaCode = betaCode.substring(betaCode.indexOf("=") + 1, betaCode.indexOf(";"))
76-
77-
this.setUserProperty("Beta Code", betaCode)
78-
}
79-
80-
if (MOBILE_USER_AGENT_REGEX.test(navigator.userAgent)) {
81-
this.setUserProperty("Is Mobile", "true")
82-
} else {
83-
this.setUserProperty("Is Mobile", "false")
117+
this.setUserProperty("betaCode", betaCode)
84118
}
119+
this.setUserProperty("isMobile", MOBILE_USER_AGENT_REGEX.test(navigator.userAgent))
85120
}
86121

87122
private currentSampleInterval() {

fission/src/systems/input/DefaultInputs.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class DefaultInputs {
2727

2828
ButtonInput.onKeyboard("intake", "KeyE"),
2929
ButtonInput.onKeyboard("eject", "KeyQ"),
30+
ButtonInput.onKeyboard("unstick", "Space"),
3031

3132
AxisInput.onKeyboardSingleKey("joint 1", "Digit1", negativeModifierKeys),
3233
AxisInput.onKeyboardSingleKey("joint 2", "Digit2", negativeModifierKeys),
@@ -57,6 +58,7 @@ class DefaultInputs {
5758

5859
ButtonInput.onKeyboard("intake", "KeyE"),
5960
ButtonInput.onKeyboard("eject", "KeyQ"),
61+
ButtonInput.onKeyboard("unstick", "Space"),
6062

6163
AxisInput.onKeyboardSingleKey("joint 1", "Digit1", negativeModifierKeys),
6264
AxisInput.onKeyboardSingleKey("joint 2", "Digit2", negativeModifierKeys),
@@ -87,6 +89,7 @@ class DefaultInputs {
8789

8890
ButtonInput.onKeyboard("intake", "Semicolon"),
8991
ButtonInput.onKeyboard("eject", "KeyL"),
92+
ButtonInput.onKeyboard("unstick", "KeyK"),
9093

9194
AxisInput.onKeyboardSingleKey("joint 1", "Slash", negativeModifierKeys),
9295
AxisInput.onKeyboardSingleKey("joint 2", "Period", negativeModifierKeys),
@@ -113,6 +116,7 @@ class DefaultInputs {
113116

114117
ButtonInput.onGamepad("intake", 4),
115118
ButtonInput.onGamepad("eject", 5),
119+
ButtonInput.onGamepad("unstick", 6),
116120

117121
AxisInput.onGamepadButtons("joint 1", 3, 0),
118122
AxisInput.onGamepadButtons("joint 2", 1, 2),
@@ -137,6 +141,7 @@ class DefaultInputs {
137141

138142
ButtonInput.onGamepad("intake", 4),
139143
ButtonInput.onGamepad("eject", 5),
144+
ButtonInput.onGamepad("unstick", 6),
140145

141146
AxisInput.onGamepadButtons("joint 1", 12, 13),
142147
AxisInput.onGamepadButtons("joint 2", 15, 14),
@@ -158,6 +163,7 @@ class DefaultInputs {
158163

159164
ButtonInput.onGamepad("intake", 4),
160165
ButtonInput.onGamepad("eject", 5),
166+
ButtonInput.onGamepad("unstick", 6),
161167

162168
AxisInput.onGamepadButtons("joint 1", 3, 0),
163169
AxisInput.onGamepadButtons("joint 2", 1, 2),
@@ -231,6 +237,7 @@ class DefaultInputs {
231237

232238
ButtonInput.unbound("intake"),
233239
ButtonInput.unbound("eject"),
240+
ButtonInput.unbound("unstick"),
234241
],
235242
}
236243
}

fission/src/systems/input/InputSchemeManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class InputSchemeManager {
131131
result[scheme.schemeName] ??= {
132132
scheme,
133133
status: InputSchemeUseType.CONFLICT,
134-
conflicts_with_names: [...new Set(conflictingSchemes)].join(", "),
134+
conflictingSchemeNames: [...new Set(conflictingSchemes)].join(", "),
135135
}
136136
} else {
137137
result[scheme.schemeName] = {

0 commit comments

Comments
 (0)