-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
404 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<div fxLayout="column" fxFlex> | ||
<ui-contextual-action-bar></ui-contextual-action-bar> | ||
<ui-contextual-action-bar></ui-contextual-action-bar> | ||
|
||
<div fxFlex class="outlet-container" [@routerTransition]="routerTransition | async"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
<div fxFlex class="outlet-container" [@routerTransition]="routerTransition | async"> | ||
<router-outlet></router-outlet> | ||
</div> | ||
|
||
<ui-data-collection></ui-data-collection> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import * as ua from 'universal-analytics'; | ||
import {ipcMain} from 'electron'; | ||
const uuidv4 = require('uuid/v4'); | ||
const Store = require('electron-store'); | ||
const store = new Store(); | ||
|
||
const visitor = new ua.Visitor('UA-88380372-8', getUuiId(), { | ||
https: true | ||
}); | ||
|
||
// must be called before electron app is created | ||
export function setUpAnalytics() { | ||
process.env.trackingID = 'UA-88380372-8'; | ||
ipcMain.on( | ||
'reportEvent', | ||
(event: any, arg: any) => reportEvent(arg.categroy, arg.action, arg.label, arg.value)); | ||
ipcMain.on( | ||
'dataCollectionEvent', | ||
(event: any, arg: any) => dataCollectionEvent(arg.value)); | ||
ipcMain.on( | ||
'reportPageView', | ||
(event: any, arg: any) => reportPageView(arg.path)); | ||
ipcMain.on( | ||
'reportException', | ||
(event: any, arg: any) => reportException(arg.description)); | ||
} | ||
|
||
export function dataCollectionEvent(value: boolean) { | ||
store.set('canCollectData', value); | ||
visitor.event("DataCollection", "DataCollectionResponse", value.toString()).send(); | ||
} | ||
|
||
export function reportEvent(category: string, action: string, label?: string, value?: number) { | ||
if (canCollectData()) { | ||
if (value) { | ||
visitor.event(category, action, label, value, {}).send(); | ||
} else { | ||
visitor.event(category, action, label).send(); | ||
} | ||
} | ||
} | ||
|
||
export function reportException(description: string) { | ||
if (canCollectData()) { | ||
console.error(description); | ||
visitor.exception(description).send(); | ||
} | ||
} | ||
|
||
export function reportPageView(path: string) { | ||
if (canCollectData()) { | ||
visitor.pageview(path, 'Angular Console', '6.0.0-beta.1').send(); | ||
} | ||
} | ||
|
||
function getUuiId() { | ||
if (store.get('uuid')) { | ||
return store.get('uuid'); | ||
} | ||
const uuid = uuidv4(); | ||
store.set('uuid', uuid); | ||
return uuid; | ||
} | ||
|
||
function canCollectData(): boolean { | ||
return store.get('canCollectData') === true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
libs/ui/src/lib/data-collection/data-collection.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div id="data-collection" *ngIf="showMessage"> | ||
<p> | ||
Help making Angular Console better by sending anonymous usage data to the Angular Console team. | ||
</p> | ||
|
||
<button mat-stroked-button color="primary" (click)="close(true)">Send</button> | ||
<button mat-stroked-button (click)="close(false)">Do not send</button> | ||
</div> |
19 changes: 19 additions & 0 deletions
19
libs/ui/src/lib/data-collection/data-collection.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#data-collection { | ||
position: absolute; | ||
width: 400px; | ||
padding: 20px; | ||
margin: 20px; | ||
bottom: 0; | ||
right: 0; | ||
background-color: rgb(242, 242, 242); | ||
border: 1px solid rgb(200, 200, 200); | ||
|
||
p { | ||
font-size: 14px; | ||
color: rgba(0, 0, 0, 0.54) !important; | ||
} | ||
|
||
button { | ||
margin-right: 5px; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
libs/ui/src/lib/data-collection/data-collection.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Component } from '@angular/core'; | ||
import { AnalyticsCollector, Settings } from '@angular-console/utils'; | ||
|
||
@Component({ | ||
selector: 'ui-data-collection', | ||
templateUrl: './data-collection.component.html', | ||
styleUrls: ['./data-collection.component.scss'] | ||
}) | ||
export class DataCollectionComponent { | ||
constructor( | ||
private readonly analytics: AnalyticsCollector, | ||
private readonly settings: Settings | ||
) {} | ||
|
||
get showMessage() { | ||
return this.settings.canCollectData() === undefined; | ||
} | ||
|
||
close(value: boolean) { | ||
this.settings.setCanCollectData(value); | ||
this.analytics.reportDataCollectionEvent(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.