@@ -12,6 +12,8 @@ export class CustomEvent {
12
12
_value ?: number ;
13
13
_properties : JsonObject ;
14
14
_transactionId ?: string ;
15
+ _interactionId ?: string ;
16
+ _interactionType ?: string ;
15
17
16
18
/**
17
19
* Custom event constructor.
@@ -39,6 +41,34 @@ export class CustomEvent {
39
41
this . _transactionId = value ;
40
42
}
41
43
44
+ /**
45
+ * Gets the event's interaction ID.
46
+ */
47
+ get interactionId ( ) : string | undefined {
48
+ return this . _interactionId ;
49
+ }
50
+
51
+ /**
52
+ * Sets the event's interaction ID.
53
+ */
54
+ set interactionId ( value : string | undefined ) {
55
+ this . _interactionId = value ;
56
+ }
57
+
58
+ /**
59
+ * Gets the event's interaction Type.
60
+ */
61
+ get interactionType ( ) : string | undefined {
62
+ return this . _interactionType ;
63
+ }
64
+
65
+ /**
66
+ * Sets the event's interaction Type.
67
+ */
68
+ set interactionType ( value : string | undefined ) {
69
+ this . _interactionType = value ;
70
+ }
71
+
42
72
/**
43
73
* Adds a property to the custom event.
44
74
*
@@ -48,4 +78,28 @@ export class CustomEvent {
48
78
addProperty ( name : string , value : JsonValue ) {
49
79
this . _properties [ name ] = value ;
50
80
}
81
+
82
+ /**
83
+ * Converts a CustomEvent into a JsonValue.
84
+ *
85
+ * @returns A JsonValue.
86
+ */
87
+ toJsonValue ( ) : JsonValue {
88
+ let jsonObject : JsonObject = { } ;
89
+ jsonObject . eventName = this . _name ;
90
+ if ( this . _value ) {
91
+ jsonObject . eventValue = this . _value ;
92
+ }
93
+ jsonObject . properties = this . _properties ;
94
+ if ( this . _transactionId ) {
95
+ jsonObject . transactionId = this . _transactionId ;
96
+ }
97
+ if ( this . _interactionId ) {
98
+ jsonObject . interactionId = this . _interactionId ;
99
+ }
100
+ if ( this . _interactionType ) {
101
+ jsonObject . interactionType = this . _interactionType ;
102
+ }
103
+ return jsonObject ;
104
+ }
51
105
}
0 commit comments