@thoughtspot/visual-embed-sdk 1.19.0-alpha.2 → 1.19.0-alpha.4

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.
Files changed (85) hide show
  1. package/dist/src/auth.d.ts +21 -1
  2. package/dist/src/auth.d.ts.map +1 -1
  3. package/dist/src/embed/base.d.ts +2 -5
  4. package/dist/src/embed/base.d.ts.map +1 -1
  5. package/dist/src/embed/search.d.ts +6 -0
  6. package/dist/src/embed/search.d.ts.map +1 -1
  7. package/dist/src/embed/ts-embed.d.ts +1 -0
  8. package/dist/src/embed/ts-embed.d.ts.map +1 -1
  9. package/dist/src/index.d.ts +2 -2
  10. package/dist/src/index.d.ts.map +1 -1
  11. package/dist/src/mixpanel-service.d.ts +3 -1
  12. package/dist/src/mixpanel-service.d.ts.map +1 -1
  13. package/dist/src/react/index.d.ts.map +1 -1
  14. package/dist/src/react/util.d.ts +1 -1
  15. package/dist/src/react/util.d.ts.map +1 -1
  16. package/dist/src/test/test-utils.d.ts +1 -1
  17. package/dist/src/test/test-utils.d.ts.map +1 -1
  18. package/dist/src/types.d.ts +19 -8
  19. package/dist/src/types.d.ts.map +1 -1
  20. package/dist/src/utils.d.ts +1 -0
  21. package/dist/src/utils.d.ts.map +1 -1
  22. package/dist/tsembed.es.js +114 -68
  23. package/dist/tsembed.js +112 -67
  24. package/lib/package.json +1 -1
  25. package/lib/src/auth.d.ts +21 -1
  26. package/lib/src/auth.d.ts.map +1 -1
  27. package/lib/src/auth.js +66 -12
  28. package/lib/src/auth.js.map +1 -1
  29. package/lib/src/embed/base.d.ts +2 -5
  30. package/lib/src/embed/base.d.ts.map +1 -1
  31. package/lib/src/embed/base.js +8 -36
  32. package/lib/src/embed/base.js.map +1 -1
  33. package/lib/src/embed/base.spec.js +0 -9
  34. package/lib/src/embed/base.spec.js.map +1 -1
  35. package/lib/src/embed/search.d.ts +6 -0
  36. package/lib/src/embed/search.d.ts.map +1 -1
  37. package/lib/src/embed/search.js.map +1 -1
  38. package/lib/src/embed/ts-embed.d.ts +1 -0
  39. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  40. package/lib/src/embed/ts-embed.js +23 -5
  41. package/lib/src/embed/ts-embed.js.map +1 -1
  42. package/lib/src/embed/ts-embed.spec.js +15 -1
  43. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  44. package/lib/src/index.d.ts +2 -2
  45. package/lib/src/index.d.ts.map +1 -1
  46. package/lib/src/index.js +2 -2
  47. package/lib/src/index.js.map +1 -1
  48. package/lib/src/mixpanel-service.d.ts +3 -1
  49. package/lib/src/mixpanel-service.d.ts.map +1 -1
  50. package/lib/src/mixpanel-service.js +18 -15
  51. package/lib/src/mixpanel-service.js.map +1 -1
  52. package/lib/src/mixpanel-service.spec.js +20 -4
  53. package/lib/src/mixpanel-service.spec.js.map +1 -1
  54. package/lib/src/react/index.d.ts.map +1 -1
  55. package/lib/src/react/index.js +8 -4
  56. package/lib/src/react/index.js.map +1 -1
  57. package/lib/src/react/index.spec.js +3 -3
  58. package/lib/src/react/index.spec.js.map +1 -1
  59. package/lib/src/react/util.d.ts +1 -1
  60. package/lib/src/react/util.d.ts.map +1 -1
  61. package/lib/src/test/test-utils.d.ts +1 -1
  62. package/lib/src/test/test-utils.d.ts.map +1 -1
  63. package/lib/src/types.d.ts +19 -8
  64. package/lib/src/types.d.ts.map +1 -1
  65. package/lib/src/types.js +7 -0
  66. package/lib/src/types.js.map +1 -1
  67. package/lib/src/utils.d.ts +1 -0
  68. package/lib/src/utils.d.ts.map +1 -1
  69. package/lib/src/utils.js +11 -0
  70. package/lib/src/utils.js.map +1 -1
  71. package/lib/src/visual-embed-sdk.d.ts +44 -9
  72. package/package.json +1 -1
  73. package/src/auth.ts +78 -19
  74. package/src/embed/base.spec.ts +0 -10
  75. package/src/embed/base.ts +18 -37
  76. package/src/embed/search.ts +6 -0
  77. package/src/embed/ts-embed.spec.ts +15 -0
  78. package/src/embed/ts-embed.ts +22 -5
  79. package/src/index.ts +2 -1
  80. package/src/mixpanel-service.spec.ts +26 -5
  81. package/src/mixpanel-service.ts +19 -20
  82. package/src/react/index.spec.tsx +3 -7
  83. package/src/react/index.tsx +16 -6
  84. package/src/types.ts +11 -0
  85. package/src/utils.ts +13 -0
