Crashlytics
getCrashlyticsUnsentReports()
sendCrashlyticsUnsentReports()
Management of user reports
Client action
/**
* Send chat notification
*/
function sendChatNotification() {
//Send chat notification
var notifParam = {
fileLogPath: destFileNameLog,
fileDbPath: destFileNameDb,
fileCrashPath: destFileNameCrash
};
var notifNote = "";
if (!notifParam.fileLogPath || notifParam.fileLogPath == "") {
notifNote += "Nessun LOG inviato\n";
}
if (!notifParam.fileDbPath || notifParam.fileDbPath == "") {
notifNote += "Nessun DB inviato\n";
}
if (!notifParam.fileCrashPath || notifParam.fileCrashPath == "") {
notifNote += "Nessun CRASH inviato\n";
}
if (notifNote && notifNote != "") {
notifNote += "\n";
}
if (note && note != "") {
notifNote += note;
}
notifParam.note = notifNote;
executeServerAction(8479, notifParam);
}
/**
* Send logs to server
*/
function showError(){
asyncFunction("sendChatNotification", []);
setFormPanelLabel(5269,"lblTitle",getTranslation("error"));
setFormPanelLabel(5269,"lblSubtitle",getTranslation("segnalazioneNonInviata"));
setFormPanelValue(5269,"imgStatus","error.png");
setVisibleComponent(5269,"btnChiudi","Y");
}
/**
* Callback chiamata dopo l'invio del file
**/
function sendCallback(responseFromWebService) {
if(!responseFromWebService){
showError();
}else{
var respObj = JSON.parse(responseFromWebService);
if(respObj.success){
asyncFunction("sendChatNotification", []);
/*
var risp = {
title : getTranslation("segnalazioneInviata"),
subtitle : getTranslation("segnalazioneInviataMsg"),
colorButtonSuccess : "#50A3ED",
titleColorButtonSuccess: "#FFFFFF",
titleColor : "#50A3ED",
subtitleColor: "#000000",
backgroundColor : "#FFFFFF",
titleButtonSuccess : "Ok"
};
showMessageDialog(risp,"");
*/
setFormPanelValue(5289,"txtComment","");
setFormPanelLabel(5269,"lblTitle",getTranslation("segnalazioneInviata"));
setFormPanelLabel(5269,"lblSubtitle",getTranslation("segnalazioneInviataMsg"));
setFormPanelValue(5269,"imgStatus","success.png");
setVisibleComponent(5269,"btnChiudi","Y");
}else{
showError();
}
}
}
/**
* Salva nel bucket i crash non inviati a chraslytics
*/
function saveUnsentCrash(){
try{
//recupero il file di log
var crashPath = getCrashlyticsUnsentReports();
if(crashPath){
//invio il file al server che lo carica nel bucket
var logDir = 49;
//platform in autmatico mette già COMPANY_ID/SITE_ID
//il file avrà un percorso tipo 210_1001/210_1001_20191126_123000.zip
destFileNameCrash = destFilePrefix + "_CRASH.zip";
var url = getBaseURL() + "/uploadfiles/uploadfilegrid?appId=MOBILE_SHOP&applicationId=MOBILE_SHOP&dirId=" + logDir + "&unzip=false&restfulToken="+getToken();
sendFile(url, crashPath, destFileNameCrash, "saveDb");
}else{
log("[3629] saveUnsentCrash SKIPPED NO PATH");
saveDb();
}
try{
//invio i report mancanti a crashlytics
sendCrashlyticsUnsentReports();
}catch(ec){
log("[3629] sendCrashlyticsUnsentReports error: " + ec);
}
}catch(e){
log("[3629] saveUnsentCrash ERROR: " + e);
saveDb();
}
}
/**
* Salva nel bucket il db dell'app
*/
function saveDb(connectionData) {
log("Connection data: " + connectionData);
try {
//uso il path fisso!!
var dbPath = getDbPath("DBNOSYNC");
if (dbPath) {
var zipPathDb = zipFile(dbPath,"dbnosync.zip");
//invio il file al server che lo carica nel bucket
var logDirDb = 49;
var filePathDb = zipPathDb;
//platform in autmatico mette già COMPANY_ID/SITE_ID
//il file avrà un percorso tipo 210_1001/210_1001_20191126_123000.zip
destFileNameDb = destFilePrefix + "_DB.zip";
var urlDb = getBaseURL() + "/uploadfiles/uploadfilegrid?appId=MOBILE_SHOP&applicationId=MOBILE_SHOP&dirId=" + logDirDb + "&unzip=false&restfulToken="+getToken();
sendFile(urlDb, filePathDb, destFileNameDb, "saveLog");
}else {
log("[3629] saveDb SKIPPED NO PATH");
saveLog();
}
}catch(e) {
log("[3629] saveDb ERROR: " + e);
saveLog();
}
}
/**
* Salva il file di log
*/
function saveLog(){
log("[3629] NOTE SEGNALAZIONE: " + note);
//recupero il file di log
var logPath = getLogFilePath();
if(logPath){
//faccio uno zip del log
var zipPath = zipFile(logPath, "log.zip");
if(zipPath){
//invio il file al server che lo carica nel bucket
var logDir = 49;
var filePath = zipPath;
//platform in autmatico mette già COMPANY_ID/SITE_ID
//il file avrà un percorso tipo 210_1001/210_1001_20191126_123000.zip
destFileNameLog = destFilePrefix + "_LOG.zip";
var url = getBaseURL() + "/uploadfiles/uploadfilegrid?appId=MOBILE_SHOP&applicationId=MOBILE_SHOP&dirId=" + logDir + "&unzip=false&restfulToken="+getToken();
sendFile(url, zipPath, destFileNameLog, "sendCallback");
//condivide lo zip con le app presenti nel device
//shareDocument(zipPath,log.zip);
}else{
showError();
}
}else{
showError();
}
}
function inviaSegnalazione() {
setFormPanelValue(5269,"imgStatus","invio_in_corso.gif");
//invia crahs, log e db dell'app
getConnectionData("saveUnsentCrash");
}
setVisibleComponent(5269,"btnChiudi","N");
var lastSyncDate = getVariable("LAST_SYNC_DATE");
log("lastSyncDate: " + lastSyncDate);
var destFilePrefix = userInfo.username + "/" + userInfo.username + "_" + userInfo.deviceId + "_" + stringifyDate(new Date().getTime(), "yyyyMMdd_HHmmss", true);
var destFileNameLog = "";
var destFileNameDb = "";
var destFileNameCrash = "";
var note = getFormPanelValue(5289,"txtComment");
showCardPanel(5309,5269);
asyncFunction("inviaSegnalazione", [],400);
Server action
Last updated