Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions build-helpers/index-maker.js

This file was deleted.

73 changes: 18 additions & 55 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,18 @@
const fs = require('fs');
const path = require('path');
const ncp = require('ncp');
const rimraf = require('rimraf');
const less = require('less');
const ng2Inline = require('./build-helpers/inliner');

const inline = (dir) => {
let files = fs.readdirSync(dir);

files.forEach((file) => {
const src = path.join(dir, file);

if (fs.statSync(src).isDirectory()) {
inline(src);
}
else if (src.endsWith('.component.ts')) {
ng2Inline(fs.readFileSync(src, 'utf-8'), {
base: dir
}, dir).then((file) => {
fs.writeFileSync(src, file);
});
}
});
};

console.log('cleaning...');
rimraf.sync('prebuild', fs, (err) => {
if (err) {
return console.error(err);
}
});

rimraf.sync('aot', fs, (err) => {
if (err) {
return console.error(err);
}
});

console.log('done cleaning!');

console.log('cloning src...');
ncp('src', 'prebuild', (err) => {
if (err) {
return console.error(err);
}

console.log('done cloning src!');

console.log('inlining...');
inline(path.resolve('./prebuild/'));
console.log('done inlining!');

console.log('ready for ngc!');
});
const fs = require('fs').promises;

async function setGa() {
const html = await fs.readFile('./dist/index.html', 'utf-8');
const newHtml = html.replace('<!--GA-->', `
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-86826463-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-86826463-1');
</script>
`);

await fs.writeFile('./dist/index.html', newHtml);
}

setGa();
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"e2e": "ng e2e --port 3200",
"e2e:quick": "ng e2e --dev-server-target --webdriverUpdate=false",
"e2e:headless": "HEADLESS=true ng e2e",
"build:index": "cd build-helpers && node index-maker.js",
"build:index": "node build.js",
"build:demo": "rm -rf dist/ && ng build --prod --base-href /angular-datepicker/ && npm run build:index",
"build:prod": "ng-packagr -p package.json",
"release": "npm run build:prod && npm publish bin",
Expand Down
8 changes: 0 additions & 8 deletions src/demo/demo/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,6 @@ export class DemoComponent implements OnInit {
console.log(data);
}

trackFiver(): void {
this.gaService.emitEvent('fiverr', 'clicked');
}

toggleDisabled(disabled: boolean) {
disabled ? this.formGroup.disable() : this.formGroup.enable()
}

private buildForm(): FormGroup {
return new FormGroup({
datePicker: new FormControl({value: this.date, disabled: this.disabled}, [
Expand Down
16 changes: 7 additions & 9 deletions src/demo/services/ga/ga.service.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import {Injectable} from '@angular/core';
import {environment} from '../../../environments/environment';

declare const ga: Function;
declare const gtag: Function;

@Injectable()
export class GaService {

public emitEvent(eventCategory: string,
eventAction: string,
eventLabel: string = null,
eventLabel: string,
eventValue: number = null) {
if (environment.production && window['ga']) {
ga('send', 'event', {
eventCategory: eventCategory,
eventLabel: eventLabel,
eventAction: eventAction,
eventValue: eventValue
if (environment.production && window['gtag']) {
gtag('event', 'send', {
event_category: eventCategory,
event_label: eventLabel,
value: eventValue
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<script id="ga-analitics"></script>
<!--GA-->

<dp-demo-root>Loading...</dp-demo-root>

Expand Down