Skip to content

Conversation

@arusakov
Copy link

@arusakov arusakov commented Jul 1, 2016

Plugin with simple dataCallback() and some tests


This change is Reviewable

@arusakov arusakov mentioned this pull request Jul 1, 2016
@benvinegar
Copy link
Contributor

Hey @arusakov – looks pretty good, but I would like to explore making this its own repository before merging. I'll probably do that sometime this week.

@dcramer
Copy link
Member

dcramer commented Sep 7, 2016

If this only requires mangling filenames I'd like to figure out how we move this to server (ala getsentry/sentry#4090).

I'm wondering if we could just maintain the file:///(.+/)?[^/+].app/ pattern for stripping prefixes?

@dcramer
Copy link
Member

dcramer commented Sep 7, 2016

@getsentry/javascript

@arusakov
Copy link
Author

arusakov commented Sep 7, 2016

@dcramer
It's interesting. But one simple pattern in server code is not enough.
file:///(.+/)?[^/+].app/ pattern is good only for Electron apps for Mac OS X. For Windows app we need another pattern (maybe another for linux app). I need to research it.

@arusakov
Copy link
Author

arusakov commented Sep 7, 2016

@dcramer @benvinegar
Ok, I research it. Paths can be:
**/NAME.app/Contents/Resources/app/main.js - Mac OS X
**/NAME/resources/app/main.js - Windows and Linux

But you can bundle app to asar archive:
**/NAME.app/Contents/Resources/app.asar/main.js - Max OS X
**/NAME/resources/app.asar/main.js - Windows and Linux

Origin http://electron.atom.io/docs/tutorial/application-distribution/

@dcramer
Copy link
Member

dcramer commented Sep 14, 2016

@arusakov implemented the other path names in getsentry/sentry#4090

@benvinegar
Copy link
Contributor

@arusakov – I appreciate the contribution, but our plan is to develop a plugin that leverages both raven-node and raven-js (so it can be used on both server and client). We'll refer back to this for posterity.

@benvinegar benvinegar closed this Mar 23, 2017
@VladimirPal
Copy link

Can you suggest any temporary decision for electron?

@arusakov
Copy link
Author

arusakov commented Mar 30, 2017

@VladimirPal
You can see this in PR. Use electronPlugin._normalizeData as dataCallback for raven-js.

@VladimirPal
Copy link

@arusakov Thank you, already did it.

// raven-electron-plugin.js
const PATH_MATCH_RE = /[^/]+$/;

function normalizeUrl(url) {
  const match = url.match(PATH_MATCH_RE);
  return match ? `~/${match[0]}` : url;
}

function electronPlugin(Raven) {
  Raven.setDataCallback((data) => {
    electronPlugin._normalizeData(data);
  });
}

electronPlugin._normalizeData = function normalizeData(data) {
  if (data.culprit) {
    data.culprit = normalizeUrl(data.culprit);

    const stacktrace = data.stacktrace || data.exception && data.exception.values[0].stacktrace; // eslint-disable-line
    if (stacktrace) {
      stacktrace.frames.forEach((frame) => {
        frame.filename = normalizeUrl(frame.filename);
      });
    }
  }
};

module.exports = electronPlugin;
// index.js - endpoint on my app
import Raven from 'raven-js';
Raven.addPlugin(require('./raven-electron-plugin'));

@LewisJEllis
Copy link
Contributor

Note also that some users have reported (in #812) simply using raven-node in their electron apps. I haven't investigated what the difference in functionality might be, just pointing out the option/alternative.

logaretm added a commit that referenced this pull request Nov 18, 2025
Bumps the vendored-in web vitals library to include the changes between
`5.0.2` <-> `5.1.0` from upstream

#### Changes from upstream

- Remove `visibilitychange` event listeners when no longer required
[#627](GoogleChrome/web-vitals#627)
- Register visibility-change early
[#637](GoogleChrome/web-vitals#637)
- Only finalize LCP on user events (isTrusted=true)
[#635](GoogleChrome/web-vitals#635)
- Fallback to default getSelector if custom function is null or
undefined [#634](GoogleChrome/web-vitals#634)

#### Our own Changes

- Added `addPageListener` and `removePageListener` utilities because the
upstream package changed the listeners to be added on `window` instead
of `document`, so I added those utilities to avoid having to check for
window every time we try to add a listener.
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.

5 participants