GithubHelp home page GithubHelp logo

isabella232 / moesif-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moesif/moesif-android

0.0 0.0 0.0 77 KB

Moesif SDK for Android

Home Page: https://www.moesif.com

License: Other

Java 100.00%

moesif-android's Introduction

Moesif SDK for Android

Built For Latest Version Software License Source Code

moesif-android is a SDK that automatically captures HTTP traffic such as to your internal APIs or external APIs like Stripe and sends to Moesif for API analytics and log analysis.

Requirements

This lib requires the use of OkHttp 2.2 or better. OkHttp 3.x is also supported.

The two popular Android networking clients (Volley and Retrofit) support using OkHttp so you are probably fine if using one of these two libs.

If using Retrofit, 1.9 or greater is required. If using Volley, a simple one line change is required to use our MoesifOkHttpXStack.

Module Structure

moesif-android: The core SDK shared across platforms, imported automatically by the below HTTP stack specific modules.

moesif-android-okhttp3: Supports the latest version (3.x) of OkHttp

moesif-android-okhttp2: If you want to stick with OkHttp 2.x for legacy reasons, import this module instead of moesif-android-okhttp3

How To Configure:

1. Add the dependency to your app/build.gradle

# Add the jcenter repository, if not present

repositories {
  jcenter()
}

dependencies {
    compile 'com.moesif.android:moesif-android-okhttp3:1.1.2'
}

If your Android project imports Volley as an unmanaged artifact, you may have to exclude volley as a transitive dependency: Otherwise, you may get duplicate class errors.

# Add the jcenter repository, if not present

repositories {
  jcenter()
}

dependencies {
    compile ('com.moesif.android:moesif-android-okhttp3:1.1.2') {
        exclude group: 'com.android.volley'
    }
}

2. In your AndroidManifest.xml, add your Moesif ApplicationId under the "application" node:

Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.

You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking Installation.

<application>

    <!-- Your other code -->

    <meta-data
        android:name="com.moesif.android.ApplicationId"
        android:value="Your Moesif Application Id" />
</application>

3. In your Application's onCreate(), initialize the lib

import com.moesif.android.MoesifClient;

public final class MyApplicationClass extends Application {

    @Override
    public void onCreate() {
        MoesifClient.initialize(this);
    }
}

4. Add the Interceptor

4.a If using Retrofit/OkHttp3 natively:

Add the Moesif MoesifOkHttp3Interceptor when building the Retrofit/OkHttp Client. If you have existing interceptors, you probably want Moesif's interceptor last in the chain to ensure it captures the HTTP call just before going over the wire. See more Info on using OkHttp Interceptors

import com.moesif.android.okhttp3;

OkHttpClient client = new OkHttpClient.Builder()
    .addInterceptor(new MoesifOkHttp3Interceptor())
    .build();

4.a If using Volley:

Pass in a new MoesifOkHttp3Stack object when creating Volley's request queue. See more info on setting up volley

import com.moesif.android.okhttp3;

    RequestQueue queue = Volley.newRequestQueue(myContext.getApplicationContext(),
                                                new MoesifOkHttp3Stack());

Configuring using OkHttp2:

Follow the previous configuration steps, except a few changes:

1. Import moesif-android-okhttp2 instead

# Add the jcenter repository, if not present
repositories {
  jcenter()
}

dependencies {
    compile 'com.moesif.android:moesif-android-okhttp2:1.1.2'
}

2. Use the corresponding OkHttp2 classes instead.

2.a If using Retrofit/OkHttp3 natively:

import com.moesif.android.okhttp2;

OkHttpClient myHttpClient new OkHttpClient();
myHttpClient.networkInterceptors().add(new MoesifOkHttp2Interceptor());

2.a Or Volley:

import com.moesif.android.okhttp2;

    RequestQueue queue = Volley.newRequestQueue(myContext.getApplicationContext(),
                                                new MoesifOkHttp2Stack(new OkHttpClient()));

License info for the Android SDK

See LICENSE File for details. The MoesifOkHttp3Stack and MoesifOkHttp2Stack classes, and the entirety of the com.moesif.android.inspector package used by this software have been licensed from non-Moesif sources and modified for use in the library. Please see the relevant source files, and the LICENSE file in the com.moesif.android.inspector package for details.

Other Integrations

To view more more documenation on integration options, please visit the Integration Options Documentation.

moesif-android's People

Contributors

dgilling avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.