Including Date Range Selector for Google Analytics api implementation - javascript

I've been trying to implement the date range selector by following the demo in https://ga-dev-tools.appspot.com/embed-api/custom-components/ But, whenever I try to test my script, I get errors.
For these scripts,
/public/javascript/embed-api/date-range-selector.js"
/public/javascript/embed-api/components/date-range-selector.js"
I get a 404 error saying that the scripts are not found. Whenever I check my sources in the browser, the generated .js files are blank.
Additionally, I tried this:
https://ga-dev-tools.appspot.com/public/javascript/embed-api/components/date-range-selector.js
And I got an error saying that gapi was undefined.
How am I supposed to include this js to my project so I can implement it? I've also already disabled AdBlock if that means anything.

Related

JSON Parse error: Unrecognized token '!' - error caught by Sentry

The error in the title is caught by Sentry (an error tracking tool). Below is a screenshot from Sentry - showing the stack trace.
Note: the script /en_US/iab.autofill.payment.js where handleMessage is located is loaded from Facebook (link here), and I couldn't find this script in the javascript bundle, nor anything related to it. I assume it's loaded by a 3rd party script - I'm using Google Tag Manager (which is also loading Facebook Pixel), Segment (loading Hotjar and Mixpanel), and Snapchat. The error started to appear without any changes in these scripts or the services that they're sending data to.
Note 2: It seems that the error is triggered quite often, about 10-15% of the time. I tried to reproduce it but given that it's a handled error, it doesn't show in the dev console.
Any direction on where to look would be much appreciated.
I'm seeing this a lot, and it seems to be coming 100% from users using Facebook browser on iOS (I guess this is the browser you see when you're using the Facebook app).
I tried to debug this with a snippet:
<script>
window.addEventListener('message', function (e) {
console.log(e);
JSON.parse(e.data);
console.log('foo');
}, false);
</script>
This is from the library you linked. Assuming that e.data is JSON string (not e.g. an object?), without any safeguard seems to be breaking things.
The second console.log doesn't fire, so I think this is causing some unexpected behaviours in my case (buttons not reacting to clicks with js listeners etc)
I don't know if there is a workaround or a way to protect from this in Facebook embedded browser (I guess it's loaded there)
Looking forward to hear more info
i have meet that too, its because the one script facebook inject in. will postMessage(Object), but the another script will listen the message and try to JSON.parse an object ,so it will came out a error. u can use 'vconsole' lib, and add a window.addEventListener('message',(e)=>{console.log(e.data)}) and u can see that
Apparently, the issue went away after a couple of weeks without changing anything on my side.

Occasionally getting Reference Error in Javascript console

I am occasionally getting different types of Reference errors logged in chrome console.
For eg: require not defined
Cookies not defined
lozad not defined
The code is bundled in static-internal-bundle.js which is a combination of 7 different util files and minified using gulp-minify.
This error is coming mainly when the url is hit from paid.braintree.com Ad urls and has utm_source, utm_medium and utm_campaign as query parameters.
This error is not consistent and mostly does not reoccur if the site is refreshed.
Also, it has been logged in sentry for all types of devices and Os for over 1.5k times in 6 months. Though it gets logged in console, nothing seems to break on the webpage.
What could be the possible reasons for this type of error?
<script type="text/javascript" src="https://static.pens.com/576801d7b3a368c06ba1944c07fe260b970da596/build/static-internal-bundle.js"></script>
This is the script that gets added into the page in which the error is coming.
I would add this as a comment but StackO won't let me without 50+ rep... I'll edit as needed.
Possibly the error could be in using "require" on the browser side, as browsers do not implement require
This sounds like a problem I have had with Babel, if it is being used I would try updating.

I couldn't find my .js file on firebug

