rudder-sdk-js 2.32.0 → 2.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,13 +1,24 @@
1
1
  {
2
2
  "name": "rudder-sdk-js",
3
- "version": "2.32.0",
3
+ "version": "2.33.0",
4
4
  "description": "RudderStack Javascript SDK",
5
5
  "main": "index.js",
6
6
  "module": "index.es.js",
7
7
  "exports": {
8
- ".": "./index.js",
9
- "./service-worker": "./service-worker/index.js",
10
- "./service-worker/index.es": "./service-worker/index.es.js"
8
+ ".": {
9
+ "types": "./index.d.ts",
10
+ "import": "./index.es.js",
11
+ "require": "./index.js"
12
+ },
13
+ "./service-worker": {
14
+ "types": "./service-worker/index.d.ts",
15
+ "import": "./service-worker/index.es.js",
16
+ "require": "./service-worker/index.js"
17
+ },
18
+ "./service-worker/index.es": {
19
+ "types": "./service-worker/index.d.ts",
20
+ "import": "./service-worker/index.es.js"
21
+ }
11
22
  },
12
23
  "typesVersions": {
13
24
  "*": {
@@ -29,17 +29,36 @@ export interface integrationOptions {
29
29
  [index: string]: boolean | apiObject | undefined;
30
30
  }
31
31
 
32
+ /**
33
+ * Represents the first argument object for flushOverride method
34
+ */
35
+ export type FlushOverrideMessage = {
36
+ host: string;
37
+ writeKey: string;
38
+ data: {
39
+ batch: Object[],
40
+ sentAt: string;
41
+ };
42
+ headers: Record<string, string>;
43
+ reqTimeout: number;
44
+ flush: (callback?: apiCallback) => void;
45
+ done: (error?: Error) => void;
46
+ isErrorRetryable: (error: Error) => boolean;
47
+ }
48
+
32
49
  /**
33
50
  * Represents the constructor options object
34
51
  * Example usages:
35
52
  * constructorOptions { flushAt: 20, "flushInterval": 20000, "enable": true, "maxInternalQueueSize":20000, "logLevel": "info"/"debug"/"error"/"silly"/"off"}
36
53
  */
37
54
  export interface constructorOptions {
55
+ timeout?: number;
38
56
  flushAt?: number;
39
57
  flushInterval?: number;
40
58
  enable?: boolean;
41
59
  maxInternalQueueSize?: number;
42
60
  logLevel?: 'silly' | 'debug' | 'info' | 'error' | 'off';
61
+ flushOverride?: (message: FlushOverrideMessage) => void;
43
62
  }
44
63
 
45
64
  /**
@@ -566,7 +566,7 @@ var platform = 'browser';
566
566
  var browser = true;
567
567
  var env = {};
568
568
  var argv = [];
569
- var version$2 = ''; // empty string to avoid regexp issues
569
+ var version$1 = ''; // empty string to avoid regexp issues
570
570
  var versions = {};
571
571
  var release = {};
572
572
  var config = {};
@@ -630,7 +630,7 @@ var browser$1 = {
630
630
  browser: browser,
631
631
  env: env,
632
632
  argv: argv,
633
- version: version$2,
633
+ version: version$1,
634
634
  versions: versions,
635
635
  on: on,
636
636
  addListener: addListener,
@@ -2802,7 +2802,7 @@ function formatValue(ctx, value, recurseTimes) {
2802
2802
  // Check that value is an object with an inspect function on it
2803
2803
  if (ctx.customInspect &&
2804
2804
  value &&
2805
- isFunction$1(value.inspect) &&
2805
+ isFunction$2(value.inspect) &&
2806
2806
  // Filter out the util module, it's inspect function is special
2807
2807
  value.inspect !== inspect$1 &&
2808
2808
  // Also filter out any prototype objects using the circular check.
@@ -2837,7 +2837,7 @@ function formatValue(ctx, value, recurseTimes) {
2837
2837
 
2838
2838
  // Some type of object without properties can be shortcutted.
2839
2839
  if (keys.length === 0) {
2840
- if (isFunction$1(value)) {
2840
+ if (isFunction$2(value)) {
2841
2841
  var name = value.name ? ': ' + value.name : '';
2842
2842
  return ctx.stylize('[Function' + name + ']', 'special');
2843
2843
  }
@@ -2861,7 +2861,7 @@ function formatValue(ctx, value, recurseTimes) {
2861
2861
  }
2862
2862
 
2863
2863
  // Make functions say that they are functions
2864
- if (isFunction$1(value)) {
2864
+ if (isFunction$2(value)) {
2865
2865
  var n = value.name ? ': ' + value.name : '';
2866
2866
  base = ' [Function' + n + ']';
2867
2867
  }
@@ -3075,7 +3075,7 @@ function isError(e) {
3075
3075
  (objectToString$1(e) === '[object Error]' || e instanceof Error);
3076
3076
  }
3077
3077
 
3078
- function isFunction$1(arg) {
3078
+ function isFunction$2(arg) {
3079
3079
  return typeof arg === 'function';
3080
3080
  }
3081
3081
 
@@ -3190,7 +3190,7 @@ function assert$1(value, message) {
3190
3190
  var regex = /\s*function\s+([^\(\s]*)\s*/;
3191
3191
  // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
3192
3192
  function getName(func) {
3193
- if (!isFunction$1(func)) {
3193
+ if (!isFunction$2(func)) {
3194
3194
  return;
3195
3195
  }
3196
3196
  if (functionsHaveNames()) {
@@ -3248,7 +3248,7 @@ function truncate(s, n) {
3248
3248
  }
3249
3249
  }
3250
3250
  function inspect(something) {
3251
- if (functionsHaveNames() || !isFunction$1(something)) {
3251
+ if (functionsHaveNames() || !isFunction$2(something)) {
3252
3252
  return inspect$1(something);
3253
3253
  }
3254
3254
  var rawname = getName(something);
@@ -3702,17 +3702,17 @@ return function(thing){var str=toString.call(thing);return cache[str]||(cache[st
3702
3702
  *
3703
3703
  * @param {Object} val The value to test
3704
3704
  * @returns {boolean} True if value is a Function, otherwise false
3705
- */function isFunction(val){return toString.call(val)==='[object Function]';}/**
3705
+ */function isFunction$1(val){return toString.call(val)==='[object Function]';}/**
3706
3706
  * Determine if a value is a Stream
3707
3707
  *
3708
3708
  * @param {Object} val The value to test
3709
3709
  * @returns {boolean} True if value is a Stream, otherwise false
3710
- */function isStream(val){return isObject(val)&&isFunction(val.pipe);}/**
3710
+ */function isStream(val){return isObject(val)&&isFunction$1(val.pipe);}/**
3711
3711
  * Determine if a value is a FormData
3712
3712
  *
3713
3713
  * @param {Object} thing The value to test
3714
3714
  * @returns {boolean} True if value is an FormData, otherwise false
3715
- */function isFormData(thing){var pattern='[object FormData]';return thing&&(typeof FormData==='function'&&thing instanceof FormData||toString.call(thing)===pattern||isFunction(thing.toString)&&thing.toString()===pattern);}/**
3715
+ */function isFormData(thing){var pattern='[object FormData]';return thing&&(typeof FormData==='function'&&thing instanceof FormData||toString.call(thing)===pattern||isFunction$1(thing.toString)&&thing.toString()===pattern);}/**
3716
3716
  * Determine if a value is a URLSearchParams object
3717
3717
  * @function
3718
3718
  * @param {Object} val The value to test
@@ -3803,7 +3803,7 @@ for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){fn.call(nu
3803
3803
  * @returns {Array}
3804
3804
  */function toArray(thing){if(!thing)return null;var i=thing.length;if(isUndefined(i))return null;var arr=new Array(i);while(i-->0){arr[i]=thing[i];}return arr;}// eslint-disable-next-line func-names
3805
3805
  var isTypedArray=function(TypedArray){// eslint-disable-next-line func-names
3806
- return function(thing){return TypedArray&&thing instanceof TypedArray;};}(typeof Uint8Array!=='undefined'&&Object.getPrototypeOf(Uint8Array));var utils$9={isArray:isArray$1,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString$1,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};
3806
+ return function(thing){return TypedArray&&thing instanceof TypedArray;};}(typeof Uint8Array!=='undefined'&&Object.getPrototypeOf(Uint8Array));var utils$9={isArray:isArray$1,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString$1,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction$1,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};
3807
3807
 
3808
3808
  var utils$8=utils$9;function encode(val){return encodeURIComponent(val).replace(/%3A/gi,':').replace(/%24/g,'$').replace(/%2C/gi,',').replace(/%20/g,'+').replace(/%5B/gi,'[').replace(/%5D/gi,']');}/**
3809
3809
  * Build a URL by appending params to the end
@@ -5229,9 +5229,7 @@ description:this.description,number:this.number,// Mozilla
5229
5229
  fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,// Axios
5230
5230
  config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null};};return error;}
5231
5231
 
5232
- var version$1 = "2.32.0";
5233
-
5234
- var version=version$1;var removeTrailingSlashes=function removeTrailingSlashes(inURL){return inURL&&inURL.endsWith('/')?inURL.replace(/\/+$/,''):inURL;};var setImmediate=browser$1.nextTick.bind(browser$1);var noop=function noop(){};var Analytics=/*#__PURE__*/function(){/**
5232
+ var version='2.33.0';var removeTrailingSlashes=function removeTrailingSlashes(inURL){return inURL&&inURL.endsWith('/')?inURL.replace(/\/+$/,''):inURL;};var isFunction=function isFunction(value){return typeof value==='function'&&Boolean(value.constructor&&value.call&&value.apply);};var setImmediate=browser$1.nextTick.bind(browser$1);var noop=function noop(){};var Analytics=/*#__PURE__*/function(){/**
5235
5233
  * Initialize a new `Analytics` with your RudderStack source's `writeKey` and an
5236
5234
  * optional dictionary of `options`.
5237
5235
  *
@@ -5244,7 +5242,8 @@ var version=version$1;var removeTrailingSlashes=function removeTrailingSlashes(i
5244
5242
  * @param {Number=20000} options.maxInternalQueueSize (default: 20000)
5245
5243
  * @param {Number} options.timeout (default: false)
5246
5244
  * @param {String=info} options.logLevel (default: info)
5247
- */function Analytics(writeKey,dataPlaneURL,options){_classCallCheck(this,Analytics);options=options||{};if(!writeKey){throw new Error('You must pass your project\'s write key.');}if(!dataPlaneURL){throw new Error('You must pass our data plane url.');}this.queue=[];this.writeKey=writeKey;this.host=removeTrailingSlashes(dataPlaneURL);this.timeout=options.timeout||false;this.flushAt=Math.max(options.flushAt,1)||20;this.flushInterval=options.flushInterval||20000;this.maxInternalQueueSize=options.maxInternalQueueSize||20000;this.logLevel=options.logLevel||'info';this.flushed=false;this.axiosInstance=axios.create({adapter:fetchAdapter});Object.defineProperty(this,'enable',{configurable:false,writable:false,enumerable:true,value:typeof options.enable==='boolean'?options.enable:true});this.logger={error:function error(message){if(this.logLevel!=='off'){var _console;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}(_console=console).error.apply(_console,["".concat(new Date().toISOString()," [\"Rudder\"] error: ").concat(message)].concat(args));}},info:function info(message){if(['silly','debug','info'].includes(this.logLevel)){var _console2;for(var _len2=arguments.length,args=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2];}(_console2=console).log.apply(_console2,["".concat(new Date().toISOString()," [\"Rudder\"] info: ").concat(message)].concat(args));}},debug:function debug(message){if(['silly','debug'].includes(this.logLevel)){var _console3;for(var _len3=arguments.length,args=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3];}(_console3=console).debug.apply(_console3,["".concat(new Date().toISOString()," [\"Rudder\"] debug: ").concat(message)].concat(args));}},silly:function silly(message){if(['silly'].includes(this.logLevel)){var _console4;for(var _len4=arguments.length,args=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){args[_key4-1]=arguments[_key4];}(_console4=console).info.apply(_console4,["".concat(new Date().toISOString()," [\"Rudder\"] silly: ").concat(message)].concat(args));}}};axiosRetry(this.axiosInstance,{retries:0});}_createClass(Analytics,[{key:"_validate",value:function _validate(message,type){try{looselyValidateEvent_1(message,type);}catch(e){if(e.message==='Your message must be < 32kb.'){this.logger.info('Your message must be < 32kb. This is currently surfaced as a warning. Please update your code',message);return;}throw e;}}/**
5245
+ * @param {Function} options.flushOverride (optional)
5246
+ */function Analytics(writeKey,dataPlaneURL,options){_classCallCheck(this,Analytics);options=options||{};if(!writeKey){throw new Error('You must pass your project\'s write key.');}if(!dataPlaneURL){throw new Error('You must pass our data plane url.');}this.queue=[];this.writeKey=writeKey;this.host=removeTrailingSlashes(dataPlaneURL);this.timeout=options.timeout||false;this.flushAt=Math.max(options.flushAt,1)||20;this.flushInterval=options.flushInterval||20000;this.maxInternalQueueSize=options.maxInternalQueueSize||20000;this.logLevel=options.logLevel||'info';this.flushOverride=options.flushOverride&&isFunction(options.flushOverride)?options.flushOverride:undefined;this.flushed=false;this.axiosInstance=axios.create({adapter:fetchAdapter});Object.defineProperty(this,'enable',{configurable:false,writable:false,enumerable:true,value:typeof options.enable==='boolean'?options.enable:true});this.logger={error:function error(message){if(this.logLevel!=='off'){var _console;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}(_console=console).error.apply(_console,["".concat(new Date().toISOString()," [\"Rudder\"] error: ").concat(message)].concat(args));}},info:function info(message){if(['silly','debug','info'].includes(this.logLevel)){var _console2;for(var _len2=arguments.length,args=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2];}(_console2=console).log.apply(_console2,["".concat(new Date().toISOString()," [\"Rudder\"] info: ").concat(message)].concat(args));}},debug:function debug(message){if(['silly','debug'].includes(this.logLevel)){var _console3;for(var _len3=arguments.length,args=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3];}(_console3=console).debug.apply(_console3,["".concat(new Date().toISOString()," [\"Rudder\"] debug: ").concat(message)].concat(args));}},silly:function silly(message){if(['silly'].includes(this.logLevel)){var _console4;for(var _len4=arguments.length,args=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){args[_key4-1]=arguments[_key4];}(_console4=console).info.apply(_console4,["".concat(new Date().toISOString()," [\"Rudder\"] silly: ").concat(message)].concat(args));}}};axiosRetry(this.axiosInstance,{retries:0});}_createClass(Analytics,[{key:"_validate",value:function _validate(message,type){try{looselyValidateEvent_1(message,type);}catch(e){if(e.message==='Your message must be < 32kb.'){this.logger.info('Your message must be < 32kb. This is currently surfaced as a warning. Please update your code',message);return;}throw e;}}/**
5248
5247
  * Send an identify `message`.
5249
5248
  *
5250
5249
  * @param {Object} message
@@ -5338,7 +5337,7 @@ if(_typeof(item.message)==='object'){item.message.sentAt=new Date();}return item
5338
5337
  // the User-Agent header (see https://fetch.spec.whatwg.org/#terminology-headers
5339
5338
  // and https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader),
5340
5339
  // but browsers such as Chrome and Safari have not caught up.
5341
- var headers={};if(typeof window==='undefined'){headers['user-agent']="analytics-service-worker/".concat(version);headers['Content-Type']="application/json";}var req={method:'POST',url:"".concat(this.host),auth:{username:this.writeKey},data:data,headers:headers};if(this.timeout){req.timeout=typeof this.timeout==='string'?ms(this.timeout):this.timeout;}this.axiosInstance(_objectSpread2(_objectSpread2({},req),{},{'axios-retry':{retries:3,retryCondition:this._isErrorRetryable.bind(this),retryDelay:axiosRetry.exponentialDelay}})).then(function(response){_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);done();}).catch(function(err){console.log(err);_this.logger.error("got error while attempting send for 3 times, dropping ".concat(items.length," events"));_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);if(err.response){var error=new Error(err.response.statusText);return done(error);}done(err);});}},{key:"_isErrorRetryable",value:function _isErrorRetryable(error){// Retry Network Errors.
5340
+ var headers={};if(typeof window==='undefined'){headers['user-agent']="analytics-service-worker/".concat(version);headers['Content-Type']="application/json";}var reqTimeout=typeof this.timeout==='string'?ms(this.timeout):this.timeout;if(this.flushOverride){this.flushOverride({host:"".concat(this.host),writeKey:this.writeKey,data:data,headers:headers,reqTimeout:reqTimeout,flush:this.flush.bind(this),done:done,isErrorRetryable:this._isErrorRetryable.bind(this)});}else {var req={method:'POST',url:"".concat(this.host),auth:{username:this.writeKey},data:data,headers:headers};if(reqTimeout){req.timeout=reqTimeout;}this.axiosInstance(_objectSpread2(_objectSpread2({},req),{},{'axios-retry':{retries:3,retryCondition:this._isErrorRetryable.bind(this),retryDelay:axiosRetry.exponentialDelay}})).then(function(response){_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);done();}).catch(function(err){console.log(err);_this.logger.error("got error while attempting send for 3 times, dropping ".concat(items.length," events"));_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);if(err.response){var error=new Error(err.response.statusText);return done(error);}done(err);});}}},{key:"_isErrorRetryable",value:function _isErrorRetryable(error){// Retry Network Errors.
5342
5341
  if(axiosRetry.isNetworkError(error)){return true;}if(!error.response){// Cannot determine if the request can be retried
5343
5342
  return false;}this.logger.error("error status: ".concat(error.response.status));// Retry Server Errors (5xx).
5344
5343
  if(error.response.status>=500&&error.response.status<=599){return true;}// Retry if rate limited.
@@ -572,7 +572,7 @@
572
572
  var browser = true;
573
573
  var env = {};
574
574
  var argv = [];
575
- var version$2 = ''; // empty string to avoid regexp issues
575
+ var version$1 = ''; // empty string to avoid regexp issues
576
576
  var versions = {};
577
577
  var release = {};
578
578
  var config = {};
@@ -636,7 +636,7 @@
636
636
  browser: browser,
637
637
  env: env,
638
638
  argv: argv,
639
- version: version$2,
639
+ version: version$1,
640
640
  versions: versions,
641
641
  on: on,
642
642
  addListener: addListener,
@@ -2808,7 +2808,7 @@
2808
2808
  // Check that value is an object with an inspect function on it
2809
2809
  if (ctx.customInspect &&
2810
2810
  value &&
2811
- isFunction$1(value.inspect) &&
2811
+ isFunction$2(value.inspect) &&
2812
2812
  // Filter out the util module, it's inspect function is special
2813
2813
  value.inspect !== inspect$1 &&
2814
2814
  // Also filter out any prototype objects using the circular check.
@@ -2843,7 +2843,7 @@
2843
2843
 
2844
2844
  // Some type of object without properties can be shortcutted.
2845
2845
  if (keys.length === 0) {
2846
- if (isFunction$1(value)) {
2846
+ if (isFunction$2(value)) {
2847
2847
  var name = value.name ? ': ' + value.name : '';
2848
2848
  return ctx.stylize('[Function' + name + ']', 'special');
2849
2849
  }
@@ -2867,7 +2867,7 @@
2867
2867
  }
2868
2868
 
2869
2869
  // Make functions say that they are functions
2870
- if (isFunction$1(value)) {
2870
+ if (isFunction$2(value)) {
2871
2871
  var n = value.name ? ': ' + value.name : '';
2872
2872
  base = ' [Function' + n + ']';
2873
2873
  }
@@ -3081,7 +3081,7 @@
3081
3081
  (objectToString$1(e) === '[object Error]' || e instanceof Error);
3082
3082
  }
3083
3083
 
3084
- function isFunction$1(arg) {
3084
+ function isFunction$2(arg) {
3085
3085
  return typeof arg === 'function';
3086
3086
  }
3087
3087
 
@@ -3196,7 +3196,7 @@
3196
3196
  var regex = /\s*function\s+([^\(\s]*)\s*/;
3197
3197
  // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
3198
3198
  function getName(func) {
3199
- if (!isFunction$1(func)) {
3199
+ if (!isFunction$2(func)) {
3200
3200
  return;
3201
3201
  }
3202
3202
  if (functionsHaveNames()) {
@@ -3254,7 +3254,7 @@
3254
3254
  }
3255
3255
  }
3256
3256
  function inspect(something) {
3257
- if (functionsHaveNames() || !isFunction$1(something)) {
3257
+ if (functionsHaveNames() || !isFunction$2(something)) {
3258
3258
  return inspect$1(something);
3259
3259
  }
3260
3260
  var rawname = getName(something);
@@ -3708,17 +3708,17 @@
3708
3708
  *
3709
3709
  * @param {Object} val The value to test
3710
3710
  * @returns {boolean} True if value is a Function, otherwise false
3711
- */function isFunction(val){return toString.call(val)==='[object Function]';}/**
3711
+ */function isFunction$1(val){return toString.call(val)==='[object Function]';}/**
3712
3712
  * Determine if a value is a Stream
3713
3713
  *
3714
3714
  * @param {Object} val The value to test
3715
3715
  * @returns {boolean} True if value is a Stream, otherwise false
3716
- */function isStream(val){return isObject(val)&&isFunction(val.pipe);}/**
3716
+ */function isStream(val){return isObject(val)&&isFunction$1(val.pipe);}/**
3717
3717
  * Determine if a value is a FormData
3718
3718
  *
3719
3719
  * @param {Object} thing The value to test
3720
3720
  * @returns {boolean} True if value is an FormData, otherwise false
3721
- */function isFormData(thing){var pattern='[object FormData]';return thing&&(typeof FormData==='function'&&thing instanceof FormData||toString.call(thing)===pattern||isFunction(thing.toString)&&thing.toString()===pattern);}/**
3721
+ */function isFormData(thing){var pattern='[object FormData]';return thing&&(typeof FormData==='function'&&thing instanceof FormData||toString.call(thing)===pattern||isFunction$1(thing.toString)&&thing.toString()===pattern);}/**
3722
3722
  * Determine if a value is a URLSearchParams object
3723
3723
  * @function
3724
3724
  * @param {Object} val The value to test
@@ -3809,7 +3809,7 @@
3809
3809
  * @returns {Array}
3810
3810
  */function toArray(thing){if(!thing)return null;var i=thing.length;if(isUndefined(i))return null;var arr=new Array(i);while(i-->0){arr[i]=thing[i];}return arr;}// eslint-disable-next-line func-names
3811
3811
  var isTypedArray=function(TypedArray){// eslint-disable-next-line func-names
3812
- return function(thing){return TypedArray&&thing instanceof TypedArray;};}(typeof Uint8Array!=='undefined'&&Object.getPrototypeOf(Uint8Array));var utils$9={isArray:isArray$1,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString$1,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};
3812
+ return function(thing){return TypedArray&&thing instanceof TypedArray;};}(typeof Uint8Array!=='undefined'&&Object.getPrototypeOf(Uint8Array));var utils$9={isArray:isArray$1,isArrayBuffer:isArrayBuffer,isBuffer:isBuffer,isFormData:isFormData,isArrayBufferView:isArrayBufferView,isString:isString$1,isNumber:isNumber,isObject:isObject,isPlainObject:isPlainObject,isUndefined:isUndefined,isDate:isDate,isFile:isFile,isBlob:isBlob,isFunction:isFunction$1,isStream:isStream,isURLSearchParams:isURLSearchParams,isStandardBrowserEnv:isStandardBrowserEnv,forEach:forEach,merge:merge,extend:extend,trim:trim,stripBOM:stripBOM,inherits:inherits,toFlatObject:toFlatObject,kindOf:kindOf,kindOfTest:kindOfTest,endsWith:endsWith,toArray:toArray,isTypedArray:isTypedArray,isFileList:isFileList};
3813
3813
 
3814
3814
  var utils$8=utils$9;function encode(val){return encodeURIComponent(val).replace(/%3A/gi,':').replace(/%24/g,'$').replace(/%2C/gi,',').replace(/%20/g,'+').replace(/%5B/gi,'[').replace(/%5D/gi,']');}/**
3815
3815
  * Build a URL by appending params to the end
@@ -5235,9 +5235,7 @@
5235
5235
  fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,// Axios
5236
5236
  config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null};};return error;}
5237
5237
 
5238
- var version$1 = "2.32.0";
5239
-
5240
- var version=version$1;var removeTrailingSlashes=function removeTrailingSlashes(inURL){return inURL&&inURL.endsWith('/')?inURL.replace(/\/+$/,''):inURL;};var setImmediate=browser$1.nextTick.bind(browser$1);var noop=function noop(){};var Analytics=/*#__PURE__*/function(){/**
5238
+ var version='2.33.0';var removeTrailingSlashes=function removeTrailingSlashes(inURL){return inURL&&inURL.endsWith('/')?inURL.replace(/\/+$/,''):inURL;};var isFunction=function isFunction(value){return typeof value==='function'&&Boolean(value.constructor&&value.call&&value.apply);};var setImmediate=browser$1.nextTick.bind(browser$1);var noop=function noop(){};var Analytics=/*#__PURE__*/function(){/**
5241
5239
  * Initialize a new `Analytics` with your RudderStack source's `writeKey` and an
5242
5240
  * optional dictionary of `options`.
5243
5241
  *
@@ -5250,7 +5248,8 @@
5250
5248
  * @param {Number=20000} options.maxInternalQueueSize (default: 20000)
5251
5249
  * @param {Number} options.timeout (default: false)
5252
5250
  * @param {String=info} options.logLevel (default: info)
5253
- */function Analytics(writeKey,dataPlaneURL,options){_classCallCheck(this,Analytics);options=options||{};if(!writeKey){throw new Error('You must pass your project\'s write key.');}if(!dataPlaneURL){throw new Error('You must pass our data plane url.');}this.queue=[];this.writeKey=writeKey;this.host=removeTrailingSlashes(dataPlaneURL);this.timeout=options.timeout||false;this.flushAt=Math.max(options.flushAt,1)||20;this.flushInterval=options.flushInterval||20000;this.maxInternalQueueSize=options.maxInternalQueueSize||20000;this.logLevel=options.logLevel||'info';this.flushed=false;this.axiosInstance=axios.create({adapter:fetchAdapter});Object.defineProperty(this,'enable',{configurable:false,writable:false,enumerable:true,value:typeof options.enable==='boolean'?options.enable:true});this.logger={error:function error(message){if(this.logLevel!=='off'){var _console;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}(_console=console).error.apply(_console,["".concat(new Date().toISOString()," [\"Rudder\"] error: ").concat(message)].concat(args));}},info:function info(message){if(['silly','debug','info'].includes(this.logLevel)){var _console2;for(var _len2=arguments.length,args=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2];}(_console2=console).log.apply(_console2,["".concat(new Date().toISOString()," [\"Rudder\"] info: ").concat(message)].concat(args));}},debug:function debug(message){if(['silly','debug'].includes(this.logLevel)){var _console3;for(var _len3=arguments.length,args=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3];}(_console3=console).debug.apply(_console3,["".concat(new Date().toISOString()," [\"Rudder\"] debug: ").concat(message)].concat(args));}},silly:function silly(message){if(['silly'].includes(this.logLevel)){var _console4;for(var _len4=arguments.length,args=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){args[_key4-1]=arguments[_key4];}(_console4=console).info.apply(_console4,["".concat(new Date().toISOString()," [\"Rudder\"] silly: ").concat(message)].concat(args));}}};axiosRetry(this.axiosInstance,{retries:0});}_createClass(Analytics,[{key:"_validate",value:function _validate(message,type){try{looselyValidateEvent_1(message,type);}catch(e){if(e.message==='Your message must be < 32kb.'){this.logger.info('Your message must be < 32kb. This is currently surfaced as a warning. Please update your code',message);return;}throw e;}}/**
5251
+ * @param {Function} options.flushOverride (optional)
5252
+ */function Analytics(writeKey,dataPlaneURL,options){_classCallCheck(this,Analytics);options=options||{};if(!writeKey){throw new Error('You must pass your project\'s write key.');}if(!dataPlaneURL){throw new Error('You must pass our data plane url.');}this.queue=[];this.writeKey=writeKey;this.host=removeTrailingSlashes(dataPlaneURL);this.timeout=options.timeout||false;this.flushAt=Math.max(options.flushAt,1)||20;this.flushInterval=options.flushInterval||20000;this.maxInternalQueueSize=options.maxInternalQueueSize||20000;this.logLevel=options.logLevel||'info';this.flushOverride=options.flushOverride&&isFunction(options.flushOverride)?options.flushOverride:undefined;this.flushed=false;this.axiosInstance=axios.create({adapter:fetchAdapter});Object.defineProperty(this,'enable',{configurable:false,writable:false,enumerable:true,value:typeof options.enable==='boolean'?options.enable:true});this.logger={error:function error(message){if(this.logLevel!=='off'){var _console;for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){args[_key-1]=arguments[_key];}(_console=console).error.apply(_console,["".concat(new Date().toISOString()," [\"Rudder\"] error: ").concat(message)].concat(args));}},info:function info(message){if(['silly','debug','info'].includes(this.logLevel)){var _console2;for(var _len2=arguments.length,args=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){args[_key2-1]=arguments[_key2];}(_console2=console).log.apply(_console2,["".concat(new Date().toISOString()," [\"Rudder\"] info: ").concat(message)].concat(args));}},debug:function debug(message){if(['silly','debug'].includes(this.logLevel)){var _console3;for(var _len3=arguments.length,args=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){args[_key3-1]=arguments[_key3];}(_console3=console).debug.apply(_console3,["".concat(new Date().toISOString()," [\"Rudder\"] debug: ").concat(message)].concat(args));}},silly:function silly(message){if(['silly'].includes(this.logLevel)){var _console4;for(var _len4=arguments.length,args=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){args[_key4-1]=arguments[_key4];}(_console4=console).info.apply(_console4,["".concat(new Date().toISOString()," [\"Rudder\"] silly: ").concat(message)].concat(args));}}};axiosRetry(this.axiosInstance,{retries:0});}_createClass(Analytics,[{key:"_validate",value:function _validate(message,type){try{looselyValidateEvent_1(message,type);}catch(e){if(e.message==='Your message must be < 32kb.'){this.logger.info('Your message must be < 32kb. This is currently surfaced as a warning. Please update your code',message);return;}throw e;}}/**
5254
5253
  * Send an identify `message`.
5255
5254
  *
5256
5255
  * @param {Object} message
@@ -5344,7 +5343,7 @@
5344
5343
  // the User-Agent header (see https://fetch.spec.whatwg.org/#terminology-headers
5345
5344
  // and https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader),
5346
5345
  // but browsers such as Chrome and Safari have not caught up.
5347
- var headers={};if(typeof window==='undefined'){headers['user-agent']="analytics-service-worker/".concat(version);headers['Content-Type']="application/json";}var req={method:'POST',url:"".concat(this.host),auth:{username:this.writeKey},data:data,headers:headers};if(this.timeout){req.timeout=typeof this.timeout==='string'?ms(this.timeout):this.timeout;}this.axiosInstance(_objectSpread2(_objectSpread2({},req),{},{'axios-retry':{retries:3,retryCondition:this._isErrorRetryable.bind(this),retryDelay:axiosRetry.exponentialDelay}})).then(function(response){_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);done();}).catch(function(err){console.log(err);_this.logger.error("got error while attempting send for 3 times, dropping ".concat(items.length," events"));_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);if(err.response){var error=new Error(err.response.statusText);return done(error);}done(err);});}},{key:"_isErrorRetryable",value:function _isErrorRetryable(error){// Retry Network Errors.
5346
+ var headers={};if(typeof window==='undefined'){headers['user-agent']="analytics-service-worker/".concat(version);headers['Content-Type']="application/json";}var reqTimeout=typeof this.timeout==='string'?ms(this.timeout):this.timeout;if(this.flushOverride){this.flushOverride({host:"".concat(this.host),writeKey:this.writeKey,data:data,headers:headers,reqTimeout:reqTimeout,flush:this.flush.bind(this),done:done,isErrorRetryable:this._isErrorRetryable.bind(this)});}else {var req={method:'POST',url:"".concat(this.host),auth:{username:this.writeKey},data:data,headers:headers};if(reqTimeout){req.timeout=reqTimeout;}this.axiosInstance(_objectSpread2(_objectSpread2({},req),{},{'axios-retry':{retries:3,retryCondition:this._isErrorRetryable.bind(this),retryDelay:axiosRetry.exponentialDelay}})).then(function(response){_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);done();}).catch(function(err){console.log(err);_this.logger.error("got error while attempting send for 3 times, dropping ".concat(items.length," events"));_this.timer=setTimeout(_this.flush.bind(_this),_this.flushInterval);if(err.response){var error=new Error(err.response.statusText);return done(error);}done(err);});}}},{key:"_isErrorRetryable",value:function _isErrorRetryable(error){// Retry Network Errors.
5348
5347
  if(axiosRetry.isNetworkError(error)){return true;}if(!error.response){// Cannot determine if the request can be retried
5349
5348
  return false;}this.logger.error("error status: ".concat(error.response.status));// Retry Server Errors (5xx).
5350
5349
  if(error.response.status>=500&&error.response.status<=599){return true;}// Retry if rate limited.