@thoughtspot/visual-embed-sdk 1.32.7 → 1.32.8

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 (48) hide show
  1. package/cjs/package.json +3 -3
  2. package/cjs/src/css-variables.d.ts +18 -3
  3. package/cjs/src/css-variables.d.ts.map +1 -1
  4. package/cjs/src/embed/base.d.ts +34 -32
  5. package/cjs/src/embed/base.d.ts.map +1 -1
  6. package/cjs/src/embed/base.js +34 -32
  7. package/cjs/src/embed/base.js.map +1 -1
  8. package/cjs/src/tokenizedFetch.d.ts.map +1 -1
  9. package/cjs/src/tokenizedFetch.js +5 -1
  10. package/cjs/src/tokenizedFetch.js.map +1 -1
  11. package/cjs/src/types.d.ts +3 -3
  12. package/cjs/src/types.js +3 -3
  13. package/cjs/src/utils/authService/authService.spec.js +3 -1
  14. package/cjs/src/utils/authService/authService.spec.js.map +1 -1
  15. package/dist/src/css-variables.d.ts +18 -3
  16. package/dist/src/css-variables.d.ts.map +1 -1
  17. package/dist/src/embed/base.d.ts +34 -32
  18. package/dist/src/embed/base.d.ts.map +1 -1
  19. package/dist/src/tokenizedFetch.d.ts.map +1 -1
  20. package/dist/src/types.d.ts +3 -3
  21. package/dist/tsembed-react.es.js +238 -78
  22. package/dist/tsembed-react.js +238 -78
  23. package/dist/tsembed.es.js +272 -110
  24. package/dist/tsembed.js +272 -110
  25. package/dist/visual-embed-sdk-react-full.d.ts +55 -38
  26. package/dist/visual-embed-sdk-react.d.ts +55 -38
  27. package/dist/visual-embed-sdk.d.ts +55 -38
  28. package/lib/package.json +3 -3
  29. package/lib/src/css-variables.d.ts +18 -3
  30. package/lib/src/css-variables.d.ts.map +1 -1
  31. package/lib/src/embed/base.d.ts +34 -32
  32. package/lib/src/embed/base.d.ts.map +1 -1
  33. package/lib/src/embed/base.js +34 -32
  34. package/lib/src/embed/base.js.map +1 -1
  35. package/lib/src/tokenizedFetch.d.ts.map +1 -1
  36. package/lib/src/tokenizedFetch.js +5 -1
  37. package/lib/src/tokenizedFetch.js.map +1 -1
  38. package/lib/src/types.d.ts +3 -3
  39. package/lib/src/types.js +3 -3
  40. package/lib/src/utils/authService/authService.spec.js +3 -1
  41. package/lib/src/utils/authService/authService.spec.js.map +1 -1
  42. package/lib/src/visual-embed-sdk.d.ts +55 -38
  43. package/package.json +3 -3
  44. package/src/css-variables.ts +21 -3
  45. package/src/embed/base.ts +34 -32
  46. package/src/tokenizedFetch.ts +5 -1
  47. package/src/types.ts +3 -3
  48. package/src/utils/authService/authService.spec.ts +3 -1
