Android Open Source - woopra-android-sdk Woopra






From Project

Back to project page woopra-android-sdk.

License

The source code is released under:

Apache License

If you think the Android project woopra-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2014 Woopra, Inc.//  w w  w.  ja v a  2s.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.woopra.tracking.android;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import android.content.Context;
import android.util.Log;

public class Woopra {
  private final static String TAG = Woopra.class.getName();

  private final static Object sync = new Object();

  private final static Map<String, WoopraTracker> trackers = new HashMap<String, WoopraTracker>();

  private final static ExecutorService executor = Executors
      .newFixedThreadPool(1);

  private static WoopraVisitor visitor;
  private static WoopraClientInfo clientInfo;

  public static Woopra getInstance(Context c) {
    return new Woopra(c);
  }

  private Woopra(Context context) {
    synchronized (sync) {
      if (visitor == null) {
        visitor = WoopraVisitor.getVisitorByContext(context);
        Log.d(TAG, "WoopraVistor Cookie: " + visitor.getCookie());
      }
      if (clientInfo == null) {
        clientInfo = new WoopraClientInfo(context);
        Log.d(TAG, "UserAgent: " + clientInfo.getUserAgent());
      }
    }
  }

  public WoopraTracker getTracker(String domain) {
    synchronized (sync) {
      WoopraTracker tracker = trackers.get(domain);
      if (tracker == null) {
        tracker = new WoopraTracker(executor, domain, visitor, clientInfo);
        trackers.put(domain, tracker);
      }
      return tracker;
    }
  }

}




Java Source Code List

com.woopra.tracking.android.WoopraClientInfo.java
com.woopra.tracking.android.WoopraEvent.java
com.woopra.tracking.android.WoopraPing.java
com.woopra.tracking.android.WoopraTracker.java
com.woopra.tracking.android.WoopraVisitor.java
com.woopra.tracking.android.Woopra.java