@@ -953,6 +953,13 @@ var HostEvent;
953
953
  * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
954
954
  */
955
955
  HostEvent["ManagePipelines"] = "manage-pipeline";
956
+ /**
957
+ * Triggers the Reset search in answer
958
+ * @example
959
+ * searchEmbed.trigger(HostEvent.SearchReset
960
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.2.0.cl, 9.0.1-sw
961
+ */
962
+ HostEvent["ResetSearch"] = "resetSearch";
956
963
  })(HostEvent || (HostEvent = {}));
957
964
  /**
958
965
  * The different visual modes that the data sources panel within
@@ -7242,32 +7249,31 @@ const MIXPANEL_EVENT = {
7242
7249
  VISUAL_SDK_RENDER_COMPLETE: 'visual-sdk-render-complete',
7243
7250
  VISUAL_SDK_RENDER_FAILED: 'visual-sdk-render-failed',
7244
7251
  VISUAL_SDK_TRIGGER: 'visual-sdk-trigger',
7252
+ VISUAL_SDK_ON: 'visual-sdk-on',
7245
7253
  VISUAL_SDK_IFRAME_LOAD_PERFORMANCE: 'visual-sdk-iframe-load-performance',
7246
7254
  };
7247
- let isEventCollectorOn = false;
7248
- const eventCollectorQueue = [];
7249
- function setEventCollectorOn() {
7250
- isEventCollectorOn = true;
7251
- }
7252
- function getEventCollectorOnValue() {
7253
- return isEventCollectorOn;
7254
- }
7255
+ let isMixpanelInitialized = false;
7256
+ let eventQueue = [];
7255
7257
  /**
7256
7258
  * Pushes the event with its Property key-value map to mixpanel.
7257
7259
  * @param eventId
7258
7260
  * @param eventProps
7259
7261
  */
