@aws-amplify/analytics
Version:
Analytics category of aws-amplify
44 lines (41 loc) • 1.66 kB
JavaScript
import { AnalyticsAction } from '@aws-amplify/core/internals/utils';
import { ConsoleLogger } from '@aws-amplify/core';
import { resolveConfig } from '../utils/resolveConfig.mjs';
import { resolveCredentials } from '../../../utils/resolveCredentials.mjs';
import '../../../utils/eventBuffer/EventBuffer.mjs';
import { getAnalyticsUserAgentString } from '../../../utils/userAgent.mjs';
import '../../../trackers/EventTracker.mjs';
import '../../../trackers/PageViewTracker.mjs';
import '../../../trackers/SessionTracker.mjs';
import '../../../errors/validation.mjs';
import { getEventBuffer } from '../utils/getEventBuffer.mjs';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
const logger = new ConsoleLogger('Kinesis');
/**
* Flushes all buffered Kinesis events to the service.
*
* @note
* This API will make a best-effort attempt to flush events from the buffer. Events recorded immediately after invoking
* this API may not be included in the flush.
*/
const flushEvents = () => {
const { region, flushSize, flushInterval, bufferSize, resendLimit } = resolveConfig();
resolveCredentials()
.then(({ credentials, identityId }) => getEventBuffer({
region,
flushSize,
flushInterval,
bufferSize,
credentials,
identityId,
resendLimit,
userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record),
}))
.then(eventBuffer => eventBuffer.flushAll())
.catch(e => {
logger.warn('Failed to flush events.', e);
});
};
export { flushEvents };
//# sourceMappingURL=flushEvents.mjs.map