UNPKG

@aws-amplify/analytics

Version:

Analytics category of aws-amplify

46 lines (43 loc) 1.71 kB
import { flushEvents as flushEvents$1 } from '@aws-amplify/core/internals/providers/pinpoint'; 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 '../../../errors/validation.mjs'; import '../../../utils/eventBuffer/EventBuffer.mjs'; import { getAnalyticsUserAgentString } from '../../../utils/userAgent.mjs'; import '../../../trackers/EventTracker.mjs'; import '../../../trackers/PageViewTracker.mjs'; import '../../../trackers/SessionTracker.mjs'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 const logger = new ConsoleLogger('Analytics'); /** * Flushes all buffered Pinpoint 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 { appId, region, bufferSize, flushSize, flushInterval, resendLimit } = resolveConfig(); resolveCredentials() .then(({ credentials, identityId }) => { flushEvents$1({ appId, region, credentials, identityId, bufferSize, flushSize, flushInterval, resendLimit, userAgentValue: getAnalyticsUserAgentString(AnalyticsAction.Record), }); }) .catch(e => { logger.warn('Failed to flush events', e); }); }; export { flushEvents }; //# sourceMappingURL=flushEvents.mjs.map