7260
- async function uploadMixpanelEvent(eventId, eventProps = {}) {
7261
- if (!getEventCollectorOnValue()) {
7262
- eventCollectorQueue.push({ eventId, eventProps });
7263
- return Promise.resolve();
7262
+ function uploadMixpanelEvent(eventId, eventProps = {}) {
7263
+ if (!isMixpanelInitialized) {
7264
+ eventQueue.push({ eventId, eventProps });
7265
+ return;
7264
7266
  }
7265
- return new Promise(() => mixpanel_cjs.track(eventId, eventProps));
7267
+ mixpanel_cjs.track(eventId, eventProps);
7266
7268
  }
7267
7269
  function emptyQueue() {
7268
- eventCollectorQueue.forEach((event) => {
7270
+ if (!isMixpanelInitialized) {
7271
+ return;
7272
+ }
7273
+ eventQueue.forEach((event) => {
7269
7274
  uploadMixpanelEvent(event.eventId, event.eventProps);
7270
7275
  });
7276
+ eventQueue = [];
7271
7277
  }
7272
7278
  function initMixpanel(sessionInfo) {
7273
7279
  if (!sessionInfo || !sessionInfo.mixpanelToken) {
@@ -7281,7 +7287,7 @@ function initMixpanel(sessionInfo) {
7281
7287
  if (!isPublicCluster) {
7282
7288
  mixpanel_cjs.identify(sessionInfo.userGUID);
7283
7289
  }
7284
- setEventCollectorOn();
7290
+ isMixpanelInitialized = true;
7285
7291
  emptyQueue();
7286
7292
  }
7287
7293
  }
@@ -8852,7 +8858,53 @@ var AuthStatus;
8852
8858
  * Emits when a user logs out
8853
8859
  */
8854
8860
  AuthStatus["LOGOUT"] = "LOGOUT";
8861
+ /**
8862
+ * Emitted when inPopup: true in the SAMLRedirect flow.
8863
+ * And, we are waiting for popup to be triggered either programatically
8864
+ * or by the trigger button.
8865
+ * @version SDK: 1.19.0
8866
+ */
8867
+ AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
8855
8868
  })(AuthStatus || (AuthStatus = {}));
8869
+ var AuthEvent;
8870
+ (function (AuthEvent) {
8871
+ /**
8872
+ * Manually trigger the SSO popup.
8873
+ */
8874
+ AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
8875
+ })(AuthEvent || (AuthEvent = {}));
8876
+ let authEE;
8877
+ function setAuthEE(eventEmitter) {
8878
+ authEE = eventEmitter;
8879
+ }
8880
+ function notifyAuthSDKSuccess() {
8881
+ if (!authEE) {
8882
+ console.error('SDK not initialized');
8883
+ return;
8884
+ }
8885
+ authEE.emit(AuthStatus.SDK_SUCCESS);
8886
+ }
8887
+ function notifyAuthSuccess() {
8888
+ if (!authEE) {
8889
+ console.error('SDK not initialized');
8890
+ return;
8891
+ }
8892
+ authEE.emit(AuthStatus.SUCCESS);
8893
+ }
8894
+ function notifyAuthFailure(failureType) {
8895
+ if (!authEE) {
8896
+ console.error('SDK not initialized');
8897
+ return;
8898
+ }
8899
+ authEE.emit(AuthStatus.FAILURE, failureType);
8900
+ }
8901
+ function notifyLogout() {
8902
+ if (!authEE) {
8903
+ console.error('SDK not initialized');
8904
+ return;
8905
+ }
8906
+ authEE.emit(AuthStatus.LOGOUT);
8907
+ }
8856
8908
  /**
8857
8909
  * Check if we are logged into the ThoughtSpot cluster
8858
8910
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
@@ -8968,11 +9020,23 @@ const doBasicAuth = async (embedConfig) => {
8968
9020
  return loggedInStatus;
8969
9021
  };
8970
9022
  async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
9023
+ const openPopup = () => {
9024
+ if (samlAuthWindow === null || samlAuthWindow.closed) {
9025
+ samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
9026
+ }
9027
+ else {
9028
+ samlAuthWindow.focus();
9029
+ }
9030
+ };
9031
+ authEE === null || authEE === void 0 ? void 0 : authEE.emit(AuthStatus.WAITING_FOR_POPUP);
8971
9032
  const containerEl = getDOMNode(triggerContainer);
8972
- containerEl.innerHTML =
8973
- '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
8974
- const authElem = document.getElementById('ts-auth-btn');
8975
- authElem.textContent = triggerText;
9033
+ if (containerEl) {
9034
+ containerEl.innerHTML =
9035
+ '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
9036
+ const authElem = document.getElementById('ts-auth-btn');
9037
+ authElem.textContent = triggerText;
9038
+ authElem.addEventListener('click', openPopup, { once: true });
9039
+ }
8976
9040
  samlCompletionPromise =
8977
9041
  samlCompletionPromise ||
8978
9042
  new Promise((resolve, reject) => {
@@ -8983,14 +9047,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
8983
9047
  }
8984
9048
  });
8985
9049
  });
8986
- authElem.addEventListener('click', () => {
8987
- if (samlAuthWindow === null || samlAuthWindow.closed) {
8988
- samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
8989
- }
8990
- else {
8991
- samlAuthWindow.focus();
8992
- }
8993
- }, { once: true });
9050
+ authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
8994
9051
  return samlCompletionPromise;
8995
9052
  }
8996
9053
  /**
@@ -9086,35 +9143,6 @@ const CONFIG_DEFAULTS = {
9086
9143
  let authPromise;
9087
9144
  const getEmbedConfig = () => config;
9088
9145
  const getAuthPromise = () => authPromise;
9089
- let authEE;
9090
- function notifyAuthSDKSuccess() {
9091
- if (!authEE) {
9092
- console.error('SDK not initialized');
9093
- return;
9094
- }
9095
- authEE.emit(AuthStatus.SDK_SUCCESS);
9096
- }
9097
- function notifyAuthSuccess() {
9098
- if (!authEE) {
9099
- console.error('SDK not initialized');
9100
- return;
9101
- }
9102
- authEE.emit(AuthStatus.SUCCESS);
9103
- }
9104
- function notifyAuthFailure(failureType) {
9105
- if (!authEE) {
9106
- console.error('SDK not initialized');
9107
- return;
9108
- }
9109
- authEE.emit(AuthStatus.FAILURE, failureType);
9110
- }
9111
- function notifyLogout() {
9112
- if (!authEE) {
9113
- console.error('SDK not initialized');
9114
- return;
9115
- }
9116
- authEE.emit(AuthStatus.LOGOUT);
9117
- }
9118
9146
  /**
9119
9147
  * Perform authentication on the ThoughtSpot app as applicable.
9120
9148
  */
@@ -9178,9 +9206,6 @@ function sanity(embedConfig) {
9178
9206
  throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
9179
9207
  }
9180
9208
  }
9181
- if (embedConfig.noRedirect && !embedConfig.authTriggerContainer) {
9182
- throw new Error('authTriggerContainer not provided with noRedirect');
9183
- }
9184
9209
  }
9185
9210
  /**
9186
9211
  * Initializes the Visual Embed SDK globally and perform
@@ -9193,14 +9218,15 @@ function sanity(embedConfig) {
9193
9218
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
9194
9219
  */
9195
9220
  const init = (embedConfig) => {
9196
- var _a, _b, _c, _d, _e, _f, _g, _h;
9221
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
9197
9222
  sanity(embedConfig);
9198
9223
  config = {
9199
9224
  ...CONFIG_DEFAULTS,
9200
9225
  ...embedConfig,
9201
9226
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
9202
9227
  };
9203
- authEE = new eventemitter3();
9228
+ const authEE = new eventemitter3();
9229
+ setAuthEE(authEE);
9204
9230
  handleAuth();
9205
9231
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
9206
9232
  authType: config.authType,
@@ -9209,6 +9235,8 @@ const init = (embedConfig) => {
9209
9235
  usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
9210
9236
  usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) !=
9211
9237
  null,
9238
+ usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
9239
+ usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
9212
9240
  });
