@devskin/browser-sdk 1.0.27 → 1.0.29

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.
@@ -517,7 +517,7 @@
517
517
  stack: error.stack,
518
518
  type: error.name || 'Error',
519
519
  timestamp: new Date().toISOString(),
520
- session_id: '', // Will be set by transport
520
+ sessionId: '', // Will be set by transport
521
521
  url: window.location.href,
522
522
  breadcrumbs: [...this.breadcrumbs],
523
523
  context: Object.assign(Object.assign({}, context), { userAgent: navigator.userAgent, viewport: {
@@ -540,7 +540,7 @@
540
540
  message: String(error),
541
541
  type: 'Error',
542
542
  timestamp: new Date().toISOString(),
543
- session_id: '',
543
+ sessionId: '',
544
544
  url: window.location.href,
545
545
  breadcrumbs: [...this.breadcrumbs],
546
546
  context,
@@ -13716,9 +13716,12 @@
13716
13716
  }
13717
13717
  }
13718
13718
  enqueue(type, data) {
13719
+ // Add applicationId to RUM events (event, error, network, performance)
13720
+ // Heatmap uses apiKey/appId in payload root instead
13721
+ const enrichedData = type !== 'heatmap' ? Object.assign(Object.assign({}, data), { applicationId: this.config.appId }) : data;
13719
13722
  this.queue.push({
13720
13723
  type,
13721
- data,
13724
+ data: enrichedData,
13722
13725
  timestamp: Date.now(),
13723
13726
  });
13724
13727
  // Flush if queue is full
@@ -13750,7 +13753,7 @@
13750
13753
  sendToBackendXHR(endpoint, data) {
13751
13754
  return __awaiter$1(this, void 0, void 0, function* () {
13752
13755
  const url = `${this.apiUrl}${endpoint}`;
13753
- const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, appId: this.config.appId, environment: this.config.environment, release: this.config.release });
13756
+ const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, applicationId: this.config.appId, environment: this.config.environment, release: this.config.release });
13754
13757
  // Apply beforeSend hook if provided
13755
13758
  if (this.config.beforeSend) {
13756
13759
  const processed = this.config.beforeSend(payload);
@@ -13800,7 +13803,7 @@
13800
13803
  sendToBackend(endpoint_1, data_1) {
13801
13804
  return __awaiter$1(this, arguments, void 0, function* (endpoint, data, useBeacon = false) {
13802
13805
  const url = `${this.apiUrl}${endpoint}`;
13803
- const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, appId: this.config.appId, environment: this.config.environment, release: this.config.release });
13806
+ const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, applicationId: this.config.appId, environment: this.config.environment, release: this.config.release });
13804
13807
  // Apply beforeSend hook if provided
13805
13808
  if (this.config.beforeSend) {
13806
13809
  const processed = this.config.beforeSend(payload);
@@ -13984,15 +13987,15 @@
13984
13987
  return;
13985
13988
  }
13986
13989
  const eventData = {
13987
- event_name: eventName,
13988
- event_type: 'track',
13990
+ eventName: eventName,
13991
+ eventType: 'track',
13989
13992
  timestamp: new Date().toISOString(),
13990
- session_id: this.sessionId,
13991
- user_id: this.userId || undefined,
13992
- anonymous_id: this.anonymousId || undefined,
13993
+ sessionId: this.sessionId,
13994
+ userId: this.userId || undefined,
13995
+ anonymousId: this.anonymousId || undefined,
13993
13996
  properties: Object.assign(Object.assign({}, properties), this.getContextData()),
13994
- page_url: window.location.href,
13995
- page_title: document.title,
13997
+ pageUrl: window.location.href,
13998
+ pageTitle: document.title,
13996
13999
  };
13997
14000
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.sendEvent(eventData);
13998
14001
  if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) {
@@ -14033,10 +14036,10 @@
14033
14036
  }
14034
14037
  this.userId = userId;
