Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mparticle/web-sdk

Package Overview
Dependencies
Maintainers
7
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mparticle/web-sdk

mParticle core SDK for web applications

  • 2.9.6-rc.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.8K
decreased by-68.24%
Maintainers
7
Weekly downloads
 
Created
Source

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 dev@mparticle.com to learn more.

Documentation

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

Include and Initialize the SDK

1. Customize the SDK

You can customize the SDK by setting the mParticle.config object prior to the SDK-download snippet.

mParticle.config = {
   isDevelopmentMode: true,
   identifyRequest: {
      userIdentities: { email: 'email@example.com', customerid: '123456' }
   },
   identityCallback: myIdentityCallback
}

2. Include the SDK

To integrate the SDK add the following snippet to your site after customizing mParticle.config, ideally in the <head> element. Replace YOUR_API_KEY with the API key for your mParticle Web workspace.

<script type="text/javascript">
    (function (apiKey) {
        window.mParticle = window.mParticle || {};
        window.mParticle.EventType = {Unknown:0, Navigation:1, Location:2, Search:3, Transaction:4, UserContent:5, UserPreference:6, Social:7, Other:8};
        window.mParticle.eCommerce = { Cart: {} };
        window.mParticle.Identity = {};
        window.mParticle.config = window.mParticle.config || {};
        window.mParticle.config.rq = [];
        window.mParticle.config.snippetVersion = 2.1;
        window.mParticle.ready = function (f) {
        window.mParticle.config.rq.push(f);
    };

        function a(o,t){return function(){t&&(o=t+'.'+o);var e=Array.prototype.slice.call(arguments);e.unshift(o),window.mParticle.config.rq.push(e)}}var x=['endSession','logError','logEvent','logForm','logLink','logPageView','setSessionAttribute','setAppName','setAppVersion','setOptOut','setPosition','startNewSession','startTrackingLocation','stopTrackingLocation'],y=['setCurrencyCode','logCheckout'],z=['identify','login','logout','modify'];x.forEach(function(o){window.mParticle[o]=a(o)}),y.forEach(function(o){window.mParticle.eCommerce[o]=a(o,'eCommerce')}),z.forEach(function(o){window.mParticle.Identity[o]=a(o,'Identity')});

       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/v2/' + apiKey + '/mparticle.js';
       var s = document.getElementsByTagName('script')[0];
       s.parentNode.insertBefore(mp, s);
   })('REPLACE WITH 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, and build the mParticle.js file as well as the test file by running npm run build:

$ npm install
$ npm run build
$ npm run testKarma

The test script will run all tests using Karma and ChromeHeadless, Firefox, and Safari by default. To run tests using a different browser, use the command:

$ BROWSER=[browserBrand] npm run testBrowser

where browserBrand can be Edge or IE.

Development Notes

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

Support

support@mparticle.com

License

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

Keywords

FAQs

Package last updated on 09 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc