aurea-tracking-sdk 1.0.0 → 1.1.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.
package/dist/index.d.mts CHANGED
@@ -62,6 +62,10 @@ declare class AureaSDK {
62
62
  * Get or create anonymous ID
63
63
  */
64
64
  private getOrCreateAnonymousId;
65
+ /**
66
+ * Parse device information from user agent
67
+ */
68
+ private parseDeviceInfo;
65
69
  /**
66
70
  * Build event context
67
71
  */
package/dist/index.d.ts CHANGED
@@ -62,6 +62,10 @@ declare class AureaSDK {
62
62
  * Get or create anonymous ID
63
63
  */
64
64
  private getOrCreateAnonymousId;
65
+ /**
66
+ * Parse device information from user agent
67
+ */
68
+ private parseDeviceInfo;
65
69
  /**
66
70
  * Build event context
67
71
  */
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ __export(index_exports, {
27
27
  trackPage: () => trackPage
28
28
  });
29
29
  module.exports = __toCommonJS(index_exports);
30
+ var import_ua_parser_js = require("ua-parser-js");
30
31
  var AureaSDK = class {
31
32
  constructor(config) {
32
33
  this.eventQueue = [];
@@ -184,6 +185,48 @@ var AureaSDK = class {
184
185
  }
185
186
  return anonymousId;
186
187
  }
188
+ /**
189
+ * Parse device information from user agent
190
+ */
191
+ parseDeviceInfo() {
192
+ if (typeof navigator === "undefined") return void 0;
193
+ const parser = new import_ua_parser_js.UAParser(navigator.userAgent);
194
+ const result = parser.getResult();
195
+ let deviceType = "Desktop";
196
+ if (result.device.type) {
197
+ switch (result.device.type.toLowerCase()) {
198
+ case "mobile":
199
+ deviceType = "Mobile";
200
+ break;
201
+ case "tablet":
202
+ deviceType = "Tablet";
203
+ break;
204
+ case "smarttv":
205
+ deviceType = "Smart TV";
206
+ break;
207
+ case "wearable":
208
+ deviceType = "Wearable";
209
+ break;
210
+ case "console":
211
+ deviceType = "Console";
212
+ break;
213
+ default:
214
+ deviceType = "Desktop";
215
+ }
216
+ }
217
+ return {
218
+ userAgent: navigator.userAgent,
219
+ deviceType,
220
+ browserName: result.browser.name || "Unknown",
221
+ browserVersion: result.browser.version || "Unknown",
222
+ osName: result.os.name || "Unknown",
223
+ osVersion: result.os.version || "Unknown",
224
+ screenWidth: window.screen?.width,
225
+ screenHeight: window.screen?.height,
226
+ language: navigator.language,
227
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
228
+ };
229
+ }
187
230
  /**
188
231
  * Build event context
189
232
  */
@@ -210,13 +253,7 @@ var AureaSDK = class {
210
253
  session: {
211
254
  sessionId: this.sessionId
212
255
  },
213
- device: typeof navigator !== "undefined" ? {
214
- userAgent: navigator.userAgent,
215
- screenWidth: window.screen?.width,
216
- screenHeight: window.screen?.height,
217
- language: navigator.language,
218
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
219
- } : void 0
256
+ device: typeof navigator !== "undefined" ? this.parseDeviceInfo() : void 0
220
257
  };
221
258
  }
222
259
  /**
@@ -386,9 +423,8 @@ var AureaSDK = class {
386
423
  */
387
424
  async checkForPurchase() {
388
425
  try {
389
- const response = await fetch(
390
- `${this.config.apiUrl?.replace("/api", "")}/api/check-purchase?anonymousId=${this.anonymousId}`
391
- );
426
+ const checkUrl = `${window.location.origin}/api/check-purchase?anonymousId=${this.anonymousId}`;
427
+ const response = await fetch(checkUrl);
392
428
  const data = await response.json();
393
429
  if (data.hasPurchased) {
394
430
  console.log("[Aurea SDK] Purchase detected! Redirecting to thank-you page...");
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/index.ts
2
+ import { UAParser } from "ua-parser-js";
2
3
  var AureaSDK = class {
3
4
  constructor(config) {
4
5
  this.eventQueue = [];
@@ -156,6 +157,48 @@ var AureaSDK = class {
156
157
  }
157
158
  return anonymousId;
158
159
  }
160
+ /**
161
+ * Parse device information from user agent
162
+ */
163
+ parseDeviceInfo() {
164
+ if (typeof navigator === "undefined") return void 0;
165
+ const parser = new UAParser(navigator.userAgent);
166
+ const result = parser.getResult();
167
+ let deviceType = "Desktop";
168
+ if (result.device.type) {
169
+ switch (result.device.type.toLowerCase()) {
170
+ case "mobile":
171
+ deviceType = "Mobile";
172
+ break;
173
+ case "tablet":
174
+ deviceType = "Tablet";
175
+ break;
176
+ case "smarttv":
177
+ deviceType = "Smart TV";
178
+ break;
179
+ case "wearable":
180
+ deviceType = "Wearable";
181
+ break;
182
+ case "console":
183
+ deviceType = "Console";
184
+ break;
185
+ default:
186
+ deviceType = "Desktop";
187
+ }
188
+ }
189
+ return {
190
+ userAgent: navigator.userAgent,
191
+ deviceType,
192
+ browserName: result.browser.name || "Unknown",
193
+ browserVersion: result.browser.version || "Unknown",
194
+ osName: result.os.name || "Unknown",
195
+ osVersion: result.os.version || "Unknown",
196
+ screenWidth: window.screen?.width,
197
+ screenHeight: window.screen?.height,
198
+ language: navigator.language,
199
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
200
+ };
201
+ }
159
202
  /**
160
203
  * Build event context
161
204
  */
@@ -182,13 +225,7 @@ var AureaSDK = class {
182
225
  session: {
183
226
  sessionId: this.sessionId
184
227
  },
185
- device: typeof navigator !== "undefined" ? {
186
- userAgent: navigator.userAgent,
187
- screenWidth: window.screen?.width,
188
- screenHeight: window.screen?.height,
189
- language: navigator.language,
190
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
191
- } : void 0
228
+ device: typeof navigator !== "undefined" ? this.parseDeviceInfo() : void 0
192
229
  };
193
230
  }
194
231
  /**
@@ -358,9 +395,8 @@ var AureaSDK = class {
358
395
  */
359
396
  async checkForPurchase() {
360
397
  try {
361
- const response = await fetch(
362
- `${this.config.apiUrl?.replace("/api", "")}/api/check-purchase?anonymousId=${this.anonymousId}`
363
- );
398
+ const checkUrl = `${window.location.origin}/api/check-purchase?anonymousId=${this.anonymousId}`;
399
+ const response = await fetch(checkUrl);
364
400
  const data = await response.json();
365
401
  if (data.hasPurchased) {
366
402
  console.log("[Aurea SDK] Purchase detected! Redirecting to thank-you page...");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aurea-tracking-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Standalone tracking SDK for Aurea CRM external funnels",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -36,5 +36,8 @@
36
36
  "@types/node": "^25.0.3",
37
37
  "tsup": "^8.0.1",
38
38
  "typescript": "^5.3.3"
39
+ },
40
+ "dependencies": {
41
+ "ua-parser-js": "^2.0.7"
39
42
  }
40
43
  }