@aws-amplify/analytics
Version:
Analytics category of aws-amplify
41 lines (38 loc) • 1.83 kB
JavaScript
import '@aws-amplify/core';
import '@aws-amplify/core/internals/utils';
import '../../../errors/validation.mjs';
import '../../../utils/eventBuffer/EventBuffer.mjs';
import { updateProviderTrackers } from '../../../utils/trackerHelpers.mjs';
import { validateTrackerConfiguration } from '../../../utils/trackerConfigHelpers.mjs';
import { record } from './record.mjs';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Configured Tracker instances for Pinpoint
const configuredTrackers = {};
// Callback that will emit an appropriate event to Pinpoint when required by the Tracker
const emitTrackingEvent = (eventName, attributes) => {
record({
name: eventName,
attributes,
});
};
/**
* Configures automatic event tracking for Pinpoint. This API will automatically transmit an analytic event when
* configured events are detected within your application. This can include: DOM element events (via the `event`
* tracker), session events (via the `session` tracker), and page view events (via the `pageView` tracker).
*
* @remark Only session tracking is currently supported on React Native.
*
* @param {ConfigureAutoTrackInput} params The input object to configure auto track behavior.
*
* @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.
* @throws validation: {@link AnalyticsValidationErrorCode} - Thrown when the provided parameters or library
* configuration is incorrect.
*/
const configureAutoTrack = (input) => {
validateTrackerConfiguration(input);
// Initialize or update this provider's trackers
updateProviderTrackers(input, emitTrackingEvent, configuredTrackers);
};
export { configureAutoTrack };
//# sourceMappingURL=configureAutoTrack.mjs.map