Code Monkey home page Code Monkey logo

Comments (5)

BillyRayPreachersSon avatar BillyRayPreachersSon commented on July 20, 2024 1

We're on Ember 2.14.1, have just installed ember-cli-google-analytics ^1.5.0 as per the installation instructions, and are seeing the same error. We're not using Cordova, it's just a plain Ember app running from the command line and accessed at localhost:4200.

The error only seems to get thrown when I forcibly refresh the page. Navigating around our app without refreshing doesn't throw any errors, and seems to track as expected.

The line in question (see full stack trace below) is trying to perform the send (window[globalVariable]('send', 'pageview', {), but my guess is that window.ga isn't available at that point (which would explain why it only throws the error on a page refresh and not when navigating around).

Interestingly enough, when the error gets thrown, the tracking data still seems to get sent to our GA dashboard.

There was an error running your app in fastboot. More info about the error: 
 TypeError: window[globalVariable] is not a function
    at Class.pageviewToGA (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/ew/mixins/google-pageview.js:22:1)
    at Object.applyStr (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:45470:1)
    at sendEvent (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:22871:1)
    at Class.trigger (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:38519:1)
    at invokeWithOnError (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:9035:1)
    at Queue.flush (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:8923:1)
    at DeferredActionQueues.flush (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:9086:1)
    at Backburner.end (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:9165:1)
    at Timeout.Backburner._boundAutorunEnd [as _onTimeout] (/sitepath/tmp/broccoli_merge_trees-output_path-0o3SJA8u.tmp/assets/vendor/ember/ember.debug.js:9134:1)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

Update:

Our error was probably down to window not being available with FastBoot, so we edited our router.js file to detect window.ga and conditionally mix in the GA code:

import Ember from 'ember';
import config from './config/environment';
import OtherMixin from 'other-mixin';
import googlePageview from './mixins/google-pageview';

let routerData = {
	location: config.locationType,
	rootURL: config.rootURL
};

let Router;
if ('ga' in window) {
	// Only add GA tracking if it's available (e.g. we're not using FastBoot)
	Router = Ember.Router.extend(OtherMixin, googlePageview, routerData);
} else {
	Router = Ember.Router.extend(OtherMixin, routerData);
}

Router.map(function() {
	// ... 
});

export default Router;

from ember-cli-google-analytics.

PowerP avatar PowerP commented on July 20, 2024

Also get this error but on line 21. How did you fix this? For me only in combination with cordova the problem appears.

thx

from ember-cli-google-analytics.

swelther avatar swelther commented on July 20, 2024

I fear I don't remember the details, its too long ago. We updated in the meantime to a newer Ember CLI version and the problem vanished.

Do you still use Ember CLI 0.2.5?

from ember-cli-google-analytics.

PowerP avatar PowerP commented on July 20, 2024

I use 1.13.13.
On normal browser all is fine so I guess in my case it might not be a problem with ember at all. I also build a cordova app and on android it breaks. I just hopped that you had a similar problem. :(

from ember-cli-google-analytics.

ihomp avatar ihomp commented on July 20, 2024

@BillyRayPreachersSon Thanks :) had the same issue..

from ember-cli-google-analytics.

Related Issues (13)

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.