9213
9241
  if (config.callPrefetch) {
9214
9242
  prefetch(config.thoughtSpotHost);
@@ -9427,7 +9455,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
9427
9455
  });
9428
9456
  }
9429
9457
 
9430
- var name="@thoughtspot/visual-embed-sdk";var version="1.19.0-alpha.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9458
+ var name="@thoughtspot/visual-embed-sdk";var version="1.19.0-alpha.4";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9431
9459
 
9432
9460
  /**
9433
9461
  * Copyright (c) 2022
@@ -9691,7 +9719,7 @@ class TsEmbed {
9691
9719
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9692
9720
  return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9693
9721
  if (!isLoggedIn) {
9694
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9722
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9695
9723
  return;
9696
9724
  }
9697
9725
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
@@ -9734,8 +9762,7 @@ class TsEmbed {
9734
9762
  this.iFrame.addEventListener('error', () => {
9735
9763
  nextInQueue();
9736
9764
  });
9737
- this.el.innerHTML = '';
9738
- this.el.appendChild(this.iFrame);
9765
+ this.insertIntoDOM(this.iFrame);
9739
9766
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
9740
9767
  if (prefetchIframe.length) {
9741
9768
  prefetchIframe.forEach((el) => {
@@ -9745,12 +9772,30 @@ class TsEmbed {
9745
9772
  this.subscribeToEvents();
9746
9773
  }).catch((error) => {
9747
9774
  nextInQueue();
9748
- uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9749
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9775
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, { error: JSON.stringify(error) });
9776
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9750
9777
  this.handleError(error);
9751
9778
  });
9752
9779
  });
9753
9780
  }
9781
+ insertIntoDOM(child) {
9782
+ if (this.viewConfig.insertAsSibling) {
9783
+ if (typeof child === 'string') {
9784
+ const div = document.createElement('div');
9785
+ div.innerHTML = child;
9786
+ // eslint-disable-next-line no-param-reassign
9787
+ child = div;
9788
+ }
9789
+ this.el.parentElement.insertBefore(child, this.el.nextSibling);
9790
+ }
9791
+ else if (typeof child === 'string') {
9792
+ this.el.innerHTML = child;
9793
+ }
9794
+ else {
9795
+ this.el.innerHTML = '';
9796
+ this.el.appendChild(child);
9797
+ }
9798
+ }
9754
9799
  /**
9755
9800
  * Sets the height of the iframe
9756
9801
  * @param height The height in pixels
@@ -9936,6 +9981,7 @@ class V1Embed extends TsEmbed {
9936
9981
  // @override
9937
9982
  on(messageType, callback, options = { start: false }) {
9938
9983
  const eventType = this.getCompatibleEventType(messageType);
9984
+ uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_ON}-${messageType}`);
9939
9985
  return super.on(eventType, callback, options);
9940
9986
  }
9941
9987
  }
@@ -10410,4 +10456,4 @@ class SearchBarEmbed extends TsEmbed {
10410
10456
  }
10411
10457
  }
10412
10458
 
10413
- export { Action, AppEmbed, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SearchBarEmbed, SearchEmbed, init, logout$1 as logout, prefetch };
10459
+ export { Action, AppEmbed, AuthEvent, AuthFailureType, AuthStatus, AuthType, DataSourceVisualMode, EmbedEvent, HostEvent, LiveboardEmbed, Page, PinboardEmbed, PrefetchFeatures, RuntimeFilterOp, SearchBarEmbed, SearchEmbed, init, logout$1 as logout, prefetch };
package/dist/tsembed.js CHANGED
@@ -934,6 +934,13 @@
934
934
  * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
935
935
  */
