@aws-amplify/analytics
Version:
Analytics category of aws-amplify
38 lines (36 loc) • 1.49 kB
JavaScript
;
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.flushEvents = void 0;
const resolveConfig_1 = require("../utils/resolveConfig");
const utils_1 = require("../../../utils");
const getEventBuffer_1 = require("../utils/getEventBuffer");
const utils_2 = require("@aws-amplify/core/internals/utils");
const core_1 = require("@aws-amplify/core");
const logger = new core_1.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 } = (0, resolveConfig_1.resolveConfig)();
(0, utils_1.resolveCredentials)()
.then(({ credentials, identityId }) => (0, getEventBuffer_1.getEventBuffer)({
region,
flushSize,
flushInterval,
bufferSize,
credentials,
identityId,
resendLimit,
userAgentValue: (0, utils_1.getAnalyticsUserAgentString)(utils_2.AnalyticsAction.Record),
}))
.then(eventBuffer => eventBuffer.flushAll())
.catch(e => logger.warn('Failed to flush events.', e));
};
exports.flushEvents = flushEvents;
//# sourceMappingURL=flushEvents.js.map