Skip to content

Commit 2a9bb6a

Browse files
committed
Merge remote-tracking branch 'origin/master' into joshua/feat/dsc
# Conflicts: # CHANGELOG.md
2 parents 2f6fef9 + fef7868 commit 2a9bb6a

27 files changed

Lines changed: 440 additions & 84 deletions

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
- Compiles also on Xbox One ([#1294](https://github.com/getsentry/sentry-native/pull/1294))
1212
- Provide `sentry_regenerate_trace()` to allow users to set manual trace boundaries. ([#1293](https://github.com/getsentry/sentry-native/pull/1293))
1313
- Add `Dynamic Sampling Context (DSC)` to events. ([#1254](https://github.com/getsentry/sentry-native/pull/1254))
14+
- Add `sentry_value_new_feedback` and `sentry_capture_feedback` to allow capturing [User Feedback](https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback). ([#1304](https://github.com/getsentry/sentry-native/pull/1304))
15+
- Deprecate `sentry_value_new_user_feedback` and `sentry_capture_user_feedback` in favor of the new API.
16+
17+
**Fixes**:
18+
19+
- Update Xbox toolchain to include `UseDebugLibraries` fix for Debug builds. ([#1302](https://github.com/getsentry/sentry-native/pull/1302))
20+
21+
**Meta**:
22+
23+
- Marked deprecated functions with `SENTRY_DEPRECATED(msg)`. ([#1308](https://github.com/getsentry/sentry-native/pull/1308))
1424

1525
## 0.9.1
1626

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ The example currently supports the following commands:
189189
- `capture-with-scope`: Captures an event with a local scope.
190190
- `attach-to-scope`: Same as `attachment` but attaches the file to the local scope.
191191
- `clear-attachments`: Clears all attachments from the global scope.
192+
- `capture-user-feedback`: Captures a user feedback event.
192193

193194
Only on Linux using crashpad:
194195
- `crashpad-wait-for-upload`: Couples application shutdown to complete the upload in the `crashpad_handler`.

examples/example.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,22 @@ main(int argc, char **argv)
556556
sentry_capture_event(event);
557557
}
558558
if (has_arg(argc, argv, "capture-user-feedback")) {
559+
sentry_value_t user_feedback = sentry_value_new_feedback(
560+
"some-message", "some-email", "some-name", NULL);
561+
562+
sentry_capture_feedback(user_feedback);
563+
}
564+
if (has_arg(argc, argv, "capture-user-report")) {
559565
sentry_value_t event = sentry_value_new_message_event(
560566
SENTRY_LEVEL_INFO, "my-logger", "Hello user feedback!");
561567
sentry_uuid_t event_id = sentry_capture_event(event);
562568

569+
SENTRY_SUPPRESS_DEPRECATED
563570
sentry_value_t user_feedback = sentry_value_new_user_feedback(
564571
&event_id, "some-name", "some-email", "some-comment");
565572

566573
sentry_capture_user_feedback(user_feedback);
574+
SENTRY_RESTORE_DEPRECATED
567575
}
568576

569577
if (has_arg(argc, argv, "capture-transaction")) {

include/sentry.h

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,40 @@ extern "C" {
100100
# endif
101101
#endif
102102

103+
#ifdef __has_attribute
104+
# if __has_attribute(deprecated)
105+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
106+
# endif
107+
#endif
108+
#ifndef SENTRY_DEPRECATED
109+
# if defined(__GNUC__) \
110+
&& (__GNUC__ > 4 \
111+
|| (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) /* GCC 4.5 */
112+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
113+
# elif defined(__clang__) && __clang__major__ >= 3 /* Clang 3.0 */
114+
# define SENTRY_DEPRECATED(msg) __attribute__((deprecated(msg)))
115+
# elif defined(_MSC_VER) && _MSC_VER >= 1400 /* VS 2005 (8.0) */
116+
# define SENTRY_DEPRECATED(msg) __declspec(deprecated(msg))
117+
# else
118+
# define SENTRY_DEPRECATED(msg)
119+
# endif
120+
#endif
121+
122+
#if defined(__GNUC__) || defined(__clang__)
123+
# define SENTRY_SUPPRESS_DEPRECATED \
124+
_Pragma("GCC diagnostic push"); \
125+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
126+
# define SENTRY_RESTORE_DEPRECATED _Pragma("GCC diagnostic pop")
127+
#elif defined(_MSC_VER)
128+
# define SENTRY_SUPPRESS_DEPRECATED \
129+
__pragma(warning(push)); \
130+
__pragma(warning(disable : 4996))
131+
# define SENTRY_RESTORE_DEPRECATED __pragma(warning(pop))
132+
#else
133+
# define SENTRY_SUPPRESS_DEPRECATED
134+
# define SENTRY_RESTORE_DEPRECATED
135+
#endif
136+
103137
/* marks a function as experimental api */
104138
#ifndef SENTRY_EXPERIMENTAL_API
105139
# define SENTRY_EXPERIMENTAL_API SENTRY_API
@@ -515,13 +549,13 @@ SENTRY_EXPERIMENTAL_API char *sentry_value_to_msgpack(
515549
* Adds a stack trace to an event.
516550
*
517551
* The stack trace is added as part of a new thread object.
518-
* This function is **deprecated** in favor of using
519-
* `sentry_value_new_stacktrace` in combination with `sentry_value_new_thread`
520-
* and `sentry_event_add_thread`.
521552
*
522553
* If `ips` is NULL the current stack trace is captured, otherwise `len`
523554
* stack trace instruction pointers are attached to the event.
524555
*/
556+
SENTRY_DEPRECATED(
557+
"Use `sentry_value_new_stacktrace` in combination with "
558+
"`sentry_value_new_thread` and `sentry_event_add_thread` instead")
525559
SENTRY_EXPERIMENTAL_API void sentry_event_value_add_stacktrace(
526560
sentry_value_t event, void **ips, size_t len);
527561

@@ -772,11 +806,8 @@ SENTRY_API void sentry_transport_free(sentry_transport_t *transport);
772806
* It is a convenience function which works with a borrowed `data`, and will
773807
* automatically free the envelope, so the user provided function does not need
774808
* to do that.
775-
*
776-
* This function is *deprecated* and will be removed in a future version.
777-
* It is here for backwards compatibility. Users should migrate to the
778-
* `sentry_transport_new` API.
779809
*/
810+
SENTRY_DEPRECATED("Use `sentry_transport_new` instead")
780811
SENTRY_API sentry_transport_t *sentry_new_function_transport(
781812
void (*func)(const sentry_envelope_t *envelope, void *data), void *data);
782813

@@ -1053,13 +1084,13 @@ SENTRY_API const char *sentry_options_get_proxy(const sentry_options_t *opts);
10531084
/**
10541085
* Configures the proxy.
10551086
*
1056-
* This is a **deprecated** alias for `sentry_options_set_proxy(_n)`.
1057-
*
10581087
* The given proxy has to include the full scheme,
10591088
* eg. `http://some.proxy/.
10601089
*/
1090+
SENTRY_DEPRECATED("Use `sentry_options_set_proxy` instead")
10611091
SENTRY_API void sentry_options_set_http_proxy(
10621092
sentry_options_t *opts, const char *proxy);
1093+
SENTRY_DEPRECATED("Use `sentry_options_set_proxy_n` instead")
10631094
SENTRY_API void sentry_options_set_http_proxy_n(
10641095
sentry_options_t *opts, const char *proxy, size_t proxy_len);
10651096

@@ -1465,10 +1496,9 @@ SENTRY_API int sentry_close(void);
14651496
/**
14661497
* Shuts down the sentry client and forces transports to flush out.
14671498
*
1468-
* This is a **deprecated** alias for `sentry_close`.
1469-
*
14701499
* Returns 0 on success.
14711500
*/
1501+
SENTRY_DEPRECATED("Use `sentry_close` instead")
14721502
SENTRY_API int sentry_shutdown(void);
14731503

14741504
/**
@@ -2419,25 +2449,48 @@ SENTRY_EXPERIMENTAL_API void sentry_transaction_set_name_n(
24192449
sentry_transaction_t *transaction, const char *name, size_t name_len);
24202450

24212451
/**
2422-
* Creates a new User Feedback with a specific name, email and comments.
2452+
* Creates a deprecated User Report with a specific name, email and comments.
24232453
*
2424-
* See https://develop.sentry.dev/sdk/envelopes/#user-feedback
2425-
*
2426-
* User Feedback has to be associated with a specific event that has been
2427-
* sent to Sentry earlier.
2454+
* See
2455+
* https://develop.sentry.dev/sdk/data-model/envelope-items/#user-report---deprecated
24282456
*/
2457+
SENTRY_DEPRECATED("Use `sentry_value_new_feedback` instead")
24292458
SENTRY_API sentry_value_t sentry_value_new_user_feedback(
24302459
const sentry_uuid_t *uuid, const char *name, const char *email,
24312460
const char *comments);
2461+
SENTRY_DEPRECATED("Use `sentry_value_new_feedback_n` instead")
24322462
SENTRY_API sentry_value_t sentry_value_new_user_feedback_n(
24332463
const sentry_uuid_t *uuid, const char *name, size_t name_len,
24342464
const char *email, size_t email_len, const char *comments,
24352465
size_t comments_len);
24362466

2467+
/**
2468+
* Captures a deprecated User Report and sends it to Sentry.
2469+
*/
2470+
SENTRY_DEPRECATED("Use `sentry_capture_feedback` instead")
2471+
SENTRY_API void sentry_capture_user_feedback(sentry_value_t user_report);
2472+
2473+
/**
2474+
* Creates a new User Feedback with a specific message (required), and optional
2475+
* contact_email, name, message, and associated_event_id.
2476+
*
2477+
* See https://develop.sentry.dev/sdk/data-model/envelope-items/#user-feedback
2478+
*
2479+
* User Feedback can be associated with a specific event that has been
2480+
* sent to Sentry earlier.
2481+
*/
2482+
SENTRY_API sentry_value_t sentry_value_new_feedback(const char *message,
2483+
const char *contact_email, const char *name,
2484+
const sentry_uuid_t *associated_event_id);
2485+
SENTRY_API sentry_value_t sentry_value_new_feedback_n(const char *message,
2486+
size_t message_len, const char *contact_email, size_t contact_email_len,
2487+
const char *name, size_t name_len,
2488+
const sentry_uuid_t *associated_event_id);
2489+
24372490
/**
24382491
* Captures a manually created User Feedback and sends it to Sentry.
24392492
*/
2440-
SENTRY_API void sentry_capture_user_feedback(sentry_value_t user_feedback);
2493+
SENTRY_API void sentry_capture_feedback(sentry_value_t user_feedback);
24412494

24422495
/**
24432496
* The status of a Span or Transaction.
@@ -2573,14 +2626,14 @@ SENTRY_EXPERIMENTAL_API const char *sentry_sdk_version(void);
25732626

25742627
/**
25752628
* Sentry SDK name set during build time.
2576-
* Deprecated: Please use sentry_options_get_sdk_name instead.
25772629
*/
2630+
SENTRY_DEPRECATED("Use `sentry_options_get_sdk_name` instead")
25782631
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_name(void);
25792632

25802633
/**
25812634
* Sentry SDK User-Agent set during build time.
2582-
* Deprecated: Please use sentry_options_get_user_agent instead.
25832635
*/
2636+
SENTRY_DEPRECATED("Use `sentry_options_get_user_agent` instead")
25842637
SENTRY_EXPERIMENTAL_API const char *sentry_sdk_user_agent(void);
25852638

25862639
#ifdef __cplusplus

src/sentry_core.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,25 @@ sentry__prepare_transaction(const sentry_options_t *options,
695695
return NULL;
696696
}
697697

698+
static sentry_envelope_t *
699+
prepare_user_report(sentry_value_t user_report)
700+
{
701+
sentry_envelope_t *envelope = NULL;
702+
703+
envelope = sentry__envelope_new();
704+
if (!envelope || !sentry__envelope_add_user_report(envelope, user_report)) {
705+
goto fail;
706+
}
707+
708+
return envelope;
709+
710+
fail:
711+
SENTRY_WARN("dropping user report");
712+
sentry_envelope_free(envelope);
713+
sentry_value_decref(user_report);
714+
return NULL;
715+
}
716+
698717
static sentry_envelope_t *
699718
prepare_user_feedback(sentry_value_t user_feedback)
700719
{
@@ -1381,17 +1400,32 @@ sentry_span_finish_ts(sentry_span_t *opaque_span, uint64_t timestamp)
13811400
}
13821401

13831402
void
1384-
sentry_capture_user_feedback(sentry_value_t user_feedback)
1403+
sentry_capture_user_feedback(sentry_value_t user_report)
1404+
{
1405+
sentry_envelope_t *envelope = NULL;
1406+
1407+
SENTRY_WITH_OPTIONS (options) {
1408+
envelope = prepare_user_report(user_report);
1409+
if (envelope) {
1410+
sentry__capture_envelope(options->transport, envelope);
1411+
}
1412+
}
1413+
sentry_value_decref(user_report);
1414+
}
1415+
1416+
void
1417+
sentry_capture_feedback(sentry_value_t user_feedback)
13851418
{
13861419
sentry_envelope_t *envelope = NULL;
13871420

13881421
SENTRY_WITH_OPTIONS (options) {
13891422
envelope = prepare_user_feedback(user_feedback);
13901423
if (envelope) {
13911424
sentry__capture_envelope(options->transport, envelope);
1425+
} else {
1426+
sentry_value_decref(user_feedback);
13921427
}
13931428
}
1394-
sentry_value_decref(user_feedback);
13951429
}
13961430

13971431
int

src/sentry_envelope.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ sentry__envelope_add_transaction(
372372
}
373373

374374
sentry_envelope_item_t *
375-
sentry__envelope_add_user_feedback(
376-
sentry_envelope_t *envelope, sentry_value_t user_feedback)
375+
sentry__envelope_add_user_report(
376+
sentry_envelope_t *envelope, sentry_value_t user_report)
377377
{
378378
sentry_envelope_item_t *item = envelope_add_item(envelope);
379379
if (!item) {
@@ -385,9 +385,9 @@ sentry__envelope_add_user_feedback(
385385
return NULL;
386386
}
387387

388-
sentry_value_t event_id = sentry__ensure_event_id(user_feedback, NULL);
388+
sentry_value_t event_id = sentry__ensure_event_id(user_report, NULL);
389389

390-
sentry__jsonwriter_write_value(jw, user_feedback);
390+
sentry__jsonwriter_write_value(jw, user_report);
391391
item->payload = sentry__jsonwriter_into_string(jw, &item->payload_len);
392392

393393
sentry__envelope_item_set_header(
@@ -401,6 +401,30 @@ sentry__envelope_add_user_feedback(
401401
return item;
402402
}
403403

404+
sentry_envelope_item_t *
405+
sentry__envelope_add_user_feedback(
406+
sentry_envelope_t *envelope, sentry_value_t user_feedback)
407+
{
408+
sentry_value_t event = sentry_value_new_event();
409+
sentry_value_t contexts = sentry_value_get_by_key(event, "contexts");
410+
if (sentry_value_is_null(contexts)) {
411+
contexts = sentry_value_new_object();
412+
}
413+
sentry_value_set_by_key(contexts, "feedback", user_feedback);
414+
sentry_value_set_by_key(event, "contexts", contexts);
415+
416+
sentry_envelope_item_t *item = sentry__envelope_add_event(envelope, event);
417+
if (!item) {
418+
sentry_value_decref(event);
419+
return NULL;
420+
}
421+
422+
sentry__envelope_item_set_header(
423+
item, "type", sentry_value_new_string("feedback"));
424+
425+
return item;
426+
}
427+
404428
sentry_envelope_item_t *
405429
sentry__envelope_add_session(
406430
sentry_envelope_t *envelope, const sentry_session_t *session)

src/sentry_envelope.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ sentry_envelope_item_t *sentry__envelope_add_event(
4343
sentry_envelope_item_t *sentry__envelope_add_transaction(
4444
sentry_envelope_t *envelope, sentry_value_t transaction);
4545

46+
/**
47+
* Add a deprecated user report to this envelope.
48+
*/
49+
sentry_envelope_item_t *sentry__envelope_add_user_report(
50+
sentry_envelope_t *envelope, sentry_value_t user_report);
51+
4652
/**
4753
* Add a user feedback to this envelope.
4854
*/

0 commit comments

Comments
 (0)