(options: TimelineEventOptions, app: App, ctx: BackendContext)
| 138 | } |
| 139 | |
| 140 | export async function addTimelineEvent(options: TimelineEventOptions, app: App, ctx: BackendContext) { |
| 141 | if (!SharedData.timelineRecording) { |
| 142 | return |
| 143 | } |
| 144 | const appId = app ? getAppRecordId(app) : null |
| 145 | const isAllApps = options.all || !app || appId == null |
| 146 | |
| 147 | const id = ctx.nextTimelineEventId++ |
| 148 | |
| 149 | const eventData: TimelineEventOptions & WithId = { |
| 150 | id, |
| 151 | ...options, |
| 152 | all: isAllApps, |
| 153 | } |
| 154 | ctx.timelineEventMap.set(eventData.id, eventData) |
| 155 | |
| 156 | ctx.bridge.send(BridgeEvents.TO_FRONT_TIMELINE_EVENT, { |
| 157 | appId: eventData.all ? 'all' : appId, |
| 158 | layerId: eventData.layerId, |
| 159 | event: mapTimelineEvent(eventData), |
| 160 | }) |
| 161 | |
| 162 | const layer = ctx.timelineLayers.find(l => (isAllApps || l.appRecord?.options.app === app) && l.id === options.layerId) |
| 163 | if (layer) { |
| 164 | layer.events.push(eventData) |
| 165 | } |
| 166 | else if (SharedData.debugInfo) { |
| 167 | console.warn(`Timeline layer ${options.layerId} not found`) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | const initialTime = Date.now() |
| 172 | export const dateThreshold = initialTime - 1_000_000 |
no test coverage detected