@thoughtspot/visual-embed-sdk 1.19.0-alpha.1 → 1.19.0-alpha.3

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 (82) 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.map +1 -1
  10. package/dist/src/mixpanel-service.d.ts +3 -1
  11. package/dist/src/mixpanel-service.d.ts.map +1 -1
  12. package/dist/src/react/index.d.ts.map +1 -1
  13. package/dist/src/react/util.d.ts +1 -1
  14. package/dist/src/react/util.d.ts.map +1 -1
  15. package/dist/src/test/test-utils.d.ts +1 -1
  16. package/dist/src/test/test-utils.d.ts.map +1 -1
  17. package/dist/src/types.d.ts +25 -9
  18. package/dist/src/types.d.ts.map +1 -1
  19. package/dist/src/utils.d.ts +1 -0
  20. package/dist/src/utils.d.ts.map +1 -1
  21. package/dist/tsembed.es.js +118 -67
  22. package/dist/tsembed.js +118 -67
  23. package/lib/package.json +1 -1
  24. package/lib/src/auth.d.ts +21 -1
  25. package/lib/src/auth.d.ts.map +1 -1
  26. package/lib/src/auth.js +66 -12
  27. package/lib/src/auth.js.map +1 -1
  28. package/lib/src/embed/base.d.ts +2 -5
  29. package/lib/src/embed/base.d.ts.map +1 -1
  30. package/lib/src/embed/base.js +8 -36
  31. package/lib/src/embed/base.js.map +1 -1
  32. package/lib/src/embed/base.spec.js +0 -9
  33. package/lib/src/embed/base.spec.js.map +1 -1
  34. package/lib/src/embed/search.d.ts +6 -0
  35. package/lib/src/embed/search.d.ts.map +1 -1
  36. package/lib/src/embed/search.js.map +1 -1
  37. package/lib/src/embed/ts-embed.d.ts +1 -0
  38. package/lib/src/embed/ts-embed.d.ts.map +1 -1
  39. package/lib/src/embed/ts-embed.js +23 -5
  40. package/lib/src/embed/ts-embed.js.map +1 -1
  41. package/lib/src/embed/ts-embed.spec.js +15 -1
  42. package/lib/src/embed/ts-embed.spec.js.map +1 -1
  43. package/lib/src/index.d.ts.map +1 -1
  44. package/lib/src/index.js.map +1 -1
  45. package/lib/src/mixpanel-service.d.ts +3 -1
  46. package/lib/src/mixpanel-service.d.ts.map +1 -1
  47. package/lib/src/mixpanel-service.js +18 -15
  48. package/lib/src/mixpanel-service.js.map +1 -1
  49. package/lib/src/mixpanel-service.spec.js +20 -4
  50. package/lib/src/mixpanel-service.spec.js.map +1 -1
  51. package/lib/src/react/index.d.ts.map +1 -1
  52. package/lib/src/react/index.js +8 -4
  53. package/lib/src/react/index.js.map +1 -1
  54. package/lib/src/react/index.spec.js +3 -3
  55. package/lib/src/react/index.spec.js.map +1 -1
  56. package/lib/src/react/util.d.ts +1 -1
  57. package/lib/src/react/util.d.ts.map +1 -1
  58. package/lib/src/test/test-utils.d.ts +1 -1
  59. package/lib/src/test/test-utils.d.ts.map +1 -1
  60. package/lib/src/types.d.ts +25 -9
  61. package/lib/src/types.d.ts.map +1 -1
  62. package/lib/src/types.js +12 -0
  63. package/lib/src/types.js.map +1 -1
  64. package/lib/src/utils.d.ts +1 -0
  65. package/lib/src/utils.d.ts.map +1 -1
  66. package/lib/src/utils.js +11 -0
  67. package/lib/src/utils.js.map +1 -1
  68. package/lib/src/visual-embed-sdk.d.ts +48 -8
  69. package/package.json +1 -1
  70. package/src/auth.ts +78 -19
  71. package/src/embed/base.spec.ts +0 -10
  72. package/src/embed/base.ts +18 -37
  73. package/src/embed/search.ts +6 -0
  74. package/src/embed/ts-embed.spec.ts +15 -0
  75. package/src/embed/ts-embed.ts +22 -5
  76. package/src/index.ts +1 -1
  77. package/src/mixpanel-service.spec.ts +26 -5
  78. package/src/mixpanel-service.ts +19 -20
  79. package/src/react/index.spec.tsx +3 -7
  80. package/src/react/index.tsx +16 -6
  81. package/src/types.ts +16 -0
  82. package/src/utils.ts +13 -0
