Git Product home page Git Product logo

analytics.js-integration's People

Contributors

amillet89 avatar calvinfo avatar ccnixon avatar danieljackins avatar f2prateek avatar fathyb avatar hankim813 avatar ianstormtaylor avatar innovative-gauravkochar avatar jlee9595 avatar juliofarah avatar lancejpollard avatar ndhoule avatar reinpk avatar sperand-io avatar wcjohnson11 avatar yields avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analytics.js-integration's Issues

.load callback should not fire until .loaded returns true ?

some people are getting errors on ie8, i think the reason is that some browsers (ie) emits script complete|loaded before the script is evaluated.

a simple solution would be to call .loaded() after .load() completed with no errors, and if .loaded() returns false, we should retry X times until Xms and then error if .loaded() still returns false.

what do you guys think ?

cc @lancejpollard @ianstormtaylor

add way to remove DOM elements in .reset

so we can clean up this stuff:

afterEach(function() {
  hellobar.reset();
  var el = document.getElementById('hellobar_container');
  if (el) el.parentNode.removeChild(el);
});

maybe

integration.selector('#hellobar_container')

or maybe it can figure it out from the .script(<tag>) code

No version for package.json

Hey!

There is no version in the package.json file, so when trying to install this integration directly it errors out. Seems this is the same for most the integrations. Thanks!!!

reset common window methods in .reset?

should we add this here?

var setTimeout = window.setTimeout;
var setInterval = window.setInterval;
var onerror = undefined;
var onload = undefined;

exports.reset = function(){
  for (var i = 0, key; key = this.globals[i]; i++) window[key] = undefined;
  window.setTimeout = setTimeout;
  window.setInterval = setInterval;
  window.onerror = onerror;
  window.onload = onload;
};

if not here, where should we put this? didn't want to put it into analytics.js-integration-tester because sometimes you want to wait until multiple tests have run (at least for now). doesn't seem ideal to have to define this for each integration though, since we could just removing the .global property?

/cc @ianstormtaylor @yields

.mapping but for attributes

The .mapping feature looks really awesome, but seems a bit hamstrung. As a consumer, I would expect to be able to map not only the event name (for a particular integration) but also the attributes for a given track call. For example, GTM is quite happy accepting a nested json structure of attributes; however, Optimizely cannot. So in order to send the "same" data to optimizely as GTM, the attribute structure must be mutated for one or the other (or both) of the integrations.

It would be fantastic if there were a feature like .mapping but for attributes as well. Has there been any thought about this type of feature in the past? Any recommended alternatives? As best as I can tell, it would be presently implemented as a per-integration option. But having the capability to define it for all integrations would be fantastic.

api simplification ideas

Some random things that could potentially cleanup some repetitive code and simplify things for testing and whatnot.

First is what about removing the plugin code block? We can still figure out a way to make it pluggable without needing this:

/**
 * Expose plugin.
 */

module.exports = exports = function(analytics){
  analytics.addIntegration(AdRoll);
};

If the Integration constructor just looked something like this, it would work too:

function Integration(opts) {
  if (opts instanceof Analytics) return opts.addIntegration(Integration);
  // ...
}

Then to handle the other couple things you find in those code blocks, such as this:

/**
 * Expose plugin.
 */

module.exports = exports = function(analytics){
  analytics.addIntegration(AdRoll);
  ajs = analytics;
  user = analytics.user(); // store for later
};

We could just set those as variables on every integration. That would make it much easier to test as well. Any reasons why we don't want to do that? That way you could just do this:

AdRoll.prototype.track = function(track){
  var user = this.user;
  var data = {};
  if (user.id()) data.user_id = user.id();
  // ...
};

Right now it feels hard to access and work with the user object, and it could be just this simple.


Also, we can potentially move all of those push blocks to the DSL, and then make a .push method on the integration prototype. So go from this:

var push = require('global-queue')('_curebitq');
// ...
Curebit.prototype.page = function(page){
  // ...
  push('register_affiliate', settings);
};

to something like this:

Curebit.queue('_curebitq');

// ...
Curebit.prototype.page = function(page){
  // ...
  this.push('register_affiliate', settings);
};

This would make it so we can use that information in the tests as well, and also for scraping pages. It would also kind of keep it consistent with the rest of the declarative definition.


So then integrations would start just looking like this:

/**
 * Module dependencies.
 */

var integration = require('analytics.js-integration');

/**
 * Expose `WebEngage` integration.
 */

var WebEngage = module.exports = integration('WebEngage')
  .assumesPageview()
  .global('_weq')
  .global('webengage')
  .option('widgetVersion', '4.0')
  .option('licenseCode', '')
  .tag('<script src="http://cdn.widgets.webengage.com/js/widget/webengage-min-v-4.0.js">');

/**
 * Initialize.
 *
 * @param {Object} page
 */

WebEngage.prototype.initialize = function(page){
  var _weq = window._weq = window._weq || {};
  _weq['webengage.licenseCode'] = this.options.licenseCode;
  _weq['webengage.widgetVersion'] = this.options.widgetVersion;
  this.load(this.ready);
};

Thoughts?

/cc @ianstormtaylor @yields

Trouble running `make`

Hi,

I have trouble completing a make from a fresh clone. Here is what I get:

    ...[npm completed + other installed]...

    installed : [email protected]
    installed : [email protected]
    installed : ianstormtaylor-sinon@duo
    installed : [email protected]
    installed : [email protected]
    installed : [email protected]
        error : Error: segmentio/stub@*: Not Found

Am I missing something?

Building from the latest tag (0.2.2) instead of master yields some other errors.

Thanks for your help,

add eCommerce abstraction

@ianstormtaylor did we decide to go with this ?

here's how i think it should be implemented:

this lib receives track calls with events, it will lowercase / normalize them and check for methods like checkedout, removedProduct, addedProduct etc..

if the integration support those it will call them, otherwise it will fallback to just calling track.

since we don't want to do if (/removed product/i.test(track.event())) do() inside every integration that supports ecommerce.

any thoughts ?

Don't call load callback for scripts?

@ianstormtaylor segmentio/analytics.js-integrations#353

I think it used to not do the callback, but then with the changes we removed that. We could just do this:

exports.load = function(name, locals, fn){
  if ('function' == typeof name) fn = name, locals = null, name = null;
  if (name && 'object' == typeof name) fn = locals, locals = name, name = null;
  if ('function' == typeof locals) fn = locals, locals = null;
  name = name || 'library';
  locals = locals || {};
  locals = this.locals(locals);
  var template = this.templates[name];
  assert(template, fmt('Template "%s" not defined.', name));
  var attrs = render(template, locals);
  var el;

  function done(err) {
    if (err) return; // don't callback at all
    fn();
  }

  switch (template.type) {
    case 'img':
      attrs.width = 1;
      attrs.height = 1;
      el = loadImage(attrs, done);
      break;
    case 'script':
      el = loadScript(attrs, done);
      // TODO: hack until refactoring load-script
      delete attrs.src;
      each(attrs, function(key, val){
        el.setAttribute(key, val);
      });
      break;
    case 'iframe':
      el = loadIframe(attrs, done);
      break;
  }

  return el;
};

But, we really only want this behavior for the global script, the main script for the app. So maybe we have a special load function for initializing? Not sure, what do you think is best?

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.