11import { ExceptionlessClient } from "./ExceptionlessClient.js" ;
2- import {
3- Event ,
4- KnownEventDataKeys
5- } from "./models/Event.js" ;
2+ import { Event , KnownEventDataKeys } from "./models/Event.js" ;
63import { ManualStackingInfo } from "./models/data/ManualStackingInfo.js" ;
74import { RequestInfo } from "./models/data/RequestInfo.js" ;
85import { 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" ;
108import { EventPluginContext } from "./plugins/EventPluginContext.js" ;
11- import {
12- isEmpty ,
13- stringify
14- } from "./Utils.js" ;
159
1610export class EventBuilder {
1711 public target : Event ;
1812 public client : ExceptionlessClient ;
19- public pluginContextData : ContextData ;
13+ public context : EventContext ;
2014
2115 private _validIdentifierErrorMessage = "must contain between 8 and 100 alphanumeric or '-' characters." ;
2216
23- constructor (
24- event : Event ,
25- client : ExceptionlessClient ,
26- pluginContextData ?: ContextData ,
27- ) {
17+ constructor ( event : Event , client : ExceptionlessClient , context ?: EventContext ) {
2818 this . target = event ;
2919 this . client = client ;
30- this . pluginContextData = pluginContextData || new ContextData ( ) ;
20+ this . context = context || new EventContext ( ) ;
3121 }
3222
3323 public setType ( type : string ) : EventBuilder {
@@ -59,7 +49,6 @@ export class EventBuilder {
5949 * Allows you to reference a parent event by its ReferenceId property. This allows you to have parent and child relationships.
6050 * @param name Reference name
6151 * @param id The reference id that points to a specific event
62- * @returns {EventBuilder }
6352 */
6453 public setEventReference ( name : string , id : string ) : EventBuilder {
6554 if ( ! name ) {
@@ -100,10 +89,7 @@ export class EventBuilder {
10089 public setUserIdentity ( userInfo : UserInfo ) : EventBuilder ;
10190 public setUserIdentity ( identity : string ) : EventBuilder ;
10291 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 {
10793 const userInfo = typeof userInfoOrIdentity !== "string"
10894 ? userInfoOrIdentity
10995 : { identity : userInfoOrIdentity , name } ;
@@ -120,12 +106,8 @@ export class EventBuilder {
120106 *
121107 * @param emailAddress The email address
122108 * @param description The user"s description of the event.
123- * @returns {EventBuilder }
124109 */
125- public setUserDescription (
126- emailAddress : string ,
127- description : string ,
128- ) : EventBuilder {
110+ public setUserDescription ( emailAddress : string , description : string ) : EventBuilder {
129111 if ( emailAddress && description ) {
130112 this . setProperty ( KnownEventDataKeys . UserDescription , {
131113 email_address : emailAddress ,
@@ -141,12 +123,8 @@ export class EventBuilder {
141123 * stacking information.
142124 * @param signatureData A dictionary of strings to use for stacking.
143125 * @param title An optional title for the stacking information.
144- * @returns {EventBuilder }
145126 */
146- public setManualStackingInfo (
147- signatureData : Record < string , string > ,
148- title ?: string ,
149- ) : EventBuilder {
127+ public setManualStackingInfo ( signatureData : Record < string , string > , title ?: string ) : EventBuilder {
150128 if ( signatureData ) {
151129 const stack : ManualStackingInfo = { signature_data : signatureData } ;
152130 if ( title ) {
@@ -163,12 +141,8 @@ export class EventBuilder {
163141 * Changes default stacking behavior by setting the stacking key.
164142 * @param manualStackingKey The manual stacking key.
165143 * @param title An optional title for the stacking information.
166- * @returns {EventBuilder }
167144 */
168- public setManualStackingKey (
169- manualStackingKey : string ,
170- title ?: string ,
171- ) : EventBuilder {
145+ public setManualStackingKey ( manualStackingKey : string , title ?: string ) : EventBuilder {
172146 if ( manualStackingKey ) {
173147 const data = { ManualStackingKey : manualStackingKey } ;
174148 this . setManualStackingInfo ( data , title ) ;
@@ -180,7 +154,6 @@ export class EventBuilder {
180154 /**
181155 * Sets the event value.
182156 * @param value The value of the event.
183- * @returns {EventBuilder }
184157 */
185158 public setValue ( value : number ) : EventBuilder {
186159 if ( value ) {
@@ -203,12 +176,7 @@ export class EventBuilder {
203176 * @param maxDepth The max depth of the object to include.
204177 * @param excludedPropertyNames Any property names that should be excluded.
205178 */
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 {
212180 if ( ! name || ( value === undefined || value == null ) ) {
213181 return this ;
214182 }
@@ -241,14 +209,14 @@ export class EventBuilder {
241209
242210 public addRequestInfo ( request : RequestInfo ) : EventBuilder {
243211 if ( request ) {
244- this . pluginContextData [ KnownEventDataKeys . RequestInfo ] = request ;
212+ this . context [ KnownEventDataKeys . RequestInfo ] = request ;
245213 }
246214
247215 return this ;
248216 }
249217
250218 public submit ( ) : Promise < EventPluginContext > {
251- return this . client . submitEvent ( this . target , this . pluginContextData ) ;
219+ return this . client . submitEvent ( this . target , this . context ) ;
252220 }
253221
254222 private isValidIdentifier ( value : string ) : boolean {
0 commit comments