Skip to content

Commit

Permalink
automatic-commit-alias
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianobapo committed Mar 5, 2017
1 parent 6b6145f commit ffe3231
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 59 deletions.
25 changes: 20 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,20 @@ gulp.task('preprocess-html', function() {
});
});

const psi = require('psi');


// Run PageSpeed Insights
gulp.task('pagespeed', cb =>
gulp.task('pagespeed', cb =>{

var psi = require('psi');
// Output a formatted report to the terminal
psi.output('delivery-v3.ilhanet.com').then(() => {
console.log('done');
})
psi.output('https://delivery-v3.ilhanet.com').then(
(att) => console.log('done',att),
(att) => console.log('reject',att)
)
}


// Update the below URL to the public URL of your site
// psi('delivery-v3.ilhanet.com', {
// strategy: 'mobile'
Expand All @@ -48,6 +54,15 @@ gulp.task('pagespeed', cb =>
// }, cb)
);

gulp.task('pagespeed2', cb =>{
var psi = require('psi');
// Output a formatted report to the terminal
psi.output('https://delivery24horas.com').then(
(att) => console.log('done',att),
(att) => console.log('reject',att)
)
});

gulp.task('generate-service-worker', function(callback) {
var path = require('path');
var swPrecache = require('sw-precache');
Expand Down
11 changes: 10 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ import {CartService} from '../providers/cart-service';
import {ProductService} from "../providers/product-service";
import {CategoriesService} from "../providers/categories-service";
import {CepService} from "../providers/cep-service";
import {AnalyticsService} from "../providers/analytics-service";

@Component({
templateUrl: 'app.html',
providers: [DataService, LogService, CepService, CartService, CategoriesService, ProductService]
providers: [
DataService,
LogService,
CepService,
CartService,
CategoriesService,
ProductService,
AnalyticsService
]
})
export class MyApp {
rootPage = HomePage;
Expand Down
16 changes: 16 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,28 @@ <h2 style="text-align: center" *ngIf="false">Carregando...</h2>
<!-- @if CORDOVA -->
addScript('cordova.js');
<!-- @endif -->
// addScript('https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js');
addScript('https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/shim.min.js');
addScript('build/polyfills.js');
addScript('https://cdn.polyfill.io/v2/polyfill.js?features=Intl.~locale.pt-BR');
addScript('build/main.js');
}(document, 'script'));
</script>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-59766919-3', 'auto');
ga('send', 'pageview');
// Requires the Enhanced Ecommerce plugin.
ga('require', 'ecommerce');
// ga('require', 'ec');

</script>

<!--<script src="build/main.js" type="text/javascript" async></script>-->

</body>
Expand Down
3 changes: 3 additions & 0 deletions src/pages/cart/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {LogService} from "../../providers/log-service";
import {CepService} from "../../providers/cep-service";
import {NavController} from "ionic-angular";
import {CheckoutPage} from "../checkout/checkout";
import {AnalyticsService} from "../../providers/analytics-service";

/*
Generated class for the Cart page.
Expand All @@ -27,11 +28,13 @@ export class CartPage{
constructor(protected navCtrl: NavController,
protected cartService: CartService,
protected cepService: CepService,
protected analyticsService: AnalyticsService,
protected log: LogService) {
}

ionViewDidLoad() {
this.log.l('ionViewDidLoad CartPage');
this.analyticsService.sendPageviewGa('/cart');
}

onKeyUpLogradouro($event){
Expand Down
4 changes: 3 additions & 1 deletion src/pages/checkout/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Component, OnInit} from '@angular/core';
import {NavController, NavParams} from 'ionic-angular';
import {CartService} from "../../providers/cart-service";
import {LogService} from "../../providers/log-service";
import {AnalyticsService} from "../../providers/analytics-service";

/*
Generated class for the Checkout page.
Expand Down Expand Up @@ -31,13 +32,14 @@ export class CheckoutPage implements OnInit {
constructor(protected navCtrl: NavController,
protected cartService: CartService,
protected navParams: NavParams,
protected analyticsService: AnalyticsService,
protected log: LogService) {
this.fillOrder();
}

ionViewDidLoad() {
this.log.l('ionViewDidLoad CheckoutPage');

this.analyticsService.sendPageviewGa('/checkout');
}

ngOnInit() {
Expand Down
7 changes: 7 additions & 0 deletions src/pages/home/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {ProductPage} from "../product/product";
import {BasePage} from "../base-page";
import {CartService} from "../../providers/cart-service";
import {CartPage} from "../cart/cart";
import {AnalyticsService} from "../../providers/analytics-service";

@Component({
selector: 'page-home',
Expand All @@ -24,10 +25,16 @@ export class HomePage extends BasePage implements OnInit {
protected log: LogService,
protected categoriesService: CategoriesService,
protected productService: ProductService,
protected analyticsService: AnalyticsService,
protected cartService: CartService) {
super();
}

ionViewDidLoad() {
this.log.l('ionViewDidLoad HomePage');
this.analyticsService.sendPageviewGa('/home');
}

ngOnInit() {
this.categoriesService.findAll().subscribe(
data => this.categories = data,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/product/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ProductService} from "../../providers/product-service";
import {CategoriesService} from "../../providers/categories-service";
import {CartPage} from "../cart/cart";
import {HintPopoverPage} from "../hint-popover/hint-popover";
import {AnalyticsService} from "../../providers/analytics-service";

/*
Generated class for the Product page.
Expand Down Expand Up @@ -41,6 +42,7 @@ export class ProductPage extends BasePage implements OnInit {
protected cartService: CartService,
protected productService: ProductService,
protected categoriesService: CategoriesService,
protected analyticsService: AnalyticsService,
protected popoverCtrl: PopoverController) {
super();
}
Expand All @@ -54,6 +56,7 @@ export class ProductPage extends BasePage implements OnInit {
}

ngOnInit() {
this.analyticsService.sendPageviewGa('/product');
let categoryId = this.navParams.get("categoryId");
this.categoriesService.findAll().subscribe(
data => {
Expand Down
74 changes: 74 additions & 0 deletions src/providers/analytics-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {Injectable} from '@angular/core';
import 'rxjs/add/operator/map';
import {Title} from "@angular/platform-browser";

window.ga = window.ga || {};

/*
Generated class for the AnalyticsService provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class AnalyticsService {

protected googleAnalytics;

constructor(protected titleService: Title) {
console.log('Hello AnalyticsService Provider');

if(window.hasOwnProperty('ga')) {
this.googleAnalytics = window.ga;
console.log(window.ga);
}
}

sendTransactionGa(){
this.googleAnalytics('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'Delivery24Horas', // Affiliation or store name.
// 'revenue': '11.99', // Grand Total.
// 'shipping': '5', // Shipping.
// 'tax': '1.29' // Tax.
'currency': 'BRL' // local currency code.
});
}

sendOrderGa(){
this.googleAnalytics('send', 'event', 'Enviar Pedido', 'submit');
this.googleAnalytics('ecommerce:send');
}

sendPageviewGa(page='/home'){
let params = {
'hitType': 'pageview',
'title': this.titleService.getTitle(),
'page': page
};
this.googleAnalytics('send', params);

}

sendAddProductGa(itemFields){
this.googleAnalytics('send', 'event', {
'eventCategory': 'Products',
'eventAction': 'AddItem'
});
this.googleAnalytics('ecommerce:addItem', {
'id': '1234', // Transaction ID. Required.
'sku': itemFields.product_id.toString(),
'name': 'Android T-Shirt',
'price': itemFields.valor_unitario.toString(),
'quantity': itemFields.quantidade
});

this.googleAnalytics('ecommerce:send');
// ga('ec:addProduct', {'id': 'P12345'});
// ga('ec:addProduct', {'name': 'Android T-Shirt'});
// ga('ec:addProduct', {'price': '29.20'});
// ga('ec:addProduct', {'quantity': 2});
}


}
25 changes: 18 additions & 7 deletions src/providers/cart-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {LogService} from "./log-service";
import {ProductService} from './product-service';
import {DataService} from "./data-service";
import {FormBuilder, FormControl, Validators, FormGroup, AbstractControl} from "@angular/forms";
import {AnalyticsService} from "./analytics-service";

/*
Generated class for the CartService provider.
Expand Down Expand Up @@ -34,6 +35,7 @@ export class CartService {
constructor(protected productService: ProductService,
protected log: LogService,
protected dataService: DataService,
protected analyticsService: AnalyticsService,
protected formBuilder: FormBuilder) {
this.log.l('Hello CartService Provider');

Expand Down Expand Up @@ -69,20 +71,28 @@ export class CartService {
contacts: this.contacts,
items: this.items
});

this.analyticsService.sendTransactionGa();
}

add(productId) {
let updatedItems = this.items.value;
let itemFields = {
mandante: this.mandante,
cost_id: this.productService.getCostId(productId),
product_id: productId,
quantidade: 1,
valor_unitario: this.productService.getValorVenda(productId)
};

this.analyticsService.sendAddProductGa(itemFields);

if (this.foundItem(productId))
updatedItems[this.itemIndex(productId)].quantidade++;
else
updatedItems.push({
mandante: this.mandante,
cost_id: this.productService.getCostId(productId),
product_id: productId,
quantidade: 1,
valor_unitario: this.productService.getValorVenda(productId)
});
{
updatedItems.push(itemFields);
}
this.items.setValue(updatedItems);
}

Expand Down Expand Up @@ -159,6 +169,7 @@ export class CartService {
}

submitOrder() {
this.analyticsService.sendOrderGa();
this.order.controls['posted_at'].setValue(CartService.getFormattedDate());
if (this.order.controls['troco'].value!=''){
let newObservacao = 'Troco: '+this.order.controls['troco'].value;
Expand Down
3 changes: 3 additions & 0 deletions src/window.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface Window {
ga: any;
}
84 changes: 42 additions & 42 deletions www/build/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion www/build/main.js.map

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@
id && (elToInsert.id = id);
fjs.parentNode.insertBefore(elToInsert, fjs);
};
// addScript('https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.3/es6-shim.min.js');
addScript('https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/shim.min.js');
addScript('build/polyfills.js');
addScript('https://cdn.polyfill.io/v2/polyfill.js?features=Intl.~locale.pt-BR');
addScript('build/main.js');
}(document, 'script'));</script><!--<script src="build/main.js" type="text/javascript" async></script>--></body></html>
}(document, 'script'));</script><script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-59766919-3', 'auto');
ga('send', 'pageview');
// Requires the Enhanced Ecommerce plugin.
ga('require', 'ecommerce');
// ga('require', 'ec');</script><!--<script src="build/main.js" type="text/javascript" async></script>--></body></html>
2 changes: 1 addition & 1 deletion www/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/* eslint-disable indent, no-unused-vars, no-multiple-empty-lines, max-nested-callbacks, space-before-function-paren, quotes, comma-spacing */
'use strict';

var precacheConfig = [["/assets/fonts/fontawesome-webfont.eot","674f50d287a8c48dc19ba404d20fe713"],["/assets/fonts/fontawesome-webfont.svg","912ec66d7572ff821749319396470bde"],["/assets/fonts/fontawesome-webfont.ttf","b06871f281fee6b241d60582ae9369b9"],["/assets/fonts/fontawesome-webfont.woff","fee66e712a8a08eef5805a46892932ad"],["/assets/fonts/ionicons.eot","bdf1d30681cf87986c385eea78e8de9a"],["/assets/fonts/ionicons.svg","d9496a234c81179afbca6bf5959cc30a"],["/assets/fonts/ionicons.ttf","74c652671225d6ded874a648502e5f0a"],["/assets/fonts/ionicons.woff","81414686e99c00d2921e03dd53c0ab04"],["/assets/fonts/noto-sans-bold.ttf","a165a42685795361b25593effb32fdb1"],["/assets/fonts/noto-sans-regular.ttf","2fd9c16b805724d590c0cff96da070a4"],["/assets/fonts/roboto-bold.ttf","1f4fd7e4df65487f07ba9148f7ca095d"],["/assets/fonts/roboto-bold.woff","43183beef21370d8a4b0d64152287eba"],["/assets/fonts/roboto-light.ttf","9ff15bd34ea83e4dd3f23c20c7f5090e"],["/assets/fonts/roboto-light.woff","7e2d32e7141050d758a38b4ec96390c0"],["/assets/fonts/roboto-medium.ttf","a937e2cae14e68262a45aa91204c2fdf"],["/assets/fonts/roboto-medium.woff","0f3b7101a8adc1afe1fbe89775553c32"],["/assets/fonts/roboto-regular.ttf","07f8fb6acbabeb10d3fad9ab02d65e0b"],["/assets/fonts/roboto-regular.woff","f94d5e5102359961c44a1da1b58d37c9"],["/build/main.css","08cf1f6d9484d24098eb18ac43d1c1ba"],["/build/main.js","c8ac536795b75489a8e7af9304c1e94a"],["/build/polyfills.js","eaa2a2df3350d74170e7de0d05344c72"],["/build/sw-toolbox.js","e7e54a466864d42dcccc8c3f80a91d1f"],["/index.html","38e101bf8d1204af42a1dc0b2ebd5b56"]];
var precacheConfig = [["/assets/fonts/fontawesome-webfont.eot","674f50d287a8c48dc19ba404d20fe713"],["/assets/fonts/fontawesome-webfont.svg","912ec66d7572ff821749319396470bde"],["/assets/fonts/fontawesome-webfont.ttf","b06871f281fee6b241d60582ae9369b9"],["/assets/fonts/fontawesome-webfont.woff","fee66e712a8a08eef5805a46892932ad"],["/assets/fonts/ionicons.eot","bdf1d30681cf87986c385eea78e8de9a"],["/assets/fonts/ionicons.svg","d9496a234c81179afbca6bf5959cc30a"],["/assets/fonts/ionicons.ttf","74c652671225d6ded874a648502e5f0a"],["/assets/fonts/ionicons.woff","81414686e99c00d2921e03dd53c0ab04"],["/assets/fonts/noto-sans-bold.ttf","a165a42685795361b25593effb32fdb1"],["/assets/fonts/noto-sans-regular.ttf","2fd9c16b805724d590c0cff96da070a4"],["/assets/fonts/roboto-bold.ttf","1f4fd7e4df65487f07ba9148f7ca095d"],["/assets/fonts/roboto-bold.woff","43183beef21370d8a4b0d64152287eba"],["/assets/fonts/roboto-light.ttf","9ff15bd34ea83e4dd3f23c20c7f5090e"],["/assets/fonts/roboto-light.woff","7e2d32e7141050d758a38b4ec96390c0"],["/assets/fonts/roboto-medium.ttf","a937e2cae14e68262a45aa91204c2fdf"],["/assets/fonts/roboto-medium.woff","0f3b7101a8adc1afe1fbe89775553c32"],["/assets/fonts/roboto-regular.ttf","07f8fb6acbabeb10d3fad9ab02d65e0b"],["/assets/fonts/roboto-regular.woff","f94d5e5102359961c44a1da1b58d37c9"],["/build/main.css","08cf1f6d9484d24098eb18ac43d1c1ba"],["/build/main.js","8e6ea37e512f66bd86ff44446ac6179d"],["/build/polyfills.js","eaa2a2df3350d74170e7de0d05344c72"],["/build/sw-toolbox.js","e7e54a466864d42dcccc8c3f80a91d1f"],["/index.html","d9de297e7c3f15c7b618333f951035bc"]];
var cacheName = 'sw-precache-v3--' + (self.registration ? self.registration.scope : '');


Expand Down

0 comments on commit ffe3231

Please sign in to comment.