@@ -2090,8 +2090,8 @@ export declare enum EmbedEvent {
2090
2090
  * Prerequisite: Set isOnBeforeGetVizDataInterceptEnabled : true
2091
2091
  * for this embed event to get emitted.
2092
2092
  *
2093
- * Parameter: payload
2094
- * Parameter: responder
2093
+ * @param: payload
2094
+ * @param: responder
2095
2095
  * Contains elements that lets developers define whether ThoughtSpot
2096
2096
  * will run the search or not, and if not, which error message to provide.
2097
2097
  *
@@ -2103,6 +2103,7 @@ export declare enum EmbedEvent {
2103
2103
  *
2104
2104
  * @version SDK : 1.29.0 | Thoughtspot : 10.2.0.cl
2105
2105
  *
2106
+ * @example
2106
2107
  *```js
2107
2108
  * .on(EmbedEvent.OnBeforeGetVizDataIntercept,
2108
2109
  * (payload, responder) => {
@@ -2138,7 +2139,6 @@ export declare enum EmbedEvent {
2138
2139
  * }})
2139
2140
  * })
2140
2141
  *```
2141
- *
2142
2142
  */
2143
2143
  OnBeforeGetVizDataIntercept = "onBeforeGetVizDataIntercept",
2144
2144
  /**
@@ -1620,8 +1620,8 @@ var EmbedEvent;
1620
1620
  * Prerequisite: Set isOnBeforeGetVizDataInterceptEnabled : true
1621
1621
  * for this embed event to get emitted.
1622
1622
  *
1623
- * Parameter: payload
1624
- * Parameter: responder
1623
+ * @param: payload
1624
+ * @param: responder
1625
1625
  * Contains elements that lets developers define whether ThoughtSpot
1626
1626
  * will run the search or not, and if not, which error message to provide.
1627
1627
  *
@@ -1633,6 +1633,7 @@ var EmbedEvent;
1633
1633
  *
1634
1634
  * @version SDK : 1.29.0 | Thoughtspot : 10.2.0.cl
1635
1635
  *
1636
+ * @example
1636
1637
  *```js
1637
1638
  * .on(EmbedEvent.OnBeforeGetVizDataIntercept,
1638
1639
  * (payload, responder) => {
@@ -1668,7 +1669,6 @@ var EmbedEvent;
1668
1669
  * }})
1669
1670
  * })
1670
1671
  *```
1671
- *
1672
1672
  */
1673
1673
  EmbedEvent["OnBeforeGetVizDataIntercept"] = "onBeforeGetVizDataIntercept";
1674
1674
  /**
@@ -6309,7 +6309,11 @@ const getEmbedConfig = () => config;
6309
6309
  const tokenizedFetch = async (input, init) => {
6310
6310
  const embedConfig = getEmbedConfig();
6311
6311
  if (embedConfig.authType !== AuthType.TrustedAuthTokenCookieless) {
6312
- return fetch(input, init);
6312
+ return fetch(input, {
6313
+ // ensure cookies are included for the non cookie-less api calls.
6314
+ credentials: 'include',
6315
+ ...init,
6316
+ });
6313
6317
  }
6314
6318
  const req = new Request(input, init);
6315
6319
  const authToken = await getAuthenticationToken(embedConfig);
@@ -6976,7 +6980,7 @@ const DEFAULT_EMBED_HEIGHT = '100%';
6976
6980
 
6977
6981
  var Config = {
6978
6982
  DEBUG: false,
6979
- LIB_VERSION: '2.45.0'
6983
+ LIB_VERSION: '2.47.0'
6980
6984
  };
6981
6985
 
6982
6986
  // since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
@@ -7806,20 +7810,24 @@ _.utf8Encode = function(string) {
7806
7810
 
7807
7811
  _.UUID = (function() {
7808
7812
 
7809
- // Time/ticks information
7810
- // 1*new Date() is a cross browser version of Date.now()
7813
+ // Time-based entropy
7811
7814
  var T = function() {
7812
- var d = 1 * new Date(),
7813
- i = 0;
7814
-
7815
- // this while loop figures how many browser ticks go by
7816
- // before 1*new Date() returns a new number, ie the amount
7817
- // of ticks that go by per millisecond
7818
- while (d == 1 * new Date()) {
7819
- i++;
7815
+ var time = 1 * new Date(); // cross-browser version of Date.now()
7816
+ var ticks;
7817
+ if (window$1.performance && window$1.performance.now) {
7818
+ ticks = window$1.performance.now();
7819
+ } else {
7820
+ // fall back to busy loop
7821
+ ticks = 0;
7822
+
7823
+ // this while loop figures how many browser ticks go by
7824
+ // before 1*new Date() returns a new number, ie the amount
7825
+ // of ticks that go by per millisecond
7826
+ while (time == 1 * new Date()) {
7827
+ ticks++;
7828
+ }
7820
7829
  }
7821
-
7822
- return d.toString(16) + i.toString(16);
7830
+ return time.toString(16) + Math.floor(ticks).toString(16);
7823
7831
  };
7824
7832
 
7825
7833
  // Math.Random entropy
@@ -8386,21 +8394,42 @@ _.dom_query = (function() {
8386
8394
  };
8387
8395
  })();
8388
8396
 
8397
+ var CAMPAIGN_KEYWORDS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'];
8398
+ var CLICK_IDS = ['dclid', 'fbclid', 'gclid', 'ko_click_id', 'li_fat_id', 'msclkid', 'ttclid', 'twclid', 'wbraid'];
8399
+
8389
8400
  _.info = {
8390
- campaignParams: function() {
8391
- var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' '),
8392
- kw = '',
8401
+ campaignParams: function(default_value) {
8402
+ var kw = '',
8393
8403
  params = {};
8394
- _.each(campaign_keywords, function(kwkey) {
8404
+ _.each(CAMPAIGN_KEYWORDS, function(kwkey) {
8395
8405
  kw = _.getQueryParam(document$1.URL, kwkey);
8396
8406
  if (kw.length) {
8397
8407
  params[kwkey] = kw;
8408
+ } else if (default_value !== undefined) {
8409
+ params[kwkey] = default_value;
8410
+ }
8411
+ });
8412
+
8413
+ return params;
8414
+ },
8415
+
8416
+ clickParams: function() {
8417
+ var id = '',
8418
+ params = {};
8419
+ _.each(CLICK_IDS, function(idkey) {
8420
+ id = _.getQueryParam(document$1.URL, idkey);
8421
+ if (id.length) {
8422
+ params[idkey] = id;
8398
8423
  }
8399
8424
  });
8400
8425
 
8401
8426
  return params;
8402
8427
  },
8403
8428
 
8429
+ marketingParams: function() {
8430
+ return _.extend(_.info.campaignParams(), _.info.clickParams());
8431
+ },
8432
+
8404
8433
  searchEngine: function(referrer) {
8405
8434
  if (referrer.search('https?://(.*)google.([^/?]*)') === 0) {
8406
8435
  return 'google';
@@ -8597,12 +8626,13 @@ _.info = {
8597
8626
  });
8598
8627
  },
8599
8628
 
8600
- pageviewInfo: function(page) {
8629
+ mpPageViewProperties: function() {
8601
8630
  return _.strip_empty_properties({
8602
- 'mp_page': page,
8603
- 'mp_referrer': document$1.referrer,
8604
- 'mp_browser': _.info.browser(userAgent, navigator.vendor, windowOpera),
8605
- 'mp_platform': _.info.os()
8631
+ 'current_page_title': document$1.title,
8632
+ 'current_domain': window$1.location.hostname,
8633
+ 'current_url_path': window$1.location.pathname,
8634
+ 'current_url_protocol': window$1.location.protocol,
8635
+ 'current_url_search': window$1.location.search
8606
8636
  });
8607
8637
  }
8608
8638
  };
@@ -9269,6 +9299,9 @@ var RequestBatcher = function(storageKey, options) {
9269
9299
 
9270
9300
  this.stopped = !this.libConfig['batch_autostart'];
9271
9301
  this.consecutiveRemovalFailures = 0;
9302
+
9303
+ // extra client-side dedupe
9304
+ this.itemIdsSentSuccessfully = {};
9272
9305
  };
9273
9306
 
9274
9307
  /**
@@ -9361,7 +9394,34 @@ RequestBatcher.prototype.flush = function(options) {
9361
9394
  payload = this.beforeSendHook(payload);
9362
9395
  }
9363
9396
  if (payload) {
9364
- dataForRequest.push(payload);
9397
+ // mp_sent_by_lib_version prop captures which lib version actually
9398
+ // sends each event (regardless of which version originally queued
9399
+ // it for sending)
9400
+ if (payload['event'] && payload['properties']) {
9401
+ payload['properties'] = _.extend(
9402
+ {},
9403
+ payload['properties'],
9404
+ {'mp_sent_by_lib_version': Config.LIB_VERSION}
9405
+ );
9406
+ }
9407
+ var addPayload = true;
9408
+ var itemId = item['id'];
9409
+ if (itemId) {
9410
+ if ((this.itemIdsSentSuccessfully[itemId] || 0) > 5) {
9411
+ this.reportError('[dupe] item ID sent too many times, not sending', {
9412
+ item: item,
9413
+ batchSize: batch.length,
9414
+ timesSent: this.itemIdsSentSuccessfully[itemId]
9415
+ });
9416
+ addPayload = false;
9417
+ }
9418
+ } else {
9419
+ this.reportError('[dupe] found item with no ID', {item: item});
9420
+ }
9421
+
9422
+ if (addPayload) {
9423
+ dataForRequest.push(payload);
9424
+ }
9365
9425
  }
9366
9426
  transformedItems[item['id']] = payload;
9367
9427
  }, this);
@@ -9444,6 +9504,24 @@ RequestBatcher.prototype.flush = function(options) {
9444
9504
  }
9445
9505
  }, this)
9446
9506
  );
9507
+
9508
+ // client-side dedupe
9509
+ _.each(batch, _.bind(function(item) {
9510
+ var itemId = item['id'];
9511
+ if (itemId) {
9512
+ this.itemIdsSentSuccessfully[itemId] = this.itemIdsSentSuccessfully[itemId] || 0;
9513
+ this.itemIdsSentSuccessfully[itemId]++;
9514
+ if (this.itemIdsSentSuccessfully[itemId] > 5) {
9515
+ this.reportError('[dupe] item ID sent too many times', {
9516
+ item: item,
9517
+ batchSize: batch.length,
9518
+ timesSent: this.itemIdsSentSuccessfully[itemId]
9519
+ });
9520
+ }
9521
+ } else {
9522
+ this.reportError('[dupe] found item with no ID while removing', {item: item});
9523
+ }
9524
+ }, this));
9447
9525
  }
9448
9526
 
9449
9527
  } catch(err) {
@@ -10289,24 +10367,25 @@ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name
10289
10367
  });
10290
10368
 
10291
10369
  /*
10292
- * Record that you have charged the current user a certain amount
10293
- * of money. Charges recorded with track_charge() will appear in the
10294
- * Mixpanel revenue report.
10295
- *
10296
- * ### Usage:
10297
- *
10298
- * // charge a user $50
10299
- * mixpanel.people.track_charge(50);
10300
- *
10301
- * // charge a user $30.50 on the 2nd of january
10302
- * mixpanel.people.track_charge(30.50, {
10303
- * '$time': new Date('jan 1 2012')
10304
- * });
10305
- *
10306
- * @param {Number} amount The amount of money charged to the current user
10307
- * @param {Object} [properties] An associative array of properties associated with the charge
10308
- * @param {Function} [callback] If provided, the callback will be called when the server responds
10309
- */
10370
+ * Record that you have charged the current user a certain amount
10371
+ * of money. Charges recorded with track_charge() will appear in the
10372
+ * Mixpanel revenue report.
10373
+ *
10374
+ * ### Usage:
10375
+ *
10376
+ * // charge a user $50
10377
+ * mixpanel.people.track_charge(50);
10378
+ *
10379
+ * // charge a user $30.50 on the 2nd of january
10380
+ * mixpanel.people.track_charge(30.50, {
10381
+ * '$time': new Date('jan 1 2012')
10382
+ * });
10383
+ *
10384
+ * @param {Number} amount The amount of money charged to the current user
10385
+ * @param {Object} [properties] An associative array of properties associated with the charge
10386
+ * @param {Function} [callback] If provided, the callback will be called when the server responds
10387
+ * @deprecated
10388
+ */
10310
10389
  MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
10311
10390
  if (!_.isNumber(amount)) {
10312
10391
  amount = parseFloat(amount);
@@ -10322,15 +10401,16 @@ MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(am
10322
10401
  });
10323
10402
 
10324
10403
  /*
10325
- * Permanently clear all revenue report transactions from the
10326
- * current user's people analytics profile.
10327
- *
10328
- * ### Usage:
10329
- *
10330
- * mixpanel.people.clear_charges();
10331
- *
10332
- * @param {Function} [callback] If provided, the callback will be called after tracking the event.
10333
- */
10404
+ * Permanently clear all revenue report transactions from the
10405
+ * current user's people analytics profile.
10406
+ *
10407
+ * ### Usage:
10408
+ *
10409
+ * mixpanel.people.clear_charges();
10410
+ *
10411
+ * @param {Function} [callback] If provided, the callback will be called after tracking the event.
10412
+ * @deprecated
10413
+ */
10334
10414
  MixpanelPeople.prototype.clear_charges = function(callback) {
10335
10415
  return this.set('$transactions', [], callback);
10336
10416
  };
@@ -10730,13 +10810,6 @@ MixpanelPersistence.prototype.unregister = function(prop) {
10730
10810
  }
10731
10811
  };
10732
10812
 
10733
- MixpanelPersistence.prototype.update_campaign_params = function() {
10734
- if (!this.campaign_params_saved) {
10735
- this.register_once(_.info.campaignParams());
10736
- this.campaign_params_saved = true;
10737
- }
10738
- };
10739
-
10740
10813
  MixpanelPersistence.prototype.update_search_keyword = function(referrer) {
10741
10814
  this.register(_.info.searchInfo(referrer));
10742
10815
  };
@@ -11019,6 +11092,7 @@ var NOOP_FUNC = function() {};
11019
11092
  /** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
11020
11093
  /** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
11021
11094
  /** @const */ var PAYLOAD_TYPE_JSON = 'json';
11095
+ /** @const */ var DEVICE_ID_PREFIX = '$device:';
11022
11096
 
11023
11097
 
11024
11098
  /*
@@ -11060,6 +11134,9 @@ var DEFAULT_CONFIG = {
11060
11134
  'cookie_domain': '',
11061
11135
  'cookie_name': '',
11062
11136
  'loaded': NOOP_FUNC,
11137
+ 'track_marketing': true,
11138
+ 'track_pageview': false,
11139
+ 'skip_first_touch_marketing': false,
11063
11140
  'store_google': true,
11064
11141
  'save_referrer': true,
11065
11142
  'test': false,
@@ -11126,6 +11203,25 @@ var create_mplib = function(token, config, name) {
11126
11203
  instance['people'] = new MixpanelPeople();
11127
11204
  instance['people']._init(instance);
11128
11205
 
11206
+ if (!instance.get_config('skip_first_touch_marketing')) {
11207
+ // We need null UTM params in the object because
11208
+ // UTM parameters act as a tuple. If any UTM param
11209
+ // is present, then we set all UTM params including
11210
+ // empty ones together
11211
+ var utm_params = _.info.campaignParams(null);
11212
+ var initial_utm_params = {};
11213
+ var has_utm = false;
11214
+ _.each(utm_params, function(utm_value, utm_key) {
11215
+ initial_utm_params['initial_' + utm_key] = utm_value;
11216
+ if (utm_value) {
11217
+ has_utm = true;
11218
+ }
11219
+ });
11220
+ if (has_utm) {
11221
+ instance['people'].set_once(initial_utm_params);
11222
+ }
11223
+ }
11224
+
11129
11225
  // if any instance on the page has debug = true, we set the
11130
11226
  // global debug to be true
11131
11227
  Config.DEBUG = Config.DEBUG || instance.get_config('debug');
@@ -11157,7 +11253,7 @@ var create_mplib = function(token, config, name) {
11157
11253
  * mixpanel.library_name.track(...);
11158
11254
  *
11159
11255
  * @param {String} token Your Mixpanel API token
11160
- * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/8b2e1f7b/src/mixpanel-core.js#L87-L110">See a list of default config options</a>.
11256
+ * @param {Object} [config] A dictionary of config options to override. <a href="https://github.com/mixpanel/mixpanel-js/blob/v2.46.0/src/mixpanel-core.js#L88-L127">See a list of default config options</a>.
11161
11257
  * @param {String} [name] The name for the new mixpanel instance that you want created
11162
11258
  */
11163
11259
  MixpanelLib.prototype.init = function (token, config, name) {
@@ -11195,7 +11291,7 @@ MixpanelLib.prototype._init = function(token, config, name) {
11195
11291
  // default to JSON payload for standard mixpanel.com API hosts
11196
11292
  if (!('api_payload_format' in config)) {
11197
11293
  var api_host = config['api_host'] || DEFAULT_CONFIG['api_host'];
11198
- if (api_host.match(/\.mixpanel\.com$/)) {
11294
+ if (api_host.match(/\.mixpanel\.com/)) {
11199
11295
  variable_features['api_payload_format'] = PAYLOAD_TYPE_JSON;
11200
11296
  }
11201
11297
  }
@@ -11266,10 +11362,14 @@ MixpanelLib.prototype._init = function(token, config, name) {
11266
11362
  // or the device id if something was already stored
11267
11363
  // in the persitence
11268
11364
  this.register_once({
11269
- 'distinct_id': uuid,
11365
+ 'distinct_id': DEVICE_ID_PREFIX + uuid,
11270
11366
  '$device_id': uuid
11271
11367
  }, '');
11272
11368
  }
11369
+
11370
+ if (this.get_config('track_pageview')) {
11371
+ this.track_pageview();
11372
+ }
11273
11373
  };
11274
11374
 
11275
11375
  // Private methods
@@ -11283,7 +11383,7 @@ MixpanelLib.prototype._loaded = function() {
11283
11383
  MixpanelLib.prototype._set_default_superprops = function() {
11284
11384
  this['persistence'].update_search_keyword(document$1.referrer);
11285
11385
  if (this.get_config('store_google')) {
11286
- this['persistence'].update_campaign_params();
11386
+ this.register(_.info.campaignParams(), {persistent: false});
11287
11387
  }
11288
11388
  if (this.get_config('save_referrer')) {
11289
11389
  this['persistence'].update_referrer_info(document$1.referrer);
@@ -11765,6 +11865,10 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
11765
11865
 
11766
11866
  this._set_default_superprops();
11767
11867
 
11868
+ var marketing_properties = this.get_config('track_marketing')
11869
+ ? _.info.marketingParams()
11870
+ : {};
11871
+
11768
11872
  // note: extend writes to the first object, so lets make sure we
11769
11873
  // don't write to the persistence properties object and info
11770
11874
  // properties object by passing in a new object
@@ -11773,6 +11877,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
11773
11877
  properties = _.extend(
11774
11878
  {},
11775
11879
  _.info.properties(),
11880
+ marketing_properties,
11776
11881
  this['persistence'].properties(),
11777
11882
  this.unpersisted_superprops,
11778
11883
  properties
@@ -11933,17 +12038,54 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
11933
12038
  };
11934
12039
 
11935
12040
  /**
11936
- * Track mp_page_view event. This is now ignored by the server.
12041
+ * Track a default Mixpanel page view event, which includes extra default event properties to
12042
+ * improve page view data. The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
12043
+ * may be turned on for tracking page loads automatically.
11937
12044
  *
11938
- * @param {String} [page] The url of the page to record. If you don't include this, it defaults to the current url.
11939
- * @deprecated
12045
+ * ### Usage
12046
+ *
12047
+ * // track a default $mp_web_page_view event
12048
+ * mixpanel.track_pageview();
12049
+ *
12050
+ * // track a page view event with additional event properties
12051
+ * mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
12052
+ *
12053
+ * // example approach to track page views on different page types as event properties
12054
+ * mixpanel.track_pageview({'page': 'pricing'});
12055
+ * mixpanel.track_pageview({'page': 'homepage'});
12056
+ *
12057
+ * // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
12058
+ * // individual pages on the same site or product. Use cases for custom event_name may be page
12059
+ * // views on different products or internal applications that are considered completely separate
12060
+ * mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
12061
+ *
12062
+ * @param {Object} [properties] An optional set of additional properties to send with the page view event
12063
+ * @param {Object} [options] Page view tracking options
12064
+ * @param {String} [options.event_name] - Alternate name for the tracking event
12065
+ * @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
12066
+ * with the tracking payload sent to the API server is returned; otherwise false.
11940
12067
  */
11941
- MixpanelLib.prototype.track_pageview = function(page) {
11942
- if (_.isUndefined(page)) {
11943
- page = document$1.location.href;
12068
+ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(properties, options) {
12069
+ if (typeof properties !== 'object') {
12070
+ properties = {};
11944
12071
  }
11945
- this.track('mp_page_view', _.info.pageviewInfo(page));
11946
- };
12072
+ options = options || {};
12073
+ var event_name = options['event_name'] || '$mp_web_page_view';
12074
+
12075
+ var default_page_properties = _.extend(
12076
+ _.info.mpPageViewProperties(),
12077
+ _.info.campaignParams(),
12078
+ _.info.clickParams()
12079
+ );
12080
+
12081
+ var event_properties = _.extend(
12082
+ {},
12083
+ default_page_properties,
12084
+ properties
12085
+ );
12086
+
12087
+ return this.track(event_name, event_properties);
12088
+ });
11947
12089
 
11948
12090
  /**
11949
12091
  * Track clicks on a set of document elements. Selector must be a
@@ -12192,7 +12334,15 @@ MixpanelLib.prototype.identify = function(
12192
12334
  // _unset_callback:function A callback to be run if and when the People unset queue is flushed
12193
12335
 
12194
12336
  var previous_distinct_id = this.get_distinct_id();
12195
- this.register({'$user_id': new_distinct_id});
12337
+ if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
12338
+ // we allow the following condition if previous distinct_id is same as new_distinct_id
12339
+ // so that you can force flush people updates for anonymous profiles.
12340
+ if (typeof new_distinct_id === 'string' && new_distinct_id.indexOf(DEVICE_ID_PREFIX) === 0) {
12341
+ this.report_error('distinct_id cannot have $device: prefix');
12342
+ return -1;
12343
+ }
12344
+ this.register({'$user_id': new_distinct_id});
12345
+ }
12196
12346
 
12197
12347
  if (!this.get_property('$device_id')) {
12198
12348
  // The persisted distinct id might not actually be a device id at all
@@ -12233,7 +12383,7 @@ MixpanelLib.prototype.reset = function() {
12233
12383
  this._flags.identify_called = false;
12234
12384
  var uuid = _.UUID();
12235
12385
  this.register_once({
12236
- 'distinct_id': uuid,
12386
+ 'distinct_id': DEVICE_ID_PREFIX + uuid,
12237
12387
  '$device_id': uuid
12238
12388
  }, '');
12239
12389
  };
@@ -12358,8 +12508,8 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
12358
12508
  * // batching or retry mechanisms.
12359
12509
  * api_transport: 'XHR'
12360
12510
  *
12361
- * // turn on request-batching/queueing/retry
12362
- * batch_requests: false,
12511
+ * // request-batching/queueing/retry
12512
+ * batch_requests: true,
12363
12513
  *
12364
12514
  * // maximum number of events/updates to send in a single
12365
12515
  * // network request
@@ -12431,10 +12581,20 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
12431
12581
  * // secure, meaning they will only be transmitted over https
12432
12582
  * secure_cookie: false
12433
12583
  *
12584
+ * // disables enriching user profiles with first touch marketing data
12585
+ * skip_first_touch_marketing: false
12586
+ *
12434
12587
  * // the amount of time track_links will
12435
12588
  * // wait for Mixpanel's servers to respond
12436
12589
  * track_links_timeout: 300
12437
12590
  *
12591
+ * // adds any UTM parameters and click IDs present on the page to any events fired
12592
+ * track_marketing: true
12593
+ *
12594
+ * // enables automatic page view tracking using default page view events through
12595
+ * // the track_pageview() method
12596
+ * track_pageview: false
12597
+ *
12438
12598
  * // if you set upgrade to be true, the library will check for
12439
12599
  * // a cookie from our old js library and import super
12440
12600
  * // properties from it, then the old cookie is deleted
@@ -14048,7 +14208,7 @@ function processTrigger(iFrame, messageType, thoughtSpotHost, data) {
14048
14208
  });
14049
14209
  }
14050
14210
 
14051
- var name="@thoughtspot/visual-embed-sdk";var version="1.32.7";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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.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","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",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","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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/lodash":"^4.17.0","@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","current-git-branch":"^1.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","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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.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","embedded","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,"size-limit":[{path:"dist/tsembed.js",limit:"48 kB"}],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};
14211
+ var name="@thoughtspot/visual-embed-sdk";var version="1.32.8";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/**","cjs/**"];var exports={".":{"import":"./lib/src/index.js",require:"./cjs/src/index.js",types:"./lib/src/index.d.ts"},"./react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"},"./lib/src/react":{"import":"./lib/src/react/all-types-export.js",require:"./cjs/src/react/all-types-export.js",types:"./lib/src/react/all-types-export.d.ts"}};var typesVersions={"*":{react:["./lib/src/react/all-types-export.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","build-and-publish":"npm run build:gatsby && npm run publish","bundle-dts-file":"dts-bundle --name @thoughtspot/visual-embed-sdk --out visual-embed-sdk.d.ts --main lib/src/index.d.ts","bundle-dts":"dts-bundle --name ../../dist/visual-embed-sdk --main lib/src/index.d.ts --outputAsModuleFolder=true","bundle-dts-react":"dts-bundle --name ../../../dist/visual-embed-sdk-react --main lib/src/react/index.d.ts --outputAsModuleFolder=true","bundle-dts-react-full":"dts-bundle --name ../../../dist/visual-embed-sdk-react-full --main lib/src/react/all-types-export.d.ts --outputAsModuleFolder=true",build:"rollup -c",watch:"rollup -cw",docgen:"typedoc --tsconfig tsconfig.json --theme typedoc-theme --json static/typedoc/typedoc.json --disableOutputCheck","test-sdk":"jest -c jest.config.sdk.js --runInBand",test:"npm run test-sdk",posttest:"cat ./coverage/sdk/lcov.info | coveralls","is-publish-allowed":"node scripts/is-publish-allowed.js",prepublishOnly:"npm run is-publish-allowed && npm run test && npm run tsc && npm run bundle-dts-file && npm run bundle-dts && npm run bundle-dts-react && npm run bundle-dts-react-full && npm run build","check-size":"npm run build && size-limit","publish-dev":"npm publish --tag dev","publish-prod":"npm publish --tag latest",dev:"vite -c vite.local.config.ts"};var peerDependencies={react:"> 16.8.0","react-dom":"> 16.8.0"};var dependencies={algoliasearch:"^4.10.5",classnames:"^2.3.1",dompurify:"^2.3.4","eslint-plugin-comment-length":"^0.9.2","eslint-plugin-jsdoc":"^46.9.0",eventemitter3:"^4.0.7","gatsby-plugin-vercel":"^1.0.3","html-react-parser":"^1.4.12",lodash:"^4.17.21","mixpanel-browser":"2.47.0","ts-deepmerge":"^6.0.2",tslib:"^2.5.3","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","@rollup/plugin-replace":"^5.0.2","@size-limit/preset-big-lib":"^8.2.6","@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/lodash":"^4.17.0","@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","current-git-branch":"^1.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","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-fetch-mock":"^3.0.3",jsdom:"^17.0.0","node-sass":"^8.0.0",prettier:"2.1.2",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-plugin-toc-group":"thoughtspot/typedoc-plugin-toc-group",typescript:"^4.9.4","url-search-params-polyfill":"^8.1.0",util:"^0.12.4",vite:"^5.3.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","embedded","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,"size-limit":[{path:"dist/tsembed.js",limit:"49 kB"}],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};
14052
14212
 
14053
14213
  /**
14054
14214
  * Copyright (c) 2022