@simple-product/sdk 0.1.0 → 0.1.2
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/chunk-LUA2QFHT.mjs +216 -0
- package/dist/chunk-QXYQQ64A.mjs +217 -0
- package/dist/index.js +3 -2
- package/dist/index.mjs +1 -1
- package/dist/react.js +3 -2
- package/dist/react.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var STORAGE_KEY_PREFIX = "sp_sdk_";
|
|
3
|
+
var HEARTBEAT_STORAGE_KEY = `${STORAGE_KEY_PREFIX}last_heartbeat`;
|
|
4
|
+
var USER_ID_STORAGE_KEY = `${STORAGE_KEY_PREFIX}user_id`;
|
|
5
|
+
var ANONYMOUS_ID_STORAGE_KEY = `${STORAGE_KEY_PREFIX}anonymous_id`;
|
|
6
|
+
var SimpleProduct = class {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.userId = null;
|
|
9
|
+
this.heartbeatInterval = null;
|
|
10
|
+
this.visibilityHandler = null;
|
|
11
|
+
this.apiKey = config.apiKey;
|
|
12
|
+
this.endpoint = config.endpoint || "https://simpleproduct.dev/api/v1";
|
|
13
|
+
this.debug = config.debug || false;
|
|
14
|
+
this.disableAutoHeartbeat = config.disableAutoHeartbeat || false;
|
|
15
|
+
this.anonymousId = this.getOrCreateAnonymousId();
|
|
16
|
+
this.userId = this.getStoredUserId();
|
|
17
|
+
if (!this.disableAutoHeartbeat && typeof window !== "undefined") {
|
|
18
|
+
this.startHeartbeat();
|
|
19
|
+
}
|
|
20
|
+
this.log("Initialized", { userId: this.userId, anonymousId: this.anonymousId });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Identify a user - call this when a user signs in
|
|
24
|
+
*/
|
|
25
|
+
identify(params) {
|
|
26
|
+
this.userId = params.userId;
|
|
27
|
+
this.storeUserId(params.userId);
|
|
28
|
+
this.log("Identify", params);
|
|
29
|
+
this.sendRequest("/people", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: {
|
|
32
|
+
externalId: params.userId,
|
|
33
|
+
email: params.email,
|
|
34
|
+
name: params.name,
|
|
35
|
+
company: params.company,
|
|
36
|
+
...params.traits
|
|
37
|
+
}
|
|
38
|
+
}).catch((err) => this.log("Identify error", err));
|
|
39
|
+
this.sendHeartbeat();
|
|
40
|
+
}
|
|
41
|
+
track(eventOrParams, properties) {
|
|
42
|
+
const event = typeof eventOrParams === "string" ? eventOrParams : eventOrParams.event;
|
|
43
|
+
const props = typeof eventOrParams === "string" ? properties : eventOrParams.properties;
|
|
44
|
+
this.log("Track", { event, properties: props });
|
|
45
|
+
this.sendRequest("/events", {
|
|
46
|
+
method: "POST",
|
|
47
|
+
body: {
|
|
48
|
+
event,
|
|
49
|
+
userId: this.userId,
|
|
50
|
+
anonymousId: this.anonymousId,
|
|
51
|
+
properties: props,
|
|
52
|
+
context: this.getContext()
|
|
53
|
+
}
|
|
54
|
+
}).catch((err) => this.log("Track error", err));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Reset the user - call this when a user signs out
|
|
58
|
+
*/
|
|
59
|
+
reset() {
|
|
60
|
+
this.userId = null;
|
|
61
|
+
this.clearStoredUserId();
|
|
62
|
+
this.anonymousId = this.generateAnonymousId();
|
|
63
|
+
this.storeAnonymousId(this.anonymousId);
|
|
64
|
+
this.log("Reset");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Manually send a heartbeat (usually not needed - happens automatically)
|
|
68
|
+
*/
|
|
69
|
+
heartbeat() {
|
|
70
|
+
this.sendHeartbeat();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Clean up SDK resources
|
|
74
|
+
*/
|
|
75
|
+
destroy() {
|
|
76
|
+
if (this.heartbeatInterval) {
|
|
77
|
+
clearInterval(this.heartbeatInterval);
|
|
78
|
+
this.heartbeatInterval = null;
|
|
79
|
+
}
|
|
80
|
+
if (this.visibilityHandler && typeof document !== "undefined") {
|
|
81
|
+
document.removeEventListener("visibilitychange", this.visibilityHandler);
|
|
82
|
+
this.visibilityHandler = null;
|
|
83
|
+
}
|
|
84
|
+
this.log("Destroyed");
|
|
85
|
+
}
|
|
86
|
+
// --- Private methods ---
|
|
87
|
+
startHeartbeat() {
|
|
88
|
+
this.sendHeartbeatIfNeeded();
|
|
89
|
+
this.heartbeatInterval = setInterval(() => {
|
|
90
|
+
this.sendHeartbeatIfNeeded();
|
|
91
|
+
}, 5 * 60 * 1e3);
|
|
92
|
+
this.visibilityHandler = () => {
|
|
93
|
+
if (document.visibilityState === "visible") {
|
|
94
|
+
this.sendHeartbeatIfNeeded();
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
document.addEventListener("visibilitychange", this.visibilityHandler);
|
|
98
|
+
}
|
|
99
|
+
sendHeartbeatIfNeeded() {
|
|
100
|
+
if (!this.userId) {
|
|
101
|
+
this.log("Skipping heartbeat - no user identified");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const today = this.getTodayString();
|
|
105
|
+
const lastHeartbeat = this.getLastHeartbeatDate();
|
|
106
|
+
if (lastHeartbeat === today) {
|
|
107
|
+
this.log("Skipping heartbeat - already sent today");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
this.sendHeartbeat();
|
|
111
|
+
}
|
|
112
|
+
sendHeartbeat() {
|
|
113
|
+
if (!this.userId) {
|
|
114
|
+
this.log("Cannot send heartbeat - no user identified");
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const today = this.getTodayString();
|
|
118
|
+
this.log("Sending heartbeat");
|
|
119
|
+
this.sendRequest("/events", {
|
|
120
|
+
method: "POST",
|
|
121
|
+
body: {
|
|
122
|
+
event: "sp_heartbeat",
|
|
123
|
+
userId: this.userId,
|
|
124
|
+
anonymousId: this.anonymousId,
|
|
125
|
+
context: this.getContext()
|
|
126
|
+
}
|
|
127
|
+
}).then(() => {
|
|
128
|
+
this.storeLastHeartbeatDate(today);
|
|
129
|
+
this.log("Heartbeat sent successfully");
|
|
130
|
+
}).catch((err) => this.log("Heartbeat error", err));
|
|
131
|
+
}
|
|
132
|
+
async sendRequest(path, options) {
|
|
133
|
+
const url = `${this.endpoint}${path}`;
|
|
134
|
+
const response = await fetch(url, {
|
|
135
|
+
method: options.method,
|
|
136
|
+
headers: {
|
|
137
|
+
"Content-Type": "application/json",
|
|
138
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
139
|
+
},
|
|
140
|
+
body: options.body ? JSON.stringify(options.body) : void 0
|
|
141
|
+
});
|
|
142
|
+
if (!response.ok) {
|
|
143
|
+
const error = await response.text();
|
|
144
|
+
throw new Error(`API error: ${response.status} ${error}`);
|
|
145
|
+
}
|
|
146
|
+
return response.json();
|
|
147
|
+
}
|
|
148
|
+
getContext() {
|
|
149
|
+
if (typeof window === "undefined") {
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
userAgent: navigator.userAgent,
|
|
154
|
+
page: {
|
|
155
|
+
url: window.location.href,
|
|
156
|
+
title: document.title,
|
|
157
|
+
referrer: document.referrer
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
getTodayString() {
|
|
162
|
+
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
163
|
+
}
|
|
164
|
+
getLastHeartbeatDate() {
|
|
165
|
+
if (typeof localStorage === "undefined") return null;
|
|
166
|
+
return localStorage.getItem(HEARTBEAT_STORAGE_KEY);
|
|
167
|
+
}
|
|
168
|
+
storeLastHeartbeatDate(date) {
|
|
169
|
+
if (typeof localStorage === "undefined") return;
|
|
170
|
+
localStorage.setItem(HEARTBEAT_STORAGE_KEY, date);
|
|
171
|
+
}
|
|
172
|
+
getStoredUserId() {
|
|
173
|
+
if (typeof localStorage === "undefined") return null;
|
|
174
|
+
return localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
175
|
+
}
|
|
176
|
+
storeUserId(userId) {
|
|
177
|
+
if (typeof localStorage === "undefined") return;
|
|
178
|
+
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
179
|
+
}
|
|
180
|
+
clearStoredUserId() {
|
|
181
|
+
if (typeof localStorage === "undefined") return;
|
|
182
|
+
localStorage.removeItem(USER_ID_STORAGE_KEY);
|
|
183
|
+
localStorage.removeItem(HEARTBEAT_STORAGE_KEY);
|
|
184
|
+
}
|
|
185
|
+
getOrCreateAnonymousId() {
|
|
186
|
+
if (typeof localStorage === "undefined") {
|
|
187
|
+
return this.generateAnonymousId();
|
|
188
|
+
}
|
|
189
|
+
const stored = localStorage.getItem(ANONYMOUS_ID_STORAGE_KEY);
|
|
190
|
+
if (stored) return stored;
|
|
191
|
+
const id = this.generateAnonymousId();
|
|
192
|
+
this.storeAnonymousId(id);
|
|
193
|
+
return id;
|
|
194
|
+
}
|
|
195
|
+
storeAnonymousId(id) {
|
|
196
|
+
if (typeof localStorage === "undefined") return;
|
|
197
|
+
localStorage.setItem(ANONYMOUS_ID_STORAGE_KEY, id);
|
|
198
|
+
}
|
|
199
|
+
generateAnonymousId() {
|
|
200
|
+
return "anon_" + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
201
|
+
}
|
|
202
|
+
log(message, data) {
|
|
203
|
+
if (!this.debug) return;
|
|
204
|
+
console.log(`[SimpleProduct] ${message}`, data !== void 0 ? data : "");
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
function createSimpleProduct(config) {
|
|
208
|
+
return new SimpleProduct(config);
|
|
209
|
+
}
|
|
210
|
+
var index_default = SimpleProduct;
|
|
211
|
+
|
|
212
|
+
export {
|
|
213
|
+
SimpleProduct,
|
|
214
|
+
createSimpleProduct,
|
|
215
|
+
index_default
|
|
216
|
+
};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var STORAGE_KEY_PREFIX = "sp_sdk_";
|
|
3
|
+
var HEARTBEAT_STORAGE_KEY = `${STORAGE_KEY_PREFIX}last_heartbeat`;
|
|
4
|
+
var USER_ID_STORAGE_KEY = `${STORAGE_KEY_PREFIX}user_id`;
|
|
5
|
+
var ANONYMOUS_ID_STORAGE_KEY = `${STORAGE_KEY_PREFIX}anonymous_id`;
|
|
6
|
+
var SimpleProduct = class {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.userId = null;
|
|
9
|
+
this.heartbeatInterval = null;
|
|
10
|
+
this.visibilityHandler = null;
|
|
11
|
+
this.apiKey = config.apiKey;
|
|
12
|
+
this.endpoint = config.endpoint || "https://simpleproduct.dev/api/v1";
|
|
13
|
+
this.debug = config.debug || false;
|
|
14
|
+
this.disableAutoHeartbeat = config.disableAutoHeartbeat || false;
|
|
15
|
+
this.anonymousId = this.getOrCreateAnonymousId();
|
|
16
|
+
this.userId = this.getStoredUserId();
|
|
17
|
+
if (!this.disableAutoHeartbeat && typeof window !== "undefined") {
|
|
18
|
+
this.startHeartbeat();
|
|
19
|
+
}
|
|
20
|
+
this.log("Initialized", { userId: this.userId, anonymousId: this.anonymousId });
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Identify a user - call this when a user signs in
|
|
24
|
+
*/
|
|
25
|
+
identify(params) {
|
|
26
|
+
this.userId = params.userId;
|
|
27
|
+
this.storeUserId(params.userId);
|
|
28
|
+
this.log("Identify", params);
|
|
29
|
+
this.sendRequest("/people", {
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: {
|
|
32
|
+
externalId: params.userId,
|
|
33
|
+
email: params.email,
|
|
34
|
+
name: params.name,
|
|
35
|
+
company: params.company,
|
|
36
|
+
...params.traits
|
|
37
|
+
}
|
|
38
|
+
}).then(() => {
|
|
39
|
+
this.sendHeartbeat();
|
|
40
|
+
}).catch((err) => this.log("Identify error", err));
|
|
41
|
+
}
|
|
42
|
+
track(eventOrParams, properties) {
|
|
43
|
+
const event = typeof eventOrParams === "string" ? eventOrParams : eventOrParams.event;
|
|
44
|
+
const props = typeof eventOrParams === "string" ? properties : eventOrParams.properties;
|
|
45
|
+
this.log("Track", { event, properties: props });
|
|
46
|
+
this.sendRequest("/events", {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: {
|
|
49
|
+
event,
|
|
50
|
+
userId: this.userId,
|
|
51
|
+
anonymousId: this.anonymousId,
|
|
52
|
+
properties: props,
|
|
53
|
+
context: this.getContext()
|
|
54
|
+
}
|
|
55
|
+
}).catch((err) => this.log("Track error", err));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reset the user - call this when a user signs out
|
|
59
|
+
*/
|
|
60
|
+
reset() {
|
|
61
|
+
this.userId = null;
|
|
62
|
+
this.clearStoredUserId();
|
|
63
|
+
this.anonymousId = this.generateAnonymousId();
|
|
64
|
+
this.storeAnonymousId(this.anonymousId);
|
|
65
|
+
this.log("Reset");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Manually send a heartbeat (usually not needed - happens automatically)
|
|
69
|
+
*/
|
|
70
|
+
heartbeat() {
|
|
71
|
+
this.sendHeartbeat();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Clean up SDK resources
|
|
75
|
+
*/
|
|
76
|
+
destroy() {
|
|
77
|
+
if (this.heartbeatInterval) {
|
|
78
|
+
clearInterval(this.heartbeatInterval);
|
|
79
|
+
this.heartbeatInterval = null;
|
|
80
|
+
}
|
|
81
|
+
if (this.visibilityHandler && typeof document !== "undefined") {
|
|
82
|
+
document.removeEventListener("visibilitychange", this.visibilityHandler);
|
|
83
|
+
this.visibilityHandler = null;
|
|
84
|
+
}
|
|
85
|
+
this.log("Destroyed");
|
|
86
|
+
}
|
|
87
|
+
// --- Private methods ---
|
|
88
|
+
startHeartbeat() {
|
|
89
|
+
this.sendHeartbeatIfNeeded();
|
|
90
|
+
this.heartbeatInterval = setInterval(() => {
|
|
91
|
+
this.sendHeartbeatIfNeeded();
|
|
92
|
+
}, 5 * 60 * 1e3);
|
|
93
|
+
this.visibilityHandler = () => {
|
|
94
|
+
if (document.visibilityState === "visible") {
|
|
95
|
+
this.sendHeartbeatIfNeeded();
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
document.addEventListener("visibilitychange", this.visibilityHandler);
|
|
99
|
+
}
|
|
100
|
+
sendHeartbeatIfNeeded() {
|
|
101
|
+
if (!this.userId) {
|
|
102
|
+
this.log("Skipping heartbeat - no user identified");
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const today = this.getTodayString();
|
|
106
|
+
const lastHeartbeat = this.getLastHeartbeatDate();
|
|
107
|
+
if (lastHeartbeat === today) {
|
|
108
|
+
this.log("Skipping heartbeat - already sent today");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.sendHeartbeat();
|
|
112
|
+
}
|
|
113
|
+
sendHeartbeat() {
|
|
114
|
+
if (!this.userId) {
|
|
115
|
+
this.log("Cannot send heartbeat - no user identified");
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const today = this.getTodayString();
|
|
119
|
+
this.log("Sending heartbeat");
|
|
120
|
+
this.sendRequest("/events", {
|
|
121
|
+
method: "POST",
|
|
122
|
+
body: {
|
|
123
|
+
event: "sp_heartbeat",
|
|
124
|
+
userId: this.userId,
|
|
125
|
+
anonymousId: this.anonymousId,
|
|
126
|
+
context: this.getContext()
|
|
127
|
+
}
|
|
128
|
+
}).then(() => {
|
|
129
|
+
this.storeLastHeartbeatDate(today);
|
|
130
|
+
this.log("Heartbeat sent successfully");
|
|
131
|
+
}).catch((err) => this.log("Heartbeat error", err));
|
|
132
|
+
}
|
|
133
|
+
async sendRequest(path, options) {
|
|
134
|
+
const url = `${this.endpoint}${path}`;
|
|
135
|
+
const response = await fetch(url, {
|
|
136
|
+
method: options.method,
|
|
137
|
+
headers: {
|
|
138
|
+
"Content-Type": "application/json",
|
|
139
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
140
|
+
},
|
|
141
|
+
body: options.body ? JSON.stringify(options.body) : void 0
|
|
142
|
+
});
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
const error = await response.text();
|
|
145
|
+
throw new Error(`API error: ${response.status} ${error}`);
|
|
146
|
+
}
|
|
147
|
+
return response.json();
|
|
148
|
+
}
|
|
149
|
+
getContext() {
|
|
150
|
+
if (typeof window === "undefined") {
|
|
151
|
+
return {};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
userAgent: navigator.userAgent,
|
|
155
|
+
page: {
|
|
156
|
+
url: window.location.href,
|
|
157
|
+
title: document.title,
|
|
158
|
+
referrer: document.referrer
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
getTodayString() {
|
|
163
|
+
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
164
|
+
}
|
|
165
|
+
getLastHeartbeatDate() {
|
|
166
|
+
if (typeof localStorage === "undefined") return null;
|
|
167
|
+
return localStorage.getItem(HEARTBEAT_STORAGE_KEY);
|
|
168
|
+
}
|
|
169
|
+
storeLastHeartbeatDate(date) {
|
|
170
|
+
if (typeof localStorage === "undefined") return;
|
|
171
|
+
localStorage.setItem(HEARTBEAT_STORAGE_KEY, date);
|
|
172
|
+
}
|
|
173
|
+
getStoredUserId() {
|
|
174
|
+
if (typeof localStorage === "undefined") return null;
|
|
175
|
+
return localStorage.getItem(USER_ID_STORAGE_KEY);
|
|
176
|
+
}
|
|
177
|
+
storeUserId(userId) {
|
|
178
|
+
if (typeof localStorage === "undefined") return;
|
|
179
|
+
localStorage.setItem(USER_ID_STORAGE_KEY, userId);
|
|
180
|
+
}
|
|
181
|
+
clearStoredUserId() {
|
|
182
|
+
if (typeof localStorage === "undefined") return;
|
|
183
|
+
localStorage.removeItem(USER_ID_STORAGE_KEY);
|
|
184
|
+
localStorage.removeItem(HEARTBEAT_STORAGE_KEY);
|
|
185
|
+
}
|
|
186
|
+
getOrCreateAnonymousId() {
|
|
187
|
+
if (typeof localStorage === "undefined") {
|
|
188
|
+
return this.generateAnonymousId();
|
|
189
|
+
}
|
|
190
|
+
const stored = localStorage.getItem(ANONYMOUS_ID_STORAGE_KEY);
|
|
191
|
+
if (stored) return stored;
|
|
192
|
+
const id = this.generateAnonymousId();
|
|
193
|
+
this.storeAnonymousId(id);
|
|
194
|
+
return id;
|
|
195
|
+
}
|
|
196
|
+
storeAnonymousId(id) {
|
|
197
|
+
if (typeof localStorage === "undefined") return;
|
|
198
|
+
localStorage.setItem(ANONYMOUS_ID_STORAGE_KEY, id);
|
|
199
|
+
}
|
|
200
|
+
generateAnonymousId() {
|
|
201
|
+
return "anon_" + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
202
|
+
}
|
|
203
|
+
log(message, data) {
|
|
204
|
+
if (!this.debug) return;
|
|
205
|
+
console.log(`[SimpleProduct] ${message}`, data !== void 0 ? data : "");
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
function createSimpleProduct(config) {
|
|
209
|
+
return new SimpleProduct(config);
|
|
210
|
+
}
|
|
211
|
+
var index_default = SimpleProduct;
|
|
212
|
+
|
|
213
|
+
export {
|
|
214
|
+
SimpleProduct,
|
|
215
|
+
createSimpleProduct,
|
|
216
|
+
index_default
|
|
217
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var SimpleProduct = class {
|
|
|
35
35
|
this.heartbeatInterval = null;
|
|
36
36
|
this.visibilityHandler = null;
|
|
37
37
|
this.apiKey = config.apiKey;
|
|
38
|
-
this.endpoint = config.endpoint || "https://simpleproduct.
|
|
38
|
+
this.endpoint = config.endpoint || "https://simpleproduct.dev/api/v1";
|
|
39
39
|
this.debug = config.debug || false;
|
|
40
40
|
this.disableAutoHeartbeat = config.disableAutoHeartbeat || false;
|
|
41
41
|
this.anonymousId = this.getOrCreateAnonymousId();
|
|
@@ -61,8 +61,9 @@ var SimpleProduct = class {
|
|
|
61
61
|
company: params.company,
|
|
62
62
|
...params.traits
|
|
63
63
|
}
|
|
64
|
+
}).then(() => {
|
|
65
|
+
this.sendHeartbeat();
|
|
64
66
|
}).catch((err) => this.log("Identify error", err));
|
|
65
|
-
this.sendHeartbeat();
|
|
66
67
|
}
|
|
67
68
|
track(eventOrParams, properties) {
|
|
68
69
|
const event = typeof eventOrParams === "string" ? eventOrParams : eventOrParams.event;
|
package/dist/index.mjs
CHANGED
package/dist/react.js
CHANGED
|
@@ -39,7 +39,7 @@ var SimpleProduct = class {
|
|
|
39
39
|
this.heartbeatInterval = null;
|
|
40
40
|
this.visibilityHandler = null;
|
|
41
41
|
this.apiKey = config.apiKey;
|
|
42
|
-
this.endpoint = config.endpoint || "https://simpleproduct.
|
|
42
|
+
this.endpoint = config.endpoint || "https://simpleproduct.dev/api/v1";
|
|
43
43
|
this.debug = config.debug || false;
|
|
44
44
|
this.disableAutoHeartbeat = config.disableAutoHeartbeat || false;
|
|
45
45
|
this.anonymousId = this.getOrCreateAnonymousId();
|
|
@@ -65,8 +65,9 @@ var SimpleProduct = class {
|
|
|
65
65
|
company: params.company,
|
|
66
66
|
...params.traits
|
|
67
67
|
}
|
|
68
|
+
}).then(() => {
|
|
69
|
+
this.sendHeartbeat();
|
|
68
70
|
}).catch((err) => this.log("Identify error", err));
|
|
69
|
-
this.sendHeartbeat();
|
|
70
71
|
}
|
|
71
72
|
track(eventOrParams, properties) {
|
|
72
73
|
const event = typeof eventOrParams === "string" ? eventOrParams : eventOrParams.event;
|
package/dist/react.mjs
CHANGED