vwo-fme-node-sdk 1.25.2 → 1.26.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/VERSION.json +1 -1
  3. package/dist/client/vwo-fme-javascript-sdk.js +213 -134
  4. package/dist/client/vwo-fme-javascript-sdk.js.map +1 -1
  5. package/dist/client/vwo-fme-javascript-sdk.min.js +2 -2
  6. package/dist/client/vwo-fme-javascript-sdk.min.js.map +1 -1
  7. package/dist/esm/VWO.js +15 -3
  8. package/dist/esm/VWO.js.map +1 -1
  9. package/dist/esm/constants/index.js +1 -0
  10. package/dist/esm/constants/index.js.map +1 -1
  11. package/dist/esm/enums/EventEnum.js +1 -0
  12. package/dist/esm/enums/EventEnum.js.map +1 -1
  13. package/dist/esm/models/schemas/SettingsSchemaValidation.js +1 -0
  14. package/dist/esm/models/schemas/SettingsSchemaValidation.js.map +1 -1
  15. package/dist/esm/models/settings/SettingsModel.js +4 -0
  16. package/dist/esm/models/settings/SettingsModel.js.map +1 -1
  17. package/dist/esm/utils/NetworkUtil.js +48 -20
  18. package/dist/esm/utils/NetworkUtil.js.map +1 -1
  19. package/dist/esm/utils/{EventUtil.js → SdkInitAndUsageStatsUtil.js} +16 -1
  20. package/dist/esm/utils/SdkInitAndUsageStatsUtil.js.map +1 -0
  21. package/dist/esm/utils/UsageStatsUtil.js +7 -4
  22. package/dist/esm/utils/UsageStatsUtil.js.map +1 -1
  23. package/dist/package.json +2 -2
  24. package/dist/server/vwo-fme-node-sdk.js +299 -213
  25. package/dist/server/vwo-fme-node-sdk.js.map +1 -1
  26. package/dist/server/vwo-fme-node-sdk.min.js +2 -2
  27. package/dist/server/vwo-fme-node-sdk.min.js.map +1 -1
  28. package/dist/server-unpacked/VWO.js +20 -9
  29. package/dist/server-unpacked/VWO.js.map +1 -1
  30. package/dist/server-unpacked/constants/index.js +1 -0
  31. package/dist/server-unpacked/constants/index.js.map +1 -1
  32. package/dist/server-unpacked/enums/EventEnum.js +1 -0
  33. package/dist/server-unpacked/enums/EventEnum.js.map +1 -1
  34. package/dist/server-unpacked/models/schemas/SettingsSchemaValidation.js +1 -0
  35. package/dist/server-unpacked/models/schemas/SettingsSchemaValidation.js.map +1 -1
  36. package/dist/server-unpacked/models/settings/SettingsModel.js +4 -0
  37. package/dist/server-unpacked/models/settings/SettingsModel.js.map +1 -1
  38. package/dist/server-unpacked/utils/NetworkUtil.js +52 -20
  39. package/dist/server-unpacked/utils/NetworkUtil.js.map +1 -1
  40. package/dist/server-unpacked/utils/{EventUtil.js → SdkInitAndUsageStatsUtil.js} +27 -1
  41. package/dist/server-unpacked/utils/SdkInitAndUsageStatsUtil.js.map +1 -0
  42. package/dist/server-unpacked/utils/UsageStatsUtil.js +7 -4
  43. package/dist/server-unpacked/utils/UsageStatsUtil.js.map +1 -1
  44. package/dist/types/constants/index.d.ts +1 -0
  45. package/dist/types/enums/EventEnum.d.ts +1 -0
  46. package/dist/types/models/settings/SettingsModel.d.ts +2 -0
  47. package/dist/types/utils/NetworkUtil.d.ts +15 -0
  48. package/dist/types/utils/{EventUtil.d.ts → SdkInitAndUsageStatsUtil.d.ts} +6 -0
  49. package/lib/VWO.ts +15 -1
  50. package/lib/constants/index.ts +1 -0
  51. package/lib/enums/EventEnum.ts +1 -0
  52. package/lib/models/schemas/SettingsSchemaValidation.ts +1 -0
  53. package/lib/models/settings/SettingsModel.ts +6 -1
  54. package/lib/utils/NetworkUtil.ts +57 -22
  55. package/lib/utils/{EventUtil.ts → SdkInitAndUsageStatsUtil.ts} +24 -1
  56. package/lib/utils/UsageStatsUtil.ts +7 -4
  57. package/package.json +2 -2
  58. package/dist/esm/utils/EventUtil.js.map +0 -1
  59. package/dist/server-unpacked/utils/EventUtil.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.26.0] - 2025-08-26
9
+
10
+ ### Added
11
+
12
+ - Sends usage statistics to VWO servers automatically during SDK initialization
13
+
8
14
  ## [1.25.2] - 2025-08-12
