@reservamos/browser-analytics 1.0.11 → 1.0.13
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/browser-analytics.cjs +3 -3
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +68 -1
- package/dist/browser-analytics.esm.js +151 -97
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +3 -3
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +7 -1
- package/src/profiles/createAnonymousProfile/createAnonymousProfile.ts +12 -3
- package/src/profiles/createAnonymousProfile/createAnonymousProfileSchema.ts +2 -0
- package/src/recommendations/createFrequentPassengers/createFrequentPassengers.ts +35 -0
- package/src/recommendations/createFrequentPassengers/createFrequentPassengersSchema.ts +23 -0
- package/src/recommendations/createFrequentPassengers/index.ts +5 -0
- package/src/recommendations/getFrequentPassengers/getFrequentPassengers.ts +24 -0
- package/src/recommendations/getFrequentPassengers/index.ts +3 -0
- package/src/util/genericFunctions.ts +21 -0
|
@@ -3982,19 +3982,19 @@ typeof SuppressedError === "function" ? SuppressedError : function(error, suppre
|
|
|
3982
3982
|
var e = new Error(message);
|
|
3983
3983
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
3984
3984
|
};
|
|
3985
|
-
function r$
|
|
3985
|
+
function r$2(e, t3) {
|
|
3986
3986
|
return function(e2, t4) {
|
|
3987
3987
|
return Object.prototype.hasOwnProperty.call(e2, t4);
|
|
3988
3988
|
}(e, t3) ? e[t3] : void 0;
|
|
3989
3989
|
}
|
|
3990
3990
|
function o$1(e, t3, n2, r2) {
|
|
3991
|
-
var o2, i = document, a2 = "securitypolicyviolation",
|
|
3991
|
+
var o2, i = document, a2 = "securitypolicyviolation", u3 = function(t4) {
|
|
3992
3992
|
var n3 = new URL(e, location.href), r3 = t4.blockedURI;
|
|
3993
3993
|
r3 !== n3.href && r3 !== n3.protocol.slice(0, -1) && r3 !== n3.origin || (o2 = t4, R2());
|
|
3994
3994
|
};
|
|
3995
|
-
i.addEventListener(a2,
|
|
3995
|
+
i.addEventListener(a2, u3);
|
|
3996
3996
|
var R2 = function() {
|
|
3997
|
-
return i.removeEventListener(a2,
|
|
3997
|
+
return i.removeEventListener(a2, u3);
|
|
3998
3998
|
};
|
|
3999
3999
|
return Promise.resolve().then(t3).then(function(e2) {
|
|
4000
4000
|
return R2(), e2;
|
|
@@ -4010,7 +4010,7 @@ function o$1(e, t3, n2, r2) {
|
|
|
4010
4010
|
});
|
|
4011
4011
|
});
|
|
4012
4012
|
}
|
|
4013
|
-
var i$3 = { default: "endpoint" }, a$
|
|
4013
|
+
var i$3 = { default: "endpoint" }, a$2 = { default: "tlsEndpoint" }, u$2 = "Client timeout", R = "Network connection error", c$3 = "Network request aborted", s$3 = "Response cannot be parsed", f$2 = "Blocked by CSP", l$2 = "The endpoint parameter is not a valid URL";
|
|
4014
4014
|
function E$1(e) {
|
|
4015
4015
|
for (var t3 = "", n2 = 0; n2 < e.length; ++n2) if (n2 > 0) {
|
|
4016
4016
|
var r2 = e[n2].toLowerCase();
|
|
@@ -4018,9 +4018,9 @@ function E$1(e) {
|
|
|
4018
4018
|
} else t3 += e[n2].toUpperCase();
|
|
4019
4019
|
return t3;
|
|
4020
4020
|
}
|
|
4021
|
-
var d$2 = /* @__PURE__ */ E$1("WrongRegion"), p$1 = /* @__PURE__ */ E$1("SubscriptionNotActive"), v = /* @__PURE__ */ E$1("UnsupportedVersion"), _$1 = /* @__PURE__ */ E$1("InstallationMethodRestricted"), O = /* @__PURE__ */ E$1("HostnameRestricted"), h = /* @__PURE__ */ E$1("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m$1 = "Request cannot be parsed", w$1 = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y$
|
|
4021
|
+
var d$2 = /* @__PURE__ */ E$1("WrongRegion"), p$1 = /* @__PURE__ */ E$1("SubscriptionNotActive"), v = /* @__PURE__ */ E$1("UnsupportedVersion"), _$1 = /* @__PURE__ */ E$1("InstallationMethodRestricted"), O = /* @__PURE__ */ E$1("HostnameRestricted"), h = /* @__PURE__ */ E$1("IntegrationFailed"), I = "API key required", N = "API key not found", T = "API key expired", m$1 = "Request cannot be parsed", w$1 = "Request failed", A = "Request failed to process", P = "Too many requests, rate limit exceeded", y$2 = "Not available for this origin", D = "Not available with restricted header", S = I, g = N, L = T, U = "3.11.1", b = "Failed to load the JS script of the agent", C$1 = "9319";
|
|
4022
4022
|
function M(t3, n2) {
|
|
4023
|
-
var r2, o2, i, a2,
|
|
4023
|
+
var r2, o2, i, a2, u3, R2, c2 = [], s2 = (r2 = function(t4) {
|
|
4024
4024
|
var n3 = __spreadArray([], t4, true);
|
|
4025
4025
|
return { current: function() {
|
|
4026
4026
|
return n3[0];
|
|
@@ -4030,15 +4030,15 @@ function M(t3, n2) {
|
|
|
4030
4030
|
}, exclude: function() {
|
|
4031
4031
|
n3.shift();
|
|
4032
4032
|
} };
|
|
4033
|
-
}(t3), a2 = 100,
|
|
4034
|
-
return Math.random() * Math.min(
|
|
4033
|
+
}(t3), a2 = 100, u3 = 3e3, R2 = 0, o2 = function() {
|
|
4034
|
+
return Math.random() * Math.min(u3, a2 * Math.pow(2, R2++));
|
|
4035
4035
|
}, i = /* @__PURE__ */ new Set(), [r2.current(), function(e, t4) {
|
|
4036
4036
|
var n3, a3 = t4 instanceof Error ? t4.message : "";
|
|
4037
|
-
if (a3 === f$
|
|
4037
|
+
if (a3 === f$2 || a3 === l$2) r2.exclude(), n3 = 0;
|
|
4038
4038
|
else if (a3 === C$1) r2.exclude();
|
|
4039
4039
|
else if (a3 === b) {
|
|
4040
|
-
var
|
|
4041
|
-
R3 &&
|
|
4040
|
+
var u4 = Date.now() - e.getTime() < 50, R3 = r2.current();
|
|
4041
|
+
R3 && u4 && !i.has(R3) && (i.add(R3), n3 = 0), r2.postpone();
|
|
4042
4042
|
} else r2.postpone();
|
|
4043
4043
|
var c3 = r2.current();
|
|
4044
4044
|
return void 0 === c3 ? void 0 : [c3, null != n3 ? n3 : e.getTime() + o2() - Date.now()];
|
|
@@ -4070,7 +4070,7 @@ var K = "https://fpnpmcdn.net/v<version>/<apiKey>/loader_v<loaderVersion>.js", B
|
|
|
4070
4070
|
function F(e) {
|
|
4071
4071
|
var o2;
|
|
4072
4072
|
e.scriptUrlPattern;
|
|
4073
|
-
var i = e.token, a2 = e.apiKey,
|
|
4073
|
+
var i = e.token, a2 = e.apiKey, u3 = void 0 === a2 ? i : a2, R2 = __rest$1(e, ["scriptUrlPattern", "token", "apiKey"]), c2 = null !== (o2 = r$2(e, "scriptUrlPattern")) && void 0 !== o2 ? o2 : K, s2 = function() {
|
|
4074
4074
|
var e2 = [], t3 = function() {
|
|
4075
4075
|
e2.push({ time: /* @__PURE__ */ new Date(), state: document.visibilityState });
|
|
4076
4076
|
}, n2 = function(e3, t4, n3, r2) {
|
|
@@ -4081,7 +4081,7 @@ function F(e) {
|
|
|
4081
4081
|
return t3(), [e2, n2];
|
|
4082
4082
|
}(), f2 = s2[0], l2 = s2[1];
|
|
4083
4083
|
return Promise.resolve().then(function() {
|
|
4084
|
-
if (!
|
|
4084
|
+
if (!u3 || "string" != typeof u3) throw new Error(I);
|
|
4085
4085
|
var e2 = function(e3, t3) {
|
|
4086
4086
|
return (Array.isArray(e3) ? e3 : [e3]).map(function(e4) {
|
|
4087
4087
|
return function(e5, t4) {
|
|
@@ -4091,7 +4091,7 @@ function F(e) {
|
|
|
4091
4091
|
});
|
|
4092
4092
|
}(String(e4), t3);
|
|
4093
4093
|
});
|
|
4094
|
-
}(c2,
|
|
4094
|
+
}(c2, u3);
|
|
4095
4095
|
return M(e2, V);
|
|
4096
4096
|
}).catch(function(e2) {
|
|
4097
4097
|
throw l2(), function(e3) {
|
|
@@ -4127,7 +4127,7 @@ function V(e) {
|
|
|
4127
4127
|
});
|
|
4128
4128
|
}(e);
|
|
4129
4129
|
}, function() {
|
|
4130
|
-
throw new Error(f$
|
|
4130
|
+
throw new Error(f$2);
|
|
4131
4131
|
}).then(k);
|
|
4132
4132
|
}
|
|
4133
4133
|
function k() {
|
|
@@ -4138,19 +4138,19 @@ function k() {
|
|
|
4138
4138
|
}(e, t3), "function" != typeof (null == n2 ? void 0 : n2.load)) throw new Error(C$1);
|
|
4139
4139
|
return n2;
|
|
4140
4140
|
}
|
|
4141
|
-
var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m$1, ERROR_BAD_RESPONSE_FORMAT: s$
|
|
4141
|
+
var G = { load: F, defaultScriptUrlPattern: B, ERROR_SCRIPT_LOAD_FAIL: b, ERROR_API_KEY_EXPIRED: T, ERROR_API_KEY_INVALID: N, ERROR_API_KEY_MISSING: I, ERROR_BAD_REQUEST_FORMAT: m$1, ERROR_BAD_RESPONSE_FORMAT: s$3, ERROR_CLIENT_TIMEOUT: u$2, ERROR_CSP_BLOCK: f$2, ERROR_FORBIDDEN_ENDPOINT: O, ERROR_FORBIDDEN_HEADER: D, ERROR_FORBIDDEN_ORIGIN: y$2, ERROR_GENERAL_SERVER_FAILURE: w$1, ERROR_INSTALLATION_METHOD_RESTRICTED: _$1, ERROR_INTEGRATION_FAILURE: h, ERROR_INVALID_ENDPOINT: l$2, ERROR_NETWORK_ABORT: c$3, ERROR_NETWORK_CONNECTION: R, ERROR_RATE_LIMIT: P, ERROR_SERVER_TIMEOUT: A, ERROR_SUBSCRIPTION_NOT_ACTIVE: p$1, ERROR_TOKEN_EXPIRED: L, ERROR_TOKEN_INVALID: g, ERROR_TOKEN_MISSING: S, ERROR_UNSUPPORTED_VERSION: v, ERROR_WRONG_REGION: d$2, defaultEndpoint: i$3, defaultTlsEndpoint: a$2 };
|
|
4142
4142
|
const FingerprintJSPro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4143
4143
|
__proto__: null,
|
|
4144
4144
|
ERROR_API_KEY_EXPIRED: T,
|
|
4145
4145
|
ERROR_API_KEY_INVALID: N,
|
|
4146
4146
|
ERROR_API_KEY_MISSING: I,
|
|
4147
4147
|
ERROR_BAD_REQUEST_FORMAT: m$1,
|
|
4148
|
-
ERROR_BAD_RESPONSE_FORMAT: s$
|
|
4149
|
-
ERROR_CLIENT_TIMEOUT: u$
|
|
4150
|
-
ERROR_CSP_BLOCK: f$
|
|
4148
|
+
ERROR_BAD_RESPONSE_FORMAT: s$3,
|
|
4149
|
+
ERROR_CLIENT_TIMEOUT: u$2,
|
|
4150
|
+
ERROR_CSP_BLOCK: f$2,
|
|
4151
4151
|
ERROR_FORBIDDEN_ENDPOINT: O,
|
|
4152
4152
|
ERROR_FORBIDDEN_HEADER: D,
|
|
4153
|
-
ERROR_FORBIDDEN_ORIGIN: y$
|
|
4153
|
+
ERROR_FORBIDDEN_ORIGIN: y$2,
|
|
4154
4154
|
ERROR_GENERAL_SERVER_FAILURE: w$1,
|
|
4155
4155
|
ERROR_INSTALLATION_METHOD_RESTRICTED: _$1,
|
|
4156
4156
|
ERROR_INTEGRATION_FAILURE: h,
|
|
@@ -4169,7 +4169,7 @@ const FingerprintJSPro = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
|
|
|
4169
4169
|
default: G,
|
|
4170
4170
|
defaultEndpoint: i$3,
|
|
4171
4171
|
defaultScriptUrlPattern: B,
|
|
4172
|
-
defaultTlsEndpoint: a$
|
|
4172
|
+
defaultTlsEndpoint: a$2,
|
|
4173
4173
|
load: F
|
|
4174
4174
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4175
4175
|
const CACHE_KEY_PREFIX = "@fpjs@client@";
|
|
@@ -4619,7 +4619,7 @@ const fingerprintService = {
|
|
|
4619
4619
|
isFingerprintReady,
|
|
4620
4620
|
getCachedFingerprint
|
|
4621
4621
|
};
|
|
4622
|
-
const r$
|
|
4622
|
+
const r$1 = {
|
|
4623
4623
|
sandbox: {
|
|
4624
4624
|
search: "https://search.resertravel.com/api",
|
|
4625
4625
|
purchase: "https://purchases.resertravel.com/api",
|
|
@@ -4630,26 +4630,26 @@ const r$2 = {
|
|
|
4630
4630
|
purchase: "https://compras.reservamos.mx/api",
|
|
4631
4631
|
core: ""
|
|
4632
4632
|
}
|
|
4633
|
-
}, s$
|
|
4634
|
-
env: s$
|
|
4633
|
+
}, s$2 = "sandbox", a$1 = "v2", t$3 = "v1", n$1 = {
|
|
4634
|
+
env: s$2,
|
|
4635
4635
|
headers: {},
|
|
4636
|
-
searchUrl: r$
|
|
4637
|
-
purchaseUrl: r$
|
|
4638
|
-
coreUrl: r$
|
|
4639
|
-
version: a$
|
|
4636
|
+
searchUrl: r$1[s$2].search,
|
|
4637
|
+
purchaseUrl: r$1[s$2].purchase,
|
|
4638
|
+
coreUrl: r$1[s$2].core,
|
|
4639
|
+
version: a$1,
|
|
4640
4640
|
coreVersion: t$3,
|
|
4641
4641
|
apiKey: void 0,
|
|
4642
4642
|
userAuthToken: void 0,
|
|
4643
4643
|
withCredentials: false
|
|
4644
4644
|
};
|
|
4645
|
-
let c$2 = Object.assign({}, n$
|
|
4645
|
+
let c$2 = Object.assign({}, n$1);
|
|
4646
4646
|
const o = {
|
|
4647
4647
|
// UNAUTHORIZED
|
|
4648
4648
|
1: {
|
|
4649
4649
|
code: 200,
|
|
4650
4650
|
message: "Operación no autorizada"
|
|
4651
4651
|
}
|
|
4652
|
-
}, s$
|
|
4652
|
+
}, s$1 = {
|
|
4653
4653
|
// INCORRECT_PARAMS
|
|
4654
4654
|
3: {
|
|
4655
4655
|
code: 300,
|
|
@@ -4660,7 +4660,7 @@ const o = {
|
|
|
4660
4660
|
code: 301,
|
|
4661
4661
|
message: "Fecha inválida"
|
|
4662
4662
|
}
|
|
4663
|
-
}, r
|
|
4663
|
+
}, r = {
|
|
4664
4664
|
// NONEXISTENT_TRIP
|
|
4665
4665
|
10: {
|
|
4666
4666
|
code: 400,
|
|
@@ -4681,7 +4681,7 @@ const o = {
|
|
|
4681
4681
|
code: 60,
|
|
4682
4682
|
message: "Tarifa no disponible"
|
|
4683
4683
|
}
|
|
4684
|
-
}, n
|
|
4684
|
+
}, n = (e) => ({
|
|
4685
4685
|
// INVALID_DISCOUNT
|
|
4686
4686
|
11: {
|
|
4687
4687
|
code: 500,
|
|
@@ -4692,7 +4692,7 @@ const o = {
|
|
|
4692
4692
|
code: 501,
|
|
4693
4693
|
message: e
|
|
4694
4694
|
}
|
|
4695
|
-
}), a
|
|
4695
|
+
}), a = {
|
|
4696
4696
|
// unavailable_student
|
|
4697
4697
|
23: {
|
|
4698
4698
|
code: 60,
|
|
@@ -4740,10 +4740,10 @@ const o = {
|
|
|
4740
4740
|
}
|
|
4741
4741
|
}, i$2 = (e) => ({
|
|
4742
4742
|
...o,
|
|
4743
|
-
...s$
|
|
4744
|
-
...r
|
|
4745
|
-
...n
|
|
4746
|
-
...a
|
|
4743
|
+
...s$1,
|
|
4744
|
+
...r,
|
|
4745
|
+
...n(e),
|
|
4746
|
+
...a,
|
|
4747
4747
|
...d$1,
|
|
4748
4748
|
...c$1(e)
|
|
4749
4749
|
});
|
|
@@ -4777,7 +4777,7 @@ function w(e) {
|
|
|
4777
4777
|
} else
|
|
4778
4778
|
return e;
|
|
4779
4779
|
}
|
|
4780
|
-
function y(...e) {
|
|
4780
|
+
function y$1(...e) {
|
|
4781
4781
|
const r2 = Object.keys(Object.assign({}, ...e)).reduce(
|
|
4782
4782
|
(n2, o2) => ({
|
|
4783
4783
|
...n2,
|
|
@@ -4793,17 +4793,17 @@ function c(e, t3 = {}, r2 = {}, n2) {
|
|
|
4793
4793
|
withCredentials: a2,
|
|
4794
4794
|
userAuthToken: s2,
|
|
4795
4795
|
headers: d2
|
|
4796
|
-
} = c$2,
|
|
4796
|
+
} = c$2, u3 = {
|
|
4797
4797
|
Accept: "application/json",
|
|
4798
4798
|
Authorization: `Token token=${r2.apiKey || o2}`,
|
|
4799
4799
|
"Content-Type": "application/json"
|
|
4800
4800
|
};
|
|
4801
|
-
return s2 && (
|
|
4801
|
+
return s2 && (u3.Authorization = `Token ${r2.apiKey || o2}, Bearer ${s2}`), t3.headers = y$1(d2, u3), t3.credentials = a2 ? "include" : "omit", typeof t3.body != "string" && (t3.body = JSON.stringify(t3.body)), fetch(e, t3).then(l$1).then(w).catch(n2);
|
|
4802
4802
|
}
|
|
4803
4803
|
function E(e, t3 = {}, r2) {
|
|
4804
4804
|
return c(e, t3, {}, r2);
|
|
4805
4805
|
}
|
|
4806
|
-
class u {
|
|
4806
|
+
let u$1 = class u {
|
|
4807
4807
|
constructor({
|
|
4808
4808
|
url: e,
|
|
4809
4809
|
watch: i,
|
|
@@ -4842,7 +4842,7 @@ class u {
|
|
|
4842
4842
|
executeEachCall(e, i) {
|
|
4843
4843
|
this.eachCall instanceof Function && this.eachCall({ status: e, payload: i }) && this.abort();
|
|
4844
4844
|
}
|
|
4845
|
-
}
|
|
4845
|
+
};
|
|
4846
4846
|
function C({
|
|
4847
4847
|
apiName: d2,
|
|
4848
4848
|
defaultApiVersion: r2
|
|
@@ -4859,13 +4859,13 @@ function C({
|
|
|
4859
4859
|
function p2(e) {
|
|
4860
4860
|
c2 = e;
|
|
4861
4861
|
}
|
|
4862
|
-
function
|
|
4862
|
+
function u3() {
|
|
4863
4863
|
if (!o2)
|
|
4864
4864
|
throw new Error(`Base URL is not set for ${d2} API.`);
|
|
4865
4865
|
}
|
|
4866
4866
|
const h2 = { body: {} };
|
|
4867
4867
|
async function $(e, t3 = h2) {
|
|
4868
|
-
|
|
4868
|
+
u3();
|
|
4869
4869
|
const { body: s2, headers: n2 = {}, apiVersion: i = r2 } = t3, l2 = `${o2}/${i}/${e}`, b2 = {
|
|
4870
4870
|
...a2,
|
|
4871
4871
|
...n2,
|
|
@@ -4878,7 +4878,7 @@ function C({
|
|
|
4878
4878
|
})).json();
|
|
4879
4879
|
}
|
|
4880
4880
|
async function y2(e, t3 = {}) {
|
|
4881
|
-
|
|
4881
|
+
u3();
|
|
4882
4882
|
const { headers: s2 = {}, apiVersion: n2 = r2 } = t3, i = `${o2}/${n2}/${e}`;
|
|
4883
4883
|
return (await fetch(i, { headers: s2 })).json();
|
|
4884
4884
|
}
|
|
@@ -4889,7 +4889,7 @@ function C({
|
|
|
4889
4889
|
expect: t3.expect,
|
|
4890
4890
|
eachCall: t3.onEachResponse
|
|
4891
4891
|
};
|
|
4892
|
-
return new u(n2);
|
|
4892
|
+
return new u$1(n2);
|
|
4893
4893
|
}
|
|
4894
4894
|
return {
|
|
4895
4895
|
get: y2,
|
|
@@ -4903,20 +4903,6 @@ const t$1 = C({
|
|
|
4903
4903
|
apiName: "Core",
|
|
4904
4904
|
defaultApiVersion: "v1"
|
|
4905
4905
|
});
|
|
4906
|
-
async function r(e) {
|
|
4907
|
-
return t$1.get(
|
|
4908
|
-
`passengers/${e}`
|
|
4909
|
-
);
|
|
4910
|
-
}
|
|
4911
|
-
async function n(e) {
|
|
4912
|
-
return t$1.post("passengers", {
|
|
4913
|
-
body: e
|
|
4914
|
-
});
|
|
4915
|
-
}
|
|
4916
|
-
const a = {
|
|
4917
|
-
getFrequentPassengers: r,
|
|
4918
|
-
createFrequentPassengers: n
|
|
4919
|
-
};
|
|
4920
4906
|
async function t2(o2) {
|
|
4921
4907
|
const { data: e } = await t$1.post(
|
|
4922
4908
|
"anonymous_profiles/identify",
|
|
@@ -4926,55 +4912,66 @@ async function t2(o2) {
|
|
|
4926
4912
|
);
|
|
4927
4913
|
return e;
|
|
4928
4914
|
}
|
|
4929
|
-
const s
|
|
4915
|
+
const s = {
|
|
4930
4916
|
createAnonymousProfile: t2
|
|
4931
4917
|
};
|
|
4932
|
-
function
|
|
4918
|
+
function i$1({
|
|
4933
4919
|
searchId: e,
|
|
4934
|
-
userIdentifier:
|
|
4920
|
+
userIdentifier: n2
|
|
4935
4921
|
}) {
|
|
4936
4922
|
return t$1.get(
|
|
4937
|
-
`trip_recommendations/${e}/${
|
|
4923
|
+
`trip_recommendations/${e}/${n2}`
|
|
4938
4924
|
);
|
|
4939
4925
|
}
|
|
4940
|
-
function
|
|
4926
|
+
function d(e) {
|
|
4941
4927
|
return t$1.post("seat_recommendations", {
|
|
4942
4928
|
body: e
|
|
4943
4929
|
});
|
|
4944
4930
|
}
|
|
4945
|
-
function
|
|
4931
|
+
function p({
|
|
4946
4932
|
distinct_id: e,
|
|
4947
|
-
...
|
|
4933
|
+
...n2
|
|
4948
4934
|
}) {
|
|
4949
4935
|
return t$1.post(`seat_recommendations/${e}`, {
|
|
4950
|
-
body:
|
|
4936
|
+
body: n2
|
|
4951
4937
|
});
|
|
4952
4938
|
}
|
|
4953
|
-
function
|
|
4954
|
-
const { start: s2, onEachResponse:
|
|
4939
|
+
function m(e, n2) {
|
|
4940
|
+
const { start: s2, onEachResponse: r2 } = n2, c2 = `profiles/${e}`, a2 = {
|
|
4955
4941
|
watch: "state",
|
|
4956
4942
|
expect: "finished",
|
|
4957
|
-
onEachResponse:
|
|
4958
|
-
},
|
|
4959
|
-
return s2 &&
|
|
4943
|
+
onEachResponse: r2
|
|
4944
|
+
}, o2 = t$1.poll(c2, a2);
|
|
4945
|
+
return s2 && o2.start(), o2;
|
|
4960
4946
|
}
|
|
4961
|
-
async function
|
|
4947
|
+
async function u2(e) {
|
|
4962
4948
|
return t$1.post("profiles", {
|
|
4963
4949
|
body: e
|
|
4964
4950
|
});
|
|
4965
4951
|
}
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4952
|
+
async function f$1(e) {
|
|
4953
|
+
return t$1.post("passengers", {
|
|
4954
|
+
body: e
|
|
4955
|
+
});
|
|
4956
|
+
}
|
|
4957
|
+
async function l(e) {
|
|
4958
|
+
return t$1.get(
|
|
4959
|
+
`passengers/${e}`
|
|
4960
|
+
);
|
|
4961
|
+
}
|
|
4962
|
+
const y = {
|
|
4963
|
+
getRecommendedTrips: i$1,
|
|
4964
|
+
createRecommendedPlaces: u2,
|
|
4965
|
+
pollRecommendedPlaces: m,
|
|
4966
|
+
createRecommendedSeats: d,
|
|
4967
|
+
getRecommendedSeats: p,
|
|
4968
|
+
getFrequentPassengers: l,
|
|
4969
|
+
createFrequentPassengers: f$1
|
|
4972
4970
|
};
|
|
4973
|
-
const
|
|
4971
|
+
const f = {
|
|
4974
4972
|
setConfig: t$1.setConfig,
|
|
4975
|
-
recommendations:
|
|
4976
|
-
profiles: s
|
|
4977
|
-
preferences: a
|
|
4973
|
+
recommendations: y,
|
|
4974
|
+
profiles: s
|
|
4978
4975
|
};
|
|
4979
4976
|
let environment;
|
|
4980
4977
|
const origin = window.location.origin;
|
|
@@ -13409,7 +13406,7 @@ function loadNoop(_src, onload) {
|
|
|
13409
13406
|
onload();
|
|
13410
13407
|
}
|
|
13411
13408
|
var mixpanel = init_as_module(loadNoop);
|
|
13412
|
-
const version = "1.0.
|
|
13409
|
+
const version = "1.0.13";
|
|
13413
13410
|
const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
|
|
13414
13411
|
function init$2(mixpanelToken, debug = false, proxyUrl) {
|
|
13415
13412
|
return new Promise((resolve) => {
|
|
@@ -13835,7 +13832,7 @@ async function init$1(config) {
|
|
|
13835
13832
|
console.error("Error initializing identification service:", error);
|
|
13836
13833
|
}
|
|
13837
13834
|
configService.setEnvironment(isSandbox ? "sandbox" : "prod");
|
|
13838
|
-
|
|
13835
|
+
f.setConfig(configService.getCoreAPIConfig());
|
|
13839
13836
|
onLoaded();
|
|
13840
13837
|
}
|
|
13841
13838
|
function isTrackerReady() {
|
|
@@ -14010,12 +14007,21 @@ function trackCustomEvent(eventName, eventData = {}, meta = {}) {
|
|
|
14010
14007
|
trackEventError(eventName, error, eventData);
|
|
14011
14008
|
}
|
|
14012
14009
|
}
|
|
14010
|
+
function isCamelCase(word) {
|
|
14011
|
+
if (!word || word.includes(" ")) return false;
|
|
14012
|
+
if (word[0] !== word[0].toLowerCase()) return false;
|
|
14013
|
+
if (/[^a-zA-Z]/.test(word)) return false;
|
|
14014
|
+
if (!/[A-Z]/.test(word)) return false;
|
|
14015
|
+
return true;
|
|
14016
|
+
}
|
|
14013
14017
|
const CreateAnonymousProfileSchema = z.object({
|
|
14014
14018
|
email: z.string().email().optional(),
|
|
14015
14019
|
phone: z.string().optional(),
|
|
14016
14020
|
cpf: z.string().optional(),
|
|
14017
14021
|
passport: z.string().optional(),
|
|
14018
|
-
rg: z.string().optional()
|
|
14022
|
+
rg: z.string().optional(),
|
|
14023
|
+
firstName: z.string().optional(),
|
|
14024
|
+
lastName: z.string().optional()
|
|
14019
14025
|
}).refine((data) => data.email || data.phone, {
|
|
14020
14026
|
message: "At least one of 'email' or 'phone' must be provided"
|
|
14021
14027
|
});
|
|
@@ -14023,6 +14029,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
|
|
|
14023
14029
|
let identifier_key = "phone";
|
|
14024
14030
|
let identifier_value = values.phone || "";
|
|
14025
14031
|
const identifiers = [];
|
|
14032
|
+
const details = {};
|
|
14026
14033
|
if (values.email) {
|
|
14027
14034
|
identifier_key = "email";
|
|
14028
14035
|
identifier_value = values.email;
|
|
@@ -14035,11 +14042,15 @@ function getAnonymousProfilePayload(values, identifiersProps) {
|
|
|
14035
14042
|
"phone",
|
|
14036
14043
|
"salesforceid"
|
|
14037
14044
|
];
|
|
14045
|
+
const allowedKeysDetails = ["name", "firstName", "lastName"];
|
|
14038
14046
|
Object.entries(values).forEach(([key, value]) => {
|
|
14039
|
-
|
|
14047
|
+
key = isCamelCase(key) ? key : key.toLocaleLowerCase();
|
|
14048
|
+
if (allowedKeys.includes(key) && value) {
|
|
14040
14049
|
if (key !== identifier_key) {
|
|
14041
14050
|
identifiers.push({ key, value });
|
|
14042
14051
|
}
|
|
14052
|
+
} else if (allowedKeysDetails.includes(key) && value) {
|
|
14053
|
+
details[key] = value;
|
|
14043
14054
|
}
|
|
14044
14055
|
});
|
|
14045
14056
|
if (identifiersProps.length) {
|
|
@@ -14048,7 +14059,7 @@ function getAnonymousProfilePayload(values, identifiersProps) {
|
|
|
14048
14059
|
return {
|
|
14049
14060
|
identifier_key,
|
|
14050
14061
|
identifier_value,
|
|
14051
|
-
details
|
|
14062
|
+
details,
|
|
14052
14063
|
identifiers
|
|
14053
14064
|
};
|
|
14054
14065
|
}
|
|
@@ -14062,7 +14073,7 @@ async function createAnonymousProfile(payload) {
|
|
|
14062
14073
|
identifiers.push({ key: "fingerprint", value: userFingerprintId });
|
|
14063
14074
|
if (distinctId) identifiers.push({ key: "distinct_id", value: distinctId });
|
|
14064
14075
|
const dataPayload = getAnonymousProfilePayload(payload, identifiers);
|
|
14065
|
-
return await
|
|
14076
|
+
return await f.profiles.createAnonymousProfile(dataPayload);
|
|
14066
14077
|
} catch (error) {
|
|
14067
14078
|
console.error("Could not create anonymous profile:", error);
|
|
14068
14079
|
return void 0;
|
|
@@ -14161,6 +14172,36 @@ const EVENT_NAME = "Purchase Canceled";
|
|
|
14161
14172
|
function trackPurchaseCanceled(eventData, meta = {}) {
|
|
14162
14173
|
trackEvent(EVENT_NAME, eventData, meta);
|
|
14163
14174
|
}
|
|
14175
|
+
const FrequentPassengersSchema = z.object({
|
|
14176
|
+
id: z.number(),
|
|
14177
|
+
first_name: z.string(),
|
|
14178
|
+
last_name: z.string(),
|
|
14179
|
+
second_last_name: z.string(),
|
|
14180
|
+
category: z.string(),
|
|
14181
|
+
bus_category: z.string(),
|
|
14182
|
+
gender: z.string(),
|
|
14183
|
+
email: z.string()
|
|
14184
|
+
});
|
|
14185
|
+
const CreateFrequentPassengersSchema = z.object({
|
|
14186
|
+
passengers: z.array(FrequentPassengersSchema).min(1)
|
|
14187
|
+
});
|
|
14188
|
+
async function createFrequentPassengers(payload) {
|
|
14189
|
+
try {
|
|
14190
|
+
validatorService.validateProps(payload, CreateFrequentPassengersSchema);
|
|
14191
|
+
const distinctId = mixpanelService.getMixpanelDistinctId();
|
|
14192
|
+
const userFingerprintId = fingerprintService.getCachedFingerprint();
|
|
14193
|
+
if (!distinctId) {
|
|
14194
|
+
throw new Error("No distinct ID found");
|
|
14195
|
+
}
|
|
14196
|
+
return await f.recommendations.createFrequentPassengers({
|
|
14197
|
+
...payload,
|
|
14198
|
+
distinct_id: distinctId,
|
|
14199
|
+
device_fingerprint: userFingerprintId || ""
|
|
14200
|
+
});
|
|
14201
|
+
} catch (error) {
|
|
14202
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
14203
|
+
}
|
|
14204
|
+
}
|
|
14164
14205
|
const SeatSchema$1 = z.object({
|
|
14165
14206
|
category: z.string(),
|
|
14166
14207
|
number: z.string().optional(),
|
|
@@ -14183,7 +14224,7 @@ async function createRecommendedSeats$1(payload) {
|
|
|
14183
14224
|
if (!distinctId) {
|
|
14184
14225
|
throw new Error("No distinct ID found");
|
|
14185
14226
|
}
|
|
14186
|
-
return await
|
|
14227
|
+
return await f.recommendations.createRecommendedSeats({
|
|
14187
14228
|
...payload,
|
|
14188
14229
|
distinct_id: distinctId,
|
|
14189
14230
|
device_fingerprint: userFingerprintId || ""
|
|
@@ -14193,6 +14234,17 @@ async function createRecommendedSeats$1(payload) {
|
|
|
14193
14234
|
throw new Error(error instanceof Error ? error.message : String(error));
|
|
14194
14235
|
}
|
|
14195
14236
|
}
|
|
14237
|
+
async function getFrequentPassengers() {
|
|
14238
|
+
try {
|
|
14239
|
+
const distinctId = mixpanelService.getMixpanelDistinctId();
|
|
14240
|
+
if (!distinctId) {
|
|
14241
|
+
throw new Error("No distinct ID found");
|
|
14242
|
+
}
|
|
14243
|
+
return await f.recommendations.getFrequentPassengers(distinctId);
|
|
14244
|
+
} catch (error) {
|
|
14245
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
14246
|
+
}
|
|
14247
|
+
}
|
|
14196
14248
|
const pollingRecommendedPlaces = async (response) => {
|
|
14197
14249
|
return new Promise((resolve, reject) => {
|
|
14198
14250
|
const { state, polling_id } = response;
|
|
@@ -14200,7 +14252,7 @@ const pollingRecommendedPlaces = async (response) => {
|
|
|
14200
14252
|
resolve(response);
|
|
14201
14253
|
return;
|
|
14202
14254
|
}
|
|
14203
|
-
|
|
14255
|
+
f.recommendations.pollRecommendedPlaces(polling_id, {
|
|
14204
14256
|
start: true,
|
|
14205
14257
|
watch: "state",
|
|
14206
14258
|
expect: "finished",
|
|
@@ -14222,7 +14274,7 @@ async function getRecommendedPlaces() {
|
|
|
14222
14274
|
if (!distinctId) {
|
|
14223
14275
|
throw new Error("No distinct ID found");
|
|
14224
14276
|
}
|
|
14225
|
-
const response = await
|
|
14277
|
+
const response = await f.recommendations.createRecommendedPlaces({
|
|
14226
14278
|
distinct_id: distinctId
|
|
14227
14279
|
});
|
|
14228
14280
|
if (!response) {
|
|
@@ -14251,7 +14303,7 @@ async function createRecommendedSeats(payload) {
|
|
|
14251
14303
|
if (!distinctId) {
|
|
14252
14304
|
throw new Error("No distinct ID found");
|
|
14253
14305
|
}
|
|
14254
|
-
return await
|
|
14306
|
+
return await f.recommendations.getRecommendedSeats({
|
|
14255
14307
|
...payload,
|
|
14256
14308
|
distinct_id: distinctId
|
|
14257
14309
|
});
|
|
@@ -14270,7 +14322,7 @@ async function getRecommendedTrips({
|
|
|
14270
14322
|
validatorService.validateProps({ searchId }, GetRecommendedTripsSchema);
|
|
14271
14323
|
const identifier = fingerprintService.getCachedFingerprint() || mixpanelService.getMixpanelDistinctId();
|
|
14272
14324
|
if (!identifier) throw new Error("No identifier id");
|
|
14273
|
-
const response = await
|
|
14325
|
+
const response = await f.recommendations.getRecommendedTrips({
|
|
14274
14326
|
searchId,
|
|
14275
14327
|
userIdentifier: String(identifier)
|
|
14276
14328
|
});
|
|
@@ -14295,7 +14347,9 @@ const analytics = {
|
|
|
14295
14347
|
getRecommendedPlaces,
|
|
14296
14348
|
createRecommendedSeats: createRecommendedSeats$1,
|
|
14297
14349
|
getRecommendedSeats: createRecommendedSeats,
|
|
14298
|
-
getRecommendedTrips
|
|
14350
|
+
getRecommendedTrips,
|
|
14351
|
+
createFrequentPassengers,
|
|
14352
|
+
getFrequentPassengers
|
|
14299
14353
|
},
|
|
14300
14354
|
track: {
|
|
14301
14355
|
search: trackSearch,
|