@statsig/client-core 1.8.0-beta.13 → 1.8.0-beta.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/client-core",
3
- "version": "1.8.0-beta.13",
3
+ "version": "1.8.0-beta.15",
4
4
  "dependencies": {},
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -76,6 +76,21 @@ class NetworkCore {
76
76
  const body = yield this._getPopulatedBody(Object.assign(Object.assign({}, args), networkProxyArgs));
77
77
  const url = yield this._getPopulatedURL(Object.assign(Object.assign({}, args), networkProxyArgs));
78
78
  const nav = navigator;
79
+ const isProxy = !url.includes('https://statsigapi.net/v1');
80
+ const parsedUrl = new URL(url);
81
+ const endpoint = parsedUrl.pathname;
82
+ if (!url.includes('https://prodregistryv2.org')) {
83
+ this.networkEvents.push({
84
+ value: isProxy ? 'proxy' : 'statsig',
85
+ eventName: 'proxy::network_request_tracking',
86
+ metadata: {
87
+ url,
88
+ endpoint,
89
+ },
90
+ time: Date.now(),
91
+ user: null,
92
+ });
93
+ }
79
94
  return nav.sendBeacon.bind(nav)(url, body);
80
95
  });
81
96
  }
@@ -95,16 +110,25 @@ class NetworkCore {
95
110
  controller === null || controller === void 0 ? void 0 : controller.abort(`Timeout of ${this._timeout}ms expired.`);
96
111
  }, this._timeout);
97
112
  const proxyUrl = (_a = args.proxyUrl) !== null && _a !== void 0 ? _a : this._proxy.getProxyUrl(args.sdkKey, args.url);
98
- console.log('1');
99
113
  const url = yield this._getPopulatedURL(Object.assign({ proxyUrl }, args));
100
- console.log('2');
101
114
  const isProxy = !url.includes('https://statsigapi.net/v1');
102
115
  const parsedUrl = new URL(url);
103
116
  const endpoint = parsedUrl.pathname;
104
117
  let response = null;
105
118
  const keepalive = (0, VisibilityObserving_1._isUnloading)();
106
- console.log('3');
107
119
  try {
120
+ if (!url.includes('https://prodregistryv2.org')) {
121
+ this.networkEvents.push({
122
+ value: isProxy ? 'proxy' : 'statsig',
123
+ eventName: 'proxy::network_request_tracking',
124
+ metadata: {
125
+ url,
126
+ endpoint,
127
+ },
128
+ time: Date.now(),
129
+ user: null,
130
+ });
131
+ }
108
132
  const config = {
109
133
  method,
110
134
  body,
@@ -113,7 +137,6 @@ class NetworkCore {
113
137
  priority: args.priority,
114
138
  keepalive,
115
139
  };
116
- console.log('3');
117
140
  if (args.isInitialize) {
118
141
  Diagnostics_1.Diagnostics._markInitNetworkReqStart(args.sdkKey, {
119
142
  attempt: currentAttempt,
@@ -122,11 +145,9 @@ class NetworkCore {
122
145
  const func = (_b = this._netConfig.networkOverrideFunc) !== null && _b !== void 0 ? _b : fetch;
123
146
  response = yield func(url, config);
124
147
  clearTimeout(handle);
125
- console.log('4');
126
148
  if (!response.ok) {
127
149
  const text = yield response.text().catch(() => 'No Text');
128
150
  const err = new Error(`NetworkError: ${url} ${text}`);
129
- console.log('response not ok!!', err);
130
151
  err.name = 'NetworkError';
131
152
  throw err;
132
153
  }
@@ -134,42 +155,12 @@ class NetworkCore {
134
155
  if (args.isInitialize) {
135
156
  Diagnostics_1.Diagnostics._markInitNetworkReqEnd(args.sdkKey, Diagnostics_1.Diagnostics._getDiagnosticsData(response, currentAttempt, text));
136
157
  }
137
- console.log('network success!!');
138
- if (!url.includes('https://prodregistryv2.org')) {
139
- console.log('pushing success network event!!');
140
- this.networkEvents.push({
141
- value: isProxy ? 'proxy' : 'statsig',
142
- eventName: 'proxy::network_request_tracking',
143
- metadata: {
144
- url,
145
- success: true,
146
- endpoint,
147
- },
148
- time: Date.now(),
149
- user: null,
150
- });
151
- }
152
158
  return {
153
159
  body: text,
154
160
  code: response.status,
155
161
  };
156
162
  }
157
163
  catch (error) {
158
- console.log('network error!!', error);
159
- if (!url.includes('https://prodregistryv2.org')) {
160
- console.log('pushing failure network event!!');
161
- this.networkEvents.push({
162
- value: isProxy ? 'proxy' : 'statsig',
163
- eventName: 'proxy::network_request_tracking',
164
- metadata: {
165
- url,
166
- success: false,
167
- endpoint,
168
- },
169
- time: Date.now(),
170
- user: null,
171
- });
172
- }
173
164
  const errorMessage = _getErrorMessage(controller, error);
174
165
  const timedOut = _didTimeout(controller);
175
166
  if (args.isInitialize) {
@@ -238,7 +229,6 @@ class NetworkCore {
238
229
  }
239
230
  _flushNetworkEvents() {
240
231
  var _a;
241
- console.log('flushing network events!!', this.networkEvents);
242
232
  if (this.networkEvents.length === 0) {
243
233
  return;
244
234
  }
@@ -254,7 +244,7 @@ class NetworkCore {
254
244
  _startBackgroundFlushNetworkEvents() {
255
245
  setInterval(() => {
256
246
  this._flushNetworkEvents();
257
- }, 10000);
247
+ }, 60000);
258
248
  }
259
249
  }
260
250
  exports.NetworkCore = NetworkCore;
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "1.8.0-beta.13";
1
+ export declare const SDK_VERSION = "1.8.0-beta.15";
2
2
  export type StatsigMetadata = {
3
3
  readonly [key: string]: string | undefined;
4
4
  readonly appVersion?: string;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '1.8.0-beta.13';
4
+ exports.SDK_VERSION = '1.8.0-beta.15';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients