@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.
@@ -511,7 +511,7 @@ class ErrorCollector {
511
511
  stack: error.stack,
512
512
  type: error.name || 'Error',
513
513
  timestamp: new Date().toISOString(),
514
- session_id: '', // Will be set by transport
514
+ sessionId: '', // Will be set by transport
515
515
  url: window.location.href,
516
516
  breadcrumbs: [...this.breadcrumbs],
517
517
  context: Object.assign(Object.assign({}, context), { userAgent: navigator.userAgent, viewport: {
@@ -534,7 +534,7 @@ class ErrorCollector {
534
534
  message: String(error),
535
535
  type: 'Error',
536
536
  timestamp: new Date().toISOString(),
537
- session_id: '',
537
+ sessionId: '',
538
538
  url: window.location.href,
539
539
  breadcrumbs: [...this.breadcrumbs],
540
540
  context,
@@ -13710,9 +13710,12 @@ class Transport {
13710
13710
  }
13711
13711
  }
13712
13712
  enqueue(type, data) {
13713
+ // Add applicationId to RUM events (event, error, network, performance)
13714
+ // Heatmap uses apiKey/appId in payload root instead
13715
+ const enrichedData = type !== 'heatmap' ? Object.assign(Object.assign({}, data), { applicationId: this.config.appId }) : data;
13713
13716
  this.queue.push({
13714
13717
  type,
13715
- data,
13718
+ data: enrichedData,
13716
13719
  timestamp: Date.now(),
13717
13720
  });
13718
13721
  // Flush if queue is full
@@ -13744,7 +13747,7 @@ class Transport {
13744
13747
  sendToBackendXHR(endpoint, data) {
13745
13748
  return __awaiter$1(this, void 0, void 0, function* () {
13746
13749
  const url = `${this.apiUrl}${endpoint}`;
13747
- const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, appId: this.config.appId, environment: this.config.environment, release: this.config.release });
13750
+ const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, applicationId: this.config.appId, environment: this.config.environment, release: this.config.release });
13748
13751
  // Apply beforeSend hook if provided
13749
13752
  if (this.config.beforeSend) {
13750
13753
  const processed = this.config.beforeSend(payload);
@@ -13794,7 +13797,7 @@ class Transport {
13794
13797
  sendToBackend(endpoint_1, data_1) {
13795
13798
  return __awaiter$1(this, arguments, void 0, function* (endpoint, data, useBeacon = false) {
13796
13799
  const url = `${this.apiUrl}${endpoint}`;
13797
- const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, appId: this.config.appId, environment: this.config.environment, release: this.config.release });
13800
+ const payload = Object.assign(Object.assign({}, data), { apiKey: this.config.apiKey, applicationId: this.config.appId, environment: this.config.environment, release: this.config.release });
13798
13801
  // Apply beforeSend hook if provided
13799
13802
  if (this.config.beforeSend) {
13800
13803
  const processed = this.config.beforeSend(payload);
@@ -13978,15 +13981,15 @@ class DevSkinSDK {
13978
13981
  return;
13979
13982
  }
13980
13983
  const eventData = {
13981
- event_name: eventName,
13982
- event_type: 'track',
13984
+ eventName: eventName,
13985
+ eventType: 'track',
13983
13986
  timestamp: new Date().toISOString(),
13984
- session_id: this.sessionId,
13985
- user_id: this.userId || undefined,
13986
- anonymous_id: this.anonymousId || undefined,
13987
+ sessionId: this.sessionId,
13988
+ userId: this.userId || undefined,
13989
+ anonymousId: this.anonymousId || undefined,
13987
13990
  properties: Object.assign(Object.assign({}, properties), this.getContextData()),
13988
- page_url: window.location.href,
13989
- page_title: document.title,
13991
+ pageUrl: window.location.href,
13992
+ pageTitle: document.title,
13990
13993
  };
13991
13994
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.sendEvent(eventData);
13992
13995
  if ((_b = this.config) === null || _b === void 0 ? void 0 : _b.debug) {
@@ -14027,10 +14030,10 @@ class DevSkinSDK {
14027
14030
  }
14028
14031
  this.userId = userId;
14029
14032
  const userData = {
14030
- user_id: userId,
14031
- anonymous_id: this.anonymousId || undefined,
14033
+ userId: userId,
14034
+ anonymousId: this.anonymousId || undefined,
14032
14035
  traits: Object.assign(Object.assign({}, traits), this.getContextData()),
14033
- session_id: this.sessionId,
14036
+ sessionId: this.sessionId,
14034
14037
  timestamp: new Date().toISOString(),
14035
14038
  };
14036
14039
  (_a = this.transport) === null || _a === void 0 ? void 0 : _a.identifyUser(userData);
@@ -14104,22 +14107,40 @@ class DevSkinSDK {
14104
14107
  // Store in sessionStorage (persists across page navigations in same tab)
14105
14108
  sessionStorage.setItem('devskin_session_id', this.sessionId);
14106
14109
  sessionStorage.setItem('devskin_session_start', this.sessionStartTime.toString());
14107
- const sessionData = Object.assign({ session_id: this.sessionId, user_id: this.userId || undefined, anonymous_id: this.anonymousId, started_at: new Date().toISOString() }, this.getContextData());
14110
+ const sessionData = Object.assign({ sessionId: this.sessionId, userId: this.userId || undefined, anonymousId: this.anonymousId, startedAt: new Date().toISOString(), platform: 'web' }, this.getContextData());
14108
14111
  (_b = this.transport) === null || _b === void 0 ? void 0 : _b.startSession(sessionData);
14109
14112
  if ((_c = this.config) === null || _c === void 0 ? void 0 : _c.debug) {
14110
14113
  console.log('[DevSkin] New session created:', this.sessionId);
14111
14114
  }
14112
14115
  }
14113
14116
  getContextData() {
14117
+ var _a, _b, _c, _d;
14114
14118
  const context = {};
14119
+ // Flatten device data to match backend schema
14115
14120
  if (this.deviceCollector) {
14116
- context.device = this.deviceCollector.collect();
14121
+ const device = this.deviceCollector.collect();
14122
+ context.deviceType = device.type;
14123
+ context.deviceModel = device.model;
14124
+ context.osName = (_a = device.os) === null || _a === void 0 ? void 0 : _a.name;
14125
+ context.osVersion = (_b = device.os) === null || _b === void 0 ? void 0 : _b.version;
14126
+ context.screenWidth = (_c = device.screen) === null || _c === void 0 ? void 0 : _c.width;
14127
+ context.screenHeight = (_d = device.screen) === null || _d === void 0 ? void 0 : _d.height;
14128
+ context.viewportWidth = window.innerWidth;
14129
+ context.viewportHeight = window.innerHeight;
14117
14130
  }
14131
+ // Flatten browser data to match backend schema
14118
14132
  if (this.browserCollector) {
14119
- context.browser = this.browserCollector.collect();
14133
+ const browser = this.browserCollector.collect();
14134
+ context.browserName = browser.name;
14135
+ context.browserVersion = browser.version;
14136
+ context.userAgent = browser.userAgent;
14120
14137
  }
14138
+ // Flatten location data to match backend schema
14121
14139
  if (this.locationCollector) {
14122
- context.location = this.locationCollector.collect();
14140
+ const location = this.locationCollector.collect();
14141
+ context.country = location.country;
14142
+ context.city = location.city;
14143
+ context.ipAddress = undefined; // Will be set by backend from request
14123
14144
  }
14124
14145
  return context;
14125
14146
  }
@@ -14165,7 +14186,7 @@ class DevSkinSDK {
14165
14186
  if (this.sessionId && this.sessionStartTime) {
14166
14187
  const endedAt = new Date();
14167
14188
  const durationMs = Date.now() - this.sessionStartTime;
14168
- (_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()));
14189
+ (_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()));
14169
14190
  // Clear session storage since session is ending
14170
14191
  sessionStorage.removeItem('devskin_session_id');
14171
14192
  sessionStorage.removeItem('devskin_session_start');