clintplay-react-native 0.1.0 → 0.2.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/dist/index.mjs CHANGED
@@ -879,7 +879,7 @@ function captureViewHierarchy() {
879
879
  }
880
880
 
881
881
  // package.json
882
- var version = "0.1.0";
882
+ var version = "0.2.0";
883
883
  var CLINTPLAY_MASK_ID = "clintplay-mask";
884
884
  var ClintplayMaskView = React5.forwardRef(function ClintplayMaskView2({ children, testID, ...rest }, ref) {
885
885
  return /* @__PURE__ */ jsx(
@@ -1249,13 +1249,14 @@ async function flushOnce(s) {
1249
1249
  }
1250
1250
  }
1251
1251
  function init(rawConfig) {
1252
- if (state?.active) return;
1253
- if (!rawConfig.apiUrl) return;
1254
- if (rawConfig.enabled === false) return;
1252
+ if (state?.active) return Clintplay;
1253
+ const apiUrl = rawConfig.apiUrl ?? rawConfig.endpoint;
1254
+ if (!apiUrl) return Clintplay;
1255
+ if (rawConfig.enabled === false) return Clintplay;
1255
1256
  const sampleRate = rawConfig.sampleRate ?? 1;
1256
- if (sampleRate < 1 && Math.random() > sampleRate) return;
1257
+ if (sampleRate < 1 && Math.random() > sampleRate) return Clintplay;
1257
1258
  const config = {
1258
- apiUrl: rawConfig.apiUrl,
1259
+ apiUrl,
1259
1260
  apiKey: rawConfig.apiKey,
1260
1261
  projectId: rawConfig.projectId ?? rawConfig.apiKey ?? "",
1261
1262
  anonId: rawConfig.anonId,
@@ -1359,15 +1360,18 @@ function init(rawConfig) {
1359
1360
  void flushOnce(local);
1360
1361
  }, config.flushIntervalMs);
1361
1362
  debugLog(config, "init", { sessionId: session.current().sessionId });
1363
+ return Clintplay;
1362
1364
  }
1363
1365
  function identify(userId, traits) {
1364
1366
  if (!state?.active) return;
1367
+ if (userId === void 0 || userId === "") return;
1368
+ const normalizedUserId = userId === null ? null : String(userId);
1365
1369
  const prevUser = state.session.current().userId;
1366
- const isUserChange = prevUser !== null && (userId === null || prevUser !== userId);
1370
+ const isUserChange = prevUser !== null && (normalizedUserId === null || prevUser !== normalizedUserId);
1367
1371
  if (isUserChange) {
1368
1372
  void flushOnce(state);
1369
1373
  }
1370
- const rotated = state.session.setUser(userId);
1374
+ const rotated = state.session.setUser(normalizedUserId);
1371
1375
  if (rotated) {
1372
1376
  state.buffer.push({
1373
1377
  type: "meta",
@@ -1380,8 +1384,10 @@ function identify(userId, traits) {
1380
1384
  state.buffer.push({
1381
1385
  type: "identify",
1382
1386
  ts: Date.now(),
1383
- userId,
1384
- traits
1387
+ data: {
1388
+ userId: normalizedUserId,
1389
+ traits: traits ?? {}
1390
+ }
1385
1391
  });
1386
1392
  }
1387
1393
  function reset(options) {
@@ -1445,6 +1451,13 @@ function current() {
1445
1451
  const s = state.session.current();
1446
1452
  return { sessionId: s.sessionId, userId: s.userId };
1447
1453
  }
1454
+ function _getState() {
1455
+ if (!state) return null;
1456
+ return {
1457
+ ...state,
1458
+ buffer: state.buffer.peek()
1459
+ };
1460
+ }
1448
1461
  var Clintplay = {
1449
1462
  init,
1450
1463
  identify,
@@ -1453,9 +1466,10 @@ var Clintplay = {
1453
1466
  reportError,
1454
1467
  flush,
1455
1468
  stop,
1456
- current
1469
+ current,
1470
+ _getState
1457
1471
  };
1458
1472
 
1459
- export { CLINTPLAY_MASK_ID, Clintplay, ClintplayCaptureProvider, ClintplayMaskImage, ClintplayMaskTextInput, ClintplayMaskView, ClintplayNavigationTracker, SDK_VERSION, _resetLastTrackedRoute, createClintplayNavigationStateListener, formatEventForBatch, getActiveRouteName, sanitizeRoute, useClintplayNavigationTracking };
1473
+ export { CLINTPLAY_MASK_ID, Clintplay, ClintplayCaptureProvider, ClintplayMaskImage, ClintplayMaskTextInput, ClintplayMaskView, ClintplayNavigationTracker, SDK_VERSION, _resetLastTrackedRoute, createClintplayNavigationStateListener, formatEventForBatch, getActiveRouteName, init, sanitizeRoute, useClintplayNavigationTracking };
1460
1474
  //# sourceMappingURL=index.mjs.map
1461
1475
  //# sourceMappingURL=index.mjs.map