@aws-amplify/analytics
Version:
Analytics category of aws-amplify
38 lines (36 loc) • 1.38 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 utils_1 = require("@aws-amplify/core/internals/utils");
const core_1 = require("@aws-amplify/core");
const utils_2 = require("../utils");
const utils_3 = require("../../../utils");
const logger = new core_1.ConsoleLogger('Personalize');
/**
* Flushes all buffered Personalize 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, bufferSize, flushInterval } = (0, utils_2.resolveConfig)();
(0, utils_3.resolveCredentials)()
.then(({ credentials, identityId }) => (0, utils_2.getEventBuffer)({
region,
flushSize,
flushInterval,
bufferSize,
credentials,
identityId,
userAgentValue: (0, utils_3.getAnalyticsUserAgentString)(utils_1.AnalyticsAction.Record),
}))
.then(eventBuffer => eventBuffer.flushAll())
.catch(e => {
logger.warn('Failed to flush events', e);
});
};
exports.flushEvents = flushEvents;
//# sourceMappingURL=flushEvents.js.map