Skip to content
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

add base Telemetry JavaScript snippet (fixes issue #172) #174

Closed

Conversation

cvan
Copy link
Contributor

@cvan cvan commented Feb 27, 2018

No description provided.

@cvan cvan self-assigned this Feb 27, 2018
@cvan cvan force-pushed the add-sentry-for-error-reporting branch from 06f1768 to 0b5216f Compare February 27, 2018 05:48
/* global localStorage, location, Raven */
(function () {
// This checks for "production"-looking origins (e.g., `https://example.com`).
if (window.isSecureContext === false ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking but perhaps we should move this to GA. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move what to GA? I'm not entirely clear what what the question is, sorry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this was for GA and not for Sentry, sorry. But my point still holds. what I mean is not to do this on the client but in the service somehow. I know GA allow to create a user segmentation with domain meeting some criterail. I never used Sentry but perhpahs filtering out development domains is something we can do there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, understood. we could move this to the server level. that's what I did with the WebVR Agent. or like how Stripe Checkout handles test/staging/prod environments. 👍

let me play with this today. I think I can this to a simpler setup, so we don't have to do all these manual checks at the client level. I had similar concerns, so I'm glad they were shared with you.

and thanks for the spot-on reviews here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvan, are you continue playing with this. If not, I would prefer to merge this PR since the GA relies on it. What do you think?

Copy link
Contributor Author

@cvan cvan Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this file in favour of a remote JavaScript file that we can update as needed

try {
var queue = JSON.parse(localStorage.getItem(offlineStorageKey)) || [];
queue.push(event.data);
localStorage.setItem(offlineStorageKey, JSON.stringify(queue));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about using synchronous storage here. If the application is offline and the application starts to error, the synchronous process would interfere with the developer debugging session. I would use asynchronous storage as IndexedDB with localForage and requestIdleCallback (if available) for a non-intrusive serialization. Until that moment, I recommend to not include this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I am too. fwiw, the Unity Engine already uses IndexedDB a ton and fires off several XHR to Unity services. and, yep, if we use IndexedDB, localForage is good, although we could probably get away with just the idb library.

thanks for bringing this up - very good call. I'll remove the offlineStoragePlugin function entirely until it's matured and merged properly in Raven.js core: getsentry/sentry-javascript#1165

(function () {
// This checks for "production"-looking origins (e.g., `https://example.com`).
if (window.isSecureContext === false ||
(location.hostname === 'localhost' ||
Copy link
Contributor Author

@cvan cvan Feb 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a pretty good check could also be checking if location.port is truthy, but it's possible for false positive

@cvan
Copy link
Contributor Author

cvan commented Feb 28, 2018

I'm looking into Rollbar possibly as an alternative to Sentry + Google Analytics. I'll keep you posted of my findings. Until then, I'll leave this PR open but marked as a WIP.

@delapuente
Copy link
Contributor

delapuente commented Feb 28, 2018

@cvan, I can remove the plugin from your branch and get it merged, and continue editing this file to configure GA. Is that OK?

@cvan
Copy link
Contributor Author

cvan commented Feb 28, 2018

@cvan, I can remove the plugin from your branch and get it merged, and continue editing this file to configure GA. Is that OK?

feel free to do that if you'd like. my only concern is #174 (comment)

I assume you're referring to hooks for only Mozilla GA? not the developer GA as well?

like from issue #169: #169 (comment)

assuming we do end up using Sentry plus Google Analytics (instead of Rollbar), does this snippet help at all for the stuff you're looking at? https://gist.github.com/cvan/78966124dd757c65e2f482b767052e44#file-ga-js

@@ -0,0 +1,109 @@
/* global localStorage, location, Raven */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the Build/ files

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right. Anyway, when I'm about to submit a version to the store, I rebuild the demo scene to align with that version.

@delapuente delapuente force-pushed the add-sentry-for-error-reporting branch from 9301034 to 4ed0cda Compare March 2, 2018 12:59
@delapuente
Copy link
Contributor

@cvan please notice that I've forced a branch update to avoid /Build changes.

@cvan cvan force-pushed the add-sentry-for-error-reporting branch from 4ed0cda to de43f71 Compare March 6, 2018 07:09
@cvan cvan changed the title add telemetry.js file; connect to Sentry via Raven.js to catch JavaScript errors (addresses issue #166, fixes issue #172) add base Telemetry JavaScript snippet (fixes issue #172) Mar 6, 2018
@cvan cvan force-pushed the add-sentry-for-error-reporting branch 2 times, most recently from 9e65217 to 1414160 Compare March 6, 2018 07:49
@cvan cvan force-pushed the add-sentry-for-error-reporting branch from 1414160 to 6c10c60 Compare March 6, 2018 08:00
@delapuente
Copy link
Contributor

@cvan I'm not sure if this is a good idea but I'm closing this PR in favour of #187, You can experiment with the idea in a separated branch or open an issue to propose this specific change and discuss there openly. Before involving maintaining a separated file, I'd prefer to have something merged.

@delapuente delapuente closed this Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants