rudder-sdk-js 1.2.16 → 1.2.19

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 (3) hide show
  1. package/index.d.ts +23 -0
  2. package/index.js +138 -26
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -29,6 +29,26 @@ declare module "rudder-sdk-js" {
29
29
  maxItems?: number;
30
30
  }
31
31
 
32
+ /**
33
+ * Represents the beacon queue options parameter in loadOptions type
34
+ */
35
+ interface beaconQueueOptions {
36
+ // Maximum number of events in storage
37
+ maxItems?: number;
38
+ // Time in milliseconds to flush the queue autometically
39
+ flushQueueInterval?: number;
40
+ }
41
+
42
+ /**
43
+ * Represents the beacon queue options parameter in loadOptions type
44
+ */
45
+ interface cookieConsentManager {
46
+ // OneTrust
47
+ oneTrust?: {
48
+ enabled: boolean;
49
+ };
50
+ }
51
+
32
52
  /**
33
53
  * Represents the options parameter in the load API
34
54
  */
@@ -51,6 +71,9 @@ declare module "rudder-sdk-js" {
51
71
  sendAdblockPage?: boolean;
52
72
  sendAdblockPageOptions?: apiOptions;
53
73
  clientSuppliedCallbacks?: { string: () => void };
74
+ useBeacon?: boolean; // Defaults to false
75
+ beaconQueueOptions?: beaconQueueOptions;
76
+ cookieConsentManager?: cookieConsentManager;
54
77
  }
55
78
 