@@ -617,6 +617,11 @@ var EmbedEvent;
617
617
  * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
618
618
  */
619
619
  EmbedEvent["CrossFilterChanged"] = "cross-filter-changed";
620
+ /**
621
+ * Emitted when a user right clicks on chart or table
622
+ * @version SDK: 1.21.0 | ThoughtSpot: 9.2.0.cl
623
+ */
624
+ EmbedEvent["VizPointRightClick"] = "vizPointRightClick";
620
625
  })(EmbedEvent || (EmbedEvent = {}));
621
626
  /**
622
627
  * Event types that can be triggered by the host application
@@ -948,6 +953,13 @@ var HostEvent;
948
953
  * @version SDK: 1.19.0 | ThoughtSpot: 9.0.0.cl, 9.0.1-sw
949
954
  */
950
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";
951
963
  })(HostEvent || (HostEvent = {}));
952
964
  /**
953
965
  * The different visual modes that the data sources panel within
@@ -7237,32 +7249,31 @@ const MIXPANEL_EVENT = {
7237
7249
  VISUAL_SDK_RENDER_COMPLETE: 'visual-sdk-render-complete',
7238
7250
  VISUAL_SDK_RENDER_FAILED: 'visual-sdk-render-failed',
7239
7251
  VISUAL_SDK_TRIGGER: 'visual-sdk-trigger',
7252
+ VISUAL_SDK_ON: 'visual-sdk-on',
7240
7253
  VISUAL_SDK_IFRAME_LOAD_PERFORMANCE: 'visual-sdk-iframe-load-performance',
7241
7254
  };
7242
- let isEventCollectorOn = false;
7243
- const eventCollectorQueue = [];
7244
- function setEventCollectorOn() {
7245
- isEventCollectorOn = true;
7246
- }
7247
- function getEventCollectorOnValue() {
7248
- return isEventCollectorOn;
7249
- }
7255
+ let isMixpanelInitialized = false;
7256
+ let eventQueue = [];
7250
7257
  /**
7251
7258
  * Pushes the event with its Property key-value map to mixpanel.
7252
7259
  * @param eventId
7253
7260
  * @param eventProps
7254
7261
  */
