Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
.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 => {
.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');
}
}
}
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');
}
}
}
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');
}
}
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,
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');
}
}