@callforge/tracking-client 0.5.0 → 0.5.1

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/dist/index.js CHANGED
@@ -234,26 +234,31 @@ var CallForge = class _CallForge {
234
234
  });
235
235
  }
236
236
  async fetchSession() {
237
+ var _a;
237
238
  const locationId = this.getLocationId();
238
- const cached = this.cache.get(locationId);
239
- if (cached) {
240
- this.sessionId = cached.sessionId;
241
- this.sessionCreated = true;
242
- return this.formatSession(cached);
243
- }
244
- const autoParams = this.getAutoParams();
245
- const cachedParams = this.cache.getParams();
246
- const params = __spreadValues(__spreadValues(__spreadValues({}, autoParams), cachedParams), this.customParams);
247
239
  if (typeof window !== "undefined" && window.__cfTracking) {
248
240
  try {
249
241
  const data2 = await window.__cfTracking;
250
- this.saveToCache(locationId, data2, params);
242
+ const dataWithExtras = data2;
243
+ const effectiveLocId = (_a = dataWithExtras.locId) != null ? _a : locationId;
244
+ const autoParams2 = this.getAutoParams();
245
+ const params2 = __spreadValues(__spreadValues(__spreadValues({}, autoParams2), dataWithExtras.params), this.customParams);
246
+ this.saveToCache(effectiveLocId, data2, params2);
251
247
  this.sessionId = data2.sessionId;
252
248
  this.sessionCreated = true;
253
249
  return this.formatApiResponse(data2);
254
250
  } catch (e) {
255
251
  }
256
252
  }
253
+ const cached = this.cache.get(locationId);
254
+ if (cached) {
255
+ this.sessionId = cached.sessionId;
256
+ this.sessionCreated = true;
257
+ return this.formatSession(cached);
258
+ }
259
+ const autoParams = this.getAutoParams();
260
+ const cachedParams = this.cache.getParams();
261
+ const params = __spreadValues(__spreadValues(__spreadValues({}, autoParams), cachedParams), this.customParams);
257
262
  const cachedSessionId = this.cache.getSessionId(locationId);
258
263
  const data = await this.fetchFromApi(locationId, cachedSessionId, params);
259
264
  this.saveToCache(locationId, data, params);
@@ -297,7 +302,7 @@ var CallForge = class _CallForge {
297
302
  }
298
303
  saveToCache(locationId, data, params) {
299
304
  const cached = {
300
- locId: locationId,
305
+ locId: locationId != null ? locationId : null,
301
306
  sessionId: data.sessionId,
302
307
  phoneNumber: data.phoneNumber,
303
308
  location: data.location,
package/dist/index.mjs CHANGED
@@ -210,26 +210,31 @@ var CallForge = class _CallForge {
210
210
  });
211
211
  }
212
212
  async fetchSession() {
213
+ var _a;
213
214
  const locationId = this.getLocationId();
214
- const cached = this.cache.get(locationId);
215
- if (cached) {
216
- this.sessionId = cached.sessionId;
217
- this.sessionCreated = true;
218
- return this.formatSession(cached);
219
- }
220
- const autoParams = this.getAutoParams();
221
- const cachedParams = this.cache.getParams();
222
- const params = __spreadValues(__spreadValues(__spreadValues({}, autoParams), cachedParams), this.customParams);
223
215
  if (typeof window !== "undefined" && window.__cfTracking) {
224
216
  try {
225
217
  const data2 = await window.__cfTracking;
226
- this.saveToCache(locationId, data2, params);
218
+ const dataWithExtras = data2;
219
+ const effectiveLocId = (_a = dataWithExtras.locId) != null ? _a : locationId;
220
+ const autoParams2 = this.getAutoParams();
221
+ const params2 = __spreadValues(__spreadValues(__spreadValues({}, autoParams2), dataWithExtras.params), this.customParams);
222
+ this.saveToCache(effectiveLocId, data2, params2);
227
223
  this.sessionId = data2.sessionId;
228
224
  this.sessionCreated = true;
229
225
  return this.formatApiResponse(data2);
230
226
  } catch (e) {
231
227
  }
232
228
  }
229
+ const cached = this.cache.get(locationId);
230
+ if (cached) {
231
+ this.sessionId = cached.sessionId;
232
+ this.sessionCreated = true;
233
+ return this.formatSession(cached);
234
+ }
235
+ const autoParams = this.getAutoParams();
236
+ const cachedParams = this.cache.getParams();
237
+ const params = __spreadValues(__spreadValues(__spreadValues({}, autoParams), cachedParams), this.customParams);
233
238
  const cachedSessionId = this.cache.getSessionId(locationId);
234
239
  const data = await this.fetchFromApi(locationId, cachedSessionId, params);
235
240
  this.saveToCache(locationId, data, params);
@@ -273,7 +278,7 @@ var CallForge = class _CallForge {
273
278
  }
274
279
  saveToCache(locationId, data, params) {
275
280
  const cached = {
276
- locId: locationId,
281
+ locId: locationId != null ? locationId : null,
277
282
  sessionId: data.sessionId,
278
283
  phoneNumber: data.phoneNumber,
279
284
  location: data.location,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callforge/tracking-client",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",