7255
- async function uploadMixpanelEvent(eventId, eventProps = {}) {
7256
- if (!getEventCollectorOnValue()) {
7257
- eventCollectorQueue.push({ eventId, eventProps });
7258
- return Promise.resolve();
7262
+ function uploadMixpanelEvent(eventId, eventProps = {}) {
7263
+ if (!isMixpanelInitialized) {
7264
+ eventQueue.push({ eventId, eventProps });
7265
+ return;
7259
7266
  }
7260
- return new Promise(() => mixpanel_cjs.track(eventId, eventProps));
7267
+ mixpanel_cjs.track(eventId, eventProps);
7261
7268
  }
7262
7269
  function emptyQueue() {
7263
- eventCollectorQueue.forEach((event) => {
7270
+ if (!isMixpanelInitialized) {
7271
+ return;
7272
+ }
7273
+ eventQueue.forEach((event) => {
7264
7274
  uploadMixpanelEvent(event.eventId, event.eventProps);
7265
7275
  });
7276
+ eventQueue = [];
7266
7277
  }
7267
7278
  function initMixpanel(sessionInfo) {
7268
7279
  if (!sessionInfo || !sessionInfo.mixpanelToken) {
@@ -7276,7 +7287,7 @@ function initMixpanel(sessionInfo) {
7276
7287
  if (!isPublicCluster) {
7277
7288
  mixpanel_cjs.identify(sessionInfo.userGUID);
7278
7289
  }
7279
- setEventCollectorOn();
7290
+ isMixpanelInitialized = true;
7280
7291
  emptyQueue();
7281
7292
  }
7282
7293
  }
@@ -8847,7 +8858,53 @@ var AuthStatus;
8847
8858
  * Emits when a user logs out
8848
8859
  */
8849
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";
8850
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
+ }
8851
8908
  /**
8852
8909
  * Check if we are logged into the ThoughtSpot cluster
8853
8910
  * @param thoughtSpotHost The ThoughtSpot cluster hostname or IP
@@ -8963,11 +9020,23 @@ const doBasicAuth = async (embedConfig) => {
8963
9020
  return loggedInStatus;
8964
9021
  };
8965
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);
8966
9032
  const containerEl = getDOMNode(triggerContainer);
8967
- containerEl.innerHTML =
8968
- '<button id="ts-auth-btn" class="ts-auth-btn" style="margin: auto;"></button>';
8969
- const authElem = document.getElementById('ts-auth-btn');
8970
- 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
+ }
8971
9040
  samlCompletionPromise =
8972
9041
  samlCompletionPromise ||
8973
9042
  new Promise((resolve, reject) => {
@@ -8978,14 +9047,7 @@ async function samlPopupFlow(ssoURL, triggerContainer, triggerText) {
8978
9047
  }
8979
9048
  });
8980
9049
  });
8981
- authElem.addEventListener('click', () => {
8982
- if (samlAuthWindow === null || samlAuthWindow.closed) {
8983
- samlAuthWindow = window.open(ssoURL, '_blank', 'location=no,height=570,width=520,scrollbars=yes,status=yes');
8984
- }
8985
- else {
8986
- samlAuthWindow.focus();
8987
- }
8988
- }, { once: true });
9050
+ authEE === null || authEE === void 0 ? void 0 : authEE.once(AuthEvent.TRIGGER_SSO_POPUP, openPopup);
8989
9051
  return samlCompletionPromise;
8990
9052
  }
8991
9053
  /**
@@ -9081,35 +9143,6 @@ const CONFIG_DEFAULTS = {
9081
9143
  let authPromise;
9082
9144
  const getEmbedConfig = () => config;
9083
9145
  const getAuthPromise = () => authPromise;
9084
- let authEE;
9085
- function notifyAuthSDKSuccess() {
9086
- if (!authEE) {
9087
- console.error('SDK not initialized');
9088
- return;
9089
- }
9090
- authEE.emit(AuthStatus.SDK_SUCCESS);
9091
- }
9092
- function notifyAuthSuccess() {
9093
- if (!authEE) {
9094
- console.error('SDK not initialized');
9095
- return;
9096
- }
9097
- authEE.emit(AuthStatus.SUCCESS);
9098
- }
9099
- function notifyAuthFailure(failureType) {
9100
- if (!authEE) {
9101
- console.error('SDK not initialized');
9102
- return;
9103
- }
9104
- authEE.emit(AuthStatus.FAILURE, failureType);
9105
- }
9106
- function notifyLogout() {
9107
- if (!authEE) {
9108
- console.error('SDK not initialized');
9109
- return;
9110
- }
9111
- authEE.emit(AuthStatus.LOGOUT);
9112
- }
9113
9146
  /**
9114
9147
  * Perform authentication on the ThoughtSpot app as applicable.
9115
9148
  */
@@ -9173,9 +9206,6 @@ function sanity(embedConfig) {
9173
9206
  throw new Error('Trusted auth should provide either authEndpoint or getAuthToken');
9174
9207
  }
9175
9208
  }
9176
- if (embedConfig.noRedirect && !embedConfig.authTriggerContainer) {
9177
- throw new Error('authTriggerContainer not provided with noRedirect');
9178
- }
9179
9209
  }
9180
9210
  /**
9181
9211
  * Initializes the Visual Embed SDK globally and perform
@@ -9188,14 +9218,15 @@ function sanity(embedConfig) {
9188
9218
  * @version SDK: 1.0.0 | ThoughtSpot ts7.april.cl, 7.2.1
9189
9219
  */
9190
9220
  const init = (embedConfig) => {
9191
- var _a, _b, _c, _d, _e, _f, _g, _h;
9221
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
9192
9222
  sanity(embedConfig);
9193
9223
  config = {
9194
9224
  ...CONFIG_DEFAULTS,
9195
9225
  ...embedConfig,
9196
9226
  thoughtSpotHost: getThoughtSpotHost(embedConfig),
9197
9227
  };
9198
- authEE = new eventemitter3();
9228
+ const authEE = new eventemitter3();
9229
+ setAuthEE(authEE);
9199
9230
  handleAuth();
9200
9231
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_CALLED_INIT, {
9201
9232
  authType: config.authType,
@@ -9204,6 +9235,8 @@ const init = (embedConfig) => {
9204
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,
9205
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) !=
9206
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),
9207
9240
  });
9208
9241
  if (config.callPrefetch) {
9209
9242
  prefetch(config.thoughtSpotHost);
@@ -9422,7 +9455,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
9422
9455
  });
