-
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.
feat: provide telemetry to console plugins
- Loading branch information
Showing
13 changed files
with
729 additions
and
536 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
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
4 changes: 2 additions & 2 deletions
4
...c/lib/analytics-collector.service.spec.ts → libs/utils/src/lib/telemetry.service.spec.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
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
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,86 @@ | ||
/* tslint:disable */ | ||
|
||
import * as ua from 'universal-analytics'; | ||
const uuidv4 = require('uuid/v4'); | ||
const Store = require('electron-store'); | ||
|
||
export class Telemetry { | ||
private readonly store = new Store(); | ||
private readonly visitor = new ua.Visitor('UA-88380372-8', this.getUuiId(), { | ||
https: true | ||
}); | ||
|
||
dataCollectionEvent(value: boolean) { | ||
try { | ||
this.visitor | ||
.event('DataCollection', 'DataCollectionResponse', value.toString()) | ||
.send(); | ||
} catch (e) { | ||
console.error('dataCollectionEvent', e); | ||
} | ||
} | ||
|
||
reportEvent( | ||
category: string, | ||
action: string, | ||
label?: string, | ||
value?: number | ||
) { | ||
try { | ||
if (value) { | ||
this.visitor.event(category, action, label!, value, {}).send(); | ||
} else { | ||
this.visitor.event(category, action, label!).send(); | ||
} | ||
} catch (e) { | ||
console.error('reportEvent', e); | ||
} | ||
} | ||
|
||
reportLifecycleEvent(action: string) { | ||
try { | ||
if (this.canCollectData()) { | ||
this.visitor.event('Lifecycle', action).send(); | ||
} | ||
} catch (e) { | ||
console.error('reportLifecycleEvent', e); | ||
} | ||
} | ||
|
||
reportException(description: string) { | ||
try { | ||
if (this.canCollectData()) { | ||
console.error(description); | ||
this.visitor.exception(description).send(); | ||
} | ||
} catch (e) { | ||
console.error('reportException', e); | ||
} | ||
} | ||
|
||
reportPageView(path: string) { | ||
try { | ||
if (this.canCollectData()) { | ||
this.visitor.pageview(path, 'Angular Console', '6.0.0').send(); | ||
} | ||
} catch (e) { | ||
console.error('reportPageView', e); | ||
} | ||
} | ||
|
||
private getUuiId() { | ||
if (this.store.get('uuid')) { | ||
return this.store.get('uuid'); | ||
} | ||
const uuid = uuidv4(); | ||
this.store.set('uuid', uuid); | ||
return uuid; | ||
} | ||
|
||
private canCollectData(): boolean { | ||
const settings = this.store.get('settings'); | ||
return settings && settings.canCollectData; | ||
} | ||
} | ||
|
||
export const telemetry = new Telemetry(); |
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.