Im using google analytics in my app. I want to start tracking on platform ready. But the code consoled in to catch function. My code is
GoogleAnalytics.startTrackerWithId('UA-xxxxxxxx-1'); //replaced id
.then(function() {
console.log('Google analytics is ready now');
}).catch(function(e) {
console.log('Error starting GoogleAnalytics', e);
});
My output is Error starting GoogleAnalytics Tracker not started. How to solve this? Thanks in advance..
Make sure you're using the latest ionic the problem was in an old ionic native version where the parameters had a problem, have a look here:
https://github.com/danwilson/google-analytics-plugin/issues/291
I've got the same issue, after updating all plugins inside the platform.json the tracking is working without any problems.
Make sure its in Platform ready, And it will only work on a device.
import { GoogleAnalytics } from 'ionic-native';
import { Platform } from 'ionic-angular';
constructor(public plt: Platform) {
this.plt.ready().then((readySource) => {
GoogleAnalytics.startTrackerWithId('YOUR_TRACKER_ID')
.then(() => {
console.log('Google analytics is ready now');
// Tracker is ready
// You can now track pages or set additional information such as AppVersion or UserId
})
.catch(e => console.log('Error starting GoogleAnalytics', e));
});
}
Is a problem related with google-play-services incompatibilities. For fix it you have to make sure that all the PLAY_SERVICES_VERSION are the same, in my case for google-maps, googleplus and the rest I used 15.0.2, but for analytics I have to use 15.0.2 (because there are not a 15.0.1 in maven repo).
SO go to your config.xml and add/change your analytics plugin tag to
<plugin name="cordova-plugin-google-analytics">
<variable name="PLAY_SERVICES_VERSION" value="15.0.2" />
</plugin>
and make sure that all the other plugins have some 15.* version. (if you are using another one just make sure that all play service use the same version)
Then if you already added a platform, go to platforms/android/project.properties and the same, just make sure that all play-services libraries are the same version. for example I have:
cordova.system.library.10=com.google.android.gms:play-services-analytics:15.0.2
cordova.system.library.13=com.google.android.gms:play-services-maps:15.0.1
...
Hope that this work for you, work for me after a lot of research.
Related
How can I use Koa library, the express replacement, in Cloud Functions?
I know KOA use all great ES2017 and make more use of Async use of JavaScript.
or it might not be needed at all working with Cloud Functions because the Firebase system won't send multiple calls to the same Cloud Function until it ends the previous one?
it unclear to me.
it know demands Node 8.x and I know the NodeJs 8.9.x, has now LTS.
Reading from cloud functions doc:
Base Image Cloud Functions uses a Debian-based execution environment
and includes contents of the gcr.io/google-appengine/nodejs Docker
image, with the Node.js runtime installed in the version, specified
above:
FROM gcr.io/google-appengine/nodejs
RUN install_node v6.14.0
To see what is included in the image, you can check its GitHub
project, or pull and inspect the image itself. Updates to the language
runtime (Node.js) are generally done automatically (unless otherwise
notified), and include any changes in the definition of the base
image.
And I saw a pull request back in November 2017, adding Nodejs v8. Here's hoping it can finally land in Google Cloud Functions 🤞🏻
UPDATE: Google Cloud Functions now support Node.js 8 and even Python!
Referring to the release notes from Google... Cloud Functions Release Notes
Node version supported is still at v6, same for firebase. You need to wait awhile before they release it in v8. Am pretty sure they will move to v8 when v6 no longer supported, but hopefully earlier...
Use babel:
index.js:
----------=
'use strict';
require('#babel/register')
require('babel-polyfill')
const http = require('http')
const createApp = require('./app/app.js')
const handle = createApp().callback()
if (process.env.IS_LOCAL_DEPLOYMENT) {
// to use same code in local server
http.createServer(handle).listen(3000)
} else {
module.exports.http = (request, response) => {
handle(request, response)
};
}
app.js:
--------
'use strict';
const Koa = require('koa')
module.exports = () => {
const app = new Koa()
app.use(......)
return app
}
package.json
------------
"scripts": {
.
.
"start": "export IS_LOCAL_DEPLOYMENT=true && node index"
.
.
}
I just saw in Cloud Functions Console editor for one of my functions that Node 8 is now a runtime option. See screenshot:
I am using the native Google Maps plugin in ionic and I am encountering a strange situation. Basically, I followed the example from the Ionic site. So when I start the app on androidn using ionic cordova run android this work fine. However, if I add --livereload, the map refuses the load. Actually, GoogleMaps.create() method returns an empty object {}. Anyone encountered this?
I am assuming that --livereload has a backend web server running that reloads the app which might cause the native plugin to fail?
Any insights?
For the livereload, insert setTimeout() before GoogleMaps.create().
Because when the app executed GoogleMaps.create(), platform.ready() is not ready.
loadMap() {
setTimeout(() => {
this.map = GoogleMaps.create('map_canvas');
}, 1000);
}
The Problem
I'm having an issue with a website (built w/ the Polymer Shop template) in production that's serving up old versions of code despite my new and improved deployments.
I'm using the Polymer CLI $ polymer build command along w/ the Firebase Tools $ firebase deploy command to push up changes to Firebase Hosting. After deploy is complete, I navigate to the website only to see the changes not updating:
Chrome: I see the old version of the website first and have to "hard refresh" for the changes to appear.
FireFox: I see the old version of the website first and have to "hard refresh" for the changes to appear.
Here's the before n' after shot:
Service Worker workflow?
I'm trying to figure out what the best workflow is for this. I want to set things up so that every time I make a new deploy, the entire site is wiped clean and the service worker resets itself through the inter webs and I'll be 100% sure that existing users will get that newly deployed experience
with out having to hard refresh or use incognito mode.
Should I...
Delete the service worker and deploy the new version without it (bad idea) ?
Create a "New Project" in the Firebase Console and re-link the custom domain up (tedious) ?
Find the "magic button" to press inside Firebase Console to reset (does this exist) ?
Edit the sw-precache-config.js file (not sure how) ?
Handle this in the $ polymer build to configure the sw-precache (not sure how) ?
Something awesome that don't even know about ¯\_(ツ)_/¯ ?
I know that the problem exists inside the sw-precache-config.js file, but I'm unsure if this is where I should be fixing this.
module.exports = {
staticFileGlobs: [
'/index.html',
'/manifest.json',
'/bower_components/webcomponentsjs/webcomponents-lite.min.js',
'/images/*'
],
navigateFallback: '/index.html',
navigateFallbackWhitelist: [/^(?!.*\.html$|\/data\/).*/],
runtimeCaching: [
{
urlPattern: /\/data\/images\/.*/,
handler: 'cacheFirst',
options: {
cache: {
maxEntries: 200,
name: 'items-cache'
}
}
},
{
urlPattern: /\/data\/.*json/,
handler: 'fastest',
options: {
cache: {
maxEntries: 100,
name: 'data-cache'
}
}
}
]
};
The Service Worker is an amazing tool and I definitely want it in my projects. I just need to learn how to tame the beast.
I don't know about polymer, but this is the flow I usually do with service workers.
- In the client I check if there is a update, the app notify the user if he/she wants to update.
- User accepts new version, then client send a message to sw to skipWating.
client.js:
navigator.serviceWorker.register('/serviceWorker.js').then(function(reg) {
reg.addEventListener('updatefound', function() {
reg.installing.addEventListener('statechange', function() {
if (reg.installing.state == 'installed') {
// Notify the user, there is a app new version.
// User accept
reg.installing.postMessage({msg: 'skipwaiting'});
}
});
});
});
-In the service worker listen for the message and skipWating if user accepts the new version.
serviceWorker.js:
self.addEventListener('message', function(event) {
if (event.data.msg === 'skipwaiting') {
self.skipWaiting();
}
});
The client refresh the application after the service worker has change state.
client.js:
let refreshing;
navigator.serviceWorker.addEventListener('controllerchange', function() {
if (refreshing)
return;
window.location.reload();
refreshing = true;
});
Maybe this can give you an idea.
I have a WP8 HTML/JS app and I need to save some simple data on the local storage. It should be something very easy, but it is giving my a headache already.
I tried to call the localStorage in many different ways but it doesn't work. The error message I get is:
The system cannot find the file specified.
The strange part, is that the sessionStorage seems to be fine. At least I don't get any error using that object.
Additional info:
- The ways I called localStorage are: localStorage.setItem(), window['localStorage'], window.localStorage, etc. they all say the same message.
- I am developing a Windows Phone HTML app OS8.
- The method I call the localStorage is in $('#channels').bind('pagebeforeshow', function (e, data) {...}
- The only references in the project are .Net for Windows Phone and Windows Phone.
- Some of the js libs I included are jQuery, jQuery mobile and ko.
- I am testing on both WP8 device and Emulator
I prefer not to use phoneGap and any other known db for devices, since I wouldn't like to involve interaction with the native code just to make the call to fetch and save some data.
UPDATE 1:
After thefrontender comment, I investigated one by one my js refs. The problem appear when I add the jqm 1.3 min.
All js are bundled with my app. Any other suggestions?
$(function () {
try {
localStorage.setItem('aaa', 123);
alert(localStorage.aaa);
}
catch (err) { alert(err.message) }
});
And if you replace
alert(localStorage.aaa);
with
alert(localStorage.getItem('aaa');
I got my answer form jQuery official forum after all.
You need to add modernizr with atleast localStorage from HTML5 section.
Add: (first or last doent matter)
as indicated in the following post too:
http://www.pksoftlab.com/?p=1073
I'm having an issue with the visualization of my site on Google Chrome and Safari (both using Webkit rendering engine), the site is built upon Symfony framework, version 1.1 (unmaintained version).
When navigating to the site, this shows an error 500 when loading a page, I read somewhere that it might be related to Symfony caching but I don't know how to solve it and turning off caching is not a solution.
Thankyou in advance.
This ticket fixes the problem, so you can patch your sfWebRequest class code.
You can see the actual problem by browsing via "dev" controller. It's called by default: yourAppName_dev.php
So if you have a "frontend" app, it's:
http://domain.tld/frontend_dev.php
Yes, most of the cases for error 500 is the cache. You can clear the cache by navigating to your project root directory and type:
symfony cc
or
./symfony cc
or
php symfony cc
which depends of you environment and setup.
Also you can delete the content of the cache directory located in your project root manually.
Hope this helps.
See this: http://forum.symfony-project.org/index.php/m/75225/
To fix, change your config/ProjectConfiguration.class.php to include the following:
public function setup()
{
// keep current code here and then add...
$this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
}
public function filterRequestParameters(sfEvent $event, $parameters)
{
$request = $event->getSubject();
if (preg_match('|Safari/([0-9\.]+)|', $request->getHttpHeader('User-Agent')))
{
$request->setRequestFormat('html');
}
return $parameters;
}