All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.brsanthu.googleanalytics.AwtRequestParameterDiscoverer Maven / Gradle / Ivy

Go to download

This is Java API for Google Analytics (Measurement Protocol). More information about the protocol is available at https://developers.google.com/analytics/devguides/collection/protocol/v1/.

There is a newer version: 2.0.0
Show newest version
package com.brsanthu.googleanalytics;

import static com.brsanthu.googleanalytics.GaUtils.isEmpty;

import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;

/**
 * Clases uses AWT classes to discover following properties.
 * 
    *
  • Screen Resolution
  • *
  • Screen Colors
  • *
* * @author Santhosh Kumar */ public class AwtRequestParameterDiscoverer extends DefaultRequestParameterDiscoverer { @Override public DefaultRequest discoverParameters(GoogleAnalyticsConfig config, DefaultRequest request) { super.discoverParameters(config, request); Toolkit toolkit = Toolkit.getDefaultToolkit(); if (isEmpty(request.screenResolution())) { Dimension screenSize = toolkit.getScreenSize(); request.screenResolution(((int) screenSize.getWidth()) + "x" + ((int) screenSize.getHeight()) + ", " + toolkit.getScreenResolution() + " dpi"); } if (isEmpty(request.screenColors())) { GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices(); StringBuilder sb = new StringBuilder(); for (GraphicsDevice graphicsDevice : graphicsDevices) { if (sb.length() != 0) { sb.append(", "); } sb.append(graphicsDevice.getDisplayMode().getBitDepth()); } request.screenColors(sb.toString()); } return request; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy