1- import { ExceptionlessClient } from ' ./ExceptionlessClient.js' ;
2- import { IEvent } from ' ./models/IEvent .js' ;
3- import { IManualStackingInfo } from ' ./models/IManualStackingInfo .js' ;
4- import { IRequestInfo } from "./models/IRequestInfo .js" ;
5- import { IUserInfo } from ' ./models/IUserInfo .js' ;
6- import { ContextData } from ' ./plugins/ContextData.js' ;
7- import { EventPluginContext } from ' ./plugins/EventPluginContext.js' ;
8- import { addRange , stringify , isEmpty } from "./Utils.js" ;
1+ import { ExceptionlessClient } from " ./ExceptionlessClient.js" ;
2+ import { Event } from " ./models/Event .js" ;
3+ import { ManualStackingInfo } from " ./models/data/ManualStackingInfo .js" ;
4+ import { RequestInfo } from "./models/data/RequestInfo .js" ;
5+ import { UserInfo } from " ./models/data/UserInfo .js" ;
6+ import { ContextData } from " ./plugins/ContextData.js" ;
7+ import { EventPluginContext } from " ./plugins/EventPluginContext.js" ;
8+ import { addRange , isEmpty , stringify } from "./Utils.js" ;
99
1010export class EventBuilder {
11- public target : IEvent ;
11+ public target : Event ;
1212 public client : ExceptionlessClient ;
1313 public pluginContextData : ContextData ;
1414
15- private _validIdentifierErrorMessage : string = 'must contain between 8 and 100 alphanumeric or \'-\' characters.' ; // optimization for minifier.
15+ private _validIdentifierErrorMessage : string =
16+ "must contain between 8 and 100 alphanumeric or '-' characters." ; // optimization for minifier.
1617
17- constructor ( event : IEvent , client : ExceptionlessClient , pluginContextData ?: ContextData ) {
18+ constructor (
19+ event : Event ,
20+ client : ExceptionlessClient ,
21+ pluginContextData ?: ContextData ,
22+ ) {
1823 this . target = event ;
1924 this . client = client ;
2025 this . pluginContextData = pluginContextData || new ContextData ( ) ;
@@ -53,14 +58,14 @@ export class EventBuilder {
5358 */
5459 public setEventReference ( name : string , id : string ) : EventBuilder {
5560 if ( ! name ) {
56- throw new Error ( ' Invalid name' ) ;
61+ throw new Error ( " Invalid name" ) ;
5762 }
5863
5964 if ( ! id || ! this . isValidIdentifier ( id ) ) {
6065 throw new Error ( `Id ${ this . _validIdentifierErrorMessage } ` ) ;
6166 }
6267
63- this . setProperty ( ' @ref:' + name , id ) ;
68+ this . setProperty ( " @ref:" + name , id ) ;
6469 return this ;
6570 }
6671
@@ -74,27 +79,34 @@ export class EventBuilder {
7479
7580 public setGeo ( latitude : number , longitude : number ) : EventBuilder {
7681 if ( latitude < - 90.0 || latitude > 90.0 ) {
77- throw new Error ( ' Must be a valid latitude value between -90.0 and 90.0.' ) ;
82+ throw new Error ( " Must be a valid latitude value between -90.0 and 90.0." ) ;
7883 }
7984
8085 if ( longitude < - 180.0 || longitude > 180.0 ) {
81- throw new Error ( 'Must be a valid longitude value between -180.0 and 180.0.' ) ;
86+ throw new Error (
87+ "Must be a valid longitude value between -180.0 and 180.0." ,
88+ ) ;
8289 }
8390
8491 this . target . geo = `${ latitude } ,${ longitude } ` ;
8592 return this ;
8693 }
8794
88- public setUserIdentity ( userInfo : IUserInfo ) : EventBuilder ;
95+ public setUserIdentity ( userInfo : UserInfo ) : EventBuilder ;
8996 public setUserIdentity ( identity : string ) : EventBuilder ;
9097 public setUserIdentity ( identity : string , name : string ) : EventBuilder ;
91- public setUserIdentity ( userInfoOrIdentity : IUserInfo | string , name ?: string ) : EventBuilder {
92- const userInfo = typeof userInfoOrIdentity !== 'string' ? userInfoOrIdentity : { identity : userInfoOrIdentity , name } ;
98+ public setUserIdentity (
99+ userInfoOrIdentity : UserInfo | string ,
100+ name ?: string ,
101+ ) : EventBuilder {
102+ const userInfo = typeof userInfoOrIdentity !== "string"
103+ ? userInfoOrIdentity
104+ : { identity : userInfoOrIdentity , name } ;
93105 if ( ! userInfo || ( ! userInfo . identity && ! userInfo . name ) ) {
94106 return this ;
95107 }
96108
97- this . setProperty ( ' @user' , userInfo ) ;
109+ this . setProperty ( " @user" , userInfo ) ;
98110 return this ;
99111 }
100112
@@ -105,9 +117,15 @@ export class EventBuilder {
105117 * @param description The user's description of the event.
106118 * @returns {EventBuilder }
107119 */
108- public setUserDescription ( emailAddress : string , description : string ) : EventBuilder {
120+ public setUserDescription (
121+ emailAddress : string ,
122+ description : string ,
123+ ) : EventBuilder {
109124 if ( emailAddress && description ) {
110- this . setProperty ( '@user_description' , { email_address : emailAddress , description } ) ;
125+ this . setProperty ( "@user_description" , {
126+ email_address : emailAddress ,
127+ description,
128+ } ) ;
111129 }
112130
113131 return this ;
@@ -120,14 +138,17 @@ export class EventBuilder {
120138 * @param title An optional title for the stacking information.
121139 * @returns {EventBuilder }
122140 */
123- public setManualStackingInfo ( signatureData : any , title ?: string ) : EventBuilder {
141+ public setManualStackingInfo (
142+ signatureData : any ,
143+ title ?: string ,
144+ ) : EventBuilder {
124145 if ( signatureData ) {
125- const stack : IManualStackingInfo = { signature_data : signatureData } ;
146+ const stack : ManualStackingInfo = { signature_data : signatureData } ;
126147 if ( title ) {
127148 stack . title = title ;
128149 }
129150
130- this . setProperty ( ' @stack' , stack ) ;
151+ this . setProperty ( " @stack" , stack ) ;
131152 }
132153
133154 return this ;
@@ -139,7 +160,10 @@ export class EventBuilder {
139160 * @param title An optional title for the stacking information.
140161 * @returns {EventBuilder }
141162 */
142- public setManualStackingKey ( manualStackingKey : string , title ?: string ) : EventBuilder {
163+ public setManualStackingKey (
164+ manualStackingKey : string ,
165+ title ?: string ,
166+ ) : EventBuilder {
143167 if ( manualStackingKey ) {
144168 const data = { ManualStackingKey : manualStackingKey } ;
145169 this . setManualStackingInfo ( data , title ) ;
@@ -174,7 +198,12 @@ export class EventBuilder {
174198 * @param maxDepth The max depth of the object to include.
175199 * @param excludedPropertyNames Any property names that should be excluded.
176200 */
177- public setProperty ( name : string , value : any , maxDepth ?: number , excludedPropertyNames ?: string [ ] ) : EventBuilder {
201+ public setProperty (
202+ name : string ,
203+ value : any ,
204+ maxDepth ?: number ,
205+ excludedPropertyNames ?: string [ ] ,
206+ ) : EventBuilder {
178207 if ( ! name || ( value === undefined || value == null ) ) {
179208 return this ;
180209 }
@@ -183,7 +212,13 @@ export class EventBuilder {
183212 this . target . data = { } ;
184213 }
185214
186- const result = JSON . parse ( stringify ( value , this . client . config . dataExclusions . concat ( excludedPropertyNames || [ ] ) , maxDepth ) ) ;
215+ const result = JSON . parse (
216+ stringify (
217+ value ,
218+ this . client . config . dataExclusions . concat ( excludedPropertyNames || [ ] ) ,
219+ maxDepth ,
220+ ) ,
221+ ) ;
187222 if ( ! isEmpty ( result ) ) {
188223 this . target . data [ name ] = result ;
189224 }
@@ -193,15 +228,15 @@ export class EventBuilder {
193228
194229 public markAsCritical ( critical : boolean ) : EventBuilder {
195230 if ( critical ) {
196- this . addTags ( ' Critical' ) ;
231+ this . addTags ( " Critical" ) ;
197232 }
198233
199234 return this ;
200235 }
201236
202- public addRequestInfo ( request : IRequestInfo ) : EventBuilder {
237+ public addRequestInfo ( request : RequestInfo ) : EventBuilder {
203238 if ( request ) {
204- this . pluginContextData [ ' @request' ] = request ;
239+ this . pluginContextData [ " @request" ] = request ;
205240 }
206241
207242 return this ;
@@ -223,7 +258,8 @@ export class EventBuilder {
223258 for ( let index = 0 ; index < value . length ; index ++ ) {
224259 const code = value . charCodeAt ( index ) ;
225260 const isDigit = ( code >= 48 ) && ( code <= 57 ) ;
226- const isLetter = ( ( code >= 65 ) && ( code <= 90 ) ) || ( ( code >= 97 ) && ( code <= 122 ) ) ;
261+ const isLetter = ( ( code >= 65 ) && ( code <= 90 ) ) ||
262+ ( ( code >= 97 ) && ( code <= 122 ) ) ;
227263 const isMinus = code === 45 ;
228264
229265 if ( ! ( isDigit || isLetter ) && ! isMinus ) {
0 commit comments