Firebug made me crazy. I want to debug my javascript codes but I couldn't find my js file.
It show the error why is line of my search .js file but when I search I couldn't find.
I search PersonManagement.js on firebug
But when I search on script section on I couldn't find, I need to review via debug this file, I mean I need to find PersonManagement.js via firebug.
Could you help me?
If there is a syntax error within a JavaScript source, the source is not listed within the Script panel, though the syntax error is logged to the Console panel (assumed you have the option Show JavaScript Errors enabled).
This is also briefly explained within the Firebug FAQ and the Script panel description.
In your case you got the syntax error 'missing name after . operator'. Just remove the . between $ and ( and your problem should be solved.

Can I prevent the Chrome Developer Tools console from logging image 404 errors? [duplicate]

This question already has answers here:
Suppress Chrome 'Failed to load resource' messages in console
(3 answers)
Closed 5 years ago.
The Chrome Developer Tools console logs an error each time a page asset (including an image) isn't found (i.e. returns 404).
In my work, I'm often working on sites where images are provided by third parties and may not be available during development. Having each missing image show up as an error in the console makes other more important errors (e.g. JavaScript errors) harder to notice.
Is there a setting that stops the console logging unfound images as errors?
Or is there some way to filter console messages by the same sort of criteria that you can filter requests by in the Network tab?
(See e.g. http://chromium.googlecode.com/issues/attachment?aid=1337330000000&name=Screenshot-Google%2B+-+Google+Chrome.png&token=1F05er8uKjAQEEBrUITFjsIGJ2A%3A1358867878658&inline=1)
Work has "started" on this by the Chromium team: https://code.google.com/p/chromium/issues/detail?id=96212
Update: The feature request was closed on March 18, 2013. I'm not sure in which version of Chrome this feature first appeared, but I can confirm console filtering options in my Chrome v33.0.1750.152 (Linux).
Update 2: Currently, when a filter (plain text or regular expression) is entered, it is tested against the message text (e.g. GET http://example.com/foobar 404 (Not Found)) as well as the text of the right side link (e.g. test.html:65). (I have filed an issue with Chromium to track this.)
As a workaround, use a regular expression filter like:
^(?!.* 404 \(Not Found\))(?!.*[file name])
where [file name] is the file name from the right side link.
For example, if my page is test.html, then ^(?!.* 404 \(Not Found\))(?!.*test\.html) will work.
Note: This will also filter out messages that have the file name in the message text. I'm not sure there is a way around this for now.
Update (2019-06-05): This expression will filter out 404s in my current version of Chrome (75.0.3770.80):
-/404\s\(Not\sFound\)$/
It seems the filtering first splits the filter string by whitespace before processing each token, but it will also split spaces inside of a regular expression, so the \s's are necessary.
Technically, this will filter out any message ending with the (case insensitive) string "404 (Not Found)", including console.log messages.
In the chrome developer tools, it's under the "Console" tab. Click "Filter" and it will be on the filter line as a checkbox.
As an alternative answer you could run a bit of javascript to alter the src attribute of the offending images when on your dev server (just make sure you don't publish it to your production environment!).
If you don't want to actually add javascript to the page (understandably) you could probably run the script on load of the page via a chrome plugin (perhaps the greasemonkey chrome clone - tampermonkey).
n.b. Thanks for the feedback, notably for this to work it'll need to be within an event after the dom is ready and before the images load.
In your app, in your 'catch' statement.. log the exception under 'console.warn' .. know it works with firebug. In Firebug, you can then find these 'errors' under the 'warnings' tab. I would like to think the same can be true for Chrome Developer Tools..
actually did something similar day ago.. my app would stop on some error, so, I instead used the 'try' and 'catch' block. My catch looks like:
catch (e) {
console.warn(e);
}

Wordpress 3.2.1 javascript error - $ is not a function

I'm receiving a $ is not a function error. This is new since I updated from 3.2.1.
I have an identical setup working on 3.1.
Have folks run into this issue? I have turned off all plugins and am just attempting to load the superfish (or any jquery) and am receiving this error.
What changed that I'm missing? These are all currently on the same server if that is any help.
thank you,
What happens if you change $ to jQuery? Does that work? $ is simply a variable for the jQuery object. In some setups, you need to use jQuery rather than $.
EDIT
I had the same error, and it was because of jQuery not loaded.
You can this error if your jquery is not loading. To determine if this is the case, you need to debug your webpage network traffic using IE9 -> F12 -> Network -> Capture to see if you get 404 for jQuery files (i.e. something/wp-includes/jquery.js), or use same thing in Firefox's Firebug extension.
You can also search for jquery in page source, it should be in tag, and when you find src (i.e. http://code.jquery.com/jquery-1.6.4.min.js) try open it, if it says 404 not found then you need to place jquery in that file on server (or change whatever php/plugin loads that script tag to correct path)
If you do not know how to do this, please provide link to your wordpress installation.

Categories

Resources