Move events processing to PSR
Summary: Means that attribution is now part of the export, too. Reviewed By: oprisnik Differential Revision: D15877937 fbshipit-source-id: e089597269b8977320d06284179f72d40d01ebf2
This commit is contained in:
committed by
Facebook Github Bot
parent
5c497d3eea
commit
e3f88e2a7b
@@ -54,6 +54,7 @@ function mockPersistedState(
|
|||||||
imagesMap,
|
imagesMap,
|
||||||
closeableReferenceLeaks: [],
|
closeableReferenceLeaks: [],
|
||||||
isLeakTrackingEnabled: false,
|
isLeakTrackingEnabled: false,
|
||||||
|
nextEventId: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +239,7 @@ test('the metric reducer with the multiple events', () => {
|
|||||||
const persistedState = {
|
const persistedState = {
|
||||||
surfaceList: new Set(),
|
surfaceList: new Set(),
|
||||||
images: [],
|
images: [],
|
||||||
|
nextEventId: 0,
|
||||||
events,
|
events,
|
||||||
imagesMap,
|
imagesMap,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export type PersistedState = {
|
|||||||
imagesMap: ImagesMap,
|
imagesMap: ImagesMap,
|
||||||
closeableReferenceLeaks: Array<AndroidCloseableReferenceLeakEvent>,
|
closeableReferenceLeaks: Array<AndroidCloseableReferenceLeakEvent>,
|
||||||
isLeakTrackingEnabled: boolean,
|
isLeakTrackingEnabled: boolean,
|
||||||
|
nextEventId: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
type PluginState = {
|
type PluginState = {
|
||||||
@@ -88,6 +89,7 @@ export default class extends FlipperPlugin<PluginState, *, PersistedState> {
|
|||||||
surfaceList: new Set(),
|
surfaceList: new Set(),
|
||||||
closeableReferenceLeaks: [],
|
closeableReferenceLeaks: [],
|
||||||
isLeakTrackingEnabled: false,
|
isLeakTrackingEnabled: false,
|
||||||
|
nextEventId: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static exportPersistedState = (
|
static exportPersistedState = (
|
||||||
@@ -156,6 +158,26 @@ export default class extends FlipperPlugin<PluginState, *, PersistedState> {
|
|||||||
event,
|
event,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
} else if (method == 'events') {
|
||||||
|
const event: ImageEvent = data;
|
||||||
|
|
||||||
|
debugLog('Received events', event);
|
||||||
|
const {surfaceList} = persistedState;
|
||||||
|
const {attribution} = event;
|
||||||
|
if (attribution instanceof Array && attribution.length > 0) {
|
||||||
|
const surface = attribution[0].trim();
|
||||||
|
if (surface.length > 0) {
|
||||||
|
surfaceList.add(surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...persistedState,
|
||||||
|
events: [
|
||||||
|
{eventId: persistedState.nextEventId, ...event},
|
||||||
|
...persistedState.events,
|
||||||
|
],
|
||||||
|
nextEventId: persistedState.nextEventId + 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return persistedState;
|
return persistedState;
|
||||||
@@ -270,24 +292,6 @@ export default class extends FlipperPlugin<PluginState, *, PersistedState> {
|
|||||||
init() {
|
init() {
|
||||||
debugLog('init()');
|
debugLog('init()');
|
||||||
this.updateCaches('init');
|
this.updateCaches('init');
|
||||||
this.client.subscribe('events', (event: ImageEvent) => {
|
|
||||||
debugLog('Received events', event);
|
|
||||||
const {surfaceList} = this.props.persistedState;
|
|
||||||
const {attribution} = event;
|
|
||||||
if (attribution instanceof Array && attribution.length > 0) {
|
|
||||||
const surface = attribution[0].trim();
|
|
||||||
if (surface.length > 0) {
|
|
||||||
surfaceList.add(surface);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.props.setPersistedState({
|
|
||||||
events: [
|
|
||||||
{eventId: this.nextEventId, ...event},
|
|
||||||
...this.props.persistedState.events,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
this.nextEventId++;
|
|
||||||
});
|
|
||||||
this.client.subscribe(
|
this.client.subscribe(
|
||||||
'debug_overlay_event',
|
'debug_overlay_event',
|
||||||
(event: FrescoDebugOverlayEvent) => {
|
(event: FrescoDebugOverlayEvent) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user