1
1
import { ExceptionlessClient } from "./ExceptionlessClient.js" ;
2
- import {
3
- Event ,
4
- KnownEventDataKeys
5
- } from "./models/Event.js" ;
2
+ import { Event , KnownEventDataKeys } from "./models/Event.js" ;
6
3
import { ManualStackingInfo } from "./models/data/ManualStackingInfo.js" ;
7
4
import { RequestInfo } from "./models/data/RequestInfo.js" ;
8
5
import { UserInfo } from "./models/data/UserInfo.js" ;
9
- import { ContextData } from "./plugins/ContextData.js" ;
6
+ import { EventContext } from "./models/EventContext.js" ;
7
+ import { isEmpty , stringify } from "./Utils.js" ;
10
8
import { EventPluginContext } from "./plugins/EventPluginContext.js" ;
11
- import {
12
- isEmpty ,
13
- stringify
14
- } from "./Utils.js" ;
15
9
16
10
export class EventBuilder {
17
11
public target : Event ;
18
12
public client : ExceptionlessClient ;
19
- public pluginContextData : ContextData ;
13
+ public context : EventContext ;
20
14
21
15
private _validIdentifierErrorMessage = "must contain between 8 and 100 alphanumeric or '-' characters." ;
22
16
23
- constructor (
24
- event : Event ,
25
- client : ExceptionlessClient ,
26
- pluginContextData ?: ContextData ,
27
- ) {
17
+ constructor ( event : Event , client : ExceptionlessClient , context ?: EventContext ) {
28
18
this . target = event ;
29
19
this . client = client ;
30
- this . pluginContextData = pluginContextData || new ContextData ( ) ;
20
+ this . context = context || new EventContext ( ) ;
31
21
}
32
22
33
23
public setType ( type : string ) : EventBuilder {
@@ -59,7 +49,6 @@ export class EventBuilder {
59
49
* Allows you to reference a parent event by its ReferenceId property. This allows you to have parent and child relationships.
60
50
* @param name Reference name
61
51
* @param id The reference id that points to a specific event
62
- * @returns {EventBuilder }
63
52
*/
64
53
public setEventReference ( name : string , id : string ) : EventBuilder {
65
54
if ( ! name ) {
@@ -100,10 +89,7 @@ export class EventBuilder {
100
89
public setUserIdentity ( userInfo : UserInfo ) : EventBuilder ;
101
90
public setUserIdentity ( identity : string ) : EventBuilder ;
102
91
public setUserIdentity ( identity : string , name : string ) : EventBuilder ;
103
- public setUserIdentity (
104
- userInfoOrIdentity : UserInfo | string ,
105
- name ?: string ,
106
- ) : EventBuilder {
92
+ public setUserIdentity ( userInfoOrIdentity : UserInfo | string , name ?: string ) : EventBuilder {
107
93
const userInfo = typeof userInfoOrIdentity !== "string"
108
94
? userInfoOrIdentity
109
95
: { identity : userInfoOrIdentity , name } ;
@@ -120,12 +106,8 @@ export class EventBuilder {
120
106
*
121
107
* @param emailAddress The email address
122
108
* @param description The user"s description of the event.
123
- * @returns {EventBuilder }
124
109
*/
125
- public setUserDescription (
126
- emailAddress : string ,
127
- description : string ,
128
- ) : EventBuilder {
110
+ public setUserDescription ( emailAddress : string , description : string ) : EventBuilder {
129
111
if ( emailAddress && description ) {
130
112
this . setProperty ( KnownEventDataKeys . UserDescription , {
131
113
email_address : emailAddress ,
@@ -141,12 +123,8 @@ export class EventBuilder {
141
123
* stacking information.
142
124
* @param signatureData A dictionary of strings to use for stacking.
143
125
* @param title An optional title for the stacking information.
144
- * @returns {EventBuilder }
145
126
*/
146
- public setManualStackingInfo (
147
- signatureData : Record < string , string > ,
148
- title ?: string ,
149
- ) : EventBuilder {
127
+ public setManualStackingInfo ( signatureData : Record < string , string > , title ?: string ) : EventBuilder {
150
128
if ( signatureData ) {
151
129
const stack : ManualStackingInfo = { signature_data : signatureData } ;
152
130
if ( title ) {
@@ -163,12 +141,8 @@ export class EventBuilder {
163
141
* Changes default stacking behavior by setting the stacking key.
164
142
* @param manualStackingKey The manual stacking key.
165
143
* @param title An optional title for the stacking information.
166
- * @returns {EventBuilder }
167
144
*/
168
- public setManualStackingKey (
169
- manualStackingKey : string ,
170
- title ?: string ,
171
- ) : EventBuilder {
145
+ public setManualStackingKey ( manualStackingKey : string , title ?: string ) : EventBuilder {
172
146
if ( manualStackingKey ) {
173
147
const data = { ManualStackingKey : manualStackingKey } ;
174
148
this . setManualStackingInfo ( data , title ) ;
@@ -180,7 +154,6 @@ export class EventBuilder {
180
154
/**
181
155
* Sets the event value.
182
156
* @param value The value of the event.
183
- * @returns {EventBuilder }
184
157
*/
185
158
public setValue ( value : number ) : EventBuilder {
186
159
if ( value ) {
@@ -203,12 +176,7 @@ export class EventBuilder {
203
176
* @param maxDepth The max depth of the object to include.
204
177
* @param excludedPropertyNames Any property names that should be excluded.
205
178
*/
206
- public setProperty (
207
- name : string ,
208
- value : unknown ,
209
- maxDepth ?: number ,
210
- excludedPropertyNames ?: string [ ] ,
211
- ) : EventBuilder {
179
+ public setProperty ( name : string , value : unknown , maxDepth ?: number , excludedPropertyNames ?: string [ ] ) : EventBuilder {
212
180
if ( ! name || ( value === undefined || value == null ) ) {
213
181
return this ;
214
182
}
@@ -241,14 +209,14 @@ export class EventBuilder {
241
209
242
210
public addRequestInfo ( request : RequestInfo ) : EventBuilder {
243
211
if ( request ) {
244
- this . pluginContextData [ KnownEventDataKeys . RequestInfo ] = request ;
212
+ this . context [ KnownEventDataKeys . RequestInfo ] = request ;
245
213
}
246
214
247
215
return this ;
248
216
}
249
217
250
218
public submit ( ) : Promise < EventPluginContext > {
251
- return this . client . submitEvent ( this . target , this . pluginContextData ) ;
219
+ return this . client . submitEvent ( this . target , this . context ) ;
252
220
}
253
221
254
222
private isValidIdentifier ( value : string ) : boolean {
0 commit comments