@aranova/tracking-react 0.20.2 → 0.22.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 +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +81 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -21
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-B2vHJkNz.d.mts → phone-utils-BhWfNuPS.d.mts} +8 -0
- package/dist/{phone-utils-B2vHJkNz.d.ts → phone-utils-BhWfNuPS.d.ts} +8 -0
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/{sales-DrH6dY5F.d.mts → sales-BhCYJqDy.d.mts} +25 -23
- package/dist/{sales-DrH6dY5F.d.ts → sales-BhCYJqDy.d.ts} +25 -23
- package/dist/sales.d.mts +1 -1
- package/dist/sales.d.ts +1 -1
- package/dist/sales.js +29 -17
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +29 -17
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
package/dist/sales.mjs
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// ../tracking-core/src/capabilities.ts
|
|
2
|
+
var registered = /* @__PURE__ */ new Set();
|
|
3
|
+
function registerCapability(capability) {
|
|
4
|
+
registered.add(capability);
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
// ../tracking-core/src/phone.ts
|
|
2
8
|
import { AsYouType, parsePhoneNumberFromString } from "libphonenumber-js";
|
|
3
9
|
var DEFAULT_PHONE_COUNTRY = "CA";
|
|
@@ -194,7 +200,7 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
194
200
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
195
201
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
196
202
|
|
|
197
|
-
// ../tracking-core/src/resources/
|
|
203
|
+
// ../tracking-core/src/resources/http/errors.ts
|
|
198
204
|
var AranovaApiError = class extends Error {
|
|
199
205
|
constructor(message, options) {
|
|
200
206
|
super(message);
|
|
@@ -205,7 +211,7 @@ var AranovaApiError = class extends Error {
|
|
|
205
211
|
}
|
|
206
212
|
};
|
|
207
213
|
|
|
208
|
-
// ../tracking-core/src/resources/
|
|
214
|
+
// ../tracking-core/src/resources/http/request.ts
|
|
209
215
|
function identityHeaders(config) {
|
|
210
216
|
const headers = { [API_KEY_HEADER]: config.apiKey };
|
|
211
217
|
if (config.sdkVersion) headers[SDK_VERSION_HEADER] = config.sdkVersion;
|
|
@@ -217,8 +223,8 @@ function identityHeaders(config) {
|
|
|
217
223
|
function joinUrl(endpoint, path) {
|
|
218
224
|
return `${endpoint.replace(/\/$/, "")}${path}`;
|
|
219
225
|
}
|
|
220
|
-
async function
|
|
221
|
-
const headers = identityHeaders(config);
|
|
226
|
+
async function apiRequest(config, method, path, body, extraHeaders) {
|
|
227
|
+
const headers = { ...identityHeaders(config), ...extraHeaders };
|
|
222
228
|
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
223
229
|
const response = await fetch(joinUrl(config.endpoint, path), {
|
|
224
230
|
method,
|
|
@@ -247,6 +253,24 @@ async function salesRequest(config, method, path, body) {
|
|
|
247
253
|
return await response.json();
|
|
248
254
|
}
|
|
249
255
|
|
|
256
|
+
// ../tracking-core/src/resources/sales/transport.ts
|
|
257
|
+
var salesRequest = apiRequest;
|
|
258
|
+
|
|
259
|
+
// ../tracking-core/src/resources/intl/date.ts
|
|
260
|
+
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
261
|
+
const date = new Date(iso);
|
|
262
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
263
|
+
return new Intl.DateTimeFormat(locale, {
|
|
264
|
+
year: "numeric",
|
|
265
|
+
month: "short",
|
|
266
|
+
day: "2-digit",
|
|
267
|
+
hour: "2-digit",
|
|
268
|
+
minute: "2-digit",
|
|
269
|
+
...opts,
|
|
270
|
+
timeZone
|
|
271
|
+
}).format(date);
|
|
272
|
+
}
|
|
273
|
+
|
|
250
274
|
// ../tracking-core/src/resources/sales/money.ts
|
|
251
275
|
var MINOR_UNIT_EXPONENT = {
|
|
252
276
|
USD: 2,
|
|
@@ -266,19 +290,6 @@ function formatMoney(cents, currency, locale) {
|
|
|
266
290
|
fromMinor(cents, currency)
|
|
267
291
|
);
|
|
268
292
|
}
|
|
269
|
-
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
270
|
-
const date = new Date(iso);
|
|
271
|
-
if (Number.isNaN(date.getTime())) return iso;
|
|
272
|
-
return new Intl.DateTimeFormat(locale, {
|
|
273
|
-
year: "numeric",
|
|
274
|
-
month: "short",
|
|
275
|
-
day: "2-digit",
|
|
276
|
-
hour: "2-digit",
|
|
277
|
-
minute: "2-digit",
|
|
278
|
-
...opts,
|
|
279
|
-
timeZone
|
|
280
|
-
}).format(date);
|
|
281
|
-
}
|
|
282
293
|
|
|
283
294
|
// ../tracking-core/src/resources/sales/client.ts
|
|
284
295
|
function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
@@ -311,6 +322,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
|
311
322
|
}
|
|
312
323
|
}
|
|
313
324
|
function createSalesClient(config) {
|
|
325
|
+
if (config.firing) registerCapability("conversion_goals_manual");
|
|
314
326
|
async function record(input) {
|
|
315
327
|
const currency = input.currency ?? config.defaultCurrency;
|
|
316
328
|
if (!currency) {
|