File size: 744 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import wpcom from 'calypso/lib/wp';

/**
 * In-memory cache to prevent duplicate requests.
 * Users can go through a flow multiple times, and this will be reset on a page reload.
 */
const previousRequests = new Set< string >();

// trigger guides on step movement, we don't care about failures or response
export function triggerGuidesForStep( flowName: string, stepName?: string, siteId?: number ) {
	const key = flowName + ':' + ( stepName || '' ) + ':' + ( siteId || 'no-id' );
	if ( previousRequests.has( key ) ) {
		return;
	}
	previousRequests.add( key );
	wpcom.req
		.post(
			'/guides/trigger',
			{
				apiNamespace: 'wpcom/v2',
			},
			{
				flow: flowName,
				step: stepName,
				siteId: siteId,
			}
		)
		.then()
		.catch();
}