56
79
  /**
package/index.js CHANGED
@@ -5464,7 +5464,12 @@
5464
5464
  "Post Affiliate Pro": "POST_AFFILIATE_PRO",
5465
5465
  postaffiliatepro: "POST_AFFILIATE_PRO",
5466
5466
  POSTAFFILIATEPRO: "POST_AFFILIATE_PRO",
5467
- POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO"
5467
+ POST_AFFILIATE_PRO: "POST_AFFILIATE_PRO",
5468
+ LaunchDarkly: "LAUNCHDARKLY",
5469
+ Launch_Darkly: "LAUNCHDARKLY",
5470
+ LAUNCHDARKLY: "LAUNCHDARKLY",
5471
+ "Launch Darkly": "LAUNCHDARKLY",
5472
+ launchDarkly: "LAUNCHDARKLY"
5468
5473
  };
5469
5474
 
5470
5475
  // from client native integration name to server identified display name
@@ -5511,7 +5516,8 @@
5511
5516
  QUALTRICS: "Qualtrics",
5512
5517
  SENTRY: "Sentry",
5513
5518
  GOOGLE_OPTIMIZE: "GoogleOptimize",
5514
- POST_AFFILIATE_PRO: "PostAffiliatePro"
5519
+ POST_AFFILIATE_PRO: "PostAffiliatePro",
5520
+ LAUNCHDARKLY: "LaunchDarkly"
5515
5521
  };
5516
5522
 
5517
5523
  // Reserved Keywords for properties/triats
@@ -5555,7 +5561,7 @@
5555
5561
  PRODUCT_REVIEWED: "Product Reviewed"
5556
5562
  }; // Enumeration for integrations supported
5557
5563
 
5558
- var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.16";
5564
+ var CONFIG_URL = "https://api.rudderlabs.com/sourceConfig/?p=npm&v=1.2.19";
5559
5565
  var MAX_WAIT_FOR_INTEGRATION_LOAD = 10000;
5560
5566
  var INTEGRATION_LOAD_CHECK_INTERVAL = 1000;
5561
5567
  /* module.exports = {
@@ -29485,8 +29491,7 @@
29485
29491
  function Hotjar(config) {
29486
29492
  _classCallCheck(this, Hotjar);
29487
29493
 
29488
- this.siteId = config.siteID; // 1549611
29489
-
29494
+ this.siteId = config.siteID;
29490
29495
  this.name = "HOTJAR";
29491
29496
  this._ready = false;
29492
29497
  }
@@ -29494,6 +29499,7 @@
29494
29499
  _createClass(Hotjar, [{
29495
29500
  key: "init",
29496
29501
  value: function init() {
29502
+ logger.debug("===In init Hotjar===");
29497
29503
  window.hotjarSiteId = this.siteId;
29498
29504
 
29499
29505
  (function (h, o, t, j, a, r) {
@@ -29513,11 +29519,11 @@
29513
29519
  })(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv=");
29514
29520
 
29515
29521
  this._ready = true;
29516
- logger.debug("===in init Hotjar===");
29517
29522
  }
29518
29523
  }, {
29519
29524
  key: "identify",
29520
29525
  value: function identify(rudderElement) {
29526
+ logger.debug("===In Hotjar identify===");
29521
29527
  var userId = rudderElement.message.userId || rudderElement.message.anonymousId;
29522
29528
 
29523
29529
  if (!userId) {
@@ -29531,21 +29537,34 @@
29531
29537
  }, {
29532
29538
  key: "track",
29533
29539
  value: function track(rudderElement) {
29534
- logger.debug("[Hotjar] track:: method not supported");
29540
+ logger.debug("===In Hotjar track===");
29541
+ var event = rudderElement.message.event;
29542
+
29543
+ if (!event) {
29544
+ logger.error("Event name not present");
29545
+ return;
29546
+ } // event name must not exceed 750 characters and can only contain alphanumeric, underscores, and dashes.
29547
+ // Ref - https://help.hotjar.com/hc/en-us/articles/4405109971095#the-events-api-call
29548
+
29549
+
29550
+ window.hj("event", event.replace(/\s\s+/g, " ").substring(0, 750).replaceAll(" ", "_"));
29535
29551
  }
29536
29552
  }, {
29537
29553
  key: "page",
29538
- value: function page(rudderElement) {
29554
+ value: function page() {
29555
+ logger.debug("===In Hotjar page===");
29539
29556
  logger.debug("[Hotjar] page:: method not supported");
29540
29557
  }
29541
29558
  }, {
29542
29559
  key: "isLoaded",
29543
29560
  value: function isLoaded() {
29561
+ logger.debug("===In isLoaded Hotjar===");
29544
29562
  return this._ready;
29545
29563
  }
29546
29564
  }, {
29547
29565
  key: "isReady",
29548
29566
  value: function isReady() {
29567
+ logger.debug("===In isReady Hotjar===");
29549
29568
  return this._ready;
29550
29569
  }
29551
29570
  }]);
@@ -34196,6 +34215,100 @@
34196
34215
  return PostAffiliatePro;
34197
34216
  }();
34198
34217
 
34218
+ var createUser = function createUser(message) {
34219
+ var user = {};
34220
+ user.key = message.userId || message.anonymousId;
34221
+ var traits = message.context.traits;
34222
+
34223
+ if (traits.anonymous !== undefined) {
34224
+ user.anonymous = traits.anonymous;
34225
+ }
34226
+
34227
+ if (traits.avatar !== undefined) user.avatar = traits.avatar;
34228
+ if (traits.country !== undefined) user.country = traits.country;
34229
+ if (traits.custom !== undefined) user.custom = traits.custom;
34230
+ if (traits.email !== undefined) user.email = traits.email;
34231
+ if (traits.firstName !== undefined) user.firstName = traits.firstName;
34232
+ if (traits.ip !== undefined) user.ip = traits.ip;
34233
+ if (traits.lastName !== undefined) user.lastName = traits.lastName;
34234
+ if (traits.name !== undefined) user.name = traits.name;
34235
+ if (traits.privateAttributeNames !== undefined) user.privateAttributeNames = traits.privateAttributeNames;
34236
+ if (traits.secondary !== undefined) user.secondary = traits.secondary;
34237
+ return user;
34238
+ };
34239
+
34240
+ var LaunchDarkly = /*#__PURE__*/function () {
34241
+ function LaunchDarkly(config) {
34242
+ _classCallCheck(this, LaunchDarkly);
34243
+
34244
+ this.name = "LaunchDarkly";
34245
+ this.clientSideId = config.clientSideId;
34246
+ }
34247
+
34248
+ _createClass(LaunchDarkly, [{
34249
+ key: "init",
34250
+ value: function init() {
34251
+ logger.debug("===in init LaunchDarkly===");
34252
+
34253
+ if (!this.clientSideId) {
34254
+ logger.error("".concat(this.name, " :: Unable to initialize destination - clientSideId is missing in config"));
34255
+ return;
34256
+ }
34257
+
34258
+ ScriptLoader(null, "https://unpkg.com/launchdarkly-js-client-sdk@2");
34259
+ }
34260
+ }, {
34261
+ key: "isLoaded",
34262
+ value: function isLoaded() {
34263
+ logger.debug("===In isLoaded LaunchDarkly===");
34264
+ return !!window.LDClient;
34265
+ }
34266
+ }, {
34267
+ key: "isReady",
34268
+ value: function isReady() {
34269
+ logger.debug("===In isReady LaunchDarkly===");
34270
+ return this.isLoaded();
34271
+ }
34272
+ }, {
34273
+ key: "identify",
34274
+ value: function identify(rudderElement) {
34275
+ var message = rudderElement.message;
34276
+ window.user = createUser(message);
34277
+
34278
+ if (window.ldclient) {
34279
+ window.ldclient.identify(window.user);
34280
+ } else {
34281
+ window.ldclient = window.LDClient.initialize(this.clientSideId, window.user);
34282
+ }
34283
+ }
34284
+ }, {
34285
+ key: "track",
34286
+ value: function track(rudderElement) {
34287
+ var _rudderElement$messag = rudderElement.message,
34288
+ event = _rudderElement$messag.event,
34289
+ properties = _rudderElement$messag.properties;
34290
+
34291
+ if (window.ldclient) {
34292
+ window.ldclient.track(event, properties);
34293
+ } else logger.error("=== In LaunchDarkly, track is not supported before identify ===");
34294
+ }
34295
+ }, {
34296
+ key: "alias",
34297
+ value: function alias(rudderElement) {
34298
+ var message = rudderElement.message;
34299
+ var newUser = {
34300
+ key: message.userId
34301
+ };
34302
+
34303
+ if (window.ldclient) {
34304
+ window.ldclient.alias(newUser, window.user);
34305
+ } else logger.error("=== In LaunchDarkly, alias is not supported before identify ===");
34306
+ }
34307
+ }]);
34308
+
34309
+ return LaunchDarkly;
34310
+ }();
34311
+
34199
34312
  // (config-plan name, native destination.name , exported integration name(this one below))
