This repository was archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6132 from trufflesuite/add-mixpanel
replace google analytics with mixpanel
- Loading branch information
Showing
10 changed files
with
211 additions
and
242 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const Config = require("@truffle/config"); | ||
const userConfig = Config.getUserConfig(); | ||
const version = require("../../version").info(); | ||
const TRUFFLE_TOKEN = version.bundled | ||
? "1d07dcde31267402f4ad0740bcc0d797" | ||
: "2247a338c6bbd7e9a65bb3923e5b10b8"; | ||
const Mixpanel = require("mixpanel"); | ||
|
||
module.exports = { | ||
sendAnalyticsEvent: function (eventObject) { | ||
const { userId } = this.getUserId(); | ||
const sendObject = {}; | ||
const eventType = eventObject.command ? "command" : "error"; | ||
if (eventObject.command) { | ||
sendObject["ec"] = eventObject["command"]; | ||
sendObject["ea"] = JSON.stringify(eventObject["args"]); | ||
sendObject["el"] = eventObject["version"]; | ||
sendObject["dp"] = "/" + eventObject["command"]; | ||
} else { | ||
sendObject["ec"] = "Error"; | ||
sendObject["ea"] = "nonzero exit code"; | ||
sendObject["el"] = | ||
eventObject["version"] + " " + eventObject["exception"]; | ||
sendObject["dp"] = "/error"; | ||
} | ||
|
||
if (userId) { | ||
const mixpanel = Mixpanel.init(TRUFFLE_TOKEN, { | ||
keepAlive: false | ||
}); | ||
mixpanel.track(eventType, eventObject); | ||
} | ||
|
||
return true; | ||
}, | ||
|
||
getUserId: function () { | ||
return { userId: userConfig.get("uniqueId") }; | ||
} | ||
}; |
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.