-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(GUI): use resin-corvus
in AnalyticsService
#1208
Conversation
resin-raven
in AnalyticsServiceresin-raven
in AnalyticsService
8b8e175
to
b265590
Compare
@stefan-mihaila This line from the Makefile (GitHub doesn't allow me to comment on it): $(foreach prerequisite,$^,$(call execute-command,cp -RLf $(prerequisite) $@)) Can be simplified to |
I think we should move |
We should probably get rid of the following TrackJS configuration: https://github.com/resin-io/etcher/blob/master/lib/gui/index.html#L15. Note that console: {
error: false
} is important to prevent multiple errors (#1176), so I think we should move that configuration setting to resin-raven, in case Sentry doesn't do that already. |
This TrackJS script import should go away as well: https://github.com/resin-io/etcher/blob/master/lib/gui/index.html#L23, along with the |
We pass the application name to TrackJS here: https://github.com/resin-io/etcher/blob/master/lib/gui/index.html#L17. Is that needed for Sentry? Should resin-raven accept that if so? |
lib/gui/modules/analytics.js
Outdated
* | ||
* @param {String} message - message | ||
* | ||
* @example | ||
* AnalyticsService.log('Hello World'); | ||
*/ | ||
this.logDebug = (message) => { | ||
const debugMessage = `${new Date()} ${message}`; | ||
|
||
if (SettingsModel.get('errorReporting') && isRunningInAsar()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is deleting SettingsModel.get('errorReporting')
indented? How does disabling error reporting from the settings page works now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't intended. I did this now: https://github.com/resin-io/etcher/pull/1208/files#diff-05cd97d7d3334a665e1467c4c5d81043R90, let me know what you think. I do need to better test it though.
lib/gui/modules/analytics.js
Outdated
@@ -130,7 +68,7 @@ analytics.service('AnalyticsService', function($log, $window, $mixpanel, Setting | |||
* @public | |||
* | |||
* @description | |||
* This function sends the debug message to TrackJS and Mixpanel. | |||
* This function sends the debug message to Mixpanel and Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can isolate Etcher from the services being used. Something like "THis function sends the debug message to error reporting services" should suffice.
lib/gui/modules/analytics.js
Outdated
@@ -141,21 +79,7 @@ analytics.service('AnalyticsService', function($log, $window, $mixpanel, Setting | |||
* }); | |||
*/ | |||
this.logEvent = (message, data) => { | |||
const debugData = utils.hideAbsolutePathsInObject(utils.makeFlatStartCaseObject(data)); | |||
|
|||
if (SettingsModel.get('errorReporting') && isRunningInAsar()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again here, how do we ensure analytics are not sent anywhere if the user disabled error reporting?
lib/gui/modules/analytics.js
Outdated
@@ -141,21 +79,7 @@ analytics.service('AnalyticsService', function($log, $window, $mixpanel, Setting | |||
* }); | |||
*/ | |||
this.logEvent = (message, data) => { | |||
const debugData = utils.hideAbsolutePathsInObject(utils.makeFlatStartCaseObject(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it looks like you even deleted utils.hideAbsolutePathsInObject
here. Is this function completely unused now? Should we move it to resin raven?
lib/gui/modules/analytics.js
Outdated
@@ -164,7 +88,7 @@ analytics.service('AnalyticsService', function($log, $window, $mixpanel, Setting | |||
* @public | |||
* | |||
* @description | |||
* This function logs an exception in TrackJS. | |||
* This function logs an exception in Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, lets say something generic like "this function logs an exception to an error reporting service" or something like that.
lib/gui/modules/analytics.js
Outdated
errors.shouldReport(exception) | ||
])) { | ||
$window.trackJs.track(exception); | ||
resinRaven.logException(exception); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed .logException
also prints the error, so the $log.error(exception)
would be redundant. Maybe we should only call $log.error(exception)
on an else
block on this conditional?
b265590
to
c428c6f
Compare
Sentry doesn't by default print the errors to the console
It is not needed. |
c428c6f
to
dfc1626
Compare
I mean, TrackJS will intercept |
resin-raven
in AnalyticsServiceresin-raven
in AnalyticsService
dfc1626
to
17592de
Compare
resin-raven
in AnalyticsServiceresin-raven
in AnalyticsService
586f231
to
09b0250
Compare
resin-raven
in AnalyticsServiceresin-corvus
in AnalyticsService
f0643ed
to
1bca884
Compare
lib/gui/modules/analytics.js
Outdated
|
||
/** | ||
* @summary Log a debug message | ||
* @function | ||
* @public | ||
* | ||
* @description | ||
* This function sends the debug message to TrackJS only. | ||
* This function sends the debug message to error reporting services. | ||
* | ||
* @param {String} message - message | ||
* | ||
* @example | ||
* AnalyticsService.log('Hello World'); | ||
*/ | ||
this.logDebug = (message) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed logDebug
, logEvent
, and logException
map exactly to resinCorvus
's functions, so maybe we can do:
this.logDebug = resinCorvus.logDebug;
this.logEvent = resinCorvus.logEvent;
this.logException = resinCorvus.logException;
lib/gui/modules/analytics.js
Outdated
* @example | ||
* AnalyticsService.disable() | ||
*/ | ||
this.disable = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I send an event/exception/etc when resinCorvus
is disabled? Is it a no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't a no-op. It will print the exception to the console, but not send it to external services.
lib/gui/modules/analytics.js
Outdated
* @example | ||
* AnalyticsService.enable() | ||
*/ | ||
this.enable = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is resinCorvus
enabled by default? Maybe we should document that somewhere in this file? If its not enable by default, maybe we should check the settings at startup and configure accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can we ensure that if resinCorvus
is enabled by default, and the user has disabled error reporting in the settings, then we don't send any analytics until ensuring that's what the user wants?
I think that other code might be evaluated before this, causing the startup events to be sent before we realise that analytics reporting shouldn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Using Store.subscribe(callback)
doesn't solve the issue, because by the time the callback is called, we already log events.
Besides checking the setting in analytics
before sending events, like we did before, I don't have any good ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides checking the setting in analytics before sending events, like we did before, I don't have any good ideas.
That is the best approach I can think of as well, lets go for it!
@@ -86,6 +86,14 @@ module.exports = function(WarningModalService, SettingsModel, ErrorService, Anal | |||
dangerous | |||
}); | |||
|
|||
if (setting === 'errorReporting') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel we shouldn't put logic on how to react to certain setting here, and that we should query the redux store for the value instead. Maybe we can add another .run()
block at app.js
that subscribes to the store and checks the setting there? e.g: like https://github.com/resin-io/etcher/blob/master/lib/gui/app.js#L132
Oh, now I understand what you are saying. I tried it now, and Sentry doesn't do that. |
No, the version of |
resin-corvus
in AnalyticsServiceresin-corvus
in AnalyticsService
Approved! There are some conflicts that we need to resolve before merging. |
b3bea9d
to
11b77f9
Compare
@jviotti Resolved conflicts |
@stefan-mihaila Looks like there are conflicts again :P Also, the builds are failing because @lurch Looks like your dependency check scripts have proved their value :D Any clues about why they don't fail on Appveyor though? See: |
11b77f9
to
1feebfe
Compare
@jviotti @lurch Rebased and added the culprit dependency (thanks @lurch) Looks like ./scripts/ci/ensure-all-node-requirements-available.sh
lib/gui/modules/analytics.js requires 'resin-corvus/browser' module which can't be located |
@stefan-mihaila Looks like we should modify the script to only consider whatever its inside |
I'm not 100% familiar with this script, but I think changing this regular expression will do the trick: https://github.com/resin-io/etcher/blob/master/scripts/ci/ensure-all-node-requirements-available.sh#L41 |
Hello! Apologies for the delayed response...
Haha, cool! :-D
Looks like my script on Appveyor did 'spot' the error:
but for some reason it didn't cause the entire CI build to fail. I'll have to investigate...
Hmm okay, so what does
Unfortunately it's not quite as simple as that, as there's also lots of 'local modules' used by Etcher, e.g. https://github.com/resin-io/etcher/blob/master/lib/start.js#L33 or https://github.com/resin-io/etcher/blob/master/lib/gui/models/flash-state.js#L28 which my script does also check for and validate. So what's the syntax used by |
* console.log('Host architecture is x64'); | ||
* } | ||
*/ | ||
const getHostArchitecture = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh? How come this isn't needed any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved to resin-corvus
@@ -189,18 +201,27 @@ $(BUILD_DIRECTORY)/node-$(TARGET_PLATFORM)-$(TARGET_ARCH)-dependencies/node_modu | |||
-t node \ | |||
-s "$(TARGET_PLATFORM)" | |||
|
|||
$(BUILD_DIRECTORY)/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-dependencies/bower_components: bower.json \ | |||
| $(BUILD_DIRECTORY)/electron-$(TARGET_PLATFORM)-$(TARGET_ARCH)-dependencies | |||
./scripts/build/dependencies-bower.sh -p -x $| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! :-)
./scripts/build/electron-create-resources-app.sh -s . -o $@ \ | ||
-v $(APPLICATION_VERSION) \ | ||
-f "$(APPLICATION_FILES)" | ||
$(foreach prerequisite,$^,$(call execute-command,cp -RLf $(prerequisite) $@)) | ||
cp -RLf $< $@ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, never realised you could include blank lines between build-steps in a Makefile
before. But I've just tested on Linux and it seems to work fine - neat!
* console.log('We should report this error'); | ||
* } | ||
*/ | ||
exports.shouldReport = (error) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this handled internally in resin-corvus now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and does resin-corvus do all the same "anonymising" that we used to do in Etcher?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, all that logic has been moved to resin-corvus
, so we can re-use it with other resin.io products.
scripts/build/jq-inplace.sh
Outdated
@@ -19,42 +19,38 @@ | |||
set -u | |||
set -e | |||
|
|||
./scripts/build/check-dependency.sh bower | |||
./scripts/build/check-dependency.sh jq |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, quite funny that Github has 'detected' this as a renamed file ;-)
Makefile
Outdated
cp -RLf $< $@ | ||
|
||
ifdef ANALYTICS_SENTRY_TOKEN | ||
./scripts/build/jq-inplace.sh \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the limited use of jq-inplace.sh
, I wonder if it'd be clearer to name it e.g. jq-insert.sh
, and then pass it the property to insert (analytics.sentry.token
) and value to insert ($(ANALYTICS_SENTRY_TOKEN)
) as separate parameters? *shrug*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jviotti What do you think, is it worth it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a new commit so you can review separately: a0f1b05
scripts/build/jq-inplace.sh
Outdated
fi | ||
|
||
TEMPORARY_FILE="$ARGV_TEMPORARY_DIRECTORY/$(basename $ARGV_FILE).TMP" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably quote $ARGV_FILE
here, i.e.
TEMPORARY_FILE="$ARGV_TEMPORARY_DIRECTORY/$(basename "$ARGV_FILE").TMP"
If the path starts with For this case, if the require path is not relative, then we should only try to detect if |
1feebfe
to
83f2c04
Compare
I guess we have to merge #1267 to the CI builds will pass |
The PR has been merged! |
9f39147
to
662c90a
Compare
This commit also removes bower. Change-Type: patch Fixes: #1027
662c90a
to
a0f1b05
Compare
This commit also removes bower.
Change-Type: patch
Fixes: #1027