Skip to content

Commit 26dcc93

Browse files
committed
Added SetEventReference method
1 parent 110e3a2 commit 26dcc93

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/EventBuilder.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ export class EventBuilder {
4343
return this;
4444
}
4545

46+
/**
47+
* Allows you to reference a parent event by its ReferenceId property. This allows you to have parent and child relationships.
48+
* @param name Reference name
49+
* @param id The reference id that points to a specific event
50+
*/
51+
public setEventReference(name: string, id: string): EventBuilder {
52+
if (!name) {
53+
throw new Error('Invalid name');
54+
}
55+
56+
if (!id ||!this.isValidIdentifier(id)) {
57+
throw new Error(`Id ${this._validIdentifierErrorMessage}`);
58+
}
59+
60+
this.setProperty('@ref:' + name, id);
61+
return this;
62+
}
63+
4664
public setMessage(message: string): EventBuilder {
4765
if (!!message) {
4866
this.target.message = message;

src/ExceptionlessClient.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,28 @@ export class ExceptionlessClient {
9393
this.createNotFound(resource).submit(callback);
9494
}
9595

96-
public createSessionStart(userIdentity?:string, userDisplayName?:string): EventBuilder {
97-
return this.createEvent().setType('session').setUserIdentity(userIdentity, userDisplayName);
96+
public createSessionStart(): EventBuilder {
97+
return this.createEvent().setType('session');
9898
}
9999

100-
public submitSessionStart(userIdentity?:string, userDisplayName?:string, callback?: (context: EventPluginContext) => void): void {
101-
this.createSessionStart(userIdentity, userDisplayName).submit(callback);
100+
public submitSessionStart(callback?: (context: EventPluginContext) => void): void {
101+
this.createSessionStart().submit(callback);
102102
}
103103

104-
public createSessionEnd(userIdentity?:string, userDisplayName?:string): EventBuilder {
105-
return this.createEvent().setType('sessionend').setUserIdentity(userIdentity, userDisplayName);
104+
public createSessionEnd(): EventBuilder {
105+
return this.createEvent().setType('sessionend');
106106
}
107107

108-
public submitSessionEnd(userIdentity?:string, userDisplayName?:string, callback?: (context: EventPluginContext) => void): void {
109-
this.createSessionEnd(userIdentity, userDisplayName).submit(callback);
108+
public submitSessionEnd(callback?: (context: EventPluginContext) => void): void {
109+
this.createSessionEnd().submit(callback);
110110
}
111111

112-
public createSessionHeartbeat(userIdentity?:string, userDisplayName?:string): EventBuilder {
113-
return this.createEvent().setType('heartbeat').setUserIdentity(userIdentity, userDisplayName);
112+
public createSessionHeartbeat(): EventBuilder {
113+
return this.createEvent().setType('heartbeat');
114114
}
115115

116-
public submitSessionHeartbeat(userIdentity?:string, userDisplayName?:string, callback?: (context: EventPluginContext) => void): void {
117-
this.createSessionHeartbeat(userIdentity, userDisplayName).submit(callback);
116+
public submitSessionHeartbeat(callback?: (context: EventPluginContext) => void): void {
117+
this.createSessionHeartbeat().submit(callback);
118118
}
119119

120120
public createEvent(pluginContextData?: ContextData): EventBuilder {

0 commit comments

Comments
 (0)