Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async createOrder(order){
//Place the order
console.log(order);
const putOrder = await API.graphql(graphqlOperation(createOrder, order));
console.log(JSON.stringify(putOrder));
this.setState({order: putOrder.data.createOrder});
this.setState({display: true}); //display Order component after a successfull purchase
//Send Analytics data to Pinpoint
Analytics.record({
name: 'unicornsPurchase',
attributes: {},
metrics: { totalOrder: order.totalOrder }
});
Analytics.record('_monetization.purchase', {
_currency: 'USD',
_product_id: order.itemId,
}, {
_item_price: order.unitPrice,
_quantity: order.count,
})
}
async createOrder(order){
//Place the order
console.log(order);
const putOrder = await API.graphql(graphqlOperation(createOrder, order));
console.log(JSON.stringify(putOrder));
this.setState({order: putOrder.data.createOrder});
this.setState({display: true}); //display Order component after a successfull purchase
//Send Analytics data to Pinpoint
Analytics.record({
name: 'unicornsPurchase',
attributes: {},
metrics: { totalOrder: order.totalOrder }
});
Analytics.record('_monetization.purchase', {
_currency: 'USD',
_product_id: order.itemId,
}, {
_item_price: order.unitPrice,
_quantity: order.count,
})
}
uploadPhotoToS3 = async (uri, key) => {
try {
this.setState({ uploading: true });
const file = await RNFetchBlob.fs.readFile(uri, 'base64');
const buffer = await Buffer.from(file, 'base64');
await Storage.put(key, buffer, {
contentType: 'image/jpeg',
});
this.setState({ uploading: false });
Analytics.record({ name: 'cameraPhotoUploaded' });
console.log('Photo uploaded!');
} catch (error) {
this.setState({ uploading: false });
console.log(error.message);
}
};
}
if (state === 'signedOut') {
state = 'signIn';
}
this.setState({ authState: state, authData: data, error: null });
if (this.props.onStateChange) {
this.props.onStateChange(state, data);
}
switch (state) {
case 'signedIn':
Analytics.record('_userauth.sign_in');
break;
case 'signedUp':
Analytics.record('_userauth.sign_up');
break;
}
}
handleStateChange(state, data) {
logger.debug('authenticator state change ' + state);
if (state === this.state.authState) { return; }
if (state === 'signedOut') { state = 'signIn'; }
this.setState({ authState: state, authData: data, error: null });
if (this.props.onStateChange) { this.props.onStateChange(state, data); }
switch(state) {
case 'signedIn':
Analytics.record('_userauth.sign_in');
break;
case 'signedUp':
Analytics.record('_userauth.sign_up');
break;
}
}
if (!this._isMounted) return;
if (state === this.state.authState) {
return;
}
if (state === 'signedOut') {
state = 'signIn';
}
this.setState({ authState: state, authData: data, error: null });
if (this.props.onStateChange) {
this.props.onStateChange(state, data);
}
switch (state) {
case 'signedIn':
Analytics.record('_userauth.sign_in');
break;
case 'signedUp':
Analytics.record('_userauth.sign_up');
break;
}
}
const track = curry((name, attributes) => {
if (!configured) {
credentials && Amplify.configure(credentials);
configured = true;
}
credentials && Analytics.record({name, attributes});
});
}
if (state === 'signedOut') {
state = 'signIn';
}
this.setState({ authState: state, authData: data, error: null });
if (this.props.onStateChange) {
this.props.onStateChange(state, data);
}
switch (state) {
case 'signedIn':
Analytics.record('_userauth.sign_in');
break;
case 'signedUp':
Analytics.record('_userauth.sign_up');
break;
}
}