GithubHelp home page GithubHelp logo

analytics.js-loader's Introduction

Hi there ๐Ÿ‘‹

Maker

  • TurnShift: Automate Your Team Schedule
  • Tweets @vvoyer: JavaScript, React, Next.js, Building In Public
  • Next.js News: The Next.js Monthly Newsletter (sold)
  • Source Karma: Discover how people react to you on GitHub ๐Ÿ‘ (archived)

analytics.js-loader's People

Contributors

cazzer avatar evanpaschke avatar nsilberman avatar vvo 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

Watchers

 avatar  avatar  avatar

analytics.js-loader's Issues

Doesn't Actually Send Data

I think this library doesn't actually do the right thing. Real issue being the goofy way Segment has done their JS. When the analytics script is loaded, it doesn't actually fix the initial window.analytics, it just replaces it, and the fact that this module exports a reference to the initial object, means that after the script is loaded, events aren't actually sent to Segment and tracked.

I could be wrong, but that is what I was observing.

Here is the module I created to fix this issue:

import loadAnalytics from 'analytics.js-loader';

/*
 * The analytics.js-loader module returns the "initial" analytics
 * object, which is basically just a queue to hold events until the
 * "real" one is loaded with a global script.  Problem is, the "real"
 * one simply replaces `window.analytics`, and doesn't change over
 * this initial "queue" object, meaning that nothing gets registered
 * after the "real" one is loaded - things just keep adding to the queue.
 * This is why we save off `initialAnalytics`, and then always run
 * methods through `window.analytics`, which might be the queue, and
 * might be the real one.
 */
const initialAnalytics = loadAnalytics({
    writeKey: 'KEY',
    skipPageCall: true
});
window.analytics = initialAnalytics;

const analytics = {};
_.each(initialAnalytics.methods, method => {
    analytics[method] = function() {
        return window.analytics[method].apply(window.analytics, arguments);
    };
});

export default analytics;

No data being sent

Continuing #6 ...

I am not seeing any data sent when using this package unless I remove the changes in 5871aa7

Is anyone else having this issue?

I was having an unrelated issue. The commit works great. Thank you.

Could call to analytics.page be conditional?

In the single page application I am working on we call analytics.page() whenever we render a new page. The issue is, on initial page load, this will be fired twice since it is also called at the end of index.js.

Could an option be passed to omit this call in case a consumer of this library wants to manually call it later?

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.