aurea-tracking-sdk 1.5.1 → 1.5.3
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 +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +158 -7
- package/dist/index.mjs +158 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -396,6 +396,23 @@ declare class AureaSDK {
|
|
|
396
396
|
* Generate event ID
|
|
397
397
|
*/
|
|
398
398
|
private generateEventId;
|
|
399
|
+
/**
|
|
400
|
+
* Get cookie value by name
|
|
401
|
+
*/
|
|
402
|
+
private getCookie;
|
|
403
|
+
/**
|
|
404
|
+
* Store click IDs in localStorage with attribution windows
|
|
405
|
+
*/
|
|
406
|
+
private storeClickIds;
|
|
407
|
+
/**
|
|
408
|
+
* Get stored click IDs from localStorage (within attribution window)
|
|
409
|
+
* Returns only the ID strings (not the full storage object)
|
|
410
|
+
*/
|
|
411
|
+
private getStoredClickIds;
|
|
412
|
+
/**
|
|
413
|
+
* Get attribution window for a platform (in milliseconds)
|
|
414
|
+
*/
|
|
415
|
+
private getAttributionWindow;
|
|
399
416
|
}
|
|
400
417
|
/**
|
|
401
418
|
* Initialize Aurea SDK
|
package/dist/index.d.ts
CHANGED
|
@@ -396,6 +396,23 @@ declare class AureaSDK {
|
|
|
396
396
|
* Generate event ID
|
|
397
397
|
*/
|
|
398
398
|
private generateEventId;
|
|
399
|
+
/**
|
|
400
|
+
* Get cookie value by name
|
|
401
|
+
*/
|
|
402
|
+
private getCookie;
|
|
403
|
+
/**
|
|
404
|
+
* Store click IDs in localStorage with attribution windows
|
|
405
|
+
*/
|
|
406
|
+
private storeClickIds;
|
|
407
|
+
/**
|
|
408
|
+
* Get stored click IDs from localStorage (within attribution window)
|
|
409
|
+
* Returns only the ID strings (not the full storage object)
|
|
410
|
+
*/
|
|
411
|
+
private getStoredClickIds;
|
|
412
|
+
/**
|
|
413
|
+
* Get attribution window for a platform (in milliseconds)
|
|
414
|
+
*/
|
|
415
|
+
private getAttributionWindow;
|
|
399
416
|
}
|
|
400
417
|
/**
|
|
401
418
|
* Initialize Aurea SDK
|
package/dist/index.js
CHANGED
|
@@ -819,13 +819,68 @@ var AureaSDK = class {
|
|
|
819
819
|
title: document.title,
|
|
820
820
|
referrer: document.referrer
|
|
821
821
|
} : void 0,
|
|
822
|
-
utm: {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
822
|
+
utm: (() => {
|
|
823
|
+
const utm = {
|
|
824
|
+
source: url.searchParams.get("utm_source") || void 0,
|
|
825
|
+
medium: url.searchParams.get("utm_medium") || void 0,
|
|
826
|
+
campaign: url.searchParams.get("utm_campaign") || void 0,
|
|
827
|
+
term: url.searchParams.get("utm_term") || void 0,
|
|
828
|
+
content: url.searchParams.get("utm_content") || void 0
|
|
829
|
+
};
|
|
830
|
+
if (this.config.debug && (utm.source || utm.medium || utm.campaign)) {
|
|
831
|
+
console.log("[Aurea SDK] UTM params extracted from URL:", utm, "URL:", url.href);
|
|
832
|
+
}
|
|
833
|
+
return utm;
|
|
834
|
+
})(),
|
|
835
|
+
// Ad Platform Click IDs (for attribution)
|
|
836
|
+
clickIds: (() => {
|
|
837
|
+
const clickIds = {
|
|
838
|
+
// Meta/Facebook
|
|
839
|
+
fbclid: url.searchParams.get("fbclid") || void 0,
|
|
840
|
+
fbadid: url.searchParams.get("fbadid") || void 0,
|
|
841
|
+
// Google Ads
|
|
842
|
+
gclid: url.searchParams.get("gclid") || void 0,
|
|
843
|
+
gbraid: url.searchParams.get("gbraid") || void 0,
|
|
844
|
+
wbraid: url.searchParams.get("wbraid") || void 0,
|
|
845
|
+
dclid: url.searchParams.get("dclid") || void 0,
|
|
846
|
+
// TikTok
|
|
847
|
+
ttclid: url.searchParams.get("ttclid") || void 0,
|
|
848
|
+
tt_content: url.searchParams.get("tt_content") || void 0,
|
|
849
|
+
// Microsoft/Bing
|
|
850
|
+
msclkid: url.searchParams.get("msclkid") || void 0,
|
|
851
|
+
// Twitter/X
|
|
852
|
+
twclid: url.searchParams.get("twclid") || void 0,
|
|
853
|
+
// LinkedIn
|
|
854
|
+
li_fat_id: url.searchParams.get("li_fat_id") || void 0,
|
|
855
|
+
// Snapchat
|
|
856
|
+
ScCid: url.searchParams.get("ScCid") || void 0,
|
|
857
|
+
// Pinterest
|
|
858
|
+
epik: url.searchParams.get("epik") || void 0,
|
|
859
|
+
// Reddit
|
|
860
|
+
rdt_cid: url.searchParams.get("rdt_cid") || void 0
|
|
861
|
+
};
|
|
862
|
+
if (Object.values(clickIds).some((v) => v)) {
|
|
863
|
+
this.storeClickIds(clickIds);
|
|
864
|
+
}
|
|
865
|
+
const stored = this.getStoredClickIds();
|
|
866
|
+
const merged = { ...stored, ...clickIds };
|
|
867
|
+
if (this.config.debug && Object.values(merged).some((v) => v)) {
|
|
868
|
+
console.log("[Aurea SDK] Click IDs extracted:", merged);
|
|
869
|
+
}
|
|
870
|
+
return merged;
|
|
871
|
+
})(),
|
|
872
|
+
// First-party cookies (for Conversion APIs)
|
|
873
|
+
cookies: (() => {
|
|
874
|
+
const cookies = {
|
|
875
|
+
fbp: this.getCookie("_fbp"),
|
|
876
|
+
fbc: this.getCookie("_fbc"),
|
|
877
|
+
ttp: this.getCookie("_ttp")
|
|
878
|
+
};
|
|
879
|
+
if (this.config.debug && Object.values(cookies).some((v) => v)) {
|
|
880
|
+
console.log("[Aurea SDK] First-party cookies extracted:", cookies);
|
|
881
|
+
}
|
|
882
|
+
return cookies;
|
|
883
|
+
})(),
|
|
829
884
|
user: {
|
|
830
885
|
userId: this.userId,
|
|
831
886
|
anonymousId: this.anonymousId
|
|
@@ -937,6 +992,18 @@ var AureaSDK = class {
|
|
|
937
992
|
*/
|
|
938
993
|
async sendEvents(events) {
|
|
939
994
|
if (events.length === 0) return;
|
|
995
|
+
if (this.config.debug) {
|
|
996
|
+
events.forEach((evt) => {
|
|
997
|
+
if (evt.eventName === "page_view") {
|
|
998
|
+
console.log("[Aurea SDK] Sending page_view with UTM:", {
|
|
999
|
+
source: evt.context.utm?.source,
|
|
1000
|
+
medium: evt.context.utm?.medium,
|
|
1001
|
+
campaign: evt.context.utm?.campaign,
|
|
1002
|
+
url: evt.context.page?.url
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
940
1007
|
try {
|
|
941
1008
|
const response = await fetch(`${this.config.apiUrl}/track/events`, {
|
|
942
1009
|
method: "POST",
|
|
@@ -1266,6 +1333,90 @@ var AureaSDK = class {
|
|
|
1266
1333
|
generateEventId() {
|
|
1267
1334
|
return `evt_${this.generateId()}`;
|
|
1268
1335
|
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Get cookie value by name
|
|
1338
|
+
*/
|
|
1339
|
+
getCookie(name) {
|
|
1340
|
+
if (typeof document === "undefined") return void 0;
|
|
1341
|
+
const value = `; ${document.cookie}`;
|
|
1342
|
+
const parts = value.split(`; ${name}=`);
|
|
1343
|
+
if (parts.length === 2) {
|
|
1344
|
+
return parts.pop()?.split(";").shift();
|
|
1345
|
+
}
|
|
1346
|
+
return void 0;
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Store click IDs in localStorage with attribution windows
|
|
1350
|
+
*/
|
|
1351
|
+
storeClickIds(clickIds) {
|
|
1352
|
+
if (typeof localStorage === "undefined") return;
|
|
1353
|
+
const stored = localStorage.getItem("aurea_click_ids");
|
|
1354
|
+
const storedData = stored ? JSON.parse(stored) : {};
|
|
1355
|
+
const now = Date.now();
|
|
1356
|
+
Object.entries(clickIds).forEach(([platform, id]) => {
|
|
1357
|
+
if (id) {
|
|
1358
|
+
storedData[platform] = {
|
|
1359
|
+
id,
|
|
1360
|
+
timestamp: now,
|
|
1361
|
+
expiresAt: now + this.getAttributionWindow(platform)
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
localStorage.setItem("aurea_click_ids", JSON.stringify(storedData));
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Get stored click IDs from localStorage (within attribution window)
|
|
1369
|
+
* Returns only the ID strings (not the full storage object)
|
|
1370
|
+
*/
|
|
1371
|
+
getStoredClickIds() {
|
|
1372
|
+
if (typeof localStorage === "undefined") return {};
|
|
1373
|
+
const stored = localStorage.getItem("aurea_click_ids");
|
|
1374
|
+
if (!stored) return {};
|
|
1375
|
+
try {
|
|
1376
|
+
const clickIds = JSON.parse(stored);
|
|
1377
|
+
const now = Date.now();
|
|
1378
|
+
const active = {};
|
|
1379
|
+
for (const [platform, data] of Object.entries(clickIds)) {
|
|
1380
|
+
if (now < data.expiresAt) {
|
|
1381
|
+
active[platform] = data.id;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
return active;
|
|
1385
|
+
} catch (error) {
|
|
1386
|
+
console.error("[Aurea SDK] Failed to parse stored click IDs:", error);
|
|
1387
|
+
return {};
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Get attribution window for a platform (in milliseconds)
|
|
1392
|
+
*/
|
|
1393
|
+
getAttributionWindow(platform) {
|
|
1394
|
+
const windows = {
|
|
1395
|
+
fbclid: 28 * 24 * 60 * 60 * 1e3,
|
|
1396
|
+
// Facebook: 28 days
|
|
1397
|
+
gclid: 90 * 24 * 60 * 60 * 1e3,
|
|
1398
|
+
// Google: 90 days
|
|
1399
|
+
gbraid: 90 * 24 * 60 * 60 * 1e3,
|
|
1400
|
+
// Google iOS: 90 days
|
|
1401
|
+
wbraid: 90 * 24 * 60 * 60 * 1e3,
|
|
1402
|
+
// Google iOS: 90 days
|
|
1403
|
+
ttclid: 28 * 24 * 60 * 60 * 1e3,
|
|
1404
|
+
// TikTok: 28 days
|
|
1405
|
+
msclkid: 90 * 24 * 60 * 60 * 1e3,
|
|
1406
|
+
// Microsoft: 90 days
|
|
1407
|
+
twclid: 30 * 24 * 60 * 60 * 1e3,
|
|
1408
|
+
// Twitter: 30 days
|
|
1409
|
+
li_fat_id: 90 * 24 * 60 * 60 * 1e3,
|
|
1410
|
+
// LinkedIn: 90 days
|
|
1411
|
+
ScCid: 28 * 24 * 60 * 60 * 1e3,
|
|
1412
|
+
// Snapchat: 28 days
|
|
1413
|
+
epik: 30 * 24 * 60 * 60 * 1e3,
|
|
1414
|
+
// Pinterest: 30 days
|
|
1415
|
+
rdt_cid: 28 * 24 * 60 * 60 * 1e3
|
|
1416
|
+
// Reddit: 28 days
|
|
1417
|
+
};
|
|
1418
|
+
return windows[platform] || 30 * 24 * 60 * 60 * 1e3;
|
|
1419
|
+
}
|
|
1269
1420
|
};
|
|
1270
1421
|
var sdkInstance = null;
|
|
1271
1422
|
function initAurea(config) {
|
package/dist/index.mjs
CHANGED
|
@@ -790,13 +790,68 @@ var AureaSDK = class {
|
|
|
790
790
|
title: document.title,
|
|
791
791
|
referrer: document.referrer
|
|
792
792
|
} : void 0,
|
|
793
|
-
utm: {
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
793
|
+
utm: (() => {
|
|
794
|
+
const utm = {
|
|
795
|
+
source: url.searchParams.get("utm_source") || void 0,
|
|
796
|
+
medium: url.searchParams.get("utm_medium") || void 0,
|
|
797
|
+
campaign: url.searchParams.get("utm_campaign") || void 0,
|
|
798
|
+
term: url.searchParams.get("utm_term") || void 0,
|
|
799
|
+
content: url.searchParams.get("utm_content") || void 0
|
|
800
|
+
};
|
|
801
|
+
if (this.config.debug && (utm.source || utm.medium || utm.campaign)) {
|
|
802
|
+
console.log("[Aurea SDK] UTM params extracted from URL:", utm, "URL:", url.href);
|
|
803
|
+
}
|
|
804
|
+
return utm;
|
|
805
|
+
})(),
|
|
806
|
+
// Ad Platform Click IDs (for attribution)
|
|
807
|
+
clickIds: (() => {
|
|
808
|
+
const clickIds = {
|
|
809
|
+
// Meta/Facebook
|
|
810
|
+
fbclid: url.searchParams.get("fbclid") || void 0,
|
|
811
|
+
fbadid: url.searchParams.get("fbadid") || void 0,
|
|
812
|
+
// Google Ads
|
|
813
|
+
gclid: url.searchParams.get("gclid") || void 0,
|
|
814
|
+
gbraid: url.searchParams.get("gbraid") || void 0,
|
|
815
|
+
wbraid: url.searchParams.get("wbraid") || void 0,
|
|
816
|
+
dclid: url.searchParams.get("dclid") || void 0,
|
|
817
|
+
// TikTok
|
|
818
|
+
ttclid: url.searchParams.get("ttclid") || void 0,
|
|
819
|
+
tt_content: url.searchParams.get("tt_content") || void 0,
|
|
820
|
+
// Microsoft/Bing
|
|
821
|
+
msclkid: url.searchParams.get("msclkid") || void 0,
|
|
822
|
+
// Twitter/X
|
|
823
|
+
twclid: url.searchParams.get("twclid") || void 0,
|
|
824
|
+
// LinkedIn
|
|
825
|
+
li_fat_id: url.searchParams.get("li_fat_id") || void 0,
|
|
826
|
+
// Snapchat
|
|
827
|
+
ScCid: url.searchParams.get("ScCid") || void 0,
|
|
828
|
+
// Pinterest
|
|
829
|
+
epik: url.searchParams.get("epik") || void 0,
|
|
830
|
+
// Reddit
|
|
831
|
+
rdt_cid: url.searchParams.get("rdt_cid") || void 0
|
|
832
|
+
};
|
|
833
|
+
if (Object.values(clickIds).some((v) => v)) {
|
|
834
|
+
this.storeClickIds(clickIds);
|
|
835
|
+
}
|
|
836
|
+
const stored = this.getStoredClickIds();
|
|
837
|
+
const merged = { ...stored, ...clickIds };
|
|
838
|
+
if (this.config.debug && Object.values(merged).some((v) => v)) {
|
|
839
|
+
console.log("[Aurea SDK] Click IDs extracted:", merged);
|
|
840
|
+
}
|
|
841
|
+
return merged;
|
|
842
|
+
})(),
|
|
843
|
+
// First-party cookies (for Conversion APIs)
|
|
844
|
+
cookies: (() => {
|
|
845
|
+
const cookies = {
|
|
846
|
+
fbp: this.getCookie("_fbp"),
|
|
847
|
+
fbc: this.getCookie("_fbc"),
|
|
848
|
+
ttp: this.getCookie("_ttp")
|
|
849
|
+
};
|
|
850
|
+
if (this.config.debug && Object.values(cookies).some((v) => v)) {
|
|
851
|
+
console.log("[Aurea SDK] First-party cookies extracted:", cookies);
|
|
852
|
+
}
|
|
853
|
+
return cookies;
|
|
854
|
+
})(),
|
|
800
855
|
user: {
|
|
801
856
|
userId: this.userId,
|
|
802
857
|
anonymousId: this.anonymousId
|
|
@@ -908,6 +963,18 @@ var AureaSDK = class {
|
|
|
908
963
|
*/
|
|
909
964
|
async sendEvents(events) {
|
|
910
965
|
if (events.length === 0) return;
|
|
966
|
+
if (this.config.debug) {
|
|
967
|
+
events.forEach((evt) => {
|
|
968
|
+
if (evt.eventName === "page_view") {
|
|
969
|
+
console.log("[Aurea SDK] Sending page_view with UTM:", {
|
|
970
|
+
source: evt.context.utm?.source,
|
|
971
|
+
medium: evt.context.utm?.medium,
|
|
972
|
+
campaign: evt.context.utm?.campaign,
|
|
973
|
+
url: evt.context.page?.url
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
911
978
|
try {
|
|
912
979
|
const response = await fetch(`${this.config.apiUrl}/track/events`, {
|
|
913
980
|
method: "POST",
|
|
@@ -1237,6 +1304,90 @@ var AureaSDK = class {
|
|
|
1237
1304
|
generateEventId() {
|
|
1238
1305
|
return `evt_${this.generateId()}`;
|
|
1239
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Get cookie value by name
|
|
1309
|
+
*/
|
|
1310
|
+
getCookie(name) {
|
|
1311
|
+
if (typeof document === "undefined") return void 0;
|
|
1312
|
+
const value = `; ${document.cookie}`;
|
|
1313
|
+
const parts = value.split(`; ${name}=`);
|
|
1314
|
+
if (parts.length === 2) {
|
|
1315
|
+
return parts.pop()?.split(";").shift();
|
|
1316
|
+
}
|
|
1317
|
+
return void 0;
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Store click IDs in localStorage with attribution windows
|
|
1321
|
+
*/
|
|
1322
|
+
storeClickIds(clickIds) {
|
|
1323
|
+
if (typeof localStorage === "undefined") return;
|
|
1324
|
+
const stored = localStorage.getItem("aurea_click_ids");
|
|
1325
|
+
const storedData = stored ? JSON.parse(stored) : {};
|
|
1326
|
+
const now = Date.now();
|
|
1327
|
+
Object.entries(clickIds).forEach(([platform, id]) => {
|
|
1328
|
+
if (id) {
|
|
1329
|
+
storedData[platform] = {
|
|
1330
|
+
id,
|
|
1331
|
+
timestamp: now,
|
|
1332
|
+
expiresAt: now + this.getAttributionWindow(platform)
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
});
|
|
1336
|
+
localStorage.setItem("aurea_click_ids", JSON.stringify(storedData));
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Get stored click IDs from localStorage (within attribution window)
|
|
1340
|
+
* Returns only the ID strings (not the full storage object)
|
|
1341
|
+
*/
|
|
1342
|
+
getStoredClickIds() {
|
|
1343
|
+
if (typeof localStorage === "undefined") return {};
|
|
1344
|
+
const stored = localStorage.getItem("aurea_click_ids");
|
|
1345
|
+
if (!stored) return {};
|
|
1346
|
+
try {
|
|
1347
|
+
const clickIds = JSON.parse(stored);
|
|
1348
|
+
const now = Date.now();
|
|
1349
|
+
const active = {};
|
|
1350
|
+
for (const [platform, data] of Object.entries(clickIds)) {
|
|
1351
|
+
if (now < data.expiresAt) {
|
|
1352
|
+
active[platform] = data.id;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
return active;
|
|
1356
|
+
} catch (error) {
|
|
1357
|
+
console.error("[Aurea SDK] Failed to parse stored click IDs:", error);
|
|
1358
|
+
return {};
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* Get attribution window for a platform (in milliseconds)
|
|
1363
|
+
*/
|
|
1364
|
+
getAttributionWindow(platform) {
|
|
1365
|
+
const windows = {
|
|
1366
|
+
fbclid: 28 * 24 * 60 * 60 * 1e3,
|
|
1367
|
+
// Facebook: 28 days
|
|
1368
|
+
gclid: 90 * 24 * 60 * 60 * 1e3,
|
|
1369
|
+
// Google: 90 days
|
|
1370
|
+
gbraid: 90 * 24 * 60 * 60 * 1e3,
|
|
1371
|
+
// Google iOS: 90 days
|
|
1372
|
+
wbraid: 90 * 24 * 60 * 60 * 1e3,
|
|
1373
|
+
// Google iOS: 90 days
|
|
1374
|
+
ttclid: 28 * 24 * 60 * 60 * 1e3,
|
|
1375
|
+
// TikTok: 28 days
|
|
1376
|
+
msclkid: 90 * 24 * 60 * 60 * 1e3,
|
|
1377
|
+
// Microsoft: 90 days
|
|
1378
|
+
twclid: 30 * 24 * 60 * 60 * 1e3,
|
|
1379
|
+
// Twitter: 30 days
|
|
1380
|
+
li_fat_id: 90 * 24 * 60 * 60 * 1e3,
|
|
1381
|
+
// LinkedIn: 90 days
|
|
1382
|
+
ScCid: 28 * 24 * 60 * 60 * 1e3,
|
|
1383
|
+
// Snapchat: 28 days
|
|
1384
|
+
epik: 30 * 24 * 60 * 60 * 1e3,
|
|
1385
|
+
// Pinterest: 30 days
|
|
1386
|
+
rdt_cid: 28 * 24 * 60 * 60 * 1e3
|
|
1387
|
+
// Reddit: 28 days
|
|
1388
|
+
};
|
|
1389
|
+
return windows[platform] || 30 * 24 * 60 * 60 * 1e3;
|
|
1390
|
+
}
|
|
1240
1391
|
};
|
|
1241
1392
|
var sdkInstance = null;
|
|
1242
1393
|
function initAurea(config) {
|