saasco-sdk 0.1.42 → 0.1.43
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/index.cjs.js +27 -9
- package/index.esm.js +27 -9
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var jsSha256 = require('js-sha256');
|
|
|
8
8
|
var uuid$1 = require('@lukeed/uuid');
|
|
9
9
|
var zod = require('zod');
|
|
10
10
|
|
|
11
|
-
var version = "0.1.
|
|
11
|
+
var version = "0.1.43";
|
|
12
12
|
|
|
13
13
|
const timezones = {
|
|
14
14
|
'Asia/Barnaul': 'RU',
|
|
@@ -1591,7 +1591,7 @@ class Saasco {
|
|
|
1591
1591
|
migrateFromLocalStorage();
|
|
1592
1592
|
this.logger.log('Saasco initialized', this.config);
|
|
1593
1593
|
if (this.config.debug) this.logger.log('Debug mode active. This will log all events to the console.');
|
|
1594
|
-
if (!this.config.enabled) this.logger.log(
|
|
1594
|
+
if (!this.config.enabled) this.logger.log(`Analytics is disabled. No requests will be sent to the server and no integrations will be initialized. ${this.config.debug ? 'Debug mode is active and will still log information.' : ''}`);
|
|
1595
1595
|
this.initAutoPageTracking();
|
|
1596
1596
|
this.isInitialized = true;
|
|
1597
1597
|
}
|
|
@@ -1609,6 +1609,10 @@ class Saasco {
|
|
|
1609
1609
|
initIntegrations() {
|
|
1610
1610
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
1611
1611
|
if (!this.config.integrations || this.config.integrations.length === 0) return;
|
|
1612
|
+
if (!this.config.enabled) {
|
|
1613
|
+
this.logger.log('Analytics is disabled. Skipping integration initialization.');
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1612
1616
|
for (const integrationConfig of this.config.integrations) {
|
|
1613
1617
|
try {
|
|
1614
1618
|
if (integrationConfig.type === 'facebook-pixel') {
|
|
@@ -1674,7 +1678,18 @@ class Saasco {
|
|
|
1674
1678
|
source: isBrowser ? 'client' : 'server',
|
|
1675
1679
|
context: JSON.stringify(context || {})
|
|
1676
1680
|
};
|
|
1677
|
-
|
|
1681
|
+
if (data.action === 'Page View') {
|
|
1682
|
+
this.logger.log('Page View', window.location.href, data);
|
|
1683
|
+
} else {
|
|
1684
|
+
this.logger.log('track', data);
|
|
1685
|
+
}
|
|
1686
|
+
if (!this.config.enabled) {
|
|
1687
|
+
return Promise.resolve({
|
|
1688
|
+
success: true,
|
|
1689
|
+
message: 'Analytics is disabled'
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
// Only send track to integrations if analytics is enabled
|
|
1678
1693
|
this.integrationManager.track(action, properties);
|
|
1679
1694
|
// Send event to API
|
|
1680
1695
|
return this.doRequest('events', data);
|
|
@@ -1735,7 +1750,6 @@ class Saasco {
|
|
|
1735
1750
|
anonymousId,
|
|
1736
1751
|
sessionId
|
|
1737
1752
|
});
|
|
1738
|
-
this.integrationManager.identify(distinctId, properties);
|
|
1739
1753
|
// No distinctId provided so we don't track the user
|
|
1740
1754
|
if (!distinctId) return Promise.resolve({
|
|
1741
1755
|
success: true,
|
|
@@ -1752,6 +1766,15 @@ class Saasco {
|
|
|
1752
1766
|
payload: properties || {},
|
|
1753
1767
|
context: context || {}
|
|
1754
1768
|
};
|
|
1769
|
+
this.logger.log('identify', data);
|
|
1770
|
+
// Only send identify to integrations if analytics is enabled
|
|
1771
|
+
if (!this.config.enabled) {
|
|
1772
|
+
return Promise.resolve({
|
|
1773
|
+
success: true,
|
|
1774
|
+
message: 'Analytics is disabled'
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
this.integrationManager.identify(distinctId, properties);
|
|
1755
1778
|
return this.doRequest('identify', data);
|
|
1756
1779
|
}
|
|
1757
1780
|
/**
|
|
@@ -1776,11 +1799,6 @@ class Saasco {
|
|
|
1776
1799
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
1777
1800
|
const base = this.config.proxy || 'https://www.saasco.com/api/';
|
|
1778
1801
|
const url = `${base}${path}`;
|
|
1779
|
-
if (data.action === 'Page View') {
|
|
1780
|
-
this.logger.log('Page View', window.location.href, data);
|
|
1781
|
-
} else {
|
|
1782
|
-
this.logger.log(data.action || path, data);
|
|
1783
|
-
}
|
|
1784
1802
|
// If analytics is disabled, don't send the request
|
|
1785
1803
|
if (this.config.enabled === false) return {
|
|
1786
1804
|
success: false,
|
package/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { sha256 } from 'js-sha256';
|
|
|
4
4
|
import { v4 } from '@lukeed/uuid';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
-
var version = "0.1.
|
|
7
|
+
var version = "0.1.43";
|
|
8
8
|
|
|
9
9
|
const timezones = {
|
|
10
10
|
'Asia/Barnaul': 'RU',
|
|
@@ -1587,7 +1587,7 @@ class Saasco {
|
|
|
1587
1587
|
migrateFromLocalStorage();
|
|
1588
1588
|
this.logger.log('Saasco initialized', this.config);
|
|
1589
1589
|
if (this.config.debug) this.logger.log('Debug mode active. This will log all events to the console.');
|
|
1590
|
-
if (!this.config.enabled) this.logger.log(
|
|
1590
|
+
if (!this.config.enabled) this.logger.log(`Analytics is disabled. No requests will be sent to the server and no integrations will be initialized. ${this.config.debug ? 'Debug mode is active and will still log information.' : ''}`);
|
|
1591
1591
|
this.initAutoPageTracking();
|
|
1592
1592
|
this.isInitialized = true;
|
|
1593
1593
|
}
|
|
@@ -1605,6 +1605,10 @@ class Saasco {
|
|
|
1605
1605
|
initIntegrations() {
|
|
1606
1606
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1607
1607
|
if (!this.config.integrations || this.config.integrations.length === 0) return;
|
|
1608
|
+
if (!this.config.enabled) {
|
|
1609
|
+
this.logger.log('Analytics is disabled. Skipping integration initialization.');
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1608
1612
|
for (const integrationConfig of this.config.integrations) {
|
|
1609
1613
|
try {
|
|
1610
1614
|
if (integrationConfig.type === 'facebook-pixel') {
|
|
@@ -1670,7 +1674,18 @@ class Saasco {
|
|
|
1670
1674
|
source: isBrowser ? 'client' : 'server',
|
|
1671
1675
|
context: JSON.stringify(context || {})
|
|
1672
1676
|
};
|
|
1673
|
-
|
|
1677
|
+
if (data.action === 'Page View') {
|
|
1678
|
+
this.logger.log('Page View', window.location.href, data);
|
|
1679
|
+
} else {
|
|
1680
|
+
this.logger.log('track', data);
|
|
1681
|
+
}
|
|
1682
|
+
if (!this.config.enabled) {
|
|
1683
|
+
return Promise.resolve({
|
|
1684
|
+
success: true,
|
|
1685
|
+
message: 'Analytics is disabled'
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
// Only send track to integrations if analytics is enabled
|
|
1674
1689
|
this.integrationManager.track(action, properties);
|
|
1675
1690
|
// Send event to API
|
|
1676
1691
|
return this.doRequest('events', data);
|
|
@@ -1731,7 +1746,6 @@ class Saasco {
|
|
|
1731
1746
|
anonymousId,
|
|
1732
1747
|
sessionId
|
|
1733
1748
|
});
|
|
1734
|
-
this.integrationManager.identify(distinctId, properties);
|
|
1735
1749
|
// No distinctId provided so we don't track the user
|
|
1736
1750
|
if (!distinctId) return Promise.resolve({
|
|
1737
1751
|
success: true,
|
|
@@ -1748,6 +1762,15 @@ class Saasco {
|
|
|
1748
1762
|
payload: properties || {},
|
|
1749
1763
|
context: context || {}
|
|
1750
1764
|
};
|
|
1765
|
+
this.logger.log('identify', data);
|
|
1766
|
+
// Only send identify to integrations if analytics is enabled
|
|
1767
|
+
if (!this.config.enabled) {
|
|
1768
|
+
return Promise.resolve({
|
|
1769
|
+
success: true,
|
|
1770
|
+
message: 'Analytics is disabled'
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
this.integrationManager.identify(distinctId, properties);
|
|
1751
1774
|
return this.doRequest('identify', data);
|
|
1752
1775
|
}
|
|
1753
1776
|
/**
|
|
@@ -1772,11 +1795,6 @@ class Saasco {
|
|
|
1772
1795
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1773
1796
|
const base = this.config.proxy || 'https://www.saasco.com/api/';
|
|
1774
1797
|
const url = `${base}${path}`;
|
|
1775
|
-
if (data.action === 'Page View') {
|
|
1776
|
-
this.logger.log('Page View', window.location.href, data);
|
|
1777
|
-
} else {
|
|
1778
|
-
this.logger.log(data.action || path, data);
|
|
1779
|
-
}
|
|
1780
1798
|
// If analytics is disabled, don't send the request
|
|
1781
1799
|
if (this.config.enabled === false) return {
|
|
1782
1800
|
success: false,
|