This repository has been archived by the owner on Apr 22, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used to determine which parts to spend time on. Tracking is done through Google Analytics and is completely anonymous. A unique id is generated the first time you install the plugin, but is in no way coupled to an EA identifier.
- Loading branch information
1 parent
6767329
commit 5207058
Showing
11 changed files
with
190 additions
and
100 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import ua from 'universal-analytics'; | ||
import uuid from 'uuid'; | ||
|
||
import { Database } from './db'; | ||
|
||
class Analytics { | ||
constructor() { | ||
if (this.ua === undefined) { | ||
let id = Database.get('uuid', ''); | ||
if (id === '') { | ||
id = uuid.v4(); | ||
Database.set('uuid', id); | ||
} | ||
|
||
this.ua = ua({ | ||
tid: UA_TOKEN, | ||
cid: id, | ||
uid: id, | ||
}); | ||
} | ||
} | ||
|
||
trackPage(pageId) { | ||
return new Promise((resolve, reject) => { | ||
this.ua.pageview(pageId, (err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
trackEvent(category, action, label = null, value = null) { | ||
return new Promise((resolve, reject) => { | ||
this.ua.event(category, action, label, value, (err) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export default new Analytics(); |
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
Oops, something went wrong.