@@ -34,6 +34,12 @@ public final class Breadcrumb implements JsonUnknown, JsonSerializable {
34
34
/** Dotted strings that indicate what the crumb is or where it comes from. */
35
35
private @ Nullable String category ;
36
36
37
+ /**
38
+ * Origin of the breadcrumb that is used to identify source of the breadcrumb. For example hybrid
39
+ * SDKs can identify native breadcrumbs from JS or Flutter.
40
+ */
41
+ private @ Nullable String origin ;
42
+
37
43
/** The level of the event. */
38
44
private @ Nullable SentryLevel level ;
39
45
@@ -54,6 +60,7 @@ public Breadcrumb(final @NotNull Date timestamp) {
54
60
this .message = breadcrumb .message ;
55
61
this .type = breadcrumb .type ;
56
62
this .category = breadcrumb .category ;
63
+ this .origin = breadcrumb .origin ;
57
64
final Map <String , Object > dataClone = CollectionUtils .newConcurrentHashMap (breadcrumb .data );
58
65
if (dataClone != null ) {
59
66
this .data = dataClone ;
@@ -78,6 +85,7 @@ public static Breadcrumb fromMap(
78
85
String type = null ;
79
86
@ NotNull Map <String , Object > data = new ConcurrentHashMap <>();
80
87
String category = null ;
88
+ String origin = null ;
81
89
SentryLevel level = null ;
82
90
Map <String , Object > unknown = null ;
83
91
@@ -116,6 +124,9 @@ public static Breadcrumb fromMap(
116
124
case JsonKeys .CATEGORY :
117
125
category = (value instanceof String ) ? (String ) value : null ;
118
126
break ;
127
+ case JsonKeys .ORIGIN :
128
+ origin = (value instanceof String ) ? (String ) value : null ;
129
+ break ;
119
130
case JsonKeys .LEVEL :
120
131
String levelString = (value instanceof String ) ? (String ) value : null ;
121
132
if (levelString != null ) {
@@ -140,6 +151,7 @@ public static Breadcrumb fromMap(
140
151
breadcrumb .type = type ;
141
152
breadcrumb .data = data ;
142
153
breadcrumb .category = category ;
154
+ breadcrumb .origin = origin ;
143
155
breadcrumb .level = level ;
144
156
145
157
breadcrumb .setUnknown (unknown );
@@ -610,6 +622,24 @@ public void setCategory(@Nullable String category) {
610
622
this .category = category ;
611
623
}
612
624
625
+ /**
626
+ * Returns the origin
627
+ *
628
+ * @return the origin
629
+ */
630
+ public @ Nullable String getOrigin () {
631
+ return origin ;
632
+ }
633
+
634
+ /**
635
+ * Sets the origin
636
+ *
637
+ * @param origin the origin
638
+ */
639
+ public void setOrigin (@ Nullable String origin ) {
640
+ this .origin = origin ;
641
+ }
642
+
613
643
/**
614
644
* Returns the SentryLevel
615
645
*
@@ -638,12 +668,13 @@ public boolean equals(Object o) {
638
668
&& Objects .equals (message , that .message )
639
669
&& Objects .equals (type , that .type )
640
670
&& Objects .equals (category , that .category )
671
+ && Objects .equals (origin , that .origin )
641
672
&& level == that .level ;
642
673
}
643
674
644
675
@ Override
645
676
public int hashCode () {
646
- return Objects .hash (timestamp , message , type , category , level );
677
+ return Objects .hash (timestamp , message , type , category , origin , level );
647
678
}
648
679
649
680
// region json
@@ -665,6 +696,7 @@ public static final class JsonKeys {
665
696
public static final String TYPE = "type" ;
666
697
public static final String DATA = "data" ;
667
698
public static final String CATEGORY = "category" ;
699
+ public static final String ORIGIN = "origin" ;
668
700
public static final String LEVEL = "level" ;
669
701
}
670
702
@@ -683,6 +715,9 @@ public void serialize(final @NotNull ObjectWriter writer, final @NotNull ILogger
683
715
if (category != null ) {
684
716
writer .name (JsonKeys .CATEGORY ).value (category );
685
717
}
718
+ if (origin != null ) {
719
+ writer .name (JsonKeys .ORIGIN ).value (origin );
720
+ }
686
721
if (level != null ) {
687
722
writer .name (JsonKeys .LEVEL ).value (logger , level );
688
723
}
@@ -707,6 +742,7 @@ public static final class Deserializer implements JsonDeserializer<Breadcrumb> {
707
742
String type = null ;
708
743
@ NotNull Map <String , Object > data = new ConcurrentHashMap <>();
709
744
String category = null ;
745
+ String origin = null ;
710
746
SentryLevel level = null ;
711
747
712
748
Map <String , Object > unknown = null ;
@@ -736,6 +772,9 @@ public static final class Deserializer implements JsonDeserializer<Breadcrumb> {
736
772
case JsonKeys .CATEGORY :
737
773
category = reader .nextStringOrNull ();
738
774
break ;
775
+ case JsonKeys .ORIGIN :
776
+ origin = reader .nextStringOrNull ();
777
+ break ;
739
778
case JsonKeys .LEVEL :
740
779
try {
741
780
level = new SentryLevel .Deserializer ().deserialize (reader , logger );
@@ -757,6 +796,7 @@ public static final class Deserializer implements JsonDeserializer<Breadcrumb> {
757
796
breadcrumb .type = type ;
758
797
breadcrumb .data = data ;
759
798
breadcrumb .category = category ;
799
+ breadcrumb .origin = origin ;
760
800
breadcrumb .level = level ;
761
801
762
802
breadcrumb .setUnknown (unknown );
0 commit comments