@genn-inc/cluebase-frontend-sdk 0.0.10 → 0.0.11
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/dist/provider/_version.d.ts +1 -1
- package/dist/provider/_version.js +1 -1
- package/dist/provider/sdk.js +72 -34
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION: "0.0.
|
|
1
|
+
export declare const SDK_VERSION: "0.0.11";
|
package/dist/provider/sdk.js
CHANGED
|
@@ -8,7 +8,7 @@ import { BatchTransport } from "../exporter/batch.js";
|
|
|
8
8
|
import { IngestClient } from "../exporter/client.js";
|
|
9
9
|
import { DiagnosticStore } from "../exporter/diagnostics.js";
|
|
10
10
|
import { detectWholeValuePII, hashIdentityValue, isDeniedKey, } from "../exporter/sanitize.js";
|
|
11
|
-
import { initSdkCoreWasm } from "../exporter/sdk-core-wasm.js";
|
|
11
|
+
import { initSdkCoreWasm, isSdkCoreWasmReady } from "../exporter/sdk-core-wasm.js";
|
|
12
12
|
import { InternalMetricsStore } from "../internal/metrics.js";
|
|
13
13
|
import { isConfigValid, resolveConfig, validateConfig } from "./config.js";
|
|
14
14
|
import { DEFAULT_BATCH_FLUSH_THRESHOLD_BYTES, DEFAULT_CONSENT, DEFAULT_MAX_BATCH_QUEUE_BYTES, DEFAULT_MAX_BATCH_QUEUE_ITEMS, SDK_VERSION, } from "./constants.js";
|
|
@@ -127,16 +127,54 @@ class CluebaseBrowserSdkImpl {
|
|
|
127
127
|
this.lifecycleDedup.clear();
|
|
128
128
|
this.config = resolved;
|
|
129
129
|
this.initSignature = nextSignature;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
const identityManager = new IdentityManager();
|
|
131
|
+
const sessionManager = new SessionManager();
|
|
132
|
+
const tabManager = new TabManager();
|
|
133
|
+
const organizationManager = new OrganizationManager();
|
|
134
|
+
const traceManager = new TraceManager();
|
|
135
|
+
traceManager.enableAsyncContext();
|
|
136
|
+
const environmentManager = new EnvironmentManager({
|
|
137
137
|
frontendRelease: resolved.release.frontendRelease,
|
|
138
138
|
contextTraitsProvider: resolved.contextTraitsProvider,
|
|
139
139
|
});
|
|
140
|
+
this.identityManager = identityManager;
|
|
141
|
+
this.sessionManager = sessionManager;
|
|
142
|
+
this.tabManager = tabManager;
|
|
143
|
+
this.organizationManager = organizationManager;
|
|
144
|
+
this.traceManager = traceManager;
|
|
145
|
+
this.environmentManager = environmentManager;
|
|
146
|
+
const managers = {
|
|
147
|
+
identityManager,
|
|
148
|
+
sessionManager,
|
|
149
|
+
tabManager,
|
|
150
|
+
organizationManager,
|
|
151
|
+
traceManager,
|
|
152
|
+
environmentManager,
|
|
153
|
+
};
|
|
154
|
+
if (isSdkCoreWasmReady()) {
|
|
155
|
+
this.completeInitAfterWasmReady(resolved, managers);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
void initSdkCoreWasm()
|
|
159
|
+
.then(() => {
|
|
160
|
+
if (this.initSignature !== nextSignature)
|
|
161
|
+
return;
|
|
162
|
+
this.completeInitAfterWasmReady(resolved, managers);
|
|
163
|
+
})
|
|
164
|
+
.catch((error) => {
|
|
165
|
+
reportSdkError("init sdk core wasm", error);
|
|
166
|
+
if (this.initSignature === nextSignature) {
|
|
167
|
+
this.handleInitFailure(error);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
this.handleInitFailure(error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
completeInitAfterWasmReady(resolved, managers) {
|
|
177
|
+
try {
|
|
140
178
|
const effectiveBatch = resolved.batch;
|
|
141
179
|
const ingestClient = new IngestClient({
|
|
142
180
|
endpoint: resolved.endpoint,
|
|
@@ -172,12 +210,12 @@ class CluebaseBrowserSdkImpl {
|
|
|
172
210
|
this.transport.start();
|
|
173
211
|
this.eventPipeline.configure({
|
|
174
212
|
config: resolved,
|
|
175
|
-
identityManager:
|
|
176
|
-
sessionManager:
|
|
177
|
-
tabManager:
|
|
178
|
-
organizationManager:
|
|
179
|
-
environmentManager:
|
|
180
|
-
traceManager:
|
|
213
|
+
identityManager: managers.identityManager,
|
|
214
|
+
sessionManager: managers.sessionManager,
|
|
215
|
+
tabManager: managers.tabManager,
|
|
216
|
+
organizationManager: managers.organizationManager,
|
|
217
|
+
environmentManager: managers.environmentManager,
|
|
218
|
+
traceManager: managers.traceManager,
|
|
181
219
|
transport: this.transport,
|
|
182
220
|
internalMetrics: this.internalMetrics,
|
|
183
221
|
logger: this.logger,
|
|
@@ -186,9 +224,6 @@ class CluebaseBrowserSdkImpl {
|
|
|
186
224
|
if (this.consent !== "denied") {
|
|
187
225
|
this.warmupBrowserToken(ingestClient);
|
|
188
226
|
}
|
|
189
|
-
void initSdkCoreWasm().catch((error) => {
|
|
190
|
-
reportSdkError("init sdk core wasm", error);
|
|
191
|
-
});
|
|
192
227
|
this.tracerProvider = createCluebaseOtelPipeline({
|
|
193
228
|
resolved,
|
|
194
229
|
getTransport: () => this.transport,
|
|
@@ -197,7 +232,7 @@ class CluebaseBrowserSdkImpl {
|
|
|
197
232
|
});
|
|
198
233
|
this.initialized = true;
|
|
199
234
|
this.refreshSessionCaptureEligibility();
|
|
200
|
-
const sessionLifecycle =
|
|
235
|
+
const sessionLifecycle = managers.sessionManager.ensureActiveSession(Date.now());
|
|
201
236
|
if (sessionLifecycle.started) {
|
|
202
237
|
this.enqueueRawEvent({
|
|
203
238
|
type: "session_started",
|
|
@@ -218,23 +253,26 @@ class CluebaseBrowserSdkImpl {
|
|
|
218
253
|
this.installUnloadHandlers();
|
|
219
254
|
}
|
|
220
255
|
catch (error) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
256
|
+
this.handleInitFailure(error);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
handleInitFailure(error) {
|
|
260
|
+
const errorDetails = getSdkErrorDetails(error);
|
|
261
|
+
this.logger.error("Cluebase Frontend SDK init failed", {
|
|
262
|
+
error_code: "sdk_operation_failed",
|
|
263
|
+
...errorDetails,
|
|
264
|
+
});
|
|
265
|
+
reportSdkError("init", error);
|
|
266
|
+
this.warnPublicDrop("init", "sdk_operation_failed");
|
|
267
|
+
try {
|
|
268
|
+
this.shutdown();
|
|
269
|
+
}
|
|
270
|
+
catch (cleanupError) {
|
|
271
|
+
this.logger.error("Cluebase Frontend SDK init cleanup failed", {
|
|
272
|
+
error_code: "sdk_cleanup_failed",
|
|
273
|
+
...getSdkErrorDetails(cleanupError),
|
|
225
274
|
});
|
|
226
|
-
reportSdkError("init",
|
|
227
|
-
this.warnPublicDrop("init", "sdk_operation_failed");
|
|
228
|
-
try {
|
|
229
|
-
this.shutdown();
|
|
230
|
-
}
|
|
231
|
-
catch (cleanupError) {
|
|
232
|
-
this.logger.error("Cluebase Frontend SDK init cleanup failed", {
|
|
233
|
-
error_code: "sdk_cleanup_failed",
|
|
234
|
-
...getSdkErrorDetails(cleanupError),
|
|
235
|
-
});
|
|
236
|
-
reportSdkError("init cleanup", cleanupError);
|
|
237
|
-
}
|
|
275
|
+
reportSdkError("init cleanup", cleanupError);
|
|
238
276
|
}
|
|
239
277
|
}
|
|
240
278
|
identify(userId, traits) {
|