14035
14038
  const userData = {
14036
- user_id: userId,
14037
- anonymous_id: this.anonymousId || undefined,
14039
+ userId: userId,
14040
+ anonymousId: this.anonymousId || undefined,
14038
14041
  traits: Object.assign(Object.assign({}, traits), this.getContextData()),
14039
- session_id: this.sessionId,
14042
+ sessionId: this.sessionId,
14040
14043
  timestamp: new Date().toISOString(),
14041
14044
  };
14042
14045
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.identifyUser(userData);
@@ -14110,22 +14113,40 @@
14110
14113
  // Store in sessionStorage (persists across page navigations in same tab)
14111
14114
  sessionStorage.setItem('devskin_session_id', this.sessionId);
14112
14115
  sessionStorage.setItem('devskin_session_start', this.sessionStartTime.toString());
14113
- const sessionData = Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, started_at: new Date().toISOString() }, this.getContextData());
14116
+ const sessionData = Object.assign({ sessionId: this.sessionId, userId: this.userId || undefined, anonymousId: this.anonymousId, startedAt: new Date().toISOString(), platform: 'web' }, this.getContextData());
14114
14117
  (_b = this.transport) === null || _b === void 0 ? void 0 : _b.startSession(sessionData);
14115
14118
  if ((_c = this.config) === null || _c === void 0 ? void 0 : _c.debug) {
14116
14119
  console.log('[DevSkin] New session created:', this.sessionId);
14117
14120
  }
14118
14121
  }
14119
14122
  getContextData() {
14123
+ var _a, _b, _c, _d;
14120
14124
  const context = {};
14125
+ // Flatten device data to match backend schema
14121
14126
  if (this.deviceCollector) {
14122
- context.device = this.deviceCollector.collect();
14127
+ const device = this.deviceCollector.collect();
14128
+ context.deviceType = device.type;
14129
+ context.deviceModel = device.model;
14130
+ context.osName = (_a = device.os) === null || _a === void 0 ? void 0 : _a.name;
14131
+ context.osVersion = (_b = device.os) === null || _b === void 0 ? void 0 : _b.version;
14132
+ context.screenWidth = (_c = device.screen) === null || _c === void 0 ? void 0 : _c.width;
14133
+ context.screenHeight = (_d = device.screen) === null || _d === void 0 ? void 0 : _d.height;
14134
+ context.viewportWidth = window.innerWidth;
14135
+ context.viewportHeight = window.innerHeight;
14123
14136
  }
14137
+ // Flatten browser data to match backend schema
14124
14138
  if (this.browserCollector) {
14125
- context.browser = this.browserCollector.collect();
14139
+ const browser = this.browserCollector.collect();
14140
+ context.browserName = browser.name;
14141
+ context.browserVersion = browser.version;
14142
+ context.userAgent = browser.userAgent;
14126
14143
  }
14144
+ // Flatten location data to match backend schema
14127
14145
  if (this.locationCollector) {
14128
- context.location = this.locationCollector.collect();
14146
+ const location = this.locationCollector.collect();
14147
+ context.country = location.country;
14148
+ context.city = location.city;
14149
+ context.ipAddress = undefined; // Will be set by backend from request
14129
14150
  }
14130
14151
  return context;
14131
14152
  }
@@ -14171,7 +14192,7 @@
14171
14192
  if (this.sessionId && this.sessionStartTime) {
14172
14193
  const endedAt = new Date();
14173
14194
  const durationMs = Date.now() - this.sessionStartTime;
14174
- (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, ended_at: endedAt.toISOString(), duration_ms: durationMs }, this.getContextData()));
14195
+ (_a = this.transport) === null || _a === void 0 ? void 0 : _a.startSession(Object.assign({ sessionId: this.sessionId, userId: this.userId || undefined, anonymousId: this.anonymousId, endedAt: endedAt.toISOString(), durationMs: durationMs, platform: 'web' }, this.getContextData()));
14175
14196
  // Clear session storage since session is ending
14176
14197
  sessionStorage.removeItem('devskin_session_id');
14177
14198
  sessionStorage.removeItem('devskin_session_start');