9
15
 
10
16
  ### Added
@@ -595,4 +601,4 @@ Client-side Javascript SDK
595
601
 
596
602
  // track event
597
603
  vwoClient.trackEvent('addToCart', eventProperties, userContext);
598
- ```
604
+ ```
package/dist/VERSION.json CHANGED
@@ -1 +1 @@
1
- {"version":"1.25.2"}
1
+ { "version": "1.26.0" }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vwo-fme-javascript-sdk - v1.25.2
2
+ * vwo-fme-javascript-sdk - v1.26.0
3
3
  * URL - https://github.com/wingify/vwo-fme-javascript-sdk
4
4
  *
5
5
  * Copyright 2024-2025 Wingify Software Pvt. Ltd.
@@ -46,7 +46,7 @@ return /******/ (() => { // webpackBootstrap
46
46
  /***/ ((module) => {
47
47
 
48
48
  "use strict";
49
- module.exports = {"version":"1.25.2"};
49
+ module.exports = {"version":"1.26.0"};
50
50
 
51
51
  /***/ }),
52
52
 
@@ -116,7 +116,7 @@ exports.onInit = onInit;
116
116
  var VWOBuilder_1 = __webpack_require__(/*! ./VWOBuilder */ "./lib/VWOBuilder.ts");
117
117
  var DataTypeUtil_1 = __webpack_require__(/*! ./utils/DataTypeUtil */ "./lib/utils/DataTypeUtil.ts");
118
118
  var PromiseUtil_1 = __webpack_require__(/*! ./utils/PromiseUtil */ "./lib/utils/PromiseUtil.ts");
119
- var EventUtil_1 = __webpack_require__(/*! ./utils/EventUtil */ "./lib/utils/EventUtil.ts");
119
+ var SdkInitAndUsageStatsUtil_1 = __webpack_require__(/*! ./utils/SdkInitAndUsageStatsUtil */ "./lib/utils/SdkInitAndUsageStatsUtil.ts");
120
120
  var log_messages_1 = __webpack_require__(/*! ./enums/log-messages */ "./lib/enums/log-messages/index.ts");
121
121
  var LogMessageUtil_1 = __webpack_require__(/*! ./utils/LogMessageUtil */ "./lib/utils/LogMessageUtil.ts");
122
122
  var PlatformEnum_1 = __webpack_require__(/*! ./enums/PlatformEnum */ "./lib/enums/PlatformEnum.ts");
@@ -244,22 +244,33 @@ function init(options) {
244
244
  instance: null,
245
245
  };
246
246
  return [2 /*return*/, instance.then(function (_vwoInstance) { return __awaiter(_this, void 0, void 0, function () {
247
- var sdkInitTime;
248
- var _a, _b, _c;
249
- return __generator(this, function (_d) {
250
- switch (_d.label) {
247
+ var sdkInitTime, usageStatsAccountId;
248
+ var _a, _b, _c, _d, _e;
249
+ return __generator(this, function (_f) {
250
+ switch (_f.label) {
251
251
  case 0:
252
252
  sdkInitTime = Date.now() - startTimeForInit_1;
253
253
  if (!(_vwoInstance.isSettingsValid && !((_b = (_a = _vwoInstance.originalSettings) === null || _a === void 0 ? void 0 : _a.sdkMetaInfo) === null || _b === void 0 ? void 0 : _b.wasInitializedEarlier))) return [3 /*break*/, 3];
254
254
  if (!((_c = _vwoInstance.options) === null || _c === void 0 ? void 0 : _c.shouldWaitForTrackingCalls)) return [3 /*break*/, 2];
255
- return [4 /*yield*/, (0, EventUtil_1.sendSdkInitEvent)(_vwoInstance.settingsFetchTime, sdkInitTime)];
255
+ return [4 /*yield*/, (0, SdkInitAndUsageStatsUtil_1.sendSdkInitEvent)(_vwoInstance.settingsFetchTime, sdkInitTime)];
256
256
  case 1:
257
- _d.sent();
257
+ _f.sent();
258
258
  return [3 /*break*/, 3];
259
259
  case 2:
260
- (0, EventUtil_1.sendSdkInitEvent)(_vwoInstance.settingsFetchTime, sdkInitTime);
261
- _d.label = 3;
260
+ (0, SdkInitAndUsageStatsUtil_1.sendSdkInitEvent)(_vwoInstance.settingsFetchTime, sdkInitTime);
261
+ _f.label = 3;
262
262
  case 3:
263
+ usageStatsAccountId = (_d = _vwoInstance.originalSettings) === null || _d === void 0 ? void 0 : _d.usageStatsAccountId;
264
+ if (!usageStatsAccountId) return [3 /*break*/, 6];
265
+ if (!((_e = _vwoInstance.options) === null || _e === void 0 ? void 0 : _e.shouldWaitForTrackingCalls)) return [3 /*break*/, 5];
266
+ return [4 /*yield*/, (0, SdkInitAndUsageStatsUtil_1.sendSDKUsageStatsEvent)(usageStatsAccountId)];
267
+ case 4:
268
+ _f.sent();
269
+ return [3 /*break*/, 6];
270
+ case 5:
271
+ (0, SdkInitAndUsageStatsUtil_1.sendSDKUsageStatsEvent)(usageStatsAccountId);
272
+ _f.label = 6;
273
+ case 6:
263
274
  _global.isSettingsFetched = true;
264
275
  _global.instance = _vwoInstance;
265
276
  _global.vwoInitDeferred.resolve(_vwoInstance);
@@ -1876,6 +1887,7 @@ exports.Constants = {
1876
1887
  DEFAULT_LOCAL_STORAGE_KEY: 'vwo_fme_data',
1877
1888
  DEFAULT_SETTINGS_STORAGE_KEY: 'vwo_fme_settings',
1878
1889
  POLLING_INTERVAL: 600000,
1890
+ PRODUCT_NAME: 'fme',
1879
1891
  };
1880
1892
 
1881
1893
 
@@ -2152,6 +2164,7 @@ var EventEnum;
2152
2164
  EventEnum["VWO_SYNC_VISITOR_PROP"] = "vwo_syncVisitorProp";
2153
2165
  EventEnum["VWO_LOG_EVENT"] = "vwo_log";
2154
2166
  EventEnum["VWO_INIT_CALLED"] = "vwo_fmeSdkInit";
2167
+ EventEnum["VWO_USAGE_STATS"] = "vwo_sdkUsageStats";
2155
2168
  })(EventEnum || (exports.EventEnum = EventEnum = {}));
2156
2169
 
2157
2170
 
@@ -3030,6 +3043,7 @@ var SettingsSchema = /** @class */ (function () {
3030
3043
  sdkKey: (0, superstruct_1.optional)((0, superstruct_1.string)()),
3031
3044
  version: (0, superstruct_1.union)([(0, superstruct_1.number)(), (0, superstruct_1.string)()]),
3032
3045
  accountId: (0, superstruct_1.union)([(0, superstruct_1.number)(), (0, superstruct_1.string)()]),
3046
+ usageStatsAccountId: (0, superstruct_1.optional)((0, superstruct_1.number)()),
3033
3047
  features: (0, superstruct_1.optional)((0, superstruct_1.array)(this.featureSchema)),
3034
3048
  campaigns: (0, superstruct_1.array)(this.campaignObjectSchema),
3035
3049
  groups: (0, superstruct_1.optional)((0, superstruct_1.object)()),
@@ -3095,6 +3109,7 @@ var SettingsModel = /** @class */ (function () {
3095
3109
  this.accountId = settings.a || settings.accountId;
3096
3110
  this.version = settings.v || settings.version;
3097
3111
  this.collectionPrefix = settings.collectionPrefix;
3112
+ this.usageStatsAccountId = settings.usageStatsAccountId;
3098
3113
  if ((settings.f && settings.f.constructor !== {}.constructor) ||
3099
3114
  (settings.features && settings.features.constructor !== {}.constructor)) {
3100
3115
  var featureList = settings.f || settings.features;
@@ -3150,6 +3165,9 @@ var SettingsModel = /** @class */ (function () {
3150
3165
  SettingsModel.prototype.getPollInterval = function () {
3151
3166
  return this.pollInterval;
3152
3167
  };
3168
+ SettingsModel.prototype.getUsageStatsAccountId = function () {
3169
+ return this.usageStatsAccountId;
3170
+ };
3153
3171
  return SettingsModel;
3154
3172
  }());
3155
3173
  exports.SettingsModel = SettingsModel;
@@ -8762,105 +8780,6 @@ var _evaluateWhitelisting = function (campaign, context) { return __awaiter(void
8762
8780
  }); };
8763
8781
 
8764
8782
 
8765
- /***/ }),
8766
-
8767
- /***/ "./lib/utils/EventUtil.ts":
8768
- /*!********************************!*\
8769
- !*** ./lib/utils/EventUtil.ts ***!
8770
- \********************************/
8771
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
8772
-
8773
- "use strict";
8774
-
8775
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8776
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8777
- return new (P || (P = Promise))(function (resolve, reject) {
8778
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8779
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8780
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8781
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8782
- });
8783
- };
8784
- var __generator = (this && this.__generator) || function (thisArg, body) {
8785
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
8786
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
8787
- function verb(n) { return function (v) { return step([n, v]); }; }
8788
- function step(op) {
8789
- if (f) throw new TypeError("Generator is already executing.");
8790
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
8791
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
8792
- if (y = 0, t) op = [op[0] & 2, t.value];
8793
- switch (op[0]) {
8794
- case 0: case 1: t = op; break;
8795
- case 4: _.label++; return { value: op[1], done: false };
8796
- case 5: _.label++; y = op[1]; op = [0]; continue;
8797
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
8798
- default:
8799
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
8800
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
8801
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
8802
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
8803
- if (t[2]) _.ops.pop();
8804
- _.trys.pop(); continue;
8805
- }
8806
- op = body.call(thisArg, _);
8807
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
8808
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
8809
- }
8810
- };
8811
- Object.defineProperty(exports, "__esModule", ({ value: true }));
8812
- exports.sendSdkInitEvent = sendSdkInitEvent;
8813
- /**
8814
- * Copyright 2024-2025 Wingify Software Pvt. Ltd.
8815
- *
8816
- * Licensed under the Apache License, Version 2.0 (the "License");
8817
- * you may not use this file except in compliance with the License.
8818
- * You may obtain a copy of the License at
8819
- *
8820
- * http://www.apache.org/licenses/LICENSE-2.0
8821
- *
8822
- * Unless required by applicable law or agreed to in writing, software
8823
- * distributed under the License is distributed on an "AS IS" BASIS,
8824
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8825
- * See the License for the specific language governing permissions and
8826
- * limitations under the License.
8827
- */
8828
- var NetworkUtil_1 = __webpack_require__(/*! ./NetworkUtil */ "./lib/utils/NetworkUtil.ts");
8829
- var EventEnum_1 = __webpack_require__(/*! ../enums/EventEnum */ "./lib/enums/EventEnum.ts");
8830
- var BatchEventsQueue_1 = __webpack_require__(/*! ../services/BatchEventsQueue */ "./lib/services/BatchEventsQueue.ts");
8831
- /**
8832
- * Sends an init called event to VWO.
8833
- * This event is triggered when the init function is called.
8834
- * @param {number} settingsFetchTime - Time taken to fetch settings in milliseconds.
8835
- * @param {number} sdkInitTime - Time taken to initialize the SDK in milliseconds.
8836
- */
8837
- function sendSdkInitEvent(settingsFetchTime, sdkInitTime) {
8838
- return __awaiter(this, void 0, void 0, function () {
8839
- var properties, payload;
8840
- return __generator(this, function (_a) {
8841
- switch (_a.label) {
8842
- case 0:
8843
- properties = (0, NetworkUtil_1.getEventsBaseProperties)(EventEnum_1.EventEnum.VWO_INIT_CALLED);
8844
- payload = (0, NetworkUtil_1.getSDKInitEventPayload)(EventEnum_1.EventEnum.VWO_INIT_CALLED, settingsFetchTime, sdkInitTime);
8845
- if (!BatchEventsQueue_1.BatchEventsQueue.Instance) return [3 /*break*/, 1];
8846
- BatchEventsQueue_1.BatchEventsQueue.Instance.enqueue(payload);
8847
- return [3 /*break*/, 3];
8848
- case 1:
8849
- // Send the constructed properties and payload as a POST request
8850
- //send eventName in parameters so that we can enable retry for this event
8851
- return [4 /*yield*/, (0, NetworkUtil_1.sendEvent)(properties, payload, EventEnum_1.EventEnum.VWO_INIT_CALLED).catch(function () { })];
8852
- case 2:
8853
- // Send the constructed properties and payload as a POST request
8854
- //send eventName in parameters so that we can enable retry for this event
8855
- _a.sent();
8856
- _a.label = 3;
8857
- case 3: return [2 /*return*/];
8858
- }
8859
- });
8860
- });
8861
- }
8862
-
8863
-
8864
8783
  /***/ }),
8865
8784
 
8866
8785
  /***/ "./lib/utils/FetchUtil.ts":
@@ -10113,6 +10032,7 @@ exports.getShouldWaitForTrackingCalls = getShouldWaitForTrackingCalls;
10113
10032
  exports.setShouldWaitForTrackingCalls = setShouldWaitForTrackingCalls;
10114
10033
  exports.getMessagingEventPayload = getMessagingEventPayload;
10115
10034
  exports.getSDKInitEventPayload = getSDKInitEventPayload;
10035
+ exports.getSDKUsageStatsEventPayload = getSDKUsageStatsEventPayload;
10116
10036
  exports.sendEvent = sendEvent;
10117
10037
  /**
10118
10038
  * Copyright 2024-2025 Wingify Software Pvt. Ltd.
@@ -10187,14 +10107,14 @@ function getTrackEventPath(event, accountId, userId) {
10187
10107
  * @param {String} eventName
10188
10108
  * @returns properties
10189
10109
  */
10190
- function getEventsBaseProperties(eventName, visitorUserAgent, ipAddress) {
10110
+ function getEventsBaseProperties(eventName, visitorUserAgent, ipAddress, isUsageStatsEvent, usageStatsAccountId) {
10191
10111
  if (visitorUserAgent === void 0) { visitorUserAgent = ''; }
10192
10112
  if (ipAddress === void 0) { ipAddress = ''; }
10193
- var sdkKey = SettingsService_1.SettingsService.Instance.sdkKey;
10113
+ if (isUsageStatsEvent === void 0) { isUsageStatsEvent = false; }
10114
+ if (usageStatsAccountId === void 0) { usageStatsAccountId = null; }
10194
10115
  var properties = Object.assign({
10195
10116
  en: eventName,
10196
10117
  a: SettingsService_1.SettingsService.Instance.accountId,
10197
- env: sdkKey,
10198
10118
  eTime: (0, FunctionUtil_1.getCurrentUnixTimestampInMillis)(),
10199
10119
  random: (0, FunctionUtil_1.getRandomNumber)(),
10200
10120
  p: 'FS',
@@ -10203,6 +10123,14 @@ function getEventsBaseProperties(eventName, visitorUserAgent, ipAddress) {
10203
10123
  sn: constants_1.Constants.SDK_NAME,
10204
10124
  sv: constants_1.Constants.SDK_VERSION,
10205
10125
  });
10126
+ if (!isUsageStatsEvent) {
10127
+ // set env key for standard sdk events
10128
+ properties.env = SettingsService_1.SettingsService.Instance.sdkKey;
10129
+ }
10130
+ else {
10131
+ // set account id for internal usage stats event
10132
+ properties.a = usageStatsAccountId;
10133
+ }
10206
10134
  properties.url = constants_1.Constants.HTTPS_PROTOCOL + UrlUtil_1.UrlUtil.getBaseUrl() + UrlEnum_1.UrlEnum.EVENTS;
10207
10135
  return properties;
10208
10136
  }
@@ -10213,16 +10141,25 @@ function getEventsBaseProperties(eventName, visitorUserAgent, ipAddress) {
10213
10141
  * @param {String} eventName event name
10214
10142
  * @returns properties
10215
10143
  */
10216
- function _getEventBasePayload(settings, userId, eventName, visitorUserAgent, ipAddress) {
10144
+ function _getEventBasePayload(settings, userId, eventName, visitorUserAgent, ipAddress, isUsageStatsEvent, usageStatsAccountId) {
10217
10145
  if (visitorUserAgent === void 0) { visitorUserAgent = ''; }
10218
10146
  if (ipAddress === void 0) { ipAddress = ''; }
10219
- var uuid = (0, UuidUtil_1.getUUID)(userId.toString(), SettingsService_1.SettingsService.Instance.accountId.toString());
10220
- var sdkKey = SettingsService_1.SettingsService.Instance.sdkKey;
10147
+ if (isUsageStatsEvent === void 0) { isUsageStatsEvent = false; }
10148
+ if (usageStatsAccountId === void 0) { usageStatsAccountId = null; }
10149
+ var accountId = SettingsService_1.SettingsService.Instance.accountId;
10150
+ if (isUsageStatsEvent) {
10151
+ // set account id for internal usage stats event
10152
+ accountId = usageStatsAccountId;
10153
+ }
10154
+ var uuid = (0, UuidUtil_1.getUUID)(userId.toString(), accountId.toString());
10221
10155
  var props = {
10222
10156
  vwo_sdkName: constants_1.Constants.SDK_NAME,
10223
10157
  vwo_sdkVersion: constants_1.Constants.SDK_VERSION,
10224
- vwo_envKey: sdkKey,
10225
10158
  };
10159
+ if (!isUsageStatsEvent) {
10160
+ // set env key for standard sdk events
10161
+ props.vwo_envKey = SettingsService_1.SettingsService.Instance.sdkKey;
10162
+ }
10226
10163
  var properties = {
10227
10164
  d: {
10228
10165
  msgId: "".concat(uuid, "-").concat((0, FunctionUtil_1.getCurrentUnixTimestampInMillis)()),
@@ -10235,13 +10172,16 @@ function _getEventBasePayload(settings, userId, eventName, visitorUserAgent, ipA
10235
10172
  name: eventName,
10236
10173
  time: (0, FunctionUtil_1.getCurrentUnixTimestampInMillis)(),
10237
10174
  },
10238
- visitor: {
10239
- props: {
10240
- vwo_fs_environment: sdkKey,
10241
- },
10242
- },
10243
10175
  },
10244
10176
  };
10177
+ if (!isUsageStatsEvent) {
10178
+ // set visitor props for standard sdk events
10179
+ properties.d.visitor = {
10180
+ props: {
10181
+ vwo_fs_environment: SettingsService_1.SettingsService.Instance.sdkKey,
10182
+ },
10183
+ };
10184
+ }
10245
10185
  return properties;
10246
10186
  }
10247
10187
  /**
@@ -10260,10 +10200,6 @@ function getTrackUserPayloadData(settings, userId, eventName, campaignId, variat
10260
10200
  properties.d.event.props.id = campaignId;
10261
10201
  properties.d.event.props.variation = variationId;
10262
10202
  properties.d.event.props.isFirst = 1;
10263
- // add usageStats as a new meta key to properties.d.events.props.vwoMeta
10264
- if (Object.keys(UsageStatsUtil_1.UsageStatsUtil.getInstance().getUsageStats()).length > 0) {
10265
- properties.d.event.props.vwoMeta = UsageStatsUtil_1.UsageStatsUtil.getInstance().getUsageStats();
10266
- }
10267
10203
  logger_1.LogManager.Instance.debug((0, LogMessageUtil_1.buildMessage)(log_messages_1.DebugLogMessagesEnum.IMPRESSION_FOR_TRACK_USER, {
10268
10204
  accountId: settings.getAccountId(),
10269
10205
  userId: userId,
@@ -10419,7 +10355,7 @@ function getMessagingEventPayload(messageType, message, eventName, extraData) {
10419
10355
  var userId = SettingsService_1.SettingsService.Instance.accountId + '_' + SettingsService_1.SettingsService.Instance.sdkKey;
10420
10356
  var properties = _getEventBasePayload(null, userId, eventName, null, null);
10421
10357
  properties.d.event.props[constants_1.Constants.VWO_FS_ENVIRONMENT] = SettingsService_1.SettingsService.Instance.sdkKey; // Set environment key
10422
- properties.d.event.props.product = 'fme';
10358
+ properties.d.event.props.product = constants_1.Constants.PRODUCT_NAME;
10423
10359
  var data = {
10424
10360
  type: messageType,
10425
10361
  content: {
@@ -10443,7 +10379,7 @@ function getSDKInitEventPayload(eventName, settingsFetchTime, sdkInitTime) {
10443
10379
  var properties = _getEventBasePayload(null, userId, eventName, null, null);
10444
10380
  // Set the required fields as specified
10445
10381
  properties.d.event.props[constants_1.Constants.VWO_FS_ENVIRONMENT] = SettingsService_1.SettingsService.Instance.sdkKey;
10446
- properties.d.event.props.product = 'fme';
10382
+ properties.d.event.props.product = constants_1.Constants.PRODUCT_NAME;
10447
10383
  var data = {
10448
10384
  isSDKInitialized: true,
10449
10385
  settingsFetchTime: settingsFetchTime,
@@ -10452,6 +10388,21 @@ function getSDKInitEventPayload(eventName, settingsFetchTime, sdkInitTime) {
10452
10388
  properties.d.event.props.data = data;
10453
10389
  return properties;
10454
10390
  }
10391
+ /**
10392
+ * Constructs the payload for sdk usage stats event.
10393
+ * @param eventName - The name of the event.
10394
+ * @param settingsFetchTime - Time taken to fetch settings in milliseconds.
10395
+ * @param sdkInitTime - Time taken to initialize the SDK in milliseconds.
10396
+ * @returns The constructed payload with required fields.
10397
+ */
10398
+ function getSDKUsageStatsEventPayload(eventName, usageStatsAccountId) {
10399
+ var userId = SettingsService_1.SettingsService.Instance.accountId + '_' + SettingsService_1.SettingsService.Instance.sdkKey;
10400
+ var properties = _getEventBasePayload(null, userId, eventName, null, null, true, usageStatsAccountId);
10401
+ // Set the required fields as specified
10402
+ properties.d.event.props.product = constants_1.Constants.PRODUCT_NAME;
10403
+ properties.d.event.props.vwoMeta = UsageStatsUtil_1.UsageStatsUtil.getInstance().getUsageStats();
10404
+ return properties;
10405
+ }
10455
10406
  /**
10456
10407
  * Sends an event to VWO (generic event sender).
10457
10408
  * @param properties - Query parameters for the request.
@@ -10470,14 +10421,14 @@ function sendEvent(properties, payload, eventName) {
10470
10421
  if (eventName === EventEnum_1.EventEnum.VWO_LOG_EVENT)
10471
10422
  retryConfig.shouldRetry = false;
10472
10423
  baseUrl = UrlUtil_1.UrlUtil.getBaseUrl();
10473
- baseUrl = UrlUtil_1.UrlUtil.getUpdatedBaseUrl(baseUrl);
10474
10424
  protocol = SettingsService_1.SettingsService.Instance.protocol;
10475
10425
  port = SettingsService_1.SettingsService.Instance.port;
10476
- if (eventName === EventEnum_1.EventEnum.VWO_LOG_EVENT) {
10426
+ if (eventName === EventEnum_1.EventEnum.VWO_LOG_EVENT || eventName === EventEnum_1.EventEnum.VWO_USAGE_STATS) {
10477
10427
  baseUrl = constants_1.Constants.HOST_NAME;
10478
10428
  protocol = constants_1.Constants.HTTPS_PROTOCOL;
10479
10429
  port = 443;
10480
10430
  }
10431
+ baseUrl = UrlUtil_1.UrlUtil.getUpdatedBaseUrl(baseUrl);
10481
10432
  try {
10482
10433
  request = new network_layer_1.RequestModel(baseUrl, HttpMethodEnum_1.HttpMethodEnum.POST, UrlEnum_1.UrlEnum.EVENTS, properties, payload, null, protocol, port, retryConfig);
10483
10434
  request.setEventName(properties.en);
@@ -10632,6 +10583,131 @@ var evaluateRule = function (settings, feature, campaign, context, evaluatedFeat
10632
10583
  exports.evaluateRule = evaluateRule;
10633
10584
 
10634
10585
 
10586
+ /***/ }),
10587
+
10588
+ /***/ "./lib/utils/SdkInitAndUsageStatsUtil.ts":
10589
+ /*!***********************************************!*\
10590
+ !*** ./lib/utils/SdkInitAndUsageStatsUtil.ts ***!
10591
+ \***********************************************/
10592
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
10593
+
10594
+ "use strict";
10595
+
10596
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10597
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10598
+ return new (P || (P = Promise))(function (resolve, reject) {
10599
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10600
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10601
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10602
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10603
+ });
10604
+ };
10605
+ var __generator = (this && this.__generator) || function (thisArg, body) {
10606
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
10607
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
10608
+ function verb(n) { return function (v) { return step([n, v]); }; }
10609
+ function step(op) {
10610
+ if (f) throw new TypeError("Generator is already executing.");
10611
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
10612
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
10613
+ if (y = 0, t) op = [op[0] & 2, t.value];
10614
+ switch (op[0]) {
10615
+ case 0: case 1: t = op; break;
10616
+ case 4: _.label++; return { value: op[1], done: false };
10617
+ case 5: _.label++; y = op[1]; op = [0]; continue;
10618
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
10619
+ default:
10620
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
10621
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
10622
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
10623
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
10624
+ if (t[2]) _.ops.pop();
10625
+ _.trys.pop(); continue;
10626
+ }
10627
+ op = body.call(thisArg, _);
10628
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
10629
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
10630
+ }
10631
+ };
10632
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
10633
+ exports.sendSdkInitEvent = sendSdkInitEvent;
10634
+ exports.sendSDKUsageStatsEvent = sendSDKUsageStatsEvent;
10635
+ /**
10636
+ * Copyright 2024-2025 Wingify Software Pvt. Ltd.
10637
+ *
10638
+ * Licensed under the Apache License, Version 2.0 (the "License");
10639
+ * you may not use this file except in compliance with the License.
10640
+ * You may obtain a copy of the License at
10641
+ *
10642
+ * http://www.apache.org/licenses/LICENSE-2.0
10643
+ *
10644
+ * Unless required by applicable law or agreed to in writing, software
10645
+ * distributed under the License is distributed on an "AS IS" BASIS,
10646
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10647
+ * See the License for the specific language governing permissions and
10648
+ * limitations under the License.
10649
+ */
10650
+ var NetworkUtil_1 = __webpack_require__(/*! ./NetworkUtil */ "./lib/utils/NetworkUtil.ts");
10651
+ var EventEnum_1 = __webpack_require__(/*! ../enums/EventEnum */ "./lib/enums/EventEnum.ts");
10652
+ var BatchEventsQueue_1 = __webpack_require__(/*! ../services/BatchEventsQueue */ "./lib/services/BatchEventsQueue.ts");
10653
+ /**
10654
+ * Sends an init called event to VWO.
10655
+ * This event is triggered when the init function is called.
10656
+ * @param {number} settingsFetchTime - Time taken to fetch settings in milliseconds.
10657
+ * @param {number} sdkInitTime - Time taken to initialize the SDK in milliseconds.
10658
+ */
10659
+ function sendSdkInitEvent(settingsFetchTime, sdkInitTime) {
10660
+ return __awaiter(this, void 0, void 0, function () {
10661
+ var properties, payload;
10662
+ return __generator(this, function (_a) {
10663
+ switch (_a.label) {
10664
+ case 0:
10665
+ properties = (0, NetworkUtil_1.getEventsBaseProperties)(EventEnum_1.EventEnum.VWO_INIT_CALLED);
10666
+ payload = (0, NetworkUtil_1.getSDKInitEventPayload)(EventEnum_1.EventEnum.VWO_INIT_CALLED, settingsFetchTime, sdkInitTime);
10667
+ if (!BatchEventsQueue_1.BatchEventsQueue.Instance) return [3 /*break*/, 1];
10668
+ BatchEventsQueue_1.BatchEventsQueue.Instance.enqueue(payload);
10669
+ return [3 /*break*/, 3];
10670
+ case 1:
10671
+ // Send the constructed properties and payload as a POST request
10672
+ //send eventName in parameters so that we can enable retry for this event
10673
+ return [4 /*yield*/, (0, NetworkUtil_1.sendEvent)(properties, payload, EventEnum_1.EventEnum.VWO_INIT_CALLED).catch(function () { })];
10674
+ case 2:
10675
+ // Send the constructed properties and payload as a POST request
10676
+ //send eventName in parameters so that we can enable retry for this event
10677
+ _a.sent();
10678
+ _a.label = 3;
10679
+ case 3: return [2 /*return*/];
10680
+ }
10681
+ });
10682
+ });
10683
+ }
10684
+ /**
10685
+ * Sends a usage stats event to VWO.
10686
+ * This event is triggered when the SDK is initialized.
10687
+ * @returns A promise that resolves to the response from the server.
10688
+ */
10689
+ function sendSDKUsageStatsEvent(usageStatsAccountId) {
10690
+ return __awaiter(this, void 0, void 0, function () {
10691
+ var properties, payload;
10692
+ return __generator(this, function (_a) {
10693
+ switch (_a.label) {
10694
+ case 0:
10695
+ properties = (0, NetworkUtil_1.getEventsBaseProperties)(EventEnum_1.EventEnum.VWO_USAGE_STATS, null, null, true, usageStatsAccountId);
10696
+ payload = (0, NetworkUtil_1.getSDKUsageStatsEventPayload)(EventEnum_1.EventEnum.VWO_USAGE_STATS, usageStatsAccountId);
10697
+ // Send the constructed properties and payload as a POST request
10698
+ //send eventName in parameters so that we can enable retry for this event
10699
+ return [4 /*yield*/, (0, NetworkUtil_1.sendEvent)(properties, payload, EventEnum_1.EventEnum.VWO_USAGE_STATS).catch(function () { })];
10700
+ case 1:
10701
+ // Send the constructed properties and payload as a POST request
10702
+ //send eventName in parameters so that we can enable retry for this event
10703
+ _a.sent();
10704
+ return [2 /*return*/];
10705
+ }
10706
+ });
10707
+ });
10708
+ }
10709
+
10710
+
10635
10711
  /***/ }),
10636
10712
 
10637
10713
  /***/ "./lib/utils/SettingsUtil.ts":
@@ -10766,6 +10842,7 @@ exports.UrlUtil = {
10766
10842
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10767
10843
  exports.UsageStatsUtil = void 0;
10768
10844
  var TransportManager_1 = __webpack_require__(/*! ../packages/logger/core/TransportManager */ "./lib/packages/logger/core/TransportManager.ts");
10845
+ var SettingsService_1 = __webpack_require__(/*! ../services/SettingsService */ "./lib/services/SettingsService.ts");
10769
10846
  /**
10770
10847
  * Manages usage statistics for the SDK.
10771
10848
  * Tracks various features and configurations being used by the client.
@@ -10802,12 +10879,14 @@ var UsageStatsUtil = /** @class */ (function () {
10802
10879
  */
10803
10880
  UsageStatsUtil.prototype.setUsageStats = function (options) {
10804
10881
  var _a;
10805
- var storage = options.storage, logger = options.logger, batchEvents = options.batchEvents, gatewayService = options.gatewayService, integrations = options.integrations, pollingInterval = options.pollingInterval, _vwo_meta = options._vwo_meta, shouldWaitForTrackingCalls = options.shouldWaitForTrackingCalls;
10882
+ var storage = options.storage, logger = options.logger, batchEventData = options.batchEventData, gatewayService = options.gatewayService, integrations = options.integrations, pollInterval = options.pollInterval, _vwo_meta = options._vwo_meta, shouldWaitForTrackingCalls = options.shouldWaitForTrackingCalls;
10806
10883
  var data = {};
10884
+ data.a = SettingsService_1.SettingsService.Instance.accountId;
10885
+ data.env = SettingsService_1.SettingsService.Instance.sdkKey;
10807
10886
  // Map configuration options to usage stats flags
10808
10887
  if (integrations)
10809
10888
  data.ig = 1; // Integration enabled
10810
- if (batchEvents)
10889
+ if (batchEventData)
10811
10890
  data.eb = 1; // Event batching enabled
10812
10891
  // if logger has transport or transports, then it is custom logger
10813
10892
  if (logger && (logger.transport || logger.transports))
@@ -10819,8 +10898,8 @@ var UsageStatsUtil = /** @class */ (function () {
10819
10898
  }
10820
10899
  if (gatewayService)
10821
10900
  data.gs = 1; // Gateway service configured
10822
- if (pollingInterval)
10823
- data.pi = 1; // Polling interval configured
10901
+ if (pollInterval)
10902
+ data.pi = pollInterval; // Polling interval configured
10824
10903
  if (shouldWaitForTrackingCalls)
10825
10904
  data.swtc = 1;
10826
10905
  // if _vwo_meta has ea, then addd data._ea to be 1