936
936
  HostEvent["ManagePipelines"] = "manage-pipeline";
937
+ /**
938
+ * Triggers the Reset search in answer
939
+ * @example
940
+ * searchEmbed.trigger(HostEvent.SearchReset
941
+ * @version SDK: 1.19.0 | ThoughtSpot: 9.2.0.cl, 9.0.1-sw
942
+ */
943
+ HostEvent["ResetSearch"] = "resetSearch";
937
944
  })(exports.HostEvent || (exports.HostEvent = {}));
938
945
  (function (DataSourceVisualMode) {
939
946
  /**
@@ -7210,32 +7217,31 @@
7210
7217
  VISUAL_SDK_RENDER_COMPLETE: 'visual-sdk-render-complete',
7211
7218
  VISUAL_SDK_RENDER_FAILED: 'visual-sdk-render-failed',
7212
7219
  VISUAL_SDK_TRIGGER: 'visual-sdk-trigger',
7220
+ VISUAL_SDK_ON: 'visual-sdk-on',
7213
7221
  VISUAL_SDK_IFRAME_LOAD_PERFORMANCE: 'visual-sdk-iframe-load-performance',
7214
7222
  };
7215
- let isEventCollectorOn = false;
7216
- const eventCollectorQueue = [];
7217
- function setEventCollectorOn() {
7218
- isEventCollectorOn = true;
7219
- }
7220
- function getEventCollectorOnValue() {
7221
- return isEventCollectorOn;
7222
- }
7223
+ let isMixpanelInitialized = false;
7224
+ let eventQueue = [];
7223
7225
  /**
7224
7226
  * Pushes the event with its Property key-value map to mixpanel.
7225
7227
  * @param eventId
7226
7228
  * @param eventProps
7227
7229
  */
7228
- async function uploadMixpanelEvent(eventId, eventProps = {}) {
7229
- if (!getEventCollectorOnValue()) {
7230
- eventCollectorQueue.push({ eventId, eventProps });
7231
- return Promise.resolve();
7230
+ function uploadMixpanelEvent(eventId, eventProps = {}) {
7231
+ if (!isMixpanelInitialized) {
7232
+ eventQueue.push({ eventId, eventProps });
7233
+ return;
7232
7234
  }
7233
- return new Promise(() => mixpanel_cjs.track(eventId, eventProps));
7235
+ mixpanel_cjs.track(eventId, eventProps);
7234
7236
  }
7235
7237
  function emptyQueue() {
7236
- eventCollectorQueue.forEach((event) => {
7238
+ if (!isMixpanelInitialized) {
7239
+ return;
7240
+ }
7241
+ eventQueue.forEach((event) => {
7237
7242
  uploadMixpanelEvent(event.eventId, event.eventProps);
7238
7243
  });
7244
+ eventQueue = [];
7239
7245
  }
7240
7246
  function initMixpanel(sessionInfo) {
7241
7247
  if (!sessionInfo || !sessionInfo.mixpanelToken) {
@@ -7249,7 +7255,7 @@
7249
7255
  if (!isPublicCluster) {
7250
7256
  mixpanel_cjs.identify(sessionInfo.userGUID);
7251
7257
  }
7252
- setEventCollectorOn();
7258
+ isMixpanelInitialized = true;
7253
7259
  emptyQueue();
7254
7260
  }
7255
7261
  }
@@ -8818,7 +8824,52 @@
8818
8824
  * Emits when a user logs out
8819
8825
  */
8820
8826
  AuthStatus["LOGOUT"] = "LOGOUT";
8827
+ /**
8828
+ * Emitted when inPopup: true in the SAMLRedirect flow.
8829
+ * And, we are waiting for popup to be triggered either programatically
8830
+ * or by the trigger button.
8831
+ * @version SDK: 1.19.0
8832
+ */
8833
+ AuthStatus["WAITING_FOR_POPUP"] = "WAITING_FOR_POPUP";
8821
8834
  })(exports.AuthStatus || (exports.AuthStatus = {}));
8835
+ (function (AuthEvent) {
8836
+ /**
8837
+ * Manually trigger the SSO popup.
8838
+ */
8839
+ AuthEvent["TRIGGER_SSO_POPUP"] = "TRIGGER_SSO_POPUP";
8840
+ })(exports.AuthEvent || (exports.AuthEvent = {}));
8841
+ let authEE;
8842
+ function setAuthEE(eventEmitter) {
8843
+ authEE = eventEmitter;
8844
+ }
8845
+ function notifyAuthSDKSuccess() {
8846
+ if (!authEE) {
8847
+ console.error('SDK not initialized');
8848
+ return;
8849
+ }
8850
+ authEE.emit(exports.AuthStatus.SDK_SUCCESS);
8851
+ }
8852
+ function notifyAuthSuccess() {
8853
+ if (!authEE) {
8854
+ console.error('SDK not initialized');
8855
+ return;
8856
+ }
8857
+ authEE.emit(exports.AuthStatus.SUCCESS);
8858
+ }
8859
+ function notifyAuthFailure(failureType) {
8860
+ if (!authEE) {
8861
+ console.error('SDK not initialized');
8862
+ return;
8863
+ }
8864
+ authEE.emit(exports.AuthStatus.FAILURE, failureType);
8865
+ }
8866
+ function notifyLogout() {
8867
+ if (!authEE) {
8868
+ console.error('SDK not initialized');
8869
+ return;
8870
+ }
8871
+ authEE.emit(exports.AuthStatus.LOGOUT);
8872
+ }
8822
8873
  /**
8823
8874
  * Check if we are logged into the ThoughtSpot cluster
8824
8875
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
@@ -8934,11 +8985,23 @@
8934
8985
  return loggedInStatus;
8935
8986
  };
8936
8987
  async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
8988
+ const openPopup = () => {
8989
+ if (samlAuthWindow === null || samlAuthWindow.closed) {
8990
+ samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
8991
+ }
8992
+ else {
8993
+ samlAuthWindow.focus();
8994
+ }
8995
+ };
8996
+ authEE === null || authEE === void 0 ? void 0 : authEE.emit(exports.AuthStatus.WAITING_FOR_POPUP);
8937
8997
  const containerEl = getDOMNode(triggerContainer);
8938
- containerEl.innerHTML =
8939
- '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
8940
- const authElem = document.getElementById('ts-auth-btn');
8941
- authElem.textContent = triggerText;
8998
+ if (containerEl) {
8999
+ containerEl.innerHTML =
9000
+ '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
9001
+ const authElem = document.getElementById('ts-auth-btn');
9002
+ authElem.textContent = triggerText;
9003
+ authElem.addEventListener('click', openPopup, { once: true });
9004
+ }
8942
9005
  samlCompletionPromise =
8943
9006
  samlCompletionPromise ||
8944
9007
  new Promise((resolve, reject) => {
@@ -8949,14 +9012,7 @@
8949
9012
  }
8950
9013
  });
8951
9014
  });
8952
- authElem.addEventListener('click', () => {
8953
- if (samlAuthWindow === null || samlAuthWindow.closed) {
8954
- samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
8955
- }
8956
- else {
8957
- samlAuthWindow.focus();
8958
- }
8959
- }, { once: true });
9015
+ authEE === null || authEE === void 0 ? void 0 : authEE.once(exports.AuthEvent.TRIGGER_SSO_POPUP, openPopup);
8960
9016
  return samlCompletionPromise;
8961
9017
  }
8962
9018
  /**
@@ -9052,35 +9108,6 @@
9052
9108
  let authPromise;
9053
9109
  const getEmbedConfig = () => config;
9054
9110
  const getAuthPromise = () => authPromise;
9055
- let authEE;
9056
- function notifyAuthSDKSuccess() {
9057
- if (!authEE) {
9058
- console.error('SDK not initialized');
9059
- return;
9060
- }
9061
- authEE.emit(exports.AuthStatus.SDK_SUCCESS);
9062
- }
9063
- function notifyAuthSuccess() {
9064
- if (!authEE) {
9065
- console.error('SDK not initialized');
9066
- return;
9067
- }
9068
- authEE.emit(exports.AuthStatus.SUCCESS);
9069
- }
9070
- function notifyAuthFailure(failureType) {
9071
- if (!authEE) {
9072
- console.error('SDK not initialized');
9073
- return;
9074
- }
9075
- authEE.emit(exports.AuthStatus.FAILURE, failureType);
9076
- }
9077
- function notifyLogout() {
9078
- if (!authEE) {
9079
- console.error('SDK not initialized');
9080
- return;
9081
- }
9082
- authEE.emit(exports.AuthStatus.LOGOUT);
9083
- }
9084
9111
  /**
9085
9112
  * Perform authentication on the ThoughtSpot app as applicable.
9086
9113
  */
@@ -9144,9 +9171,6 @@
9144
9171
  throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
9145
9172
  }
9146
9173
  }
9147
- if (embedConfig.noRedirect && !embedConfig.authTriggerContainer) {
9148
- throw new Error('authTriggerContainer not provided with noRedirect');
9149
- }
9150
9174
  }
9151
9175
  /**
9152
9176
  * Initializes the Visual Embed SDK globally and perform
@@ -9159,14 +9183,15 @@
9159
9183
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
9160
9184
  */
9161
9185
  const init = (embedConfig) => {
9162
- var _a, _b, _c, _d, _e, _f, _g, _h;
9186
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
9163
9187
  sanity(embedConfig);
9164
9188
  config = {
9165
9189
  ...CONFIG_DEFAULTS,
9166
9190
  ...embedConfig,
9167
9191
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
9168
9192
  };
9169
- authEE = new eventemitter3();
9193
+ const authEE = new eventemitter3();
9194
+ setAuthEE(authEE);
9170
9195
  handleAuth();
9171
9196
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
9172
9197
  authType: config.authType,
@@ -9175,6 +9200,8 @@
9175
9200
  usedCustomizationVariables: ((_e = (_d = (_c = embedConfig.customizations) === null || _c === void 0 ? void 0 : _c.style) === null || _d === void 0 ? void 0 : _d.customCSS) === null || _e === void 0 ? void 0 : _e.variables) != null,
9176
9201
  usedCustomizationRules: ((_h = (_g = (_f = embedConfig.customizations) === null || _f === void 0 ? void 0 : _f.style) === null || _g === void 0 ? void 0 : _g.customCSS) === null || _h === void 0 ? void 0 : _h.rules_UNSTABLE) !=
9177
9202
  null,
9203
+ usedCustomizationStrings: !!((_k = (_j = embedConfig.customizations) === null || _j === void 0 ? void 0 : _j.content) === null || _k === void 0 ? void 0 : _k.strings),
9204
+ usedCustomizationIconSprite: !!((_l = embedConfig.customizations) === null || _l === void 0 ? void 0 : _l.iconSpriteUrl),
9178
9205
  });