9423
9456
  }
9424
9457
 
9425
- var name="@thoughtspot/visual-embed-sdk";var version="1.19.0-alpha.1";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.3";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};
9426
9459
 
9427
9460
  /**
9428
9461
  * Copyright (c) 2022
@@ -9686,7 +9719,7 @@ class TsEmbed {
9686
9719
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_START);
9687
9720
  return (_a = getAuthPromise()) === null || _a === void 0 ? void 0 : _a.then((isLoggedIn) => {
9688
9721
  if (!isLoggedIn) {
9689
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9722
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9690
9723
  return;
9691
9724
  }
9692
9725
  uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_COMPLETE);
@@ -9729,8 +9762,7 @@ class TsEmbed {
9729
9762
  this.iFrame.addEventListener('error', () => {
9730
9763
  nextInQueue();
9731
9764
  });
9732
- this.el.innerHTML = '';
9733
- this.el.appendChild(this.iFrame);
9765
+ this.insertIntoDOM(this.iFrame);
9734
9766
  const prefetchIframe = document.querySelectorAll('.prefetchIframe');
9735
9767
  if (prefetchIframe.length) {
9736
9768
  prefetchIframe.forEach((el) => {
@@ -9740,12 +9772,30 @@ class TsEmbed {
9740
9772
  this.subscribeToEvents();
9741
9773
  }).catch((error) => {
9742
9774
  nextInQueue();
9743
- uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED);
9744
- this.el.innerHTML = this.embedConfig.loginFailedMessage;
9775
+ uploadMixpanelEvent(MIXPANEL_EVENT.VISUAL_SDK_RENDER_FAILED, { error: JSON.stringify(error) });
9776
+ this.insertIntoDOM(this.embedConfig.loginFailedMessage);
9745
9777
  this.handleError(error);
9746
9778
  });
9747
9779
  });
9748
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
+ }
9749
9799
  /**
9750
9800
  * Sets the height of the iframe
9751
9801
  * @param height The height in pixels
@@ -9931,6 +9981,7 @@ class V1Embed extends TsEmbed {
9931
9981
  // @override
9932
9982
  on(messageType, callback, options = { start: false }) {
9933
9983
  const eventType = this.getCompatibleEventType(messageType);
9984
+ uploadMixpanelEvent(`${MIXPANEL_EVENT.VISUAL_SDK_ON}-${messageType}`);
9934
9985
  return super.on(eventType, callback, options);
9935
9986
  }
9936
9987
  }