@opentelemetry/web-common 0.206.0 → 0.207.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -0
- package/build/esm/DefaultIdGenerator.d.ts +5 -0
- package/build/esm/DefaultIdGenerator.js +32 -0
- package/build/esm/DefaultIdGenerator.js.map +1 -0
- package/build/esm/LocalStorageSessionStore.d.ts +7 -0
- package/build/esm/LocalStorageSessionStore.js +36 -0
- package/build/esm/LocalStorageSessionStore.js.map +1 -0
- package/build/esm/SessionManager.d.ts +45 -0
- package/build/esm/SessionManager.js +131 -0
- package/build/esm/SessionManager.js.map +1 -0
- package/build/esm/index.d.ts +6 -1
- package/build/esm/index.js +1 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/types/Session.d.ts +5 -0
- package/build/esm/types/Session.js +17 -0
- package/build/esm/types/Session.js.map +1 -0
- package/build/esm/types/SessionIdGenerator.d.ts +4 -0
- package/build/esm/types/SessionIdGenerator.js +17 -0
- package/build/esm/types/SessionIdGenerator.js.map +1 -0
- package/build/esm/types/SessionObserver.d.ts +6 -0
- package/build/esm/types/SessionObserver.js +17 -0
- package/build/esm/types/SessionObserver.js.map +1 -0
- package/build/esm/types/SessionPublisher.d.ts +5 -0
- package/build/esm/types/SessionPublisher.js +17 -0
- package/build/esm/types/SessionPublisher.js.map +1 -0
- package/build/esm/types/SessionStore.d.ts +6 -0
- package/build/esm/types/SessionStore.js +17 -0
- package/build/esm/types/SessionStore.js.map +1 -0
- package/build/esm/utils.d.ts +6 -0
- package/build/esm/utils.js +13 -0
- package/build/esm/utils.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/DefaultIdGenerator.d.ts +5 -0
- package/build/esnext/DefaultIdGenerator.js +32 -0
- package/build/esnext/DefaultIdGenerator.js.map +1 -0
- package/build/esnext/LocalStorageSessionStore.d.ts +7 -0
- package/build/esnext/LocalStorageSessionStore.js +36 -0
- package/build/esnext/LocalStorageSessionStore.js.map +1 -0
- package/build/esnext/SessionManager.d.ts +45 -0
- package/build/esnext/SessionManager.js +131 -0
- package/build/esnext/SessionManager.js.map +1 -0
- package/build/esnext/index.d.ts +6 -1
- package/build/esnext/index.js +1 -1
- package/build/esnext/index.js.map +1 -1
- package/build/esnext/types/Session.d.ts +5 -0
- package/build/esnext/types/Session.js +17 -0
- package/build/esnext/types/Session.js.map +1 -0
- package/build/esnext/types/SessionIdGenerator.d.ts +4 -0
- package/build/esnext/types/SessionIdGenerator.js +17 -0
- package/build/esnext/types/SessionIdGenerator.js.map +1 -0
- package/build/esnext/types/SessionObserver.d.ts +6 -0
- package/build/esnext/types/SessionObserver.js +17 -0
- package/build/esnext/types/SessionObserver.js.map +1 -0
- package/build/esnext/types/SessionPublisher.d.ts +5 -0
- package/build/esnext/types/SessionPublisher.js +17 -0
- package/build/esnext/types/SessionPublisher.js.map +1 -0
- package/build/esnext/types/SessionStore.d.ts +6 -0
- package/build/esnext/types/SessionStore.js +17 -0
- package/build/esnext/types/SessionStore.js.map +1 -0
- package/build/esnext/utils.d.ts +6 -0
- package/build/esnext/utils.js +13 -0
- package/build/esnext/utils.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/DefaultIdGenerator.d.ts +5 -0
- package/build/src/DefaultIdGenerator.js +36 -0
- package/build/src/DefaultIdGenerator.js.map +1 -0
- package/build/src/LocalStorageSessionStore.d.ts +7 -0
- package/build/src/LocalStorageSessionStore.js +40 -0
- package/build/src/LocalStorageSessionStore.js.map +1 -0
- package/build/src/SessionManager.d.ts +45 -0
- package/build/src/SessionManager.js +135 -0
- package/build/src/SessionManager.js.map +1 -0
- package/build/src/index.d.ts +6 -1
- package/build/src/index.js +4 -1
- package/build/src/index.js.map +1 -1
- package/build/src/types/Session.d.ts +5 -0
- package/build/src/types/Session.js +18 -0
- package/build/src/types/Session.js.map +1 -0
- package/build/src/types/SessionIdGenerator.d.ts +4 -0
- package/build/src/types/SessionIdGenerator.js +18 -0
- package/build/src/types/SessionIdGenerator.js.map +1 -0
- package/build/src/types/SessionObserver.d.ts +6 -0
- package/build/src/types/SessionObserver.js +18 -0
- package/build/src/types/SessionObserver.js.map +1 -0
- package/build/src/types/SessionPublisher.d.ts +5 -0
- package/build/src/types/SessionPublisher.js +18 -0
- package/build/src/types/SessionPublisher.js.map +1 -0
- package/build/src/types/SessionStore.d.ts +6 -0
- package/build/src/types/SessionStore.js +18 -0
- package/build/src/types/SessionStore.js.map +1 -0
- package/build/src/utils.d.ts +6 -0
- package/build/src/utils.js +17 -1
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +7 -9
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Session } from './types/Session';
|
|
2
|
+
import { SessionStore } from './types/SessionStore';
|
|
3
|
+
export declare class LocalStorageSessionStore implements SessionStore {
|
|
4
|
+
save(session: Session): Promise<void>;
|
|
5
|
+
get(): Promise<Session | null>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=LocalStorageSessionStore.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.LocalStorageSessionStore = void 0;
|
|
19
|
+
const SESSION_STORAGE_KEY = 'opentelemetry-session';
|
|
20
|
+
class LocalStorageSessionStore {
|
|
21
|
+
save(session) {
|
|
22
|
+
if (typeof localStorage === 'undefined') {
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
localStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(session));
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
}
|
|
28
|
+
get() {
|
|
29
|
+
if (typeof localStorage === 'undefined') {
|
|
30
|
+
return Promise.resolve(null);
|
|
31
|
+
}
|
|
32
|
+
const sessionData = localStorage.getItem(SESSION_STORAGE_KEY);
|
|
33
|
+
if (sessionData) {
|
|
34
|
+
return Promise.resolve(JSON.parse(sessionData));
|
|
35
|
+
}
|
|
36
|
+
return Promise.resolve(null);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.LocalStorageSessionStore = LocalStorageSessionStore;
|
|
40
|
+
//# sourceMappingURL=LocalStorageSessionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalStorageSessionStore.js","sourceRoot":"","sources":["../../src/LocalStorageSessionStore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAKH,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAEpD,MAAa,wBAAwB;IACnC,IAAI,CAAC,OAAgB;QACnB,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;YACvC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,YAAY,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAEnE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,GAAG;QACD,IAAI,OAAO,YAAY,KAAK,WAAW,EAAE;YACvC,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC9B;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QAC9D,IAAI,WAAW,EAAE;YACf,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAY,CAAC,CAAC;SAC5D;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAtBD,4DAsBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Session } from './types/Session';\nimport { SessionStore } from './types/SessionStore';\n\nconst SESSION_STORAGE_KEY = 'opentelemetry-session';\n\nexport class LocalStorageSessionStore implements SessionStore {\n save(session: Session): Promise<void> {\n if (typeof localStorage === 'undefined') {\n return Promise.resolve();\n }\n\n localStorage.setItem(SESSION_STORAGE_KEY, JSON.stringify(session));\n\n return Promise.resolve();\n }\n\n get(): Promise<Session | null> {\n if (typeof localStorage === 'undefined') {\n return Promise.resolve(null);\n }\n\n const sessionData = localStorage.getItem(SESSION_STORAGE_KEY);\n if (sessionData) {\n return Promise.resolve(JSON.parse(sessionData) as Session);\n }\n return Promise.resolve(null);\n }\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SessionIdGenerator } from './types/SessionIdGenerator';
|
|
2
|
+
import { Session } from './types/Session';
|
|
3
|
+
import { SessionProvider } from './types/SessionProvider';
|
|
4
|
+
import { SessionObserver } from './types/SessionObserver';
|
|
5
|
+
import { SessionStore } from './types/SessionStore';
|
|
6
|
+
import { SessionPublisher } from './types/SessionPublisher';
|
|
7
|
+
export interface SessionManagerConfig {
|
|
8
|
+
/** Class responsible for generating a session ID */
|
|
9
|
+
sessionIdGenerator: SessionIdGenerator;
|
|
10
|
+
/** Class responsible for storing session data over multiple page loads. */
|
|
11
|
+
sessionStore: SessionStore;
|
|
12
|
+
/** Maximum duration of a session in seconds */
|
|
13
|
+
maxDuration?: number;
|
|
14
|
+
/** Maximum time without a user activity after which a session should be expired, in seconds */
|
|
15
|
+
inactivityTimeout?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* SessionManager is responsible for managing the active session including starting,
|
|
19
|
+
* resetting, and persisting.
|
|
20
|
+
*/
|
|
21
|
+
export declare class SessionManager implements SessionProvider, SessionPublisher {
|
|
22
|
+
private _session;
|
|
23
|
+
private _idGenerator;
|
|
24
|
+
private _store;
|
|
25
|
+
private _observers;
|
|
26
|
+
private _maxDuration?;
|
|
27
|
+
private _maxDurationTimeoutId?;
|
|
28
|
+
private _inactivityTimeout?;
|
|
29
|
+
private _inactivityTimeoutId?;
|
|
30
|
+
private _lastActivityTimestamp;
|
|
31
|
+
private _inactivityResetDelay;
|
|
32
|
+
constructor(config: SessionManagerConfig);
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
addObserver(observer: SessionObserver): void;
|
|
35
|
+
getSessionId(): string | null;
|
|
36
|
+
getSession(): Session;
|
|
37
|
+
shutdown(): void;
|
|
38
|
+
private startSession;
|
|
39
|
+
private endSession;
|
|
40
|
+
private resetSession;
|
|
41
|
+
private resetTimers;
|
|
42
|
+
private resetInactivityTimer;
|
|
43
|
+
private resetMaxDurationTimer;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=SessionManager.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SessionManager = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* SessionManager is responsible for managing the active session including starting,
|
|
21
|
+
* resetting, and persisting.
|
|
22
|
+
*/
|
|
23
|
+
class SessionManager {
|
|
24
|
+
_session;
|
|
25
|
+
_idGenerator;
|
|
26
|
+
_store;
|
|
27
|
+
_observers;
|
|
28
|
+
_maxDuration;
|
|
29
|
+
_maxDurationTimeoutId;
|
|
30
|
+
_inactivityTimeout;
|
|
31
|
+
_inactivityTimeoutId;
|
|
32
|
+
_lastActivityTimestamp = 0;
|
|
33
|
+
_inactivityResetDelay = 5000; // minimum time in ms between activities before timer is reset
|
|
34
|
+
constructor(config) {
|
|
35
|
+
this._idGenerator = config.sessionIdGenerator;
|
|
36
|
+
this._store = config.sessionStore;
|
|
37
|
+
this._maxDuration = config.maxDuration;
|
|
38
|
+
this._inactivityTimeout = config.inactivityTimeout;
|
|
39
|
+
this._observers = [];
|
|
40
|
+
}
|
|
41
|
+
async start() {
|
|
42
|
+
this._session = await this._store.get();
|
|
43
|
+
if (!this._session) {
|
|
44
|
+
this._session = await this.startSession();
|
|
45
|
+
}
|
|
46
|
+
this.resetTimers();
|
|
47
|
+
}
|
|
48
|
+
addObserver(observer) {
|
|
49
|
+
this._observers.push(observer);
|
|
50
|
+
}
|
|
51
|
+
getSessionId() {
|
|
52
|
+
return this.getSession().id;
|
|
53
|
+
}
|
|
54
|
+
getSession() {
|
|
55
|
+
if (!this._session) {
|
|
56
|
+
this._session = this.startSession();
|
|
57
|
+
this.resetTimers();
|
|
58
|
+
}
|
|
59
|
+
if (this._inactivityTimeout) {
|
|
60
|
+
if (Date.now() - this._lastActivityTimestamp >
|
|
61
|
+
this._inactivityResetDelay) {
|
|
62
|
+
this.resetInactivityTimer();
|
|
63
|
+
this._lastActivityTimestamp = Date.now();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return this._session;
|
|
67
|
+
}
|
|
68
|
+
shutdown() {
|
|
69
|
+
if (this._inactivityTimeoutId) {
|
|
70
|
+
clearTimeout(this._inactivityTimeoutId);
|
|
71
|
+
}
|
|
72
|
+
if (this._maxDurationTimeoutId) {
|
|
73
|
+
clearTimeout(this._maxDurationTimeoutId);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
startSession() {
|
|
77
|
+
const sessionId = this._idGenerator.generateSessionId();
|
|
78
|
+
const session = {
|
|
79
|
+
id: sessionId,
|
|
80
|
+
startTimestamp: Date.now(),
|
|
81
|
+
};
|
|
82
|
+
// this is async call, but we don't wait for it
|
|
83
|
+
void this._store.save(session);
|
|
84
|
+
for (const observer of this._observers) {
|
|
85
|
+
observer.onSessionStarted(session, this._session ?? undefined);
|
|
86
|
+
}
|
|
87
|
+
this._session = session;
|
|
88
|
+
return session;
|
|
89
|
+
}
|
|
90
|
+
endSession() {
|
|
91
|
+
if (this._session) {
|
|
92
|
+
for (const observer of this._observers) {
|
|
93
|
+
observer.onSessionEnded(this._session);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (this._inactivityTimeoutId) {
|
|
97
|
+
clearTimeout(this._inactivityTimeoutId);
|
|
98
|
+
this._inactivityTimeoutId = undefined;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
resetSession() {
|
|
102
|
+
this.endSession();
|
|
103
|
+
this.startSession();
|
|
104
|
+
this.resetTimers();
|
|
105
|
+
}
|
|
106
|
+
resetTimers() {
|
|
107
|
+
this.resetInactivityTimer();
|
|
108
|
+
this.resetMaxDurationTimer();
|
|
109
|
+
}
|
|
110
|
+
resetInactivityTimer() {
|
|
111
|
+
if (!this._inactivityTimeout) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (this._inactivityTimeoutId) {
|
|
115
|
+
clearTimeout(this._inactivityTimeoutId);
|
|
116
|
+
}
|
|
117
|
+
this._inactivityTimeoutId = setTimeout(() => {
|
|
118
|
+
this.resetSession();
|
|
119
|
+
}, this._inactivityTimeout * 1000);
|
|
120
|
+
}
|
|
121
|
+
resetMaxDurationTimer() {
|
|
122
|
+
if (!this._maxDuration || !this._session) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (this._maxDurationTimeoutId) {
|
|
126
|
+
clearTimeout(this._maxDurationTimeoutId);
|
|
127
|
+
}
|
|
128
|
+
const timeoutIn = this._maxDuration * 1000 - (Date.now() - this._session?.startTimestamp);
|
|
129
|
+
this._maxDurationTimeoutId = setTimeout(() => {
|
|
130
|
+
this.resetSession();
|
|
131
|
+
}, timeoutIn);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.SessionManager = SessionManager;
|
|
135
|
+
//# sourceMappingURL=SessionManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionManager.js","sourceRoot":"","sources":["../../src/SessionManager.ts"],"names":[],"mappings":"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","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionIdGenerator } from './types/SessionIdGenerator';\nimport { Session } from './types/Session';\nimport { SessionProvider } from './types/SessionProvider';\nimport { SessionObserver } from './types/SessionObserver';\nimport { SessionStore } from './types/SessionStore';\nimport { SessionPublisher } from './types/SessionPublisher';\n\nexport interface SessionManagerConfig {\n /** Class responsible for generating a session ID */\n sessionIdGenerator: SessionIdGenerator;\n /** Class responsible for storing session data over multiple page loads. */\n sessionStore: SessionStore;\n /** Maximum duration of a session in seconds */\n maxDuration?: number;\n /** Maximum time without a user activity after which a session should be expired, in seconds */\n inactivityTimeout?: number;\n}\n\n/**\n * SessionManager is responsible for managing the active session including starting,\n * resetting, and persisting.\n */\nexport class SessionManager implements SessionProvider, SessionPublisher {\n private _session: Session | null | undefined;\n private _idGenerator: SessionIdGenerator;\n private _store: SessionStore;\n private _observers: SessionObserver[];\n\n private _maxDuration?: number;\n private _maxDurationTimeoutId?: ReturnType<typeof setTimeout>;\n\n private _inactivityTimeout?: number;\n private _inactivityTimeoutId?: ReturnType<typeof setTimeout>;\n private _lastActivityTimestamp: number = 0;\n private _inactivityResetDelay: number = 5000; // minimum time in ms between activities before timer is reset\n\n constructor(config: SessionManagerConfig) {\n this._idGenerator = config.sessionIdGenerator;\n this._store = config.sessionStore;\n this._maxDuration = config.maxDuration;\n this._inactivityTimeout = config.inactivityTimeout;\n this._observers = [];\n }\n\n async start(): Promise<void> {\n this._session = await this._store.get();\n if (!this._session) {\n this._session = await this.startSession();\n }\n this.resetTimers();\n }\n\n addObserver(observer: SessionObserver): void {\n this._observers.push(observer);\n }\n\n getSessionId(): string | null {\n return this.getSession().id;\n }\n\n getSession(): Session {\n if (!this._session) {\n this._session = this.startSession();\n this.resetTimers();\n }\n\n if (this._inactivityTimeout) {\n if (\n Date.now() - this._lastActivityTimestamp >\n this._inactivityResetDelay\n ) {\n this.resetInactivityTimer();\n this._lastActivityTimestamp = Date.now();\n }\n }\n\n return this._session;\n }\n\n shutdown(): void {\n if (this._inactivityTimeoutId) {\n clearTimeout(this._inactivityTimeoutId);\n }\n\n if (this._maxDurationTimeoutId) {\n clearTimeout(this._maxDurationTimeoutId);\n }\n }\n\n private startSession(): Session {\n const sessionId = this._idGenerator.generateSessionId();\n\n const session: Session = {\n id: sessionId,\n startTimestamp: Date.now(),\n };\n\n // this is async call, but we don't wait for it\n void this._store.save(session);\n\n for (const observer of this._observers) {\n observer.onSessionStarted(session, this._session ?? undefined);\n }\n\n this._session = session;\n\n return session;\n }\n\n private endSession(): void {\n if (this._session) {\n for (const observer of this._observers) {\n observer.onSessionEnded(this._session);\n }\n }\n\n if (this._inactivityTimeoutId) {\n clearTimeout(this._inactivityTimeoutId);\n this._inactivityTimeoutId = undefined;\n }\n }\n\n private resetSession(): void {\n this.endSession();\n this.startSession();\n this.resetTimers();\n }\n\n private resetTimers() {\n this.resetInactivityTimer();\n this.resetMaxDurationTimer();\n }\n\n private resetInactivityTimer() {\n if (!this._inactivityTimeout) {\n return;\n }\n\n if (this._inactivityTimeoutId) {\n clearTimeout(this._inactivityTimeoutId);\n }\n\n this._inactivityTimeoutId = setTimeout(() => {\n this.resetSession();\n }, this._inactivityTimeout * 1000);\n }\n\n private resetMaxDurationTimer() {\n if (!this._maxDuration || !this._session) {\n return;\n }\n\n if (this._maxDurationTimeoutId) {\n clearTimeout(this._maxDurationTimeoutId);\n }\n\n const timeoutIn =\n this._maxDuration * 1000 - (Date.now() - this._session?.startTimestamp);\n\n this._maxDurationTimeoutId = setTimeout(() => {\n this.resetSession();\n }, timeoutIn);\n }\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export type { SessionProvider } from './types/SessionProvider';
|
|
2
|
-
export { createSessionSpanProcessor, createSessionLogRecordProcessor, } from './utils';
|
|
2
|
+
export { createSessionSpanProcessor, createSessionLogRecordProcessor, createSessionManager, createDefaultSessionIdGenerator, createLocalStorageSessionStore, } from './utils';
|
|
3
|
+
export type { Session } from './types/Session';
|
|
4
|
+
export type { SessionIdGenerator } from './types/SessionIdGenerator';
|
|
5
|
+
export type { SessionPublisher } from './types/SessionPublisher';
|
|
6
|
+
export type { SessionObserver } from './types/SessionObserver';
|
|
7
|
+
export type { SessionStore } from './types/SessionStore';
|
|
3
8
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.createSessionLogRecordProcessor = exports.createSessionSpanProcessor = void 0;
|
|
18
|
+
exports.createLocalStorageSessionStore = exports.createDefaultSessionIdGenerator = exports.createSessionManager = exports.createSessionLogRecordProcessor = exports.createSessionSpanProcessor = void 0;
|
|
19
19
|
var utils_1 = require("./utils");
|
|
20
20
|
Object.defineProperty(exports, "createSessionSpanProcessor", { enumerable: true, get: function () { return utils_1.createSessionSpanProcessor; } });
|
|
21
21
|
Object.defineProperty(exports, "createSessionLogRecordProcessor", { enumerable: true, get: function () { return utils_1.createSessionLogRecordProcessor; } });
|
|
22
|
+
Object.defineProperty(exports, "createSessionManager", { enumerable: true, get: function () { return utils_1.createSessionManager; } });
|
|
23
|
+
Object.defineProperty(exports, "createDefaultSessionIdGenerator", { enumerable: true, get: function () { return utils_1.createDefaultSessionIdGenerator; } });
|
|
24
|
+
Object.defineProperty(exports, "createLocalStorageSessionStore", { enumerable: true, get: function () { return utils_1.createLocalStorageSessionStore; } });
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAGH,iCAMiB;AALf,mHAAA,0BAA0B,OAAA;AAC1B,wHAAA,+BAA+B,OAAA;AAC/B,6GAAA,oBAAoB,OAAA;AACpB,wHAAA,+BAA+B,OAAA;AAC/B,uHAAA,8BAA8B,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { SessionProvider } from './types/SessionProvider';\nexport {\n createSessionSpanProcessor,\n createSessionLogRecordProcessor,\n createSessionManager,\n createDefaultSessionIdGenerator,\n createLocalStorageSessionStore,\n} from './utils';\nexport type { Session } from './types/Session';\nexport type { SessionIdGenerator } from './types/SessionIdGenerator';\nexport type { SessionPublisher } from './types/SessionPublisher';\nexport type { SessionObserver } from './types/SessionObserver';\nexport type { SessionStore } from './types/SessionStore';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=Session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Session.js","sourceRoot":"","sources":["../../../src/types/Session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface Session {\n id: string;\n startTimestamp: number; // epoch milliseconds\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=SessionIdGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionIdGenerator.js","sourceRoot":"","sources":["../../../src/types/SessionIdGenerator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport interface SessionIdGenerator {\n generateSessionId(): string;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=SessionObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionObserver.js","sourceRoot":"","sources":["../../../src/types/SessionObserver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Session } from './Session';\n\nexport interface SessionObserver {\n onSessionStarted(newSession: Session, previousSession?: Session): void;\n onSessionEnded(session: Session): void;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=SessionPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionPublisher.js","sourceRoot":"","sources":["../../../src/types/SessionPublisher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionObserver } from './SessionObserver';\n\nexport interface SessionPublisher {\n addObserver(observer: SessionObserver): void;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright The OpenTelemetry Authors
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=SessionStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionStore.js","sourceRoot":"","sources":["../../../src/types/SessionStore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Session } from './Session';\n\nexport interface SessionStore {\n save(session: Session): Promise<void>;\n get(): Promise<Session | null>;\n}\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { SessionProvider } from './types/SessionProvider';
|
|
2
2
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
3
3
|
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
4
|
+
import { SessionManager, SessionManagerConfig } from './SessionManager';
|
|
5
|
+
import { SessionIdGenerator } from './types/SessionIdGenerator';
|
|
6
|
+
import { SessionStore } from './types/SessionStore';
|
|
4
7
|
export declare function createSessionSpanProcessor(sessionProvider: SessionProvider): SpanProcessor;
|
|
5
8
|
export declare function createSessionLogRecordProcessor(sessionProvider: SessionProvider): LogRecordProcessor;
|
|
9
|
+
export declare function createSessionManager(config: SessionManagerConfig): SessionManager;
|
|
10
|
+
export declare function createDefaultSessionIdGenerator(): SessionIdGenerator;
|
|
11
|
+
export declare function createLocalStorageSessionStore(): SessionStore;
|
|
6
12
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
CHANGED
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.createSessionLogRecordProcessor = exports.createSessionSpanProcessor = void 0;
|
|
18
|
+
exports.createLocalStorageSessionStore = exports.createDefaultSessionIdGenerator = exports.createSessionManager = exports.createSessionLogRecordProcessor = exports.createSessionSpanProcessor = void 0;
|
|
19
19
|
const SessionSpanProcessor_1 = require("./SessionSpanProcessor");
|
|
20
20
|
const SessionLogRecordProcessor_1 = require("./SessionLogRecordProcessor");
|
|
21
|
+
const SessionManager_1 = require("./SessionManager");
|
|
22
|
+
const DefaultIdGenerator_1 = require("./DefaultIdGenerator");
|
|
23
|
+
const LocalStorageSessionStore_1 = require("./LocalStorageSessionStore");
|
|
21
24
|
function createSessionSpanProcessor(sessionProvider) {
|
|
22
25
|
return new SessionSpanProcessor_1.SessionSpanProcessor(sessionProvider);
|
|
23
26
|
}
|
|
@@ -26,4 +29,17 @@ function createSessionLogRecordProcessor(sessionProvider) {
|
|
|
26
29
|
return new SessionLogRecordProcessor_1.SessionLogRecordProcessor(sessionProvider);
|
|
27
30
|
}
|
|
28
31
|
exports.createSessionLogRecordProcessor = createSessionLogRecordProcessor;
|
|
32
|
+
function createSessionManager(config) {
|
|
33
|
+
const manager = new SessionManager_1.SessionManager(config);
|
|
34
|
+
return manager;
|
|
35
|
+
}
|
|
36
|
+
exports.createSessionManager = createSessionManager;
|
|
37
|
+
function createDefaultSessionIdGenerator() {
|
|
38
|
+
return new DefaultIdGenerator_1.DefaultIdGenerator();
|
|
39
|
+
}
|
|
40
|
+
exports.createDefaultSessionIdGenerator = createDefaultSessionIdGenerator;
|
|
41
|
+
function createLocalStorageSessionStore() {
|
|
42
|
+
return new LocalStorageSessionStore_1.LocalStorageSessionStore();
|
|
43
|
+
}
|
|
44
|
+
exports.createLocalStorageSessionStore = createLocalStorageSessionStore;
|
|
29
45
|
//# sourceMappingURL=utils.js.map
|
package/build/src/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,iEAA8D;AAE9D,2EAAwE;AAExE,SAAgB,0BAA0B,CACxC,eAAgC;IAEhC,OAAO,IAAI,2CAAoB,CAAC,eAAe,CAAC,CAAC;AACnD,CAAC;AAJD,gEAIC;AAED,SAAgB,+BAA+B,CAC7C,eAAgC;IAEhC,OAAO,IAAI,qDAAyB,CAAC,eAAe,CAAC,CAAC;AACxD,CAAC;AAJD,0EAIC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionProvider } from './types/SessionProvider';\nimport { SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { SessionSpanProcessor } from './SessionSpanProcessor';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\nimport { SessionLogRecordProcessor } from './SessionLogRecordProcessor';\n\nexport function createSessionSpanProcessor(\n sessionProvider: SessionProvider\n): SpanProcessor {\n return new SessionSpanProcessor(sessionProvider);\n}\n\nexport function createSessionLogRecordProcessor(\n sessionProvider: SessionProvider\n): LogRecordProcessor {\n return new SessionLogRecordProcessor(sessionProvider);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,iEAA8D;AAE9D,2EAAwE;AACxE,qDAAwE;AAExE,6DAA0D;AAE1D,yEAAsE;AAEtE,SAAgB,0BAA0B,CACxC,eAAgC;IAEhC,OAAO,IAAI,2CAAoB,CAAC,eAAe,CAAC,CAAC;AACnD,CAAC;AAJD,gEAIC;AAED,SAAgB,+BAA+B,CAC7C,eAAgC;IAEhC,OAAO,IAAI,qDAAyB,CAAC,eAAe,CAAC,CAAC;AACxD,CAAC;AAJD,0EAIC;AAED,SAAgB,oBAAoB,CAClC,MAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,+BAAc,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,OAAO,CAAC;AACjB,CAAC;AALD,oDAKC;AAED,SAAgB,+BAA+B;IAC7C,OAAO,IAAI,uCAAkB,EAAE,CAAC;AAClC,CAAC;AAFD,0EAEC;AAED,SAAgB,8BAA8B;IAC5C,OAAO,IAAI,mDAAwB,EAAE,CAAC;AACxC,CAAC;AAFD,wEAEC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SessionProvider } from './types/SessionProvider';\nimport { SpanProcessor } from '@opentelemetry/sdk-trace-base';\nimport { SessionSpanProcessor } from './SessionSpanProcessor';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\nimport { SessionLogRecordProcessor } from './SessionLogRecordProcessor';\nimport { SessionManager, SessionManagerConfig } from './SessionManager';\nimport { SessionIdGenerator } from './types/SessionIdGenerator';\nimport { DefaultIdGenerator } from './DefaultIdGenerator';\nimport { SessionStore } from './types/SessionStore';\nimport { LocalStorageSessionStore } from './LocalStorageSessionStore';\n\nexport function createSessionSpanProcessor(\n sessionProvider: SessionProvider\n): SpanProcessor {\n return new SessionSpanProcessor(sessionProvider);\n}\n\nexport function createSessionLogRecordProcessor(\n sessionProvider: SessionProvider\n): LogRecordProcessor {\n return new SessionLogRecordProcessor(sessionProvider);\n}\n\nexport function createSessionManager(\n config: SessionManagerConfig\n): SessionManager {\n const manager = new SessionManager(config);\n return manager;\n}\n\nexport function createDefaultSessionIdGenerator(): SessionIdGenerator {\n return new DefaultIdGenerator();\n}\n\nexport function createLocalStorageSessionStore(): SessionStore {\n return new LocalStorageSessionStore();\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.207.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.207.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/web-common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.207.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,9 +30,7 @@
|
|
|
30
30
|
"peer-api-check": "node ../../../scripts/peer-api-check.js",
|
|
31
31
|
"prepublishOnly": "npm run compile",
|
|
32
32
|
"prewatch": "npm run precompile",
|
|
33
|
-
"tdd": "
|
|
34
|
-
"tdd:browser": "karma start",
|
|
35
|
-
"test": "nyc mocha test/**/*.test.ts",
|
|
33
|
+
"tdd": "karma start",
|
|
36
34
|
"test:browser": "karma start --single-run",
|
|
37
35
|
"version": "node ../../../scripts/version-update.js",
|
|
38
36
|
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
@@ -65,14 +63,14 @@
|
|
|
65
63
|
"@opentelemetry/api": ">=1.4.0 <1.10.0"
|
|
66
64
|
},
|
|
67
65
|
"dependencies": {
|
|
68
|
-
"@opentelemetry/sdk-logs": "0.
|
|
69
|
-
"@opentelemetry/sdk-trace-base": "2.
|
|
66
|
+
"@opentelemetry/sdk-logs": "0.207.0",
|
|
67
|
+
"@opentelemetry/sdk-trace-base": "2.2.0",
|
|
70
68
|
"@opentelemetry/semantic-conventions": "^1.29.0"
|
|
71
69
|
},
|
|
72
70
|
"devDependencies": {
|
|
73
71
|
"@babel/core": "7.27.1",
|
|
74
72
|
"@opentelemetry/api": "1.9.0",
|
|
75
|
-
"@opentelemetry/api-logs": "0.
|
|
73
|
+
"@opentelemetry/api-logs": "0.207.0",
|
|
76
74
|
"@types/mocha": "10.0.10",
|
|
77
75
|
"@types/node": "18.6.5",
|
|
78
76
|
"@types/sinon": "17.0.4",
|
|
@@ -85,7 +83,7 @@
|
|
|
85
83
|
"karma-mocha": "2.0.1",
|
|
86
84
|
"karma-spec-reporter": "0.0.36",
|
|
87
85
|
"karma-webpack": "5.0.1",
|
|
88
|
-
"mocha": "11.7.
|
|
86
|
+
"mocha": "11.7.4",
|
|
89
87
|
"nyc": "17.1.0",
|
|
90
88
|
"sinon": "18.0.1",
|
|
91
89
|
"ts-loader": "9.5.4",
|
|
@@ -93,5 +91,5 @@
|
|
|
93
91
|
"webpack": "5.101.3",
|
|
94
92
|
"webpack-cli": "6.0.1"
|
|
95
93
|
},
|
|
96
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "fb6476d8243ac8dcaaea74130b9c50c43938275c"
|
|
97
95
|
}
|