Code Monkey home page Code Monkey logo

mparticle-sdk-javascript's Introduction

mParticle Javascript SDK

Hello! This is the public repo of the mParticle Javascript SDK. We've built the mParticle platform to take a new approach to web and mobile app data and the platform has grown to support 50+ services and SDKs, including developer tools, analytics, attribution, messaging, and advertising services. mParticle is designed to serve as the connector between all of these services - check out our site, or hit us at [email protected] to learn more.

Documentation

Detailed documentation and other information about mParticle SDK can be found at http://docs.mparticle.com

Usage

Once you have signed up to the mParticle platform and have a key for your App, you can begin to use the SDK by embedding the following script tag in your web page, replacing "YOUR_API_KEY" with your key. Note that the mParticle JS SDK and all mParticle integrations will be minified when served.

<script type="text/javascript">
  (function (apiKey) {
    window.mParticle = window.mParticle || {};
    window.mParticle.config = window.mParticle.config || {};
    window.mParticle.config.rq = [];
    window.mParticle.ready = function (f) {
        window.mParticle.config.rq.push(f);
    };
    var mp = document.createElement('script');
    mp.type = 'text/javascript';
    mp.async = true;
    mp.src = ('https:' == document.location.protocol ? 'https://jssdkcdns' : 'http://jssdkcdn') + '.mparticle.com/js/v1/' + apiKey + '/mparticle.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(mp, s);
  })('YOUR_API_KEY');
</script>

You can then log events, for example, as follows:

mParticle.logEvent('Play Movie', mParticle.EventType.Navigation, {'movie_length':'127 minutes','rating':'PG'});

Creating an Integration

Similar to other mParticle SDKs, the Javascript SDK is able to automatically include, initialize, and delegate API calls to 3rd-party Javascript SDKs. If you would like to add your company as a new Javascript integration, reference the following integrations as examples:

Running the Tests

Prior to running the tests please install all dev dependencies via an npm install:

$ npm install

A suite of test cases can be run by serving the /test directory from a web server (such as serve), and pointing a web browser to index.html. This will execute the tests and also display code coverage results. Note that serving the test directory from the file system directly will not work.

You can also run the tests by executing the npm test script:

$ npm test

The test script will use the browser-sync module to serve test/index.html, open the tests in a browser, and auto-refresh when a change is made to mparticle.js or any of the test files.

Development Notes

This package comes with the NPM package pre-commit, which will run ESLint when you try to commit.

Support

[email protected]

License

The mParticle Javascript SDK is available under the Apache License, Version 2.0. See the LICENSE file for more info.

mparticle-sdk-javascript's People

Contributors

rmi22186 avatar tbreffni avatar devanp92 avatar annapareddy avatar samdozor avatar peterjenkins avatar pcanterini avatar hackerrdave avatar

Watchers

James Cloos avatar  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.