export async function sendEvents()

in src/eventSubscription/commands/mock/sendEvents.ts [17:53]


export async function sendEvents(uri: Uri): Promise<void> {
    const mainMessage: string = localize('sending', 'Sending events...');
    await window.withProgress({ location: ProgressLocation.Notification, title: mainMessage }, async (progress: Progress<{}>): Promise<void> => {
        progress.report({
            percentage: 10,
            message: localize('generating', 'Generating events...')
        });

        const [events, eventGenerator]: [{}[], IMockEventGenerator] = await generateEvents(uri);

        progress.report({
            percentage: 25,
            message: localize('retrieving', 'Retrieving endpoint URL...')
        });

        const endpointUrl: string = await getEndpointUrl(eventGenerator);

        progress.report({
            percentage: 75,
            message: mainMessage
        });

        await <Thenable<void>>requestP.post(
            // tslint:disable-next-line:no-non-null-assertion
            endpointUrl,
            {
                headers: {
                    'Content-Type': 'application/json',
                    'aeg-event-type': 'Notification'
                },
                body: JSON.stringify(events)
            }
        );

        window.showInformationMessage(localize('sent', 'Successfully sent events.'));
    });
}