How to use the @aws-amplify/core.Analytics function in @aws-amplify/core

To help you get started, we’ve selected a few @aws-amplify/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
AsyncStorage.getItem(cacheKey).then((lastToken) => {
            if (!lastToken || lastToken !== token) {
                logger.debug('refresh the device token with', token);
                const config = {
                    Address: token,
                    OptOut: 'NONE'
                };
                if (Amplify.Analytics && typeof Amplify.Analytics.updateEndpoint === 'function') {
                    Amplify.Analytics.updateEndpoint(config).then((data) => {
                        logger.debug('update endpoint success, setting token into cache');
                        AsyncStorage.setItem(cacheKey, token);
                    }).catch(e => {
                        // ........
                        logger.debug('update endpoint failed', e);
                    });
                } else {
                    logger.debug('Analytics module is not registered into Amplify');
                }
            }
        }).catch(e => {
            logger.debug('set device token in cache failed', e);
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
AsyncStorage.getItem(cacheKey).then((lastToken) => {
            if (!lastToken || lastToken !== token) {
                logger.debug('refresh the device token with', token);
                const config = {
                    Address: token,
                    OptOut: 'NONE'
                };
                if (Amplify.Analytics && typeof Amplify.Analytics.updateEndpoint === 'function') {
                    Amplify.Analytics.updateEndpoint(config).then((data) => {
                        logger.debug('update endpoint success, setting token into cache');
                        AsyncStorage.setItem(cacheKey, token);
                    }).catch(e => {
                        // ........
                        logger.debug('update endpoint failed', e);
                    });
                } else {
                    logger.debug('Analytics module is not registered into Amplify');
                }
            }
        }).catch(e => {
            logger.debug('set device token in cache failed', e);
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
.then(lastToken => {
				if (!lastToken || lastToken !== token) {
					logger.debug('refresh the device token with', token);
					const config = {
						Address: token,
						OptOut: 'NONE',
					};
					if (
						Amplify.Analytics &&
						typeof Amplify.Analytics.updateEndpoint === 'function'
					) {
						Amplify.Analytics.updateEndpoint(config)
							.then(data => {
								logger.debug(
									'update endpoint success, setting token into cache'
								);
								AsyncStorage.setItem(cacheKey, token);
							})
							.catch(e => {
								// ........
								logger.debug('update endpoint failed', e);
							});
					} else {
						logger.debug('Analytics module is not registered into Amplify');
					}
				}
			})
			.catch(e => {
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
.then(lastToken => {
				if (!lastToken || lastToken !== token) {
					logger.debug('refresh the device token with', token);
					const config = {
						Address: token,
						OptOut: 'NONE',
					};
					if (
						Amplify.Analytics &&
						typeof Amplify.Analytics.updateEndpoint === 'function'
					) {
						Amplify.Analytics.updateEndpoint(config)
							.then(data => {
								logger.debug(
									'update endpoint success, setting token into cache'
								);
								AsyncStorage.setItem(cacheKey, token);
							})
							.catch(e => {
								// ........
								logger.debug('update endpoint failed', e);
							});
					} else {
						logger.debug('Analytics module is not registered into Amplify');
					}
				}
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
}

        if (!campaign) {
            logger.debug('no message received for campaign opened');
            return;
        }

        const attributes = {
            campaign_activity_id: campaign['campaign_activity_id'],
            treatment_id: campaign['treatment_id'],
            campaign_id: campaign['campaign_id']
        };

        const eventType = '_campaign.opened_notification';

        if (Amplify.Analytics && typeof Amplify.Analytics.record === 'function') {
            Amplify.Analytics.record({
                name: eventType,
                attributes,
                immediate: true
            });
        } else {
            logger.debug('Analytics module is not registered into Amplify');
        }
    }
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
}

		if (!campaign) {
			logger.debug('no message received for campaign opened');
			return;
		}

		const attributes = {
			campaign_activity_id: campaign['campaign_activity_id'],
			treatment_id: campaign['treatment_id'],
			campaign_id: campaign['campaign_id'],
		};

		const eventType = '_campaign.opened_notification';

		if (Amplify.Analytics && typeof Amplify.Analytics.record === 'function') {
			Amplify.Analytics.record({
				name: eventType,
				attributes,
				immediate: true,
			});
		} else {
			logger.debug('Analytics module is not registered into Amplify');
		}
	}
github aws-amplify / amplify-js / packages / aws-amplify / src / index.ts View on Github external
import Predictions from '@aws-amplify/predictions';

import Amplify, {
	ConsoleLogger as Logger,
	Hub,
	JS,
	ClientDevice,
	Signer,
	I18n,
	ServiceWorker,
} from '@aws-amplify/core';

export default Amplify;

Amplify.Auth = Auth;
Amplify.Analytics = Analytics;
Amplify.API = API;
Amplify.Storage = Storage;
Amplify.I18n = I18n;
Amplify.Cache = Cache;
Amplify.PubSub = PubSub;
Amplify.Logger = Logger;
Amplify.ServiceWorker = ServiceWorker;
Amplify.Interactions = Interactions;
Amplify.UI = UI;
Amplify.XR = XR;
Amplify.Predictions = Predictions;

export {
	Auth,
	Analytics,
	Storage,
github aws-amplify / amplify-js / packages / pushnotification / src / PushNotification.ts View on Github external
if (!campaign) {
            logger.debug('no message received for campaign push');
            return;
        }

        const attributes = {
            campaign_activity_id: campaign['campaign_activity_id'],
            isAppInForeground: message.foreground ? 'true' : 'false',
            treatment_id: campaign['treatment_id'],
            campaign_id: campaign['campaign_id']
        };

        const eventType = (message.foreground) ? '_campaign.received_foreground' : '_campaign.received_background';

        if (Amplify.Analytics && typeof Amplify.Analytics.record === 'function') {
            Amplify.Analytics.record({
                name: eventType,
                attributes,
                immediate: true
            });
        } else {
            logger.debug('Analytics module is not registered into Amplify');
        }
    }