9179
9206
  if (config.callPrefetch) {
9180
9207
  prefetch(config.thoughtSpotHost);
@@ -9393,7 +9420,7 @@
9393
9420
  });
9394
9421
  }
9395
9422
 
9396
- var name="@thoughtspot/visual-embed-sdk";var version="1.19.0-alpha.2";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports$1={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9423
+ var name="@thoughtspot/visual-embed-sdk";var version="1.19.0-alpha.4";var description="ThoughtSpot Embed SDK";var module="lib/src/index.js";var main="dist/tsembed.js";var types="lib/src/index.d.ts";var files=["dist/**","lib/**","src/**"];var exports$1={".":"./lib/src/index.js","./react":{"import":"./lib/src/react/index.js",require:"./cjs/src/react.index.js",types:"./lib/src/react/index.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/index.d.ts"]}};var scripts={lint:"eslint 'src/**'","lint:fix":"eslint 'src/**/*.*' --fix",tsc:"tsc -p . --incremental false; tsc -p . --incremental false --module commonjs --outDir cjs",start:"gatsby develop","build:gatsby":"npm run clean:gatsby && gatsby build --prefix-paths","build:gatsby:noprefix":"npm run clean:gatsby && gatsby build","serve:gatsby":"gatsby serve","clean:gatsby":"gatsby clean","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts",build:"rollup -c",watch:"rollup -cw","docs-cmd":"node scripts/gatsby-commands.js",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme","test-sdk":"jest -c jest.config.sdk.js --runInBand","test-docs":"jest -c jest.config.docs.js",test:"npm run test-sdk && npm run test-docs",posttest:"cat ./coverage/sdk/lcov.info | coveralls",prepublishOnly:"npm run test; npm run tsc; npm run bundle-dts; npm run build","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"^2.45.0","use-deep-compare-effect":"^1.8.1"};var devDependencies={"@mdx-js/mdx":"^1.6.22","@mdx-js/react":"^1.6.22","@react-icons/all-files":"^4.1.0","@rollup/plugin-commonjs":"^18.0.0","@rollup/plugin-json":"^4.1.0","@rollup/plugin-node-resolve":"^11.2.1","@testing-library/dom":"^7.31.0","@testing-library/jest-dom":"^5.14.1","@testing-library/react":"^11.2.7","@testing-library/user-event":"^13.1.8","@types/jest":"^22.2.3","@types/mixpanel-browser":"^2.35.6","@types/react-test-renderer":"^17.0.1","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0",asciidoctor:"^2.2.1","babel-jest":"^26.6.3","babel-preset-gatsby":"^1.10.0","command-line-args":"^5.1.1",coveralls:"^3.1.0","dts-bundle":"0.7.3",eslint:"^7.12.1","eslint-config-airbnb-base":"^14.2.0","eslint-config-prettier":"^6.15.0","eslint-import-resolver-typescript":"^2.3.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","eslint-plugin-react-hooks":"^4.2.0","fs-extra":"^10.0.0",gatsby:"3.13.1","gatsby-plugin-algolia":"^0.22.2","gatsby-plugin-catch-links":"^3.1.0","gatsby-plugin-env-variables":"^2.1.0","gatsby-plugin-intl":"^0.3.3","gatsby-plugin-manifest":"^3.2.0","gatsby-plugin-output":"^0.1.3","gatsby-plugin-sass":"4.1.0","gatsby-plugin-sitemap":"^4.10.0","gatsby-source-filesystem":"3.1.0","gatsby-transformer-asciidoc":"2.1.0","gatsby-transformer-rehype":"2.0.0","gh-pages":"^3.1.0","highlight.js":"^10.6.0","html-to-text":"^8.0.0","identity-obj-proxy":"^3.0.0","istanbul-merge":"^1.1.1",jest:"^26.6.3","jest-puppeteer":"^4.4.0",jsdom:"^17.0.0","node-sass":"^4.0.0",prettier:"2.1.2",puppeteer:"^7.0.1",react:"^16.14.0","react-dom":"^16.14.0","react-resizable":"^1.11.0","react-resize-detector":"^6.6.0","react-test-renderer":"^17.0.2","react-use-flexsearch":"^0.1.1",rollup:"2.30.0","rollup-plugin-typescript2":"0.27.3","ts-jest":"^26.5.5","ts-loader":"8.0.4",typedoc:"0.21.6","typedoc-neo-theme":"^1.1.0","typedoc-plugin-toc-group":"0.0.5",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4"};var author="ThoughtSpot";var email="support@thoughtspot.com";var license="ThoughtSpot Development Tools End User License Agreement";var directories={lib:"lib"};var repository={type:"git",url:"git+https://github.com/thoughtspot/visual-embed-sdk.git"};var publishConfig={registry:"https://registry.npmjs.org"};var keywords=["thoughtspot","everywhere","embed","sdk","analytics"];var bugs={url:"https://github.com/thoughtspot/visual-embed-sdk/issues"};var homepage="https://github.com/thoughtspot/visual-embed-sdk#readme";var globals={window:{}};var pkgInfo = {name:name,version:version,description:description,module:module,main:main,types:types,files:files,exports:exports$1,typesVersions:typesVersions,scripts:scripts,peerDependencies:peerDependencies,dependencies:dependencies,devDependencies:devDependencies,author:author,email:email,license:license,directories:directories,repository:repository,publishConfig:publishConfig,keywords:keywords,bugs:bugs,homepage:homepage,globals:globals};
9397
9424
 
9398
9425
  /**
9399
9426
  * Copyright (c) 2022
@@ -9657,7 +9684,7 @@
9657
9684
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9658
9685
  return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9659
9686
  if (!isLoggedIn) {
9660
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9687
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9661
9688
  return;
9662
9689
  }
9663
9690
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
@@ -9700,8 +9727,7 @@
9700
9727
  this.iFrame.addEventListener('error', () => {
9701
9728
  nextInQueue();
9702
9729
  });
9703
- this.el.innerHTML = '';
9704
- this.el.appendChild(this.iFrame);
9730
+ this.insertIntoDOM(this.iFrame);
9705
9731
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
9706
9732
  if (prefetchIframe.length) {
9707
9733
  prefetchIframe.forEach((el) => {
@@ -9711,12 +9737,30 @@
9711
9737
  this.subscribeToEvents();
9712
9738
  }).catch((error) => {
9713
9739
  nextInQueue();
9714
- uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9715
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9740
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, { error: JSON.stringify(error) });
9741
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9716
9742
  this.handleError(error);
9717
9743
  });
9718
9744
  });
9719
9745
  }
9746
+ insertIntoDOM(child) {
9747
+ if (this.viewConfig.insertAsSibling) {
9748
+ if (typeof child === 'string') {
9749
+ const div = document.createElement('div');
9750
+ div.innerHTML = child;
9751
+ // eslint-disable-next-line no-param-reassign
9752
+ child = div;
9753
+ }
9754
+ this.el.parentElement.insertBefore(child, this.el.nextSibling);
9755
+ }
9756
+ else if (typeof child === 'string') {
9757
+ this.el.innerHTML = child;
9758
+ }
9759
+ else {
9760
+ this.el.innerHTML = '';
9761
+ this.el.appendChild(child);
9762
+ }
9763
+ }
9720
9764
  /**
9721
9765
  * Sets the height of the iframe
9722
9766
  * @param height The height in pixels
@@ -9902,6 +9946,7 @@
9902
9946
  // @override
9903
9947
  on(messageType, callback, options = { start: false }) {
9904
9948
  const eventType = this.getCompatibleEventType(messageType);
9949
+ uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_ON}-${messageType}`);
9905
9950
  return super.on(eventType, callback, options);
9906
9951
  }
9907
9952
  }