Skip to content

Commit e7a0f69

Browse files
committed
Add activation reporting with setup/launch/app separation for Frida
1 parent 6909b42 commit e7a0f69

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/components/intercept/config/frida-config.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ class FridaConfig extends React.Component<{
186186

187187
interceptor: Interceptor,
188188
activateInterceptor: (options: FridaActivationOptions) => Promise<void>,
189-
reportStarted: () => void,
190-
reportSuccess: () => void,
189+
reportStarted: (options?: { idSuffix?: string }) => void,
190+
reportSuccess: (options?: { idSuffix?: string }) => void,
191191
closeSelf: () => void
192192
}> {
193193

@@ -327,10 +327,12 @@ class FridaConfig extends React.Component<{
327327
}, 100);
328328

329329
try {
330+
this.props.reportStarted({ idSuffix: 'setup' });
330331
await this.props.activateInterceptor({
331332
action: 'setup',
332333
hostId
333334
}).catch((e) => alertActivationError('setup Frida', e));
335+
this.props.reportSuccess({ idSuffix: 'setup' });
334336

335337
this.setHostProgress(hostId, 75);
336338
await this.launchInterceptor(hostId);
@@ -351,10 +353,12 @@ class FridaConfig extends React.Component<{
351353
}, 100);
352354

353355
try {
356+
this.props.reportStarted({ idSuffix: 'launch' });
354357
await this.props.activateInterceptor({
355358
action: 'launch',
356359
hostId
357360
}).catch((e) => alertActivationError('launch Frida', e));
361+
this.props.reportSuccess({ idSuffix: 'launch' });
358362

359363
this.setHostProgress(hostId, 100);
360364
await delay(10); // Tiny delay, purely for nice UI purposes
@@ -381,14 +385,15 @@ class FridaConfig extends React.Component<{
381385
if (!host) return;
382386

383387
this.inProgressTargetIds.push(targetId);
388+
this.props.reportStarted({ idSuffix: 'app' });
384389
this.props.activateInterceptor({
385390
action: 'intercept',
386391
hostId: host.id,
387392
targetId
388393
})
389394
.catch((e) => alertActivationError(`intercept ${targetId}`, e))
390395
.then(() => {
391-
this.props.reportSuccess();
396+
this.props.reportSuccess({ idSuffix: 'app' });
392397
}).finally(action(() => {
393398
_.pull(this.inProgressTargetIds, targetId);
394399
}));

src/components/intercept/intercept-option.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ type InterceptorConfigComponent = React.ComponentType<{
3232
// with no side effects except check for updated interceptor state afterwards.
3333
activateInterceptor: (activationOptions?: any) => Promise<any>,
3434
// This should be called when each activation is considered started (i.e. after any required
35-
// user input or confirmation).
36-
reportStarted: () => void,
35+
// user input or confirmation). Id suffix can be specified to distinguish activation types.
36+
reportStarted: (options?: { idSuffix?: string }) => void,
3737
// This should be called when each activation is considered successfully completed. If
3838
// showRequests is not explicitly set to false, it will jump to the View page.
39-
reportSuccess: (options?: { showRequests?: boolean }) => void,
39+
reportSuccess: (options?: { showRequests?: boolean, idSuffix?: string }) => void,
4040
// This should be called to hide the custom UI again. Mainly useful if interception is cancelled,
4141
// or the UI deems itself unnecessary. The UI is never closed automatically, but reportSuccess
4242
// without showRequests false will jump to the View page, giving similar results.
@@ -282,11 +282,13 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
282282
</InterceptOptionCard>;
283283
}
284284

285-
onActivationStarted = () => {
285+
onActivationStarted = (options: { idSuffix?: string } = {}) => {
286286
trackEvent({
287287
category: 'Interceptors',
288288
action: 'Activated',
289-
value: this.props.interceptor.id
289+
value: options.idSuffix
290+
? `${this.props.interceptor.id}-${options.idSuffix}`
291+
: this.props.interceptor.id
290292
});
291293
};
292294

@@ -296,12 +298,15 @@ export class InterceptOption extends React.Component<InterceptOptionProps> {
296298
};
297299

298300
onActivationSuccessful = (options: {
299-
showRequests?: boolean
301+
showRequests?: boolean,
302+
idSuffix?: string
300303
} = {}) => {
301304
trackEvent({
302305
category: 'Interceptors',
303306
action: 'Successfully Activated',
304-
value: this.props.interceptor.id
307+
value: options.idSuffix
308+
? `${this.props.interceptor.id}-${options.idSuffix}`
309+
: this.props.interceptor.id
305310
});
306311

307312
// Some interceptors don't switch to show the requests, e.g. if the UI shows a list

0 commit comments

Comments
 (0)