34200
34313
 
34201
34314
  var integrations = {
@@ -34242,7 +34355,8 @@
34242
34355
  TVSQUARED: TVSquared,
34243
34356
  VWO: VWO,
34244
34357
  GOOGLE_OPTIMIZE: GoogleOptimize,
34245
- POST_AFFILIATE_PRO: PostAffiliatePro
34358
+ POST_AFFILIATE_PRO: PostAffiliatePro,
34359
+ LAUNCHDARKLY: LaunchDarkly
34246
34360
  };
34247
34361
 
34248
34362
  // Application class
@@ -34252,7 +34366,7 @@
34252
34366
  this.build = "1.0.0";
34253
34367
  this.name = "RudderLabs JavaScript SDK";
34254
34368
  this.namespace = "com.rudderlabs.javascript";
34255
- this.version = "1.2.16";
34369
+ this.version = "1.2.19";
34256
34370
  });
34257
34371
 
34258
34372
  // Library information class
@@ -34260,7 +34374,7 @@
34260
34374
  _classCallCheck(this, RudderLibraryInfo);
34261
34375
 
34262
34376
  this.name = "RudderLabs JavaScript SDK";
34263
- this.version = "1.2.16";
34377
+ this.version = "1.2.19";
34264
34378
  }); // Operating System information class
34265
34379
 
34266
34380
 
@@ -37152,24 +37266,22 @@
37152
37266
  }, this);
37153
37267
  logger.debug("this.clientIntegrations: ", this.clientIntegrations); // intersection of config-plane native sdk destinations with sdk load time destination list
37154
37268
 
37155
- this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations); // Check if cookie consent manager is being set through load options
37269
+ this.clientIntegrations = findAllEnabledDestinations(this.loadOnlyIntegrations, this.clientIntegrations);
37270
+ var cookieConsent; // Call the cookie consent factory to initialize and return the type of cookie
37271
+ // consent being set. For now we only support OneTrust.
37156
37272
 
37157
- if (Object.keys(this.cookieConsentOptions).length) {
37158
- // Call the cookie consent factory to initialise and return the type of cookie
37159
- // consent being set. For now we only support OneTrust.
37160
- try {
37161
- var cookieConsent = CookieConsentFactory.initialize(this.cookieConsentOptions); // If cookie consent object is return we filter according to consents given by user
37162
- // else we do not consider any filtering for cookie consent.
37273
+ try {
37274
+ cookieConsent = CookieConsentFactory.initialize(this.cookieConsentOptions);
37275
+ } catch (e) {
37276
+ logger.error(e);
37277
+ } // If cookie consent object is return we filter according to consents given by user
37278
+ // else we do not consider any filtering for cookie consent.
37163
37279
 
37164
- this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
37165
- return integrations[intg.name] != undefined && (!cookieConsent || // check if cookieconsent object is present and then do filtering
37166
- cookieConsent && cookieConsent.isEnabled(intg.config));
37167
- });
37168
- } catch (e) {
37169
- logger.error(e);
37170
- }
37171
- }
37172
37280
 
37281
+ this.clientIntegrations = this.clientIntegrations.filter(function (intg) {
37282
+ return integrations[intg.name] != undefined && (!cookieConsent || // check if cookie consent object is present and then do filtering
37283
+ cookieConsent && cookieConsent.isEnabled(intg.config));
37284
+ });
37173
37285
  this.init(this.clientIntegrations);
37174
37286
  } catch (error) {
37175
37287
  handleError(error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "1.2.16",
3
+ "version": "1.2.19",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",