MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / handleSetUserSessionId

Function handleSetUserSessionId

src/scripts/logging/loggerDecorator.ts:41–75  ·  view source on GitHub ↗
(parentSessionId?: string)

Source from the content-addressed store, hash-verified

39 }
40
41 protected handleSetUserSessionId(parentSessionId?: string): string {
42 let sessionId: string;
43
44 let existingId = this.sessionId.get();
45 let generatedId = this.generateSessionId();
46
47 if (existingId) {
48 // Have we already initialized a sessionId?
49 sessionId = existingId;
50 } else if (parentSessionId) {
51 // Is my parent telling me to set a sessionId?
52 sessionId = parentSessionId;
53 } else if (generatedId) {
54 // Do I know how to generate a sessionId?
55 sessionId = generatedId;
56 }
57
58 if (this.component && sessionId) {
59 this.component.handleSetUserSessionId(sessionId);
60 } else if (this.component && !sessionId) {
61 sessionId = this.component.handleSetUserSessionId();
62 } else if (!this.component && !sessionId) {
63 // In the case where the session has Ended, we default to there being no session id as it wouldn't
64 // make sense having one
65 sessionId = this.currentSessionState === Log.Session.State.Started ?
66 "cccccccc-" + StringUtils.generateGuid().substring(9) :
67 undefined;
68 }
69
70 this.sessionId.set(sessionId);
71 this.setContextPropertyPure(Log.Context.Custom.SessionId, sessionId);
72 this.outputSetContext(Log.Context.Custom.SessionId, sessionId);
73
74 return sessionId;
75 }
76
77 protected handleClickEvent(clickId: string): void {
78 this.outputClickEvent(clickId);

Callers

nothing calls this directly

Calls 4

setMethod · 0.80
getMethod · 0.45
outputSetContextMethod · 0.45

Tested by

no test coverage detected