Uh oh!
There was an error while loading. Please reload this page.
feat(vue): Apply stateTransformer to attachments in createSentryPiniaPlugin - #14474
feat(vue): Apply stateTransformer to attachments in createSentryPiniaPlugin#14474sircharlo wants to merge 3 commits into
Conversation
onurtemizkan
commented
Nov 26, 2024
Thanks for the PR @sircharlo. Implementation looks good to me, could you also add a test for this? |
sircharlo
commented
Nov 26, 2024
Erm I can try. Not sure, I had started adding something in e2e but in the Discord I was told that was the wrong place for it. |
mydea
commented
Nov 27, 2024
As far as I see we only have pinia tests in the vue-3 and nuxt-4 E2E test apps, so adding tests to one of these (probably vue-3?) sounds reasonable to me! Not sure if others (cc @onurtemizkan or @s1gr1d ) have other ideas for this. |
@mydea, yes I also think that's reasonable (and easier) to add cases to e2e tests. IMHO a new case here will be enough for this PR. @sircharlo, please let me know if you have any issues running the E2E tests. |
sircharlo
commented
Nov 27, 2024
@onurtemizkan Thanks for the feedback! Ok, I'll continue where I had left off in that file then, as that's where I had started writing a test. Would this be the correct way to access an attachment from the current scope? I couldn't find an easy way to access the global scope from the constscopeData=error?.sdkProcessingMetadata?.capturedSpanScope?.getScopeData();conststateAttachment=scopeData?.attachments?.find(attachment=>attachment.filename.includes('pinia_state_')); |
mydea
commented
Nov 28, 2024
You can wait for an attachment envelope item like this: functionwaitForAttachment(proxyServerName: string,callback: (attachment: AttachmentItem[1])=>Promise<boolean>|boolean,): Promise<AttachmentItem[1]>{consttimestamp=getNanosecondTimestamp();returnnewPromise((resolve,reject)=>{waitForEnvelopeItem(proxyServerName,asyncenvelopeItem=>{if(envelopeItem[0].type==='attachment'){constattachmentItem=envelopeItem[1]asAttachmentItem[1];if(awaitcallback(attachmentItem)){resolve(attachmentItem);returntrue;}}returnfalse;},timestamp,).catch(reject);});}And then use it like this: consterrorPromise=waitForError('vue-3',asyncerrorEvent=>{returnerrorEvent?.exception?.values?.[0].value==='This is an error';});constattachmentPromise=waitForAttachment('vue-3',asyncattachment=>{returnattachment='...';});awaitpage.locator('#throw-error').click();consterror=awaiterrorPromise;constattachment=awaitattachmentPromise;expect(attachment).toEqual(...); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tryforceful
commented
Mar 14, 2025
Is there any update on this PR? 🙏🏼 |
s1gr1d
commented
Mar 17, 2025
The tests in the PR are still missing. @sircharlo do you want to add them? Otherwise, @onurtemizkan or me can take the PR over. |
sircharlo
commented
Mar 20, 2025
Hey there; I'm sorry I've been absolutely swamped. I'm afraid I don't have the bandwidth for this at the moment. if someone else could take over, I’d be grateful. |
s1gr1d
commented
Apr 11, 2025
Closing this in favor of this PR: #16034 |
This PR modifies the
createSentryPiniaPluginto apply thestateTransformerto attachments, in addition to the context.Why?
Attachments can quickly become large when the full
store.$stateis included, especially if there are items that do not need to be reported to Sentry. By applying thestateTransformer, developers can reduce the size of attachments, avoid unnecessary data uploads, and stay within their Sentry usage limits.Changes
store.$stateusing thestateTransformer(if provided) before including it in the attachments as well as the context.Benefits
Let me know if further adjustments are needed!
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint) & (yarn test).