@sentry-internal/feedback
Advanced tools
Comparing version 0.0.1-alpha.10 to 0.0.1-alpha.11
@@ -15,3 +15,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
}) { | ||
const eventHint = { integrations: undefined }; | ||
const eventHint = {}; | ||
if (client.emit) { | ||
@@ -24,8 +24,10 @@ client.emit('preprocessEvent', event, eventHint); | ||
event, | ||
{ integrations: undefined }, | ||
eventHint, | ||
scope, | ||
client, | ||
)) ; | ||
// If e.g. a global event processor returned null | ||
if (!preparedEvent) { | ||
if (preparedEvent === null) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
client.recordDroppedEvent('event_processor', 'feedback', event); | ||
return null; | ||
@@ -39,11 +41,2 @@ } | ||
// extract the SDK name because `client._prepareEvent` doesn't add it to the event | ||
const metadata = client.getSdkMetadata && client.getSdkMetadata(); | ||
const { name, version } = (metadata && metadata.sdk) || {}; | ||
preparedEvent.sdk = { | ||
...preparedEvent.sdk, | ||
name: name || 'sentry.javascript.unknown', | ||
version: version || '0.0.0', | ||
}; | ||
return preparedEvent; | ||
@@ -53,13 +46,8 @@ } | ||
/** | ||
* Send feedback using `fetch()` | ||
* Send feedback using transport | ||
*/ | ||
async function sendFeedbackRequest({ | ||
feedback: { message, email, name, replay_id, url }, | ||
feedback: { message, email, name, source, replay_id, url }, | ||
}) { | ||
const hub = core.getCurrentHub(); | ||
if (!hub) { | ||
return null; | ||
} | ||
const client = hub.getClient(); | ||
@@ -71,14 +59,17 @@ const scope = hub.getScope(); | ||
if (!client || !transport || !dsn) { | ||
return null; | ||
return; | ||
} | ||
const baseEvent = { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
contexts: { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
source, | ||
}, | ||
}, | ||
// type: 'feedback_event', | ||
type: 'feedback', | ||
}; | ||
@@ -92,6 +83,4 @@ | ||
if (!feedbackEvent) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
// client.recordDroppedEvent('event_processor', 'feedback', baseEvent); | ||
return null; | ||
if (feedbackEvent === null) { | ||
return; | ||
} | ||
@@ -102,63 +91,103 @@ | ||
{ | ||
"data": { | ||
"dist": "abc123", | ||
"type": "feedback", | ||
"event_id": "d2132d31b39445f1938d7e21b6bf0ec4", | ||
"timestamp": 1597977777.6189718, | ||
"dist": "1.12", | ||
"platform": "javascript", | ||
"environment": "production", | ||
"feedback": { | ||
"contact_email": "colton.allen@sentry.io", | ||
"message": "I really like this user-feedback feature!", | ||
"replay_id": "ec3b4dc8b79f417596f7a1aa4fcca5d2", | ||
"url": "https://docs.sentry.io/platforms/javascript/" | ||
"release": 42, | ||
"tags": {"transaction": "/organizations/:orgId/performance/:eventSlug/"}, | ||
"sdk": {"name": "name", "version": "version"}, | ||
"user": { | ||
"id": "123", | ||
"username": "user", | ||
"email": "user@site.com", | ||
"ip_address": "192.168.11.12", | ||
}, | ||
"id": "1ffe0775ac0f4417aed9de36d9f6f8dc", | ||
"platform": "javascript", | ||
"release": "version@1.3", | ||
"request": { | ||
"headers": { | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" | ||
} | ||
"url": None, | ||
"headers": { | ||
"user-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15" | ||
}, | ||
}, | ||
"sdk": { | ||
"name": "sentry.javascript.react", | ||
"version": "6.18.1" | ||
"contexts": { | ||
"feedback": { | ||
"message": "test message", | ||
"contact_email": "test@example.com", | ||
"type": "feedback", | ||
}, | ||
"trace": { | ||
"trace_id": "4C79F60C11214EB38604F4AE0781BFB2", | ||
"span_id": "FA90FDEAD5F74052", | ||
"type": "trace", | ||
}, | ||
"replay": { | ||
"replay_id": "e2d42047b1c5431c8cba85ee2a8ab25d", | ||
}, | ||
}, | ||
"tags": { | ||
"key": "value" | ||
}, | ||
"timestamp": "2023-08-31T14:10:34.954048", | ||
"user": { | ||
"email": "username@example.com", | ||
"id": "123", | ||
"ip_address": "127.0.0.1", | ||
"name": "user", | ||
"username": "user2270129" | ||
} | ||
} | ||
} | ||
*/ | ||
// Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to | ||
// sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may | ||
// have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid | ||
// of this `delete`, lest we miss putting it back in the next time the property is in use.) | ||
delete feedbackEvent.sdkProcessingMetadata; | ||
const envelope = core.createEventEnvelope(feedbackEvent, dsn, client.getOptions()._metadata, client.getOptions().tunnel); | ||
let response; | ||
try { | ||
const path = 'https://sentry.io/api/0/feedback/'; | ||
const response = await fetch(path, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `DSN ${utils.dsnToString(dsn)}`, | ||
}, | ||
body: JSON.stringify(feedbackEvent), | ||
}); | ||
if (!response.ok) { | ||
return null; | ||
response = await transport.send(envelope); | ||
} catch (err) { | ||
const error = new Error('Unable to send Feedback'); | ||
try { | ||
// In case browsers don't allow this property to be writable | ||
// @ts-expect-error This needs lib es2022 and newer | ||
error.cause = err; | ||
} catch (e) { | ||
// nothing to do | ||
} | ||
throw error; | ||
} | ||
// TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore | ||
if (!response) { | ||
return response; | ||
} catch (err) { | ||
return null; | ||
} | ||
// Require valid status codes, otherwise can assume feedback was not sent successfully | ||
if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) { | ||
throw new Error('Unable to send Feedback'); | ||
} | ||
return response; | ||
} | ||
/** | ||
* Public API to send a Feedback item to Sentry | ||
*/ | ||
function sendFeedback( | ||
{ name, email, message, source = 'api', url = utils.getLocationHref() }, | ||
{ includeReplay = true } = {}, | ||
) { | ||
const client = core.getCurrentHub().getClient(); | ||
const replay = includeReplay && client ? (client.getIntegrationById('Replay') ) : undefined; | ||
// Prepare session replay | ||
replay && replay.flush(); | ||
const replayId = replay && replay.getReplayId(); | ||
if (!message) { | ||
throw new Error('Unable to submit feedback with empty message'); | ||
} | ||
return sendFeedbackRequest({ | ||
feedback: { | ||
name, | ||
email, | ||
message, | ||
url, | ||
replay_id: replayId, | ||
source, | ||
}, | ||
}); | ||
} | ||
const LIGHT_BACKGROUND = '#ffffff'; | ||
@@ -612,33 +641,5 @@ const INHERIT = 'inherit'; | ||
/** | ||
* Public API to send a Feedback item to Sentry | ||
* Handles UI behavior of dialog when feedback is submitted, calls | ||
* `sendFeedback` to send feedback. | ||
*/ | ||
function sendFeedback( | ||
{ name, email, message, url = utils.getLocationHref() }, | ||
{ includeReplay = true } = {}, | ||
) { | ||
const client = core.getCurrentHub().getClient(); | ||
const replay = includeReplay && client ? (client.getIntegrationById('Replay') ) : undefined; | ||
// Prepare session replay | ||
replay && replay.flush(); | ||
const replayId = replay && replay.getReplayId(); | ||
if (!message) { | ||
throw new Error('Unable to submit feedback with empty message'); | ||
} | ||
return sendFeedbackRequest({ | ||
feedback: { | ||
name, | ||
email, | ||
message, | ||
url, | ||
replay_id: replayId, | ||
}, | ||
}); | ||
} | ||
/** | ||
* Calls `sendFeedback` to send feedback, handles UI behavior of dialog. | ||
*/ | ||
async function handleFeedbackSubmit( | ||
@@ -651,3 +652,3 @@ dialog, | ||
// Not sure when this would happen | ||
return false; | ||
return; | ||
} | ||
@@ -662,18 +663,12 @@ | ||
dialog.hideError(); | ||
try { | ||
dialog.hideError(); | ||
const resp = await sendFeedback(feedback, options); | ||
const resp = await sendFeedback({ ...feedback, source: 'widget' }, options); | ||
if (!resp) { | ||
// Errored... re-enable submit button | ||
showFetchError(); | ||
return false; | ||
} | ||
// Success! | ||
return resp; | ||
} catch (e) { | ||
// Errored... re-enable submit button | ||
} catch (err) { | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && utils.logger.error(err); | ||
showFetchError(); | ||
return false; | ||
} | ||
@@ -1898,3 +1893,3 @@ } | ||
exports.Feedback = Feedback; | ||
exports.sendFeedbackRequest = sendFeedbackRequest; | ||
exports.sendFeedback = sendFeedback; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
import { prepareEvent, getCurrentHub } from '@sentry/core'; | ||
import { dsnToString, logger, getLocationHref, isBrowser } from '@sentry/utils'; | ||
import { prepareEvent, getCurrentHub, createEventEnvelope } from '@sentry/core'; | ||
import { getLocationHref, logger, isBrowser } from '@sentry/utils'; | ||
import { WINDOW } from '@sentry/browser'; | ||
@@ -13,3 +13,3 @@ | ||
}) { | ||
const eventHint = { integrations: undefined }; | ||
const eventHint = {}; | ||
if (client.emit) { | ||
@@ -22,8 +22,10 @@ client.emit('preprocessEvent', event, eventHint); | ||
event, | ||
{ integrations: undefined }, | ||
eventHint, | ||
scope, | ||
client, | ||
)) ; | ||
// If e.g. a global event processor returned null | ||
if (!preparedEvent) { | ||
if (preparedEvent === null) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
client.recordDroppedEvent('event_processor', 'feedback', event); | ||
return null; | ||
@@ -37,11 +39,2 @@ } | ||
// extract the SDK name because `client._prepareEvent` doesn't add it to the event | ||
const metadata = client.getSdkMetadata && client.getSdkMetadata(); | ||
const { name, version } = (metadata && metadata.sdk) || {}; | ||
preparedEvent.sdk = { | ||
...preparedEvent.sdk, | ||
name: name || 'sentry.javascript.unknown', | ||
version: version || '0.0.0', | ||
}; | ||
return preparedEvent; | ||
@@ -51,13 +44,8 @@ } | ||
/** | ||
* Send feedback using `fetch()` | ||
* Send feedback using transport | ||
*/ | ||
async function sendFeedbackRequest({ | ||
feedback: { message, email, name, replay_id, url }, | ||
feedback: { message, email, name, source, replay_id, url }, | ||
}) { | ||
const hub = getCurrentHub(); | ||
if (!hub) { | ||
return null; | ||
} | ||
const client = hub.getClient(); | ||
@@ -69,14 +57,17 @@ const scope = hub.getScope(); | ||
if (!client || !transport || !dsn) { | ||
return null; | ||
return; | ||
} | ||
const baseEvent = { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
contexts: { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
source, | ||
}, | ||
}, | ||
// type: 'feedback_event', | ||
type: 'feedback', | ||
}; | ||
@@ -90,6 +81,4 @@ | ||
if (!feedbackEvent) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
// client.recordDroppedEvent('event_processor', 'feedback', baseEvent); | ||
return null; | ||
if (feedbackEvent === null) { | ||
return; | ||
} | ||
@@ -100,63 +89,103 @@ | ||
{ | ||
"data": { | ||
"dist": "abc123", | ||
"type": "feedback", | ||
"event_id": "d2132d31b39445f1938d7e21b6bf0ec4", | ||
"timestamp": 1597977777.6189718, | ||
"dist": "1.12", | ||
"platform": "javascript", | ||
"environment": "production", | ||
"feedback": { | ||
"contact_email": "colton.allen@sentry.io", | ||
"message": "I really like this user-feedback feature!", | ||
"replay_id": "ec3b4dc8b79f417596f7a1aa4fcca5d2", | ||
"url": "https://docs.sentry.io/platforms/javascript/" | ||
"release": 42, | ||
"tags": {"transaction": "/organizations/:orgId/performance/:eventSlug/"}, | ||
"sdk": {"name": "name", "version": "version"}, | ||
"user": { | ||
"id": "123", | ||
"username": "user", | ||
"email": "user@site.com", | ||
"ip_address": "192.168.11.12", | ||
}, | ||
"id": "1ffe0775ac0f4417aed9de36d9f6f8dc", | ||
"platform": "javascript", | ||
"release": "version@1.3", | ||
"request": { | ||
"headers": { | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" | ||
} | ||
"url": None, | ||
"headers": { | ||
"user-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15" | ||
}, | ||
}, | ||
"sdk": { | ||
"name": "sentry.javascript.react", | ||
"version": "6.18.1" | ||
"contexts": { | ||
"feedback": { | ||
"message": "test message", | ||
"contact_email": "test@example.com", | ||
"type": "feedback", | ||
}, | ||
"trace": { | ||
"trace_id": "4C79F60C11214EB38604F4AE0781BFB2", | ||
"span_id": "FA90FDEAD5F74052", | ||
"type": "trace", | ||
}, | ||
"replay": { | ||
"replay_id": "e2d42047b1c5431c8cba85ee2a8ab25d", | ||
}, | ||
}, | ||
"tags": { | ||
"key": "value" | ||
}, | ||
"timestamp": "2023-08-31T14:10:34.954048", | ||
"user": { | ||
"email": "username@example.com", | ||
"id": "123", | ||
"ip_address": "127.0.0.1", | ||
"name": "user", | ||
"username": "user2270129" | ||
} | ||
} | ||
} | ||
*/ | ||
// Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to | ||
// sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may | ||
// have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid | ||
// of this `delete`, lest we miss putting it back in the next time the property is in use.) | ||
delete feedbackEvent.sdkProcessingMetadata; | ||
const envelope = createEventEnvelope(feedbackEvent, dsn, client.getOptions()._metadata, client.getOptions().tunnel); | ||
let response; | ||
try { | ||
const path = 'https://sentry.io/api/0/feedback/'; | ||
const response = await fetch(path, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `DSN ${dsnToString(dsn)}`, | ||
}, | ||
body: JSON.stringify(feedbackEvent), | ||
}); | ||
if (!response.ok) { | ||
return null; | ||
response = await transport.send(envelope); | ||
} catch (err) { | ||
const error = new Error('Unable to send Feedback'); | ||
try { | ||
// In case browsers don't allow this property to be writable | ||
// @ts-expect-error This needs lib es2022 and newer | ||
error.cause = err; | ||
} catch (e) { | ||
// nothing to do | ||
} | ||
throw error; | ||
} | ||
// TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore | ||
if (!response) { | ||
return response; | ||
} catch (err) { | ||
return null; | ||
} | ||
// Require valid status codes, otherwise can assume feedback was not sent successfully | ||
if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) { | ||
throw new Error('Unable to send Feedback'); | ||
} | ||
return response; | ||
} | ||
/** | ||
* Public API to send a Feedback item to Sentry | ||
*/ | ||
function sendFeedback( | ||
{ name, email, message, source = 'api', url = getLocationHref() }, | ||
{ includeReplay = true } = {}, | ||
) { | ||
const client = getCurrentHub().getClient(); | ||
const replay = includeReplay && client ? (client.getIntegrationById('Replay') ) : undefined; | ||
// Prepare session replay | ||
replay && replay.flush(); | ||
const replayId = replay && replay.getReplayId(); | ||
if (!message) { | ||
throw new Error('Unable to submit feedback with empty message'); | ||
} | ||
return sendFeedbackRequest({ | ||
feedback: { | ||
name, | ||
email, | ||
message, | ||
url, | ||
replay_id: replayId, | ||
source, | ||
}, | ||
}); | ||
} | ||
const LIGHT_BACKGROUND = '#ffffff'; | ||
@@ -610,33 +639,5 @@ const INHERIT = 'inherit'; | ||
/** | ||
* Public API to send a Feedback item to Sentry | ||
* Handles UI behavior of dialog when feedback is submitted, calls | ||
* `sendFeedback` to send feedback. | ||
*/ | ||
function sendFeedback( | ||
{ name, email, message, url = getLocationHref() }, | ||
{ includeReplay = true } = {}, | ||
) { | ||
const client = getCurrentHub().getClient(); | ||
const replay = includeReplay && client ? (client.getIntegrationById('Replay') ) : undefined; | ||
// Prepare session replay | ||
replay && replay.flush(); | ||
const replayId = replay && replay.getReplayId(); | ||
if (!message) { | ||
throw new Error('Unable to submit feedback with empty message'); | ||
} | ||
return sendFeedbackRequest({ | ||
feedback: { | ||
name, | ||
email, | ||
message, | ||
url, | ||
replay_id: replayId, | ||
}, | ||
}); | ||
} | ||
/** | ||
* Calls `sendFeedback` to send feedback, handles UI behavior of dialog. | ||
*/ | ||
async function handleFeedbackSubmit( | ||
@@ -649,3 +650,3 @@ dialog, | ||
// Not sure when this would happen | ||
return false; | ||
return; | ||
} | ||
@@ -660,18 +661,12 @@ | ||
dialog.hideError(); | ||
try { | ||
dialog.hideError(); | ||
const resp = await sendFeedback(feedback, options); | ||
const resp = await sendFeedback({ ...feedback, source: 'widget' }, options); | ||
if (!resp) { | ||
// Errored... re-enable submit button | ||
showFetchError(); | ||
return false; | ||
} | ||
// Success! | ||
return resp; | ||
} catch (e) { | ||
// Errored... re-enable submit button | ||
} catch (err) { | ||
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(err); | ||
showFetchError(); | ||
return false; | ||
} | ||
@@ -1895,3 +1890,3 @@ } | ||
export { Feedback, sendFeedbackRequest }; | ||
export { Feedback, sendFeedback }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,3 @@ | ||
export { sendFeedbackRequest } from './util/sendFeedbackRequest'; | ||
export { sendFeedback } from './sendFeedback'; | ||
export { Feedback } from './integration'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,3 @@ import { SendFeedbackOptions } from './types'; | ||
url?: string; | ||
source?: string; | ||
} | ||
@@ -13,4 +14,4 @@ /** | ||
*/ | ||
export declare function sendFeedback({ name, email, message, url }: SendFeedbackParams, { includeReplay }?: SendFeedbackOptions): ReturnType<typeof sendFeedbackRequest>; | ||
export declare function sendFeedback({ name, email, message, source, url }: SendFeedbackParams, { includeReplay }?: SendFeedbackOptions): ReturnType<typeof sendFeedbackRequest>; | ||
export {}; | ||
//# sourceMappingURL=sendFeedback.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { Event, Primitive } from '@sentry/types'; | ||
import { Primitive } from '@sentry/types'; | ||
import { ActorComponent } from '../widget/Actor'; | ||
@@ -7,15 +7,2 @@ import { DialogComponent } from '../widget/Dialog'; | ||
} | undefined; | ||
/** | ||
* NOTE: These types are still considered Beta and subject to change. | ||
* @hidden | ||
*/ | ||
export interface FeedbackEvent extends Event { | ||
feedback: { | ||
message: string; | ||
url: string; | ||
contact_email?: string; | ||
name?: string; | ||
replay_id?: string; | ||
}; | ||
} | ||
export interface SendFeedbackData { | ||
@@ -28,2 +15,3 @@ feedback: { | ||
name?: string; | ||
source?: string; | ||
}; | ||
@@ -30,0 +18,0 @@ } |
@@ -0,7 +1,9 @@ | ||
import { TransportMakeRequestResponse } from '@sentry/types'; | ||
import { FeedbackFormData, SendFeedbackOptions } from '../types'; | ||
import { DialogComponent } from '../widget/Dialog'; | ||
/** | ||
* Calls `sendFeedback` to send feedback, handles UI behavior of dialog. | ||
* Handles UI behavior of dialog when feedback is submitted, calls | ||
* `sendFeedback` to send feedback. | ||
*/ | ||
export declare function handleFeedbackSubmit(dialog: DialogComponent | null, feedback: FeedbackFormData, options?: SendFeedbackOptions): Promise<Response | false>; | ||
export declare function handleFeedbackSubmit(dialog: DialogComponent | null, feedback: FeedbackFormData, options?: SendFeedbackOptions): Promise<TransportMakeRequestResponse | void>; | ||
//# sourceMappingURL=handleFeedbackSubmit.d.ts.map |
import { Scope } from '@sentry/core'; | ||
import { Client } from '@sentry/types'; | ||
import { FeedbackEvent } from '../types'; | ||
import { Client, FeedbackEvent } from '@sentry/types'; | ||
interface PrepareFeedbackEventParams { | ||
@@ -5,0 +4,0 @@ client: Client; |
@@ -0,6 +1,7 @@ | ||
import { TransportMakeRequestResponse } from '@sentry/types'; | ||
import { SendFeedbackData } from '../types'; | ||
/** | ||
* Send feedback using `fetch()` | ||
* Send feedback using transport | ||
*/ | ||
export declare function sendFeedbackRequest({ feedback: { message, email, name, replay_id, url }, }: SendFeedbackData): Promise<Response | null>; | ||
export declare function sendFeedbackRequest({ feedback: { message, email, name, source, replay_id, url }, }: SendFeedbackData): Promise<void | TransportMakeRequestResponse>; | ||
//# sourceMappingURL=sendFeedbackRequest.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export { sendFeedbackRequest } from './util/sendFeedbackRequest'; | ||
export { sendFeedback } from './sendFeedback'; | ||
export { Feedback } from './integration'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -8,2 +8,3 @@ import type { SendFeedbackOptions } from './types'; | ||
url?: string; | ||
source?: string; | ||
} | ||
@@ -13,4 +14,4 @@ /** | ||
*/ | ||
export declare function sendFeedback({ name, email, message, url }: SendFeedbackParams, { includeReplay }?: SendFeedbackOptions): ReturnType<typeof sendFeedbackRequest>; | ||
export declare function sendFeedback({ name, email, message, source, url }: SendFeedbackParams, { includeReplay }?: SendFeedbackOptions): ReturnType<typeof sendFeedbackRequest>; | ||
export {}; | ||
//# sourceMappingURL=sendFeedback.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { Event, Primitive } from '@sentry/types'; | ||
import type { Primitive } from '@sentry/types'; | ||
import type { ActorComponent } from '../widget/Actor'; | ||
@@ -7,15 +7,2 @@ import type { DialogComponent } from '../widget/Dialog'; | ||
} | undefined; | ||
/** | ||
* NOTE: These types are still considered Beta and subject to change. | ||
* @hidden | ||
*/ | ||
export interface FeedbackEvent extends Event { | ||
feedback: { | ||
message: string; | ||
url: string; | ||
contact_email?: string; | ||
name?: string; | ||
replay_id?: string; | ||
}; | ||
} | ||
export interface SendFeedbackData { | ||
@@ -28,2 +15,3 @@ feedback: { | ||
name?: string; | ||
source?: string; | ||
}; | ||
@@ -30,0 +18,0 @@ } |
@@ -0,7 +1,9 @@ | ||
import type { TransportMakeRequestResponse } from '@sentry/types'; | ||
import type { FeedbackFormData, SendFeedbackOptions } from '../types'; | ||
import type { DialogComponent } from '../widget/Dialog'; | ||
/** | ||
* Calls `sendFeedback` to send feedback, handles UI behavior of dialog. | ||
* Handles UI behavior of dialog when feedback is submitted, calls | ||
* `sendFeedback` to send feedback. | ||
*/ | ||
export declare function handleFeedbackSubmit(dialog: DialogComponent | null, feedback: FeedbackFormData, options?: SendFeedbackOptions): Promise<Response | false>; | ||
export declare function handleFeedbackSubmit(dialog: DialogComponent | null, feedback: FeedbackFormData, options?: SendFeedbackOptions): Promise<TransportMakeRequestResponse | void>; | ||
//# sourceMappingURL=handleFeedbackSubmit.d.ts.map |
import type { Scope } from '@sentry/core'; | ||
import type { Client } from '@sentry/types'; | ||
import type { FeedbackEvent } from '../types'; | ||
import type { Client, FeedbackEvent } from '@sentry/types'; | ||
interface PrepareFeedbackEventParams { | ||
@@ -5,0 +4,0 @@ client: Client; |
@@ -0,6 +1,7 @@ | ||
import type { TransportMakeRequestResponse } from '@sentry/types'; | ||
import type { SendFeedbackData } from '../types'; | ||
/** | ||
* Send feedback using `fetch()` | ||
* Send feedback using transport | ||
*/ | ||
export declare function sendFeedbackRequest({ feedback: { message, email, name, replay_id, url }, }: SendFeedbackData): Promise<Response | null>; | ||
export declare function sendFeedbackRequest({ feedback: { message, email, name, source, replay_id, url }, }: SendFeedbackData): Promise<void | TransportMakeRequestResponse>; | ||
//# sourceMappingURL=sendFeedbackRequest.d.ts.map |
@@ -1,1 +0,8 @@ | ||
{} | ||
{"/Users/billy/code/sentry-javascript/packages/feedback/src/constants.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/constants.ts","statementMap":{"0":{"start":{"line":1,"column":25},"end":{"line":1,"column":34}},"1":{"start":{"line":2,"column":16},"end":{"line":2,"column":25}},"2":{"start":{"line":3,"column":21},"end":{"line":3,"column":44}},"3":{"start":{"line":4,"column":20},"end":{"line":35,"column":2}},"4":{"start":{"line":37,"column":13},"end":{"line":50,"column":2}},"5":{"start":{"line":52,"column":13},"end":{"line":52,"column":42}},"6":{"start":{"line":53,"column":13},"end":{"line":53,"column":44}},"7":{"start":{"line":54,"column":13},"end":{"line":54,"column":53}},"8":{"start":{"line":55,"column":13},"end":{"line":55,"column":41}},"9":{"start":{"line":56,"column":13},"end":{"line":56,"column":58}},"10":{"start":{"line":57,"column":13},"end":{"line":57,"column":35}},"11":{"start":{"line":58,"column":13},"end":{"line":58,"column":74}},"12":{"start":{"line":59,"column":13},"end":{"line":59,"column":43}},"13":{"start":{"line":60,"column":13},"end":{"line":60,"column":44}},"14":{"start":{"line":61,"column":13},"end":{"line":61,"column":33}},"15":{"start":{"line":62,"column":13},"end":{"line":62,"column":65}}},"fnMap":{},"branchMap":{},"s":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":2,"6":2,"7":2,"8":2,"9":2,"10":2,"11":2,"12":2,"13":2,"14":2,"15":2},"f":{},"b":{}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/src/sendFeedback.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/sendFeedback.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":45}},"1":{"start":{"line":3,"column":0},"end":{"line":3,"column":48}},"2":{"start":{"line":6,"column":0},"end":{"line":6,"column":65}},"3":{"start":{"line":23,"column":17},"end":{"line":23,"column":59}},"4":{"start":{"line":24,"column":17},"end":{"line":24,"column":114}},"5":{"start":{"line":27,"column":2},"end":{"line":27,"column":27}},"6":{"start":{"line":28,"column":19},"end":{"line":28,"column":49}},"7":{"start":{"line":30,"column":2},"end":{"line":32,"column":null}},"8":{"start":{"line":31,"column":4},"end":{"line":31,"column":68}},"9":{"start":{"line":34,"column":2},"end":{"line":43,"column":5}},"10":{"start":{"line":19,"column":0},"end":{"line":19,"column":16}}},"fnMap":{"0":{"name":"sendFeedback","decl":{"start":{"line":19,"column":16},"end":{"line":19,"column":28}},"loc":{"start":{"line":21,"column":52},"end":{"line":44,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":20,"column":26},"end":{"line":20,"column":40}},"type":"default-arg","locations":[{"start":{"line":20,"column":35},"end":{"line":20,"column":40}}]},"1":{"loc":{"start":{"line":20,"column":42},"end":{"line":20,"column":65}},"type":"default-arg","locations":[{"start":{"line":20,"column":48},"end":{"line":20,"column":65}}]},"2":{"loc":{"start":{"line":21,"column":2},"end":{"line":21,"column":52}},"type":"default-arg","locations":[{"start":{"line":21,"column":50},"end":{"line":21,"column":52}}]},"3":{"loc":{"start":{"line":21,"column":4},"end":{"line":21,"column":24}},"type":"default-arg","locations":[{"start":{"line":21,"column":20},"end":{"line":21,"column":24}}]},"4":{"loc":{"start":{"line":24,"column":17},"end":{"line":24,"column":114}},"type":"cond-expr","locations":[{"start":{"line":24,"column":44},"end":{"line":24,"column":102}},{"start":{"line":24,"column":105},"end":{"line":24,"column":114}}]},"5":{"loc":{"start":{"line":24,"column":17},"end":{"line":24,"column":40}},"type":"binary-expr","locations":[{"start":{"line":24,"column":17},"end":{"line":24,"column":30}},{"start":{"line":24,"column":34},"end":{"line":24,"column":40}}]},"6":{"loc":{"start":{"line":27,"column":2},"end":{"line":27,"column":26}},"type":"binary-expr","locations":[{"start":{"line":27,"column":2},"end":{"line":27,"column":8}},{"start":{"line":27,"column":12},"end":{"line":27,"column":26}}]},"7":{"loc":{"start":{"line":28,"column":19},"end":{"line":28,"column":49}},"type":"binary-expr","locations":[{"start":{"line":28,"column":19},"end":{"line":28,"column":25}},{"start":{"line":28,"column":29},"end":{"line":28,"column":49}}]},"8":{"loc":{"start":{"line":30,"column":2},"end":{"line":32,"column":null}},"type":"if","locations":[{"start":{"line":30,"column":2},"end":{"line":32,"column":null}}]}},"s":{"0":3,"1":3,"2":3,"3":3,"4":3,"5":3,"6":3,"7":3,"8":0,"9":3,"10":3},"f":{"0":3},"b":{"0":[1],"1":[3],"2":[3],"3":[3],"4":[1,2],"5":[3,3],"6":[3,0],"7":[3,0],"8":[0]}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/src/util/handleFeedbackSubmit.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/util/handleFeedbackSubmit.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":39}},"1":{"start":{"line":4,"column":0},"end":{"line":4,"column":47}},"2":{"start":{"line":17,"column":2},"end":{"line":20,"column":null}},"3":{"start":{"line":19,"column":4},"end":{"line":19,"column":11}},"4":{"start":{"line":22,"column":25},"end":{"line":27,"column":3}},"5":{"start":{"line":23,"column":4},"end":{"line":25,"column":null}},"6":{"start":{"line":24,"column":6},"end":{"line":24,"column":13}},"7":{"start":{"line":26,"column":4},"end":{"line":26,"column":92}},"8":{"start":{"line":29,"column":2},"end":{"line":29,"column":21}},"9":{"start":{"line":31,"column":2},"end":{"line":39,"column":null}},"10":{"start":{"line":32,"column":17},"end":{"line":32,"column":79}},"11":{"start":{"line":35,"column":4},"end":{"line":35,"column":16}},"12":{"start":{"line":37,"column":4},"end":{"line":37,"column":41}},"13":{"start":{"line":38,"column":4},"end":{"line":38,"column":21}},"14":{"start":{"line":12,"column":0},"end":{"line":12,"column":22}}},"fnMap":{"0":{"name":"handleFeedbackSubmit","decl":{"start":{"line":12,"column":22},"end":{"line":12,"column":42}},"loc":{"start":{"line":15,"column":31},"end":{"line":40,"column":null}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":22,"column":25},"end":{"line":22,"column":34}},"loc":{"start":{"line":22,"column":36},"end":{"line":27,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":2},"end":{"line":20,"column":null}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":20,"column":null}}]},"1":{"loc":{"start":{"line":23,"column":4},"end":{"line":25,"column":null}},"type":"if","locations":[{"start":{"line":23,"column":4},"end":{"line":25,"column":null}}]},"2":{"loc":{"start":{"line":37,"column":4},"end":{"line":37,"column":40}},"type":"binary-expr","locations":[{"start":{"line":37,"column":4},"end":{"line":37,"column":19}},{"start":{"line":37,"column":23},"end":{"line":37,"column":40}}]}},"s":{"0":2,"1":2,"2":2,"3":0,"4":2,"5":1,"6":0,"7":1,"8":2,"9":2,"10":2,"11":1,"12":1,"13":1,"14":2},"f":{"0":2,"1":1},"b":{"0":[0],"1":[0],"2":[1,1]}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/src/util/sendFeedbackRequest.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/util/sendFeedbackRequest.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":66}},"1":{"start":{"line":5,"column":0},"end":{"line":5,"column":62}},"2":{"start":{"line":13,"column":14},"end":{"line":13,"column":29}},"3":{"start":{"line":14,"column":17},"end":{"line":14,"column":32}},"4":{"start":{"line":15,"column":16},"end":{"line":15,"column":30}},"5":{"start":{"line":16,"column":20},"end":{"line":16,"column":51}},"6":{"start":{"line":17,"column":14},"end":{"line":17,"column":39}},"7":{"start":{"line":19,"column":2},"end":{"line":21,"column":null}},"8":{"start":{"line":20,"column":4},"end":{"line":20,"column":11}},"9":{"start":{"line":23,"column":35},"end":{"line":35,"column":4}},"10":{"start":{"line":37,"column":24},"end":{"line":41,"column":4}},"11":{"start":{"line":43,"column":2},"end":{"line":45,"column":null}},"12":{"start":{"line":44,"column":4},"end":{"line":44,"column":11}},"13":{"start":{"line":89,"column":19},"end":{"line":89,"column":117}},"14":{"start":{"line":93,"column":2},"end":{"line":106,"column":null}},"15":{"start":{"line":94,"column":4},"end":{"line":94,"column":46}},"16":{"start":{"line":96,"column":18},"end":{"line":96,"column":54}},"17":{"start":{"line":98,"column":4},"end":{"line":104,"column":null}},"18":{"start":{"line":101,"column":6},"end":{"line":101,"column":24}},"19":{"start":{"line":105,"column":4},"end":{"line":105,"column":16}},"20":{"start":{"line":109,"column":2},"end":{"line":111,"column":null}},"21":{"start":{"line":110,"column":4},"end":{"line":110,"column":20}},"22":{"start":{"line":114,"column":2},"end":{"line":116,"column":null}},"23":{"start":{"line":115,"column":4},"end":{"line":115,"column":47}},"24":{"start":{"line":118,"column":2},"end":{"line":118,"column":18}},"25":{"start":{"line":10,"column":0},"end":{"line":10,"column":22}}},"fnMap":{"0":{"name":"sendFeedbackRequest","decl":{"start":{"line":10,"column":22},"end":{"line":10,"column":41}},"loc":{"start":{"line":12,"column":19},"end":{"line":119,"column":null}}}},"branchMap":{"0":{"loc":{"start":{"line":16,"column":20},"end":{"line":16,"column":51}},"type":"binary-expr","locations":[{"start":{"line":16,"column":20},"end":{"line":16,"column":26}},{"start":{"line":16,"column":30},"end":{"line":16,"column":51}}]},"1":{"loc":{"start":{"line":17,"column":14},"end":{"line":17,"column":39}},"type":"binary-expr","locations":[{"start":{"line":17,"column":14},"end":{"line":17,"column":20}},{"start":{"line":17,"column":24},"end":{"line":17,"column":39}}]},"2":{"loc":{"start":{"line":19,"column":2},"end":{"line":21,"column":null}},"type":"if","locations":[{"start":{"line":19,"column":2},"end":{"line":21,"column":null}}]},"3":{"loc":{"start":{"line":19,"column":6},"end":{"line":19,"column":35}},"type":"binary-expr","locations":[{"start":{"line":19,"column":6},"end":{"line":19,"column":13}},{"start":{"line":19,"column":17},"end":{"line":19,"column":27}},{"start":{"line":19,"column":31},"end":{"line":19,"column":35}}]},"4":{"loc":{"start":{"line":43,"column":2},"end":{"line":45,"column":null}},"type":"if","locations":[{"start":{"line":43,"column":2},"end":{"line":45,"column":null}}]},"5":{"loc":{"start":{"line":109,"column":2},"end":{"line":111,"column":null}},"type":"if","locations":[{"start":{"line":109,"column":2},"end":{"line":111,"column":null}}]},"6":{"loc":{"start":{"line":114,"column":2},"end":{"line":116,"column":null}},"type":"if","locations":[{"start":{"line":114,"column":2},"end":{"line":116,"column":null}}]},"7":{"loc":{"start":{"line":114,"column":6},"end":{"line":114,"column":106}},"type":"binary-expr","locations":[{"start":{"line":114,"column":6},"end":{"line":114,"column":45}},{"start":{"line":114,"column":50},"end":{"line":114,"column":75}},{"start":{"line":114,"column":79},"end":{"line":114,"column":105}}]}},"s":{"0":3,"1":3,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":0,"9":1,"10":1,"11":1,"12":0,"13":1,"14":1,"15":1,"16":0,"17":0,"18":0,"19":0,"20":1,"21":0,"22":1,"23":0,"24":1,"25":3},"f":{"0":1},"b":{"0":[1,1],"1":[1,1],"2":[0],"3":[1,1,1],"4":[0],"5":[0],"6":[0],"7":[1,1,1]}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/src/widget/createShadowHost.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/widget/createShadowHost.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":41}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":39}},"2":{"start":{"line":5,"column":0},"end":{"line":5,"column":50}},"3":{"start":{"line":6,"column":0},"end":{"line":6,"column":46}},"4":{"start":{"line":17,"column":2},"end":{"line":35,"column":null}},"5":{"start":{"line":18,"column":16},"end":{"line":18,"column":31}},"6":{"start":{"line":21,"column":17},"end":{"line":21,"column":41}},"7":{"start":{"line":22,"column":4},"end":{"line":22,"column":17}},"8":{"start":{"line":25,"column":19},"end":{"line":25,"column":54}},"9":{"start":{"line":27,"column":4},"end":{"line":27,"column":99}},"10":{"start":{"line":28,"column":4},"end":{"line":28,"column":48}},"11":{"start":{"line":30,"column":4},"end":{"line":30,"column":28}},"12":{"start":{"line":33,"column":4},"end":{"line":33,"column":70}},"13":{"start":{"line":34,"column":4},"end":{"line":34,"column":64}},"14":{"start":{"line":13,"column":0},"end":{"line":13,"column":16}}},"fnMap":{"0":{"name":"createShadowHost","decl":{"start":{"line":13,"column":16},"end":{"line":13,"column":32}},"loc":{"start":{"line":13,"column":99},"end":{"line":36,"column":1}}}},"branchMap":{},"s":{"0":2,"1":2,"2":2,"3":2,"4":12,"5":12,"6":12,"7":12,"8":12,"9":12,"10":12,"11":12,"12":0,"13":0,"14":2},"f":{"0":12},"b":{}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/src/widget/createWidget.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/src/widget/createWidget.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":45}},"1":{"start":{"line":2,"column":0},"end":{"line":2,"column":39}},"2":{"start":{"line":5,"column":0},"end":{"line":5,"column":68}},"3":{"start":{"line":7,"column":0},"end":{"line":7,"column":32}},"4":{"start":{"line":9,"column":0},"end":{"line":9,"column":34}},"5":{"start":{"line":10,"column":0},"end":{"line":10,"column":50}},"6":{"start":{"line":38,"column":8},"end":{"line":38,"column":null}},"7":{"start":{"line":39,"column":2},"end":{"line":39,"column":11}},"8":{"start":{"line":39,"column":37},"end":{"line":39,"column":42}},"9":{"start":{"line":39,"column":49},"end":{"line":39,"column":null}},"10":{"start":{"line":40,"column":10},"end":{"line":40,"column":null}},"11":{"start":{"line":44,"column":30},"end":{"line":44,"column":35}},"12":{"start":{"line":50,"column":4},"end":{"line":52,"column":null}},"13":{"start":{"line":51,"column":6},"end":{"line":51,"column":13}},"14":{"start":{"line":54,"column":4},"end":{"line":79,"column":null}},"15":{"start":{"line":55,"column":22},"end":{"line":63,"column":8}},"16":{"start":{"line":58,"column":10},"end":{"line":60,"column":null}},"17":{"start":{"line":59,"column":12},"end":{"line":59,"column":36}},"18":{"start":{"line":61,"column":10},"end":{"line":61,"column":22}},"19":{"start":{"line":65,"column":6},"end":{"line":67,"column":null}},"20":{"start":{"line":66,"column":8},"end":{"line":66,"column":58}},"21":{"start":{"line":69,"column":6},"end":{"line":69,"column":37}},"22":{"start":{"line":71,"column":24},"end":{"line":75,"column":14}},"23":{"start":{"line":72,"column":8},"end":{"line":74,"column":null}},"24":{"start":{"line":73,"column":10},"end":{"line":73,"column":27}},"25":{"start":{"line":78,"column":6},"end":{"line":78,"column":24}},"26":{"start":{"line":87,"column":4},"end":{"line":89,"column":null}},"27":{"start":{"line":88,"column":6},"end":{"line":88,"column":13}},"28":{"start":{"line":92,"column":4},"end":{"line":95,"column":null}},"29":{"start":{"line":93,"column":6},"end":{"line":93,"column":75}},"30":{"start":{"line":94,"column":6},"end":{"line":94,"column":13}},"31":{"start":{"line":97,"column":19},"end":{"line":97,"column":63}},"32":{"start":{"line":100,"column":4},"end":{"line":106,"column":null}},"33":{"start":{"line":101,"column":6},"end":{"line":103,"column":null}},"34":{"start":{"line":102,"column":8},"end":{"line":102,"column":32}},"35":{"start":{"line":105,"column":6},"end":{"line":105,"column":13}},"36":{"start":{"line":109,"column":4},"end":{"line":109,"column":19}},"37":{"start":{"line":110,"column":4},"end":{"line":110,"column":25}},"38":{"start":{"line":112,"column":4},"end":{"line":114,"column":null}},"39":{"start":{"line":113,"column":6},"end":{"line":113,"column":32}},"40":{"start":{"line":121,"column":4},"end":{"line":121,"column":26}},"41":{"start":{"line":128,"column":4},"end":{"line":128,"column":26}},"42":{"start":{"line":135,"column":4},"end":{"line":135,"column":43}},"43":{"start":{"line":142,"column":4},"end":{"line":203,"column":null}},"44":{"start":{"line":143,"column":6},"end":{"line":150,"column":null}},"45":{"start":{"line":144,"column":8},"end":{"line":144,"column":22}},"46":{"start":{"line":145,"column":8},"end":{"line":145,"column":28}},"47":{"start":{"line":146,"column":8},"end":{"line":148,"column":null}},"48":{"start":{"line":147,"column":10},"end":{"line":147,"column":33}},"49":{"start":{"line":149,"column":8},"end":{"line":149,"column":15}},"50":{"start":{"line":152,"column":22},"end":{"line":152,"column":67}},"51":{"start":{"line":153,"column":20},"end":{"line":153,"column":46}},"52":{"start":{"line":154,"column":19},"end":{"line":154,"column":43}},"53":{"start":{"line":156,"column":6},"end":{"line":186,"column":9}},"54":{"start":{"line":174,"column":10},"end":{"line":174,"column":22}},"55":{"start":{"line":175,"column":10},"end":{"line":175,"column":31}},"56":{"start":{"line":177,"column":10},"end":{"line":179,"column":null}},"57":{"start":{"line":178,"column":12},"end":{"line":178,"column":36}},"58":{"start":{"line":182,"column":10},"end":{"line":182,"column":24}},"59":{"start":{"line":183,"column":10},"end":{"line":183,"column":22}},"60":{"start":{"line":188,"column":6},"end":{"line":190,"column":null}},"61":{"start":{"line":189,"column":8},"end":{"line":189,"column":58}},"62":{"start":{"line":192,"column":6},"end":{"line":192,"column":36}},"63":{"start":{"line":195,"column":6},"end":{"line":195,"column":18}},"64":{"start":{"line":197,"column":6},"end":{"line":199,"column":null}},"65":{"start":{"line":198,"column":8},"end":{"line":198,"column":31}},"66":{"start":{"line":202,"column":6},"end":{"line":202,"column":24}},"67":{"start":{"line":210,"column":4},"end":{"line":217,"column":null}},"68":{"start":{"line":211,"column":6},"end":{"line":211,"column":21}},"69":{"start":{"line":212,"column":6},"end":{"line":212,"column":27}},"70":{"start":{"line":214,"column":6},"end":{"line":216,"column":null}},"71":{"start":{"line":215,"column":8},"end":{"line":215,"column":32}},"72":{"start":{"line":224,"column":4},"end":{"line":229,"column":null}},"73":{"start":{"line":225,"column":6},"end":{"line":225,"column":20}},"74":{"start":{"line":226,"column":23},"end":{"line":226,"column":32}},"75":{"start":{"line":227,"column":6},"end":{"line":227,"column":36}},"76":{"start":{"line":228,"column":6},"end":{"line":228,"column":25}},"77":{"start":{"line":237,"column":4},"end":{"line":239,"column":null}},"78":{"start":{"line":238,"column":6},"end":{"line":238,"column":19}},"79":{"start":{"line":242,"column":4},"end":{"line":242,"column":16}},"80":{"start":{"line":244,"column":4},"end":{"line":246,"column":null}},"81":{"start":{"line":245,"column":6},"end":{"line":245,"column":29}},"82":{"start":{"line":249,"column":2},"end":{"line":254,"column":null}},"83":{"start":{"line":250,"column":4},"end":{"line":250,"column":57}},"84":{"start":{"line":251,"column":9},"end":{"line":254,"column":null}},"85":{"start":{"line":252,"column":4},"end":{"line":252,"column":83}},"86":{"start":{"line":253,"column":4},"end":{"line":253,"column":45}},"87":{"start":{"line":256,"column":2},"end":{"line":271,"column":4}},"88":{"start":{"line":258,"column":6},"end":{"line":258,"column":19}},"89":{"start":{"line":261,"column":6},"end":{"line":261,"column":20}},"90":{"start":{"line":37,"column":0},"end":{"line":37,"column":16}}},"fnMap":{"0":{"name":"createWidget","decl":{"start":{"line":37,"column":16},"end":{"line":37,"column":28}},"loc":{"start":{"line":41,"column":21},"end":{"line":272,"column":1}}},"1":{"name":"showSuccessMessage","decl":{"start":{"line":49,"column":11},"end":{"line":49,"column":29}},"loc":{"start":{"line":49,"column":29},"end":{"line":80,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":57,"column":18},"end":{"line":57,"column":21}},"loc":{"start":{"line":57,"column":23},"end":{"line":62,"column":9}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":71,"column":35},"end":{"line":71,"column":38}},"loc":{"start":{"line":71,"column":40},"end":{"line":75,"column":7}}},"4":{"name":"_handleFeedbackSubmit","decl":{"start":{"line":86,"column":17},"end":{"line":86,"column":38}},"loc":{"start":{"line":86,"column":65},"end":{"line":115,"column":null}}},"5":{"name":"showActor","decl":{"start":{"line":120,"column":11},"end":{"line":120,"column":20}},"loc":{"start":{"line":120,"column":20},"end":{"line":122,"column":3}}},"6":{"name":"hideActor","decl":{"start":{"line":127,"column":11},"end":{"line":127,"column":20}},"loc":{"start":{"line":127,"column":20},"end":{"line":129,"column":3}}},"7":{"name":"removeActor","decl":{"start":{"line":134,"column":11},"end":{"line":134,"column":22}},"loc":{"start":{"line":134,"column":22},"end":{"line":136,"column":3}}},"8":{"name":"openDialog","decl":{"start":{"line":141,"column":11},"end":{"line":141,"column":21}},"loc":{"start":{"line":141,"column":21},"end":{"line":204,"column":3}}},"9":{"name":"(anonymous_10)","decl":{"start":{"line":173,"column":18},"end":{"line":173,"column":21}},"loc":{"start":{"line":173,"column":23},"end":{"line":180,"column":9}}},"10":{"name":"(anonymous_11)","decl":{"start":{"line":181,"column":18},"end":{"line":181,"column":21}},"loc":{"start":{"line":181,"column":23},"end":{"line":184,"column":9}}},"11":{"name":"closeDialog","decl":{"start":{"line":209,"column":11},"end":{"line":209,"column":22}},"loc":{"start":{"line":209,"column":22},"end":{"line":218,"column":3}}},"12":{"name":"removeDialog","decl":{"start":{"line":223,"column":11},"end":{"line":223,"column":23}},"loc":{"start":{"line":223,"column":23},"end":{"line":230,"column":3}}},"13":{"name":"handleActorClick","decl":{"start":{"line":235,"column":11},"end":{"line":235,"column":27}},"loc":{"start":{"line":235,"column":27},"end":{"line":247,"column":3}}},"14":{"name":"(anonymous_15)","decl":{"start":{"line":257,"column":4},"end":{"line":257,"column":8}},"loc":{"start":{"line":257,"column":13},"end":{"line":259,"column":5}}},"15":{"name":"(anonymous_16)","decl":{"start":{"line":260,"column":4},"end":{"line":260,"column":8}},"loc":{"start":{"line":260,"column":14},"end":{"line":262,"column":5}}}},"branchMap":{"0":{"loc":{"start":{"line":39,"column":13},"end":{"line":39,"column":37}},"type":"default-arg","locations":[{"start":{"line":39,"column":33},"end":{"line":39,"column":37}}]},"1":{"loc":{"start":{"line":50,"column":4},"end":{"line":52,"column":null}},"type":"if","locations":[{"start":{"line":50,"column":4},"end":{"line":52,"column":null}}]},"2":{"loc":{"start":{"line":58,"column":10},"end":{"line":60,"column":null}},"type":"if","locations":[{"start":{"line":58,"column":10},"end":{"line":60,"column":null}}]},"3":{"loc":{"start":{"line":65,"column":6},"end":{"line":67,"column":null}},"type":"if","locations":[{"start":{"line":65,"column":6},"end":{"line":67,"column":null}}]},"4":{"loc":{"start":{"line":72,"column":8},"end":{"line":74,"column":null}},"type":"if","locations":[{"start":{"line":72,"column":8},"end":{"line":74,"column":null}}]},"5":{"loc":{"start":{"line":87,"column":4},"end":{"line":89,"column":null}},"type":"if","locations":[{"start":{"line":87,"column":4},"end":{"line":89,"column":null}}]},"6":{"loc":{"start":{"line":92,"column":4},"end":{"line":95,"column":null}},"type":"if","locations":[{"start":{"line":92,"column":4},"end":{"line":95,"column":null}}]},"7":{"loc":{"start":{"line":100,"column":4},"end":{"line":106,"column":null}},"type":"if","locations":[{"start":{"line":100,"column":4},"end":{"line":106,"column":null}}]},"8":{"loc":{"start":{"line":101,"column":6},"end":{"line":103,"column":null}},"type":"if","locations":[{"start":{"line":101,"column":6},"end":{"line":103,"column":null}}]},"9":{"loc":{"start":{"line":112,"column":4},"end":{"line":114,"column":null}},"type":"if","locations":[{"start":{"line":112,"column":4},"end":{"line":114,"column":null}}]},"10":{"loc":{"start":{"line":121,"column":4},"end":{"line":121,"column":25}},"type":"binary-expr","locations":[{"start":{"line":121,"column":4},"end":{"line":121,"column":9}},{"start":{"line":121,"column":13},"end":{"line":121,"column":25}}]},"11":{"loc":{"start":{"line":128,"column":4},"end":{"line":128,"column":25}},"type":"binary-expr","locations":[{"start":{"line":128,"column":4},"end":{"line":128,"column":9}},{"start":{"line":128,"column":13},"end":{"line":128,"column":25}}]},"12":{"loc":{"start":{"line":135,"column":4},"end":{"line":135,"column":42}},"type":"binary-expr","locations":[{"start":{"line":135,"column":4},"end":{"line":135,"column":9}},{"start":{"line":135,"column":13},"end":{"line":135,"column":21}},{"start":{"line":135,"column":25},"end":{"line":135,"column":42}}]},"13":{"loc":{"start":{"line":143,"column":6},"end":{"line":150,"column":null}},"type":"if","locations":[{"start":{"line":143,"column":6},"end":{"line":150,"column":null}}]},"14":{"loc":{"start":{"line":146,"column":8},"end":{"line":148,"column":null}},"type":"if","locations":[{"start":{"line":146,"column":8},"end":{"line":148,"column":null}}]},"15":{"loc":{"start":{"line":152,"column":22},"end":{"line":152,"column":67}},"type":"binary-expr","locations":[{"start":{"line":152,"column":22},"end":{"line":152,"column":42}},{"start":{"line":152,"column":46},"end":{"line":152,"column":67}}]},"16":{"loc":{"start":{"line":154,"column":19},"end":{"line":154,"column":43}},"type":"binary-expr","locations":[{"start":{"line":154,"column":19},"end":{"line":154,"column":24}},{"start":{"line":154,"column":28},"end":{"line":154,"column":43}}]},"17":{"loc":{"start":{"line":171,"column":21},"end":{"line":171,"column":66}},"type":"binary-expr","locations":[{"start":{"line":171,"column":22},"end":{"line":171,"column":29}},{"start":{"line":171,"column":33},"end":{"line":171,"column":37}},{"start":{"line":171,"column":41},"end":{"line":171,"column":59}},{"start":{"line":171,"column":64},"end":{"line":171,"column":66}}]},"18":{"loc":{"start":{"line":172,"column":22},"end":{"line":172,"column":68}},"type":"binary-expr","locations":[{"start":{"line":172,"column":23},"end":{"line":172,"column":30}},{"start":{"line":172,"column":34},"end":{"line":172,"column":38}},{"start":{"line":172,"column":42},"end":{"line":172,"column":61}},{"start":{"line":172,"column":66},"end":{"line":172,"column":68}}]},"19":{"loc":{"start":{"line":177,"column":10},"end":{"line":179,"column":null}},"type":"if","locations":[{"start":{"line":177,"column":10},"end":{"line":179,"column":null}}]},"20":{"loc":{"start":{"line":188,"column":6},"end":{"line":190,"column":null}},"type":"if","locations":[{"start":{"line":188,"column":6},"end":{"line":190,"column":null}}]},"21":{"loc":{"start":{"line":197,"column":6},"end":{"line":199,"column":null}},"type":"if","locations":[{"start":{"line":197,"column":6},"end":{"line":199,"column":null}}]},"22":{"loc":{"start":{"line":210,"column":4},"end":{"line":217,"column":null}},"type":"if","locations":[{"start":{"line":210,"column":4},"end":{"line":217,"column":null}}]},"23":{"loc":{"start":{"line":214,"column":6},"end":{"line":216,"column":null}},"type":"if","locations":[{"start":{"line":214,"column":6},"end":{"line":216,"column":null}}]},"24":{"loc":{"start":{"line":224,"column":4},"end":{"line":229,"column":null}},"type":"if","locations":[{"start":{"line":224,"column":4},"end":{"line":229,"column":null}}]},"25":{"loc":{"start":{"line":227,"column":6},"end":{"line":227,"column":35}},"type":"binary-expr","locations":[{"start":{"line":227,"column":6},"end":{"line":227,"column":14}},{"start":{"line":227,"column":18},"end":{"line":227,"column":35}}]},"26":{"loc":{"start":{"line":237,"column":4},"end":{"line":239,"column":null}},"type":"if","locations":[{"start":{"line":237,"column":4},"end":{"line":239,"column":null}}]},"27":{"loc":{"start":{"line":244,"column":4},"end":{"line":246,"column":null}},"type":"if","locations":[{"start":{"line":244,"column":4},"end":{"line":246,"column":null}}]},"28":{"loc":{"start":{"line":249,"column":2},"end":{"line":254,"column":null}},"type":"if","locations":[{"start":{"line":249,"column":2},"end":{"line":254,"column":null}},{"start":{"line":251,"column":9},"end":{"line":254,"column":null}}]},"29":{"loc":{"start":{"line":251,"column":9},"end":{"line":254,"column":null}},"type":"if","locations":[{"start":{"line":251,"column":9},"end":{"line":254,"column":null}}]},"30":{"loc":{"start":{"line":253,"column":4},"end":{"line":253,"column":44}},"type":"binary-expr","locations":[{"start":{"line":253,"column":4},"end":{"line":253,"column":12}},{"start":{"line":253,"column":16},"end":{"line":253,"column":44}}]}},"s":{"0":2,"1":2,"2":2,"3":2,"4":2,"5":2,"6":13,"7":13,"8":13,"9":13,"10":13,"11":13,"12":1,"13":0,"14":1,"15":1,"16":1,"17":1,"18":1,"19":1,"20":0,"21":1,"22":1,"23":1,"24":1,"25":0,"26":2,"27":0,"28":2,"29":0,"30":0,"31":2,"32":2,"33":1,"34":1,"35":1,"36":1,"37":1,"38":1,"39":1,"40":3,"41":17,"42":2,"43":10,"44":10,"45":2,"46":2,"47":2,"48":2,"49":2,"50":8,"51":8,"52":8,"53":8,"54":1,"55":1,"56":1,"57":1,"58":1,"59":1,"60":8,"61":0,"62":8,"63":8,"64":8,"65":7,"66":0,"67":3,"68":3,"69":3,"70":3,"71":2,"72":3,"73":1,"74":1,"75":1,"76":1,"77":9,"78":9,"79":9,"80":9,"81":8,"82":13,"83":2,"84":11,"85":9,"86":9,"87":13,"88":30,"89":36,"90":2},"f":{"0":13,"1":1,"2":1,"3":1,"4":2,"5":3,"6":17,"7":2,"8":10,"9":1,"10":1,"11":3,"12":3,"13":9,"14":30,"15":36},"b":{"0":[11],"1":[0],"2":[1],"3":[0],"4":[1],"5":[0],"6":[0],"7":[1],"8":[1],"9":[1],"10":[3,3],"11":[17,12],"12":[2,2,2],"13":[2],"14":[2],"15":[8,8],"16":[8,8],"17":[8,8,8,8],"18":[8,8,8,8],"19":[1],"20":[0],"21":[7],"22":[3],"23":[2],"24":[1],"25":[1,1],"26":[9],"27":[8],"28":[2,11],"29":[9],"30":[9,9]}} | ||
,"/Users/billy/code/sentry-javascript/packages/feedback/test/utils/mockSdk.ts": {"path":"/Users/billy/code/sentry-javascript/packages/feedback/test/utils/mockSdk.ts","statementMap":{"0":{"start":{"line":4,"column":0},"end":{"line":4,"column":68}},"1":{"start":{"line":16,"column":8},"end":{"line":20,"column":6}},"2":{"start":{"line":16,"column":27},"end":{"line":20,"column":6}},"3":{"start":{"line":17,"column":6},"end":{"line":19,"column":8}},"4":{"start":{"line":22,"column":4},"end":{"line":22,"column":42}},"5":{"start":{"line":23,"column":4},"end":{"line":23,"column":21}},"6":{"start":{"line":27,"column":4},"end":{"line":27,"column":16}},"7":{"start":{"line":30,"column":4},"end":{"line":34,"column":6}},"8":{"start":{"line":37,"column":4},"end":{"line":37,"column":11}},"9":{"start":{"line":40,"column":4},"end":{"line":40,"column":11}},"10":{"start":{"line":43,"column":4},"end":{"line":43,"column":11}},"11":{"start":{"line":48,"column":2},"end":{"line":57,"column":5}},"12":{"start":{"line":53,"column":21},"end":{"line":53,"column":40}},"13":{"start":{"line":47,"column":0},"end":{"line":47,"column":22}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":13,"column":2},"end":{"line":13,"column":null}},"loc":{"start":{"line":13,"column":2},"end":{"line":24,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":16,"column":16},"end":{"line":16,"column":25}},"loc":{"start":{"line":16,"column":27},"end":{"line":20,"column":6}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":16,"column":27},"end":{"line":16,"column":null}},"loc":{"start":{"line":16,"column":27},"end":{"line":20,"column":5}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":26,"column":8},"end":{"line":26,"column":13}},"loc":{"start":{"line":26,"column":13},"end":{"line":28,"column":null}}},"4":{"name":"(anonymous_5)","decl":{"start":{"line":29,"column":8},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":27},"end":{"line":35,"column":null}}},"5":{"name":"(anonymous_7)","decl":{"start":{"line":36,"column":8},"end":{"line":36,"column":19}},"loc":{"start":{"line":36,"column":19},"end":{"line":38,"column":null}}},"6":{"name":"(anonymous_9)","decl":{"start":{"line":39,"column":8},"end":{"line":39,"column":23}},"loc":{"start":{"line":39,"column":23},"end":{"line":41,"column":null}}},"7":{"name":"(anonymous_11)","decl":{"start":{"line":42,"column":8},"end":{"line":42,"column":13}},"loc":{"start":{"line":42,"column":13},"end":{"line":44,"column":null}}},"8":{"name":"mockSdk","decl":{"start":{"line":47,"column":22},"end":{"line":47,"column":29}},"loc":{"start":{"line":47,"column":67},"end":{"line":58,"column":null}}},"9":{"name":"(anonymous_15)","decl":{"start":{"line":53,"column":15},"end":{"line":53,"column":18}},"loc":{"start":{"line":53,"column":21},"end":{"line":53,"column":40}}}},"branchMap":{"0":{"loc":{"start":{"line":47,"column":30},"end":{"line":47,"column":67}},"type":"default-arg","locations":[{"start":{"line":47,"column":65},"end":{"line":47,"column":67}}]}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":0,"7":0,"8":0,"9":0,"10":0,"11":1,"12":1,"13":1},"f":{"0":1,"1":1,"2":1,"3":0,"4":0,"5":0,"6":0,"7":0,"8":1,"9":1},"b":{"0":[1]}} | ||
} |
{ | ||
"name": "@sentry-internal/feedback", | ||
"version": "0.0.1-alpha.10", | ||
"version": "0.0.1-alpha.11", | ||
"description": "Sentry SDK integration for user feedback", | ||
@@ -26,6 +26,6 @@ "repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"dependencies": { | ||
"@sentry/browser": "7.77.0", | ||
"@sentry/core": "7.77.0", | ||
"@sentry/types": "7.77.0", | ||
"@sentry/utils": "7.77.0" | ||
"@sentry/browser": "7.80.0", | ||
"@sentry/core": "7.80.0", | ||
"@sentry/types": "7.80.0", | ||
"@sentry/utils": "7.80.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
export { sendFeedbackRequest } from './util/sendFeedbackRequest'; | ||
export { sendFeedback } from './sendFeedback'; | ||
export { Feedback } from './integration'; |
@@ -13,2 +13,3 @@ import type { BrowserClient, Replay } from '@sentry/browser'; | ||
url?: string; | ||
source?: string; | ||
} | ||
@@ -20,3 +21,3 @@ | ||
export function sendFeedback( | ||
{ name, email, message, url = getLocationHref() }: SendFeedbackParams, | ||
{ name, email, message, source = 'api', url = getLocationHref() }: SendFeedbackParams, | ||
{ includeReplay = true }: SendFeedbackOptions = {}, | ||
@@ -42,4 +43,5 @@ ): ReturnType<typeof sendFeedbackRequest> { | ||
replay_id: replayId, | ||
source, | ||
}, | ||
}); | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { Event, Primitive } from '@sentry/types'; | ||
import type { Primitive } from '@sentry/types'; | ||
@@ -8,18 +8,2 @@ import type { ActorComponent } from '../widget/Actor'; | ||
/** | ||
* NOTE: These types are still considered Beta and subject to change. | ||
* @hidden | ||
*/ | ||
export interface FeedbackEvent extends Event { | ||
feedback: { | ||
message: string; | ||
url: string; | ||
contact_email?: string; | ||
name?: string; | ||
replay_id?: string; | ||
}; | ||
// TODO: Add this event type to Event | ||
// type: 'feedback_event'; | ||
} | ||
export interface SendFeedbackData { | ||
@@ -32,2 +16,3 @@ feedback: { | ||
name?: string; | ||
source?: string; | ||
}; | ||
@@ -34,0 +19,0 @@ } |
@@ -0,1 +1,4 @@ | ||
import type { TransportMakeRequestResponse } from '@sentry/types'; | ||
import { logger } from '@sentry/utils'; | ||
import { sendFeedback } from '../sendFeedback'; | ||
@@ -6,3 +9,4 @@ import type { FeedbackFormData, SendFeedbackOptions } from '../types'; | ||
/** | ||
* Calls `sendFeedback` to send feedback, handles UI behavior of dialog. | ||
* Handles UI behavior of dialog when feedback is submitted, calls | ||
* `sendFeedback` to send feedback. | ||
*/ | ||
@@ -13,6 +17,6 @@ export async function handleFeedbackSubmit( | ||
options?: SendFeedbackOptions, | ||
): Promise<Response | false> { | ||
): Promise<TransportMakeRequestResponse | void> { | ||
if (!dialog) { | ||
// Not sure when this would happen | ||
return false; | ||
return; | ||
} | ||
@@ -27,19 +31,13 @@ | ||
dialog.hideError(); | ||
try { | ||
dialog.hideError(); | ||
const resp = await sendFeedback(feedback, options); | ||
const resp = await sendFeedback({ ...feedback, source: 'widget' }, options); | ||
if (!resp) { | ||
// Errored... re-enable submit button | ||
showFetchError(); | ||
return false; | ||
} | ||
// Success! | ||
return resp; | ||
} catch { | ||
// Errored... re-enable submit button | ||
} catch (err) { | ||
__DEBUG_BUILD__ && logger.error(err); | ||
showFetchError(); | ||
return false; | ||
} | ||
} |
import type { Scope } from '@sentry/core'; | ||
import { prepareEvent } from '@sentry/core'; | ||
import type { Client } from '@sentry/types'; | ||
import type { Client, FeedbackEvent } from '@sentry/types'; | ||
import type { FeedbackEvent } from '../types'; | ||
interface PrepareFeedbackEventParams { | ||
@@ -20,3 +18,3 @@ client: Client; | ||
}: PrepareFeedbackEventParams): Promise<FeedbackEvent | null> { | ||
const eventHint = { integrations: undefined }; | ||
const eventHint = {}; | ||
if (client.emit) { | ||
@@ -29,8 +27,10 @@ client.emit('preprocessEvent', event, eventHint); | ||
event, | ||
{ integrations: undefined }, | ||
eventHint, | ||
scope, | ||
client, | ||
)) as FeedbackEvent | null; | ||
// If e.g. a global event processor returned null | ||
if (!preparedEvent) { | ||
if (preparedEvent === null) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
client.recordDroppedEvent('event_processor', 'feedback', event); | ||
return null; | ||
@@ -44,12 +44,3 @@ } | ||
// extract the SDK name because `client._prepareEvent` doesn't add it to the event | ||
const metadata = client.getSdkMetadata && client.getSdkMetadata(); | ||
const { name, version } = (metadata && metadata.sdk) || {}; | ||
preparedEvent.sdk = { | ||
...preparedEvent.sdk, | ||
name: name || 'sentry.javascript.unknown', | ||
version: version || '0.0.0', | ||
}; | ||
return preparedEvent; | ||
} |
@@ -1,3 +0,3 @@ | ||
import { getCurrentHub } from '@sentry/core'; | ||
import { dsnToString } from '@sentry/utils'; | ||
import { createEventEnvelope, getCurrentHub } from '@sentry/core'; | ||
import type { FeedbackEvent, TransportMakeRequestResponse } from '@sentry/types'; | ||
@@ -8,13 +8,8 @@ import type { SendFeedbackData } from '../types'; | ||
/** | ||
* Send feedback using `fetch()` | ||
* Send feedback using transport | ||
*/ | ||
export async function sendFeedbackRequest({ | ||
feedback: { message, email, name, replay_id, url }, | ||
}: SendFeedbackData): Promise<Response | null> { | ||
feedback: { message, email, name, source, replay_id, url }, | ||
}: SendFeedbackData): Promise<void | TransportMakeRequestResponse> { | ||
const hub = getCurrentHub(); | ||
if (!hub) { | ||
return null; | ||
} | ||
const client = hub.getClient(); | ||
@@ -26,14 +21,17 @@ const scope = hub.getScope(); | ||
if (!client || !transport || !dsn) { | ||
return null; | ||
return; | ||
} | ||
const baseEvent = { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
const baseEvent: FeedbackEvent = { | ||
contexts: { | ||
feedback: { | ||
contact_email: email, | ||
name, | ||
message, | ||
replay_id, | ||
url, | ||
source, | ||
}, | ||
}, | ||
// type: 'feedback_event', | ||
type: 'feedback', | ||
}; | ||
@@ -47,6 +45,4 @@ | ||
if (!feedbackEvent) { | ||
// Taken from baseclient's `_processEvent` method, where this is handled for errors/transactions | ||
// client.recordDroppedEvent('event_processor', 'feedback', baseEvent); | ||
return null; | ||
if (feedbackEvent === null) { | ||
return; | ||
} | ||
@@ -57,61 +53,71 @@ | ||
{ | ||
"data": { | ||
"dist": "abc123", | ||
"type": "feedback", | ||
"event_id": "d2132d31b39445f1938d7e21b6bf0ec4", | ||
"timestamp": 1597977777.6189718, | ||
"dist": "1.12", | ||
"platform": "javascript", | ||
"environment": "production", | ||
"feedback": { | ||
"contact_email": "colton.allen@sentry.io", | ||
"message": "I really like this user-feedback feature!", | ||
"replay_id": "ec3b4dc8b79f417596f7a1aa4fcca5d2", | ||
"url": "https://docs.sentry.io/platforms/javascript/" | ||
"release": 42, | ||
"tags": {"transaction": "/organizations/:orgId/performance/:eventSlug/"}, | ||
"sdk": {"name": "name", "version": "version"}, | ||
"user": { | ||
"id": "123", | ||
"username": "user", | ||
"email": "user@site.com", | ||
"ip_address": "192.168.11.12", | ||
}, | ||
"id": "1ffe0775ac0f4417aed9de36d9f6f8dc", | ||
"platform": "javascript", | ||
"release": "version@1.3", | ||
"request": { | ||
"headers": { | ||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36" | ||
} | ||
"url": None, | ||
"headers": { | ||
"user-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Safari/605.1.15" | ||
}, | ||
}, | ||
"sdk": { | ||
"name": "sentry.javascript.react", | ||
"version": "6.18.1" | ||
"contexts": { | ||
"feedback": { | ||
"message": "test message", | ||
"contact_email": "test@example.com", | ||
"type": "feedback", | ||
}, | ||
"trace": { | ||
"trace_id": "4C79F60C11214EB38604F4AE0781BFB2", | ||
"span_id": "FA90FDEAD5F74052", | ||
"type": "trace", | ||
}, | ||
"replay": { | ||
"replay_id": "e2d42047b1c5431c8cba85ee2a8ab25d", | ||
}, | ||
}, | ||
"tags": { | ||
"key": "value" | ||
}, | ||
"timestamp": "2023-08-31T14:10:34.954048", | ||
"user": { | ||
"email": "username@example.com", | ||
"id": "123", | ||
"ip_address": "127.0.0.1", | ||
"name": "user", | ||
"username": "user2270129" | ||
} | ||
} | ||
} | ||
*/ | ||
// Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to | ||
// sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may | ||
// have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid | ||
// of this `delete`, lest we miss putting it back in the next time the property is in use.) | ||
delete feedbackEvent.sdkProcessingMetadata; | ||
const envelope = createEventEnvelope(feedbackEvent, dsn, client.getOptions()._metadata, client.getOptions().tunnel); | ||
let response: void | TransportMakeRequestResponse; | ||
try { | ||
const path = 'https://sentry.io/api/0/feedback/'; | ||
const response = await fetch(path, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `DSN ${dsnToString(dsn)}`, | ||
}, | ||
body: JSON.stringify(feedbackEvent), | ||
}); | ||
if (!response.ok) { | ||
return null; | ||
response = await transport.send(envelope); | ||
} catch (err) { | ||
const error = new Error('Unable to send Feedback'); | ||
try { | ||
// In case browsers don't allow this property to be writable | ||
// @ts-expect-error This needs lib es2022 and newer | ||
error.cause = err; | ||
} catch { | ||
// nothing to do | ||
} | ||
throw error; | ||
} | ||
// TODO (v8): we can remove this guard once transport.send's type signature doesn't include void anymore | ||
if (!response) { | ||
return response; | ||
} catch (err) { | ||
return null; | ||
} | ||
// Require valid status codes, otherwise can assume feedback was not sent successfully | ||
if (typeof response.statusCode === 'number' && (response.statusCode < 200 || response.statusCode >= 300)) { | ||
throw new Error('Unable to send Feedback'); | ||
} | ||
return response; | ||
} |
import type { Hub, Scope } from '@sentry/core'; | ||
import { getCurrentHub } from '@sentry/core'; | ||
import type { Client } from '@sentry/types'; | ||
import type { Client, FeedbackEvent } from '@sentry/types'; | ||
import type { FeedbackEvent } from '../../../src/types'; | ||
import { prepareFeedbackEvent } from '../../../src/util/prepareFeedbackEvent'; | ||
@@ -21,11 +20,2 @@ import { getDefaultClientOptions, TestClient } from '../../utils/TestClient'; | ||
scope = hub.getScope()!; | ||
jest.spyOn(client, 'getSdkMetadata').mockImplementation(() => { | ||
return { | ||
sdk: { | ||
name: 'sentry.javascript.testSdk', | ||
version: '1.0.0', | ||
}, | ||
}; | ||
}); | ||
}); | ||
@@ -45,9 +35,10 @@ | ||
event_id: 'feedback-ID', | ||
feedback: { | ||
contact_email: 'test@test.com', | ||
message: 'looks great!', | ||
replay_id: replayId, | ||
url: 'https://sentry.io/', | ||
}, | ||
type: 'feedback', | ||
contexts: { | ||
feedback: { | ||
contact_email: 'test@test.com', | ||
message: 'looks great!', | ||
replay_id: replayId, | ||
url: 'https://sentry.io/', | ||
}, | ||
replay: { | ||
@@ -62,16 +53,14 @@ error_sample_rate: 1.0, | ||
expect(client.getSdkMetadata).toHaveBeenCalledTimes(1); | ||
expect(feedbackEvent).toEqual({ | ||
timestamp: 1670837008.634, | ||
event_id: 'feedback-ID', | ||
feedback: { | ||
contact_email: 'test@test.com', | ||
message: 'looks great!', | ||
replay_id: replayId, | ||
url: 'https://sentry.io/', | ||
}, | ||
platform: 'javascript', | ||
environment: 'production', | ||
contexts: { | ||
feedback: { | ||
contact_email: 'test@test.com', | ||
message: 'looks great!', | ||
replay_id: replayId, | ||
url: 'https://sentry.io/', | ||
}, | ||
replay: { | ||
@@ -82,10 +71,7 @@ error_sample_rate: 1.0, | ||
}, | ||
sdk: { | ||
name: 'sentry.javascript.testSdk', | ||
version: '1.0.0', | ||
}, | ||
sdkProcessingMetadata: expect.any(Object), | ||
breadcrumbs: undefined, | ||
type: 'feedback', | ||
}); | ||
}); | ||
}); |
@@ -158,2 +158,3 @@ import { | ||
replay_id: undefined, | ||
source: 'widget', | ||
}, | ||
@@ -181,3 +182,3 @@ }); | ||
(sendFeedbackRequest as jest.Mock).mockImplementation(() => { | ||
return false; | ||
throw new Error('Unable to send feedback'); | ||
}); | ||
@@ -199,2 +200,3 @@ widget.actor?.el?.dispatchEvent(new Event('click')); | ||
replay_id: undefined, | ||
source: 'widget', | ||
}, | ||
@@ -201,0 +203,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
1159987
8490
0
179
+ Added@sentry-internal/tracing@7.80.0(transitive)
+ Added@sentry/browser@7.80.0(transitive)
+ Added@sentry/core@7.80.0(transitive)
+ Added@sentry/replay@7.80.0(transitive)
+ Added@sentry/types@7.80.0(transitive)
+ Added@sentry/utils@7.80.0(transitive)
- Removed@sentry-internal/tracing@7.77.0(transitive)
- Removed@sentry/browser@7.77.0(transitive)
- Removed@sentry/core@7.77.0(transitive)
- Removed@sentry/replay@7.77.0(transitive)
- Removed@sentry/types@7.77.0(transitive)
- Removed@sentry/utils@7.77.0(transitive)
Updated@sentry/browser@7.80.0
Updated@sentry/core@7.80.0
Updated@sentry/types@7.80.0
Updated@sentry/utils@7.80.0