package org.lantern;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.lantern.loggly.Loggly;
import org.lantern.loggly.LogglyMessage;
import org.lantern.state.Mode;
import org.lantern.state.Model;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class LogglyHelper {
    private static final Logger LOG = LoggerFactory.getLogger(JsonUtils.class);
    private Model model;
    private Loggly loggly;

    @Inject
    public LogglyHelper(Model model) {
        this.model = model;
        this.loggly = new Loggly(model.isDev(),
             model.getSettings().getMode() == Mode.get ?
             LanternConstants.LANTERN_LOCALHOST_ADDR :
             null);
    }

    public void submit(String json) {
        String reporterId = model.getProfile().getEmail();
        if (StringUtils.isBlank(reporterId)) {
            reporterId = model.getInstanceId();
        }
        LogglyMessage msg = new LogglyMessage(
                reporterId,
                "Lantern Feedback",
                new Date())
                .setExtraFromJson(json);
        loggly.log(msg);
        LOG.info("submitted to Loggly: %s", json);
    }
}

@@ -844,32 +844,90 @@
 ing reporterId =
+ %22(%22 + model.getInstanceId() + %22)%22;%0A        String email =
  model.getProfil
@@ -954,16 +954,17 @@
     if (
+!
 StringUt
@@ -975,26 +975,21 @@
 isBlank(
-reporterId
+email
 )) %7B%0A   
@@ -1010,37 +1010,40 @@
 terId = 
-model.getInstanceId()
+email + %22 %22 + reporterId
 ;%0A      

include instanceId in reporterId