-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please provide an example using @piwikpro/pwa-piwik-pro #19
Comments
Hi @BenLune! I'm the PM of the team responsible for Integrations at Piwik PRO. I'd like to confirm that we have received your request and planned the time to verify if and how quickly we are able to help you with it, as the full update of the Angular library is planned for a later term. We'll come back with an update on Monday. |
Hi @emtomczyk , |
Hey @BenLune, thanks for your patience. You have opened an issue in ngx-piwik-pro project, but if I understand correctly you would like to be able to use pwa-piwik-pro together with your Angular based project. I would like to make it clear that pwa-piwik-pro is a separate project and does not require ngx-piwik-pro to work, it can work independently. In fact, you can use PWA Piwik PRO even with Vanilla JS. Very importantly, PWA Piwik PRO is an extension to the Service Worker - please note that we do not import this package into the application project. Of course, sometimes the framework helps to build the serviceworker.js file however, this depends on the framework you use. You can find the pwa-piwik-pro project under HERE. To enable collecting data from your PWAs using Piwik PRO Analytics, call the initialize() method in your service worker: import PiwikPro from '@piwikpro/pwa-piwik-pro';
PiwikPro.initialize({
containerURL: 'example.com',
containerId: '12345678-1234-1234-1234-1234567890ab'
}); This is all that's required to queue and retry failed requests to Piwik PRO, and it's the simplest way to get Piwik PRO working offline. It is important to know that Angular generates the service worker file itself by default. Therefore, it is important to follow the Angular documentation in this case. Short steps on what to do to provide your own service worker without giving up the default one that angular provides.To avoid working with pure js I add custom-service-worker.ts file to the project. I make sure that it is built to custom-service-worker.js in the application building process.
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// ... other imports
import { ServiceWorkerModule } from '@angular/service-worker';
@NgModule({
declarations: [
AppComponent,
// ...
],
imports: [
// ...
ServiceWorkerModule.register('custom-service-worker.js'),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import PiwikPro from '@piwikpro/pwa-piwik-pro/src';
PiwikPro.initialize({
containerURL: 'https://test.piwik.pro',
containerId: '0c0a8661-8c10-4f59-b8fc-1c926cbac184'
});
importScripts('./ngsw-worker.js'); // Important if you don't want to lose the features that angular's default service worker provides.
self.addEventListener('message', (event) => {
console.log('message picked up by custom service worker code', event);
});
Hopefully, I have explained to you how pwa-piwik-pro works and from now on you will know how to implement it in your project. If anything remains unclear feel free to contact me! |
Hi @danieltwork , |
@BenLune, You need to know that our pwa-piwik-pro library is responsible for storing requests that have not been correctly sent to the server due to a lack of internet connection. If the library detects an internet connection, it will try to send the stored requests. This is the only thing pwa-piwik-pro does. Treat pwa-piwik-pro as an extension. Sending events will not happen without using container script. Tasks such as sending events, route change detection, etc. are performed by the container scripts you paste onto the page. Of course, if you are using an SPA framework a better choice would be to use a framework-specific library. Such libraries generate the container code and insert it at the best time into the application code, so that you do not have to do it manually. I hope I have explained what the pwa-piwik-pro library is. |
Hi,
I subscribed to the Piwik Pro Plan and wanted to use @piwikpro/pwa-piwik-pro in my angular project. It doesn't work for me yet.
Could you please update the angular example using it please ? You'll will have to make your example a PWA, then use @piwikpro/pwa-piwik-pro package.
I see that there are few answers to issues here, please give me a feedback.
Thanks,
Benoît
The text was updated successfully, but these errors were encountered: