Skip to content

Commit

Permalink
fix js output for GA
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Nov 10, 2014
1 parent cad7560 commit be150d3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

import io.bagarino.manager.system.ConfigurationManager;
import io.bagarino.model.system.ConfigurationKeys;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Optional;

@Controller
Expand All @@ -39,10 +41,9 @@ public DynamicResourcesController(ConfigurationManager configurationManager) {
}

@RequestMapping("/resources/js/google-analytics")
@ResponseBody
public String getGoogleTagManagerScript(HttpServletResponse response) {
public void getGoogleTagManagerScript(HttpServletResponse response) throws IOException {
response.setContentType("application/javascript");
final Optional<String> id = configurationManager.getStringConfigValue(ConfigurationKeys.GOOGLE_ANALYTICS_KEY);
return id.map(x -> String.format(GOOGLE_ANALYTICS_SCRIPT, x)).orElse(EMPTY);
response.getWriter().write(id.map(x -> String.format(GOOGLE_ANALYTICS_SCRIPT, x)).orElse(EMPTY));
}
}

0 comments on commit be150d3

Please sign in to comment.