@bentolabs/sdk 1.2.0 → 1.2.2

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.d.ts CHANGED
@@ -99,5 +99,5 @@ export declare class BentoLabsSDK {
99
99
  */
100
100
  trackCustomEvent(eventName: string, data?: Record<string, any>): void;
101
101
  }
102
- declare const _default: BentoLabsSDK;
103
- export default _default;
102
+ declare const sdk: BentoLabsSDK;
103
+ export default sdk;
package/dist/index.js CHANGED
@@ -9133,6 +9133,22 @@ function getDirectText$1(element) {
9133
9133
  }
9134
9134
  return text.replace(/\s+/g, " ").trim();
9135
9135
  }
9136
+ function getFullText$1(element) {
9137
+ return (element.textContent || "").replace(/\s+/g, " ").trim();
9138
+ }
9139
+ function getChildSignature(element) {
9140
+ const tags = Array.from(element.children).map(
9141
+ (c2) => c2.tagName.toLowerCase()
9142
+ );
9143
+ return tags.join(",");
9144
+ }
9145
+ function quickHash(str) {
9146
+ let hash = 5381;
9147
+ for (let i2 = 0; i2 < str.length; i2++) {
9148
+ hash = (hash << 5) + hash ^ str.charCodeAt(i2);
9149
+ }
9150
+ return (hash >>> 0).toString(16);
9151
+ }
9136
9152
  function buildBentoSelector(element) {
9137
9153
  const parts = [];
9138
9154
  const tag = element.tagName.toLowerCase();
@@ -9185,13 +9201,41 @@ function buildBentoSelector(element) {
9185
9201
  if (title) {
9186
9202
  parts.push(`title=${escapeValue(truncate(title, 50))}`);
9187
9203
  }
9188
- const interactiveTags = ["button", "a", "label", "span", "div", "li", "td", "th", "h1", "h2", "h3", "h4", "h5", "h6", "p"];
9204
+ const interactiveTags = [
9205
+ "button",
9206
+ "a",
9207
+ "label",
9208
+ "span",
9209
+ "div",
9210
+ "li",
9211
+ "td",
9212
+ "th",
9213
+ "h1",
9214
+ "h2",
9215
+ "h3",
9216
+ "h4",
9217
+ "h5",
9218
+ "h6",
9219
+ "p"
9220
+ ];
9189
9221
  if (interactiveTags.includes(tag)) {
9190
- const text = getDirectText$1(element);
9222
+ let text = getDirectText$1(element);
9223
+ if (!text) {
9224
+ text = getFullText$1(element);
9225
+ }
9191
9226
  if (text) {
9192
9227
  parts.push(`text=${escapeValue(truncate(text, 50))}`);
9193
9228
  }
9194
9229
  }
9230
+ if (parts.length === 1) {
9231
+ const childSig = getChildSignature(element);
9232
+ if (childSig) {
9233
+ parts.push(`children=${childSig}`);
9234
+ } else {
9235
+ const attrs = Array.from(element.attributes).map((a2) => `${a2.name}=${a2.value}`).sort().join(";");
9236
+ parts.push(`hash=${quickHash(tag + attrs)}`);
9237
+ }
9238
+ }
9195
9239
  return parts.join("|");
9196
9240
  }
9197
9241
  function generateSelector(outerHTML) {
@@ -12968,7 +13012,21 @@ var BentoLabsSDK = class {
12968
13012
  }
12969
13013
  }
12970
13014
  };
12971
- var index_default = new BentoLabsSDK();
13015
+ var sdk = new BentoLabsSDK();
13016
+ if (typeof window !== "undefined") {
13017
+ window.BentoLabsSDK = __spreadProps(__spreadValues({}, sdk), {
13018
+ init: sdk.init.bind(sdk),
13019
+ stop: sdk.stop.bind(sdk),
13020
+ getSessionId: sdk.getSessionId.bind(sdk),
13021
+ isRecordingActive: sdk.isRecordingActive.bind(sdk),
13022
+ getConfig: sdk.getConfig.bind(sdk),
13023
+ getEventQueueLength: sdk.getEventQueueLength.bind(sdk),
13024
+ flushEvents: sdk.flushEvents.bind(sdk),
13025
+ trackCustomEvent: sdk.trackCustomEvent.bind(sdk),
13026
+ generateSelector
13027
+ });
13028
+ }
13029
+ var index_default = sdk;
12972
13030
  /*! Bundled license information:
12973
13031
 
12974
13032
  rrweb/dist/rrweb.js: