Skip to content

Commit 0d49859

Browse files
Adding support for cancelOnBackground for UserFlow
Summary: UserFlow API now takes configuration parameter, which is required. It contains of 2 arguments: * triggerSource * cancelOnBackround Reviewed By: swillard13 Differential Revision: D25094721 fbshipit-source-id: 64a468c2168265ade9f8d4cea4beb911637544fa
1 parent defdb6d commit 0d49859

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Libraries/Reliability/UserFlow.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type PointData = $Shape<{
3434
* Example:
3535
* const flowId = UserFlow.newFlowId(QuickLogItentifiersExample.EXAMPLE_EVENT);
3636
* ...
37-
* UserFlow.start(flowId, "user_click");
37+
* UserFlow.start(flowId, {triggerSource: "user_click", cancelOnBackground: true});
3838
* ...
3939
* UserFlow.addAnnotation(flowId, "cached", "true");
4040
* ...
@@ -65,12 +65,27 @@ const UserFlow = {
6565
};
6666
},
6767

68-
start(flowId: FlowId, triggerSource: string): void {
68+
/**
69+
* Starts new flow.
70+
* Example:
71+
* UserFlow.start(flowId, {triggerSource: 'user_click', cancelOnBackground: true})
72+
*
73+
* Specify triggerSource as a place where your flow has started.
74+
* Specify if flow should be automatically cancelled if applicaton goes to background.
75+
* It is recommended to use true for cancelOnBackground - this reduces amount of lost flows due to instrumentation mistakes.
76+
* Only if you know that your flow should survive app backgrounding - use false. This includes cases of tracking cross application interactions.
77+
*
78+
*/
79+
start(
80+
flowId: FlowId,
81+
options: {triggerSource: string, cancelOnBackground: boolean},
82+
): void {
6983
if (global.nativeUserFlowStart) {
7084
global.nativeUserFlowStart(
7185
flowId.markerId,
7286
flowId.instanceKey,
73-
triggerSource,
87+
options.triggerSource,
88+
options.cancelOnBackground,
7489
);
7590
}
7691
},

0 commit comments

Comments
 (0)