Skip to content

Conversation

@pauldambra
Copy link
Member

@pauldambra pauldambra commented May 26, 2023

Changes

adds

  • autocapture for exceptions
  • autocapture for unhandled promise rejection
  • manual exception capture
  • session recording URL
  • add an captureException method to PostHog instance
  • update sentry integration to send PostHog exception fields too

@pauldambra pauldambra requested a review from benjackwhite May 26, 2023 12:01
@github-actions
Copy link
Contributor

github-actions bot commented May 26, 2023

Size Change: +32.4 kB (+1%)

Total Size: 2.35 MB

Filename Size Change
dist/array.full.js 168 kB +8.12 kB (+5%) 🔍
dist/array.js 110 kB +8.11 kB (+8%) 🔍
dist/es.js 110 kB +8.11 kB (+8%) 🔍
dist/module.js 110 kB +8.11 kB (+8%) 🔍
ℹ️ View Unchanged
Filename Size
dist/recorder-v2.js 93.6 kB
dist/recorder.js 58.3 kB
lib/rrweb/dist/plugins/console-record.js 26.6 kB
lib/rrweb/dist/plugins/console-record.min.js 10.8 kB
lib/rrweb/dist/plugins/console-replay.js 12.7 kB
lib/rrweb/dist/plugins/console-replay.min.js 5.72 kB
lib/rrweb/dist/plugins/sequential-id-record.js 910 B
lib/rrweb/dist/plugins/sequential-id-record.min.js 417 B
lib/rrweb/dist/plugins/sequential-id-replay.js 1.24 kB
lib/rrweb/dist/plugins/sequential-id-replay.min.js 578 B
lib/rrweb/dist/record/rrweb-record-pack.js 31.4 kB
lib/rrweb/dist/record/rrweb-record-pack.min.js 10.7 kB
lib/rrweb/dist/record/rrweb-record.js 140 kB
lib/rrweb/dist/record/rrweb-record.min.js 51.7 kB
lib/rrweb/dist/replay/rrweb-replay-unpack.js 188 kB
lib/rrweb/dist/replay/rrweb-replay-unpack.min.js 71.1 kB
lib/rrweb/dist/replay/rrweb-replay.js 172 kB
lib/rrweb/dist/replay/rrweb-replay.min.js 66.4 kB
lib/rrweb/dist/rrweb-all.js 356 kB
lib/rrweb/dist/rrweb-all.min.js 133 kB
lib/rrweb/dist/rrweb.js 302 kB
lib/rrweb/dist/rrweb.min.js 116 kB
lib/rrweb/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js 1.94 kB
lib/rrweb/es/rrweb/ext/mitt/dist/mitt.es.js 1.99 kB

compressed-size-action

@pauldambra pauldambra marked this pull request as ready for review May 28, 2023 14:21
Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Some first pass comments. Will take a proper look at the exception code in a bit

Comment on lines 117 to 122
if (this.instance.sessionRecordingStarted()) {
errorProperties.$exception_sessionRecordingURL =
posthogHost +
'/recordings/' +
this.instance.sessionManager.checkAndGetSessionAndWindowId(true).sessionId
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have get_session_replay_url() now which should be used here.

One thought though - why do we want this 🤔 is it not redundant given that we can rebuild it on the other end?

token: '',
autocapture: true,
// TODO: change to undefined when we release this so that remote config can turn it on even if unconfigured by the user
exception_autocapture: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feels a little weird that we have exception_autocapture locally and autocaptureExceptions remotely... Not sure if that means it should be different but it feels confusing...

Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Some first pass comments. Will take a proper look at the exception code in a bit

@pauldambra pauldambra requested a review from benjackwhite May 30, 2023 15:24
Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Small changes but overall this looks great. Didn't review the "inspired" code too deeply but it all looks very clever ;)

* Where there is a key in both generated exception and passed properties,
* the generated exception property takes precedence.
*
* If exception autocapture is not enabled this method is a no-op
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this makes sense. Why is autocapturing of exceptions a necessity to manually capture an exception?

It's like saying " capture("$pageview") only works if you have automatic pageview capturing turned on" 😅

Happy to be challenged here but my exception would be that this always works regardless of the autocapture setting

Copy link
Member Author

Choose a reason for hiding this comment

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

No, you've got tunnel vision 🙈

Comment on lines 111 to 123
captureException(args: ErrorEventArgs, properties?: Properties) {
if (this.isCapturing()) {
const errorProperties = errorToProperties(args)
const propertiesToSend = { ...properties, ...errorProperties }

const posthogHost = this.instance.config.ui_host || this.instance.config.api_host
errorProperties.$exception_personURL = posthogHost + '/person/' + this.instance.get_distinct_id()

this.sendExceptionEvent(propertiesToSend)
} else {
console.warn('PostHog exception autocapture is not enabled')
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally I think we should remove the isCapturing check and have that in the caller instead. That way we can still call this for non-autocapture use cases

@pauldambra pauldambra requested a review from benjackwhite May 31, 2023 10:13
@pauldambra pauldambra added the bump minor Bump minor version when this PR gets merged label May 31, 2023
@pauldambra pauldambra merged commit 11dd02f into master May 31, 2023
@pauldambra pauldambra deleted the feat/exception-autocapture branch May 31, 2023 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bump minor Bump minor version when this PR gets merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants