@embrace-io/web-sdk
Version:
1 lines • 7.05 kB
Source Map (JSON)
{"version":3,"file":"ProxyUserSessionManager.cjs","names":["NoOpUserSessionManager"],"sources":["../../../../src/api-sessions/manager/ProxyUserSessionManager/ProxyUserSessionManager.ts"],"sourcesContent":["import type { TracerProvider } from '@opentelemetry/api';\nimport type { ExtendedSpan } from '../../../index.ts';\nimport type {\n EndSessionPartOptions,\n RolloverSessionPartOptions,\n StartSessionPartOptions,\n UserSessionAttributes,\n UserSessionManagerInternal,\n} from '../../../managers/EmbraceUserSessionManager/types.ts';\nimport type {\n PropertyOptions,\n ReasonSessionEnded,\n SessionPartStartedEvent,\n StartSessionOptions,\n} from '../index.ts';\nimport { NoOpUserSessionManager } from '../NoOpUserSessionManager/index.ts';\n\nconst NOOP_USER_SESSION_MANAGER = new NoOpUserSessionManager();\n\nexport class ProxyUserSessionManager implements UserSessionManagerInternal {\n private _delegate?: UserSessionManagerInternal;\n\n public getDelegate(): UserSessionManagerInternal {\n return this._delegate ?? NOOP_USER_SESSION_MANAGER;\n }\n\n public setDelegate(delegate: UserSessionManagerInternal): void {\n this._delegate = delegate;\n }\n\n public addBreadcrumb(name: string): void {\n this.getDelegate().addBreadcrumb(name);\n }\n\n public addProperty(\n key: string,\n value: string,\n options?: PropertyOptions,\n ): void {\n this.getDelegate().addProperty(key, value, options);\n }\n\n public removeProperty(key: string): void {\n this.getDelegate().removeProperty(key);\n }\n\n public endSessionSpan() {\n this.getDelegate().endSessionSpan();\n }\n\n /** @deprecated Will be removed in a future major version, always returns null. */\n public currentSessionAsReadableSpan(reason: ReasonSessionEnded): null {\n return this.getDelegate().currentSessionAsReadableSpan(reason);\n }\n\n /** @deprecated Will be removed in a future version, use getUserSessionId(); returns null when no user session is active. */\n public getSessionId(): string | null {\n return this.getDelegate().getSessionId();\n }\n\n /** @deprecated Will be removed in a future version, always returns null. Use getPreviousUserSessionId(). */\n public getPreviousSessionId(): null {\n return null;\n }\n\n /** @deprecated Will be removed in a future version, use getSessionPartSpan(); returns null when no part is active. */\n public getSessionSpan() {\n return this.getDelegate().getSessionSpan();\n }\n\n /** @deprecated Will be removed in a future version, use getUserSessionStartTime(); returns null when no user session is active. */\n public getSessionStartTime(): number | null {\n return this.getDelegate().getSessionStartTime();\n }\n\n /** @deprecated Will be removed in a future version, no-op. */\n public startSessionSpan(_options?: StartSessionOptions) {}\n\n /** @deprecated Will be removed in a future version, the returned unsubscribe is a no-op. */\n public addSessionStartedListener(_listener: () => void): () => void {\n return () => {};\n }\n\n /** @deprecated Will be removed in a future version, the returned unsubscribe is a no-op. */\n public addSessionEndedListener(_listener: () => void): () => void {\n return () => {};\n }\n\n public getUserSessionId(): string | null {\n return this.getDelegate().getUserSessionId();\n }\n\n public getPreviousUserSessionId(): string | null {\n return this.getDelegate().getPreviousUserSessionId();\n }\n\n public getUserSessionStartTime(): number | null {\n return this.getDelegate().getUserSessionStartTime();\n }\n\n public endUserSession(): void {\n this.getDelegate().endUserSession();\n }\n\n public getUserSessionAttributes(): UserSessionAttributes | null {\n return this.getDelegate().getUserSessionAttributes();\n }\n\n public getSessionPartProperties(): Record<string, string> {\n return this.getDelegate().getSessionPartProperties();\n }\n\n public getSessionPartId(): string | null {\n return this.getDelegate().getSessionPartId();\n }\n\n public getSessionPartSpan(): ExtendedSpan | null {\n return this.getDelegate().getSessionPartSpan();\n }\n\n public startSessionPartInternal(options: StartSessionPartOptions): void {\n this.getDelegate().startSessionPartInternal(options);\n }\n\n public endSessionPartInternal(options: EndSessionPartOptions): void {\n this.getDelegate().endSessionPartInternal(options);\n }\n\n public rolloverSessionPartInternal(\n options: RolloverSessionPartOptions,\n ): void {\n this.getDelegate().rolloverSessionPartInternal(options);\n }\n\n public incrSessionPartCountForKey(key: string): void {\n this.getDelegate().incrSessionPartCountForKey(key);\n }\n\n public incrNextSessionPartCountForKey(key: string): void {\n this.getDelegate().incrNextSessionPartCountForKey(key);\n }\n\n public addSessionPartStartedListener(\n listener: (event: SessionPartStartedEvent) => void,\n ): () => void {\n return this.getDelegate().addSessionPartStartedListener(listener);\n }\n\n public addSessionPartEndedListener(listener: () => void): () => void {\n return this.getDelegate().addSessionPartEndedListener(listener);\n }\n\n public setTracerProvider(tracerProvider: TracerProvider): void {\n this.getDelegate().setTracerProvider(tracerProvider);\n }\n}\n"],"mappings":";;AAiBA,MAAM,4BAA4B,mEAAIA,EAAAA,CAAAA,uBAAuB;AAE7D,IAAa,0BAAb,MAA2E;CACzE;CAEA,cAAiD;EAC/C,OAAO,KAAK,aAAa;CAC3B;CAEA,YAAmB,UAA4C;EAC7D,KAAK,YAAY;CACnB;CAEA,cAAqB,MAAoB;EACvC,KAAK,YAAY,CAAC,CAAC,cAAc,IAAI;CACvC;CAEA,YACE,KACA,OACA,SACM;EACN,KAAK,YAAY,CAAC,CAAC,YAAY,KAAK,OAAO,OAAO;CACpD;CAEA,eAAsB,KAAmB;EACvC,KAAK,YAAY,CAAC,CAAC,eAAe,GAAG;CACvC;CAEA,iBAAwB;EACtB,KAAK,YAAY,CAAC,CAAC,eAAe;CACpC;;CAGA,6BAAoC,QAAkC;EACpE,OAAO,KAAK,YAAY,CAAC,CAAC,6BAA6B,MAAM;CAC/D;;CAGA,eAAqC;EACnC,OAAO,KAAK,YAAY,CAAC,CAAC,aAAa;CACzC;;CAGA,uBAAoC;EAClC,OAAO;CACT;;CAGA,iBAAwB;EACtB,OAAO,KAAK,YAAY,CAAC,CAAC,eAAe;CAC3C;;CAGA,sBAA4C;EAC1C,OAAO,KAAK,YAAY,CAAC,CAAC,oBAAoB;CAChD;;CAGA,iBAAwB,UAAgC,CAAC;;CAGzD,0BAAiC,WAAmC;EAClE,aAAa,CAAC;CAChB;;CAGA,wBAA+B,WAAmC;EAChE,aAAa,CAAC;CAChB;CAEA,mBAAyC;EACvC,OAAO,KAAK,YAAY,CAAC,CAAC,iBAAiB;CAC7C;CAEA,2BAAiD;EAC/C,OAAO,KAAK,YAAY,CAAC,CAAC,yBAAyB;CACrD;CAEA,0BAAgD;EAC9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