@yysports/tools 2.0.2 → 2.2.1
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/Track/Beacon.d.ts +6 -0
- package/dist/Track/Beacon.js +58 -0
- package/dist/Track/Config.d.ts +11 -0
- package/dist/Track/Config.js +34 -0
- package/dist/Track/Listener.d.ts +5 -0
- package/dist/Track/Listener.js +46 -0
- package/dist/Track/Log.d.ts +8 -0
- package/dist/Track/Log.js +100 -0
- package/dist/Track/Replay.d.ts +6 -0
- package/dist/Track/Replay.js +77 -0
- package/dist/Track/System.d.ts +5 -0
- package/dist/Track/System.js +24 -0
- package/dist/Track/User.d.ts +6 -0
- package/dist/Track/User.js +29 -0
- package/dist/Track/index.d.ts +15 -17
- package/dist/Track/index.js +56 -67
- package/dist/Utils/auth.d.ts +9 -2
- package/dist/Utils/auth.js +80 -20
- package/dist/Utils/route.d.ts +11 -3
- package/dist/Utils/route.js +49 -56
- package/dist/Utils/url.js +3 -13
- package/dist/interfaces/track.interface.d.ts +2 -80
- package/dist/interfaces/track.interface.js +1 -5
- package/lib/Track/Beacon.d.ts +6 -0
- package/lib/Track/Beacon.js +73 -0
- package/lib/Track/Config.d.ts +11 -0
- package/lib/Track/{core/queue.js → Config.js} +23 -27
- package/lib/Track/Listener.d.ts +5 -0
- package/lib/Track/Listener.js +62 -0
- package/lib/Track/Log.d.ts +8 -0
- package/lib/Track/Log.js +95 -0
- package/lib/Track/Replay.d.ts +6 -0
- package/lib/Track/Replay.js +79 -0
- package/lib/Track/System.d.ts +5 -0
- package/lib/Track/{core/router.js → System.js} +18 -20
- package/lib/Track/User.d.ts +6 -0
- package/lib/Track/User.js +40 -0
- package/lib/Track/index.d.ts +15 -17
- package/lib/Track/index.js +45 -39
- package/lib/Utils/auth.d.ts +9 -2
- package/lib/Utils/auth.js +52 -17
- package/lib/Utils/route.d.ts +11 -3
- package/lib/Utils/route.js +34 -49
- package/lib/Utils/url.js +3 -3
- package/lib/interfaces/track.interface.d.ts +2 -80
- package/package.json +13 -13
- package/dist/Track/core/auth.d.ts +0 -16
- package/dist/Track/core/auth.js +0 -83
- package/dist/Track/core/constants.d.ts +0 -17
- package/dist/Track/core/constants.js +0 -34
- package/dist/Track/core/envelope.d.ts +0 -9
- package/dist/Track/core/envelope.js +0 -54
- package/dist/Track/core/index.d.ts +0 -22
- package/dist/Track/core/index.js +0 -23
- package/dist/Track/core/instance.d.ts +0 -108
- package/dist/Track/core/instance.js +0 -375
- package/dist/Track/core/lifecycle.d.ts +0 -18
- package/dist/Track/core/lifecycle.js +0 -59
- package/dist/Track/core/profile.d.ts +0 -5
- package/dist/Track/core/profile.js +0 -30
- package/dist/Track/core/queue.d.ts +0 -13
- package/dist/Track/core/queue.js +0 -36
- package/dist/Track/core/replay.d.ts +0 -17
- package/dist/Track/core/replay.js +0 -117
- package/dist/Track/core/router.d.ts +0 -6
- package/dist/Track/core/router.js +0 -15
- package/dist/Track/core/system.d.ts +0 -14
- package/dist/Track/core/system.js +0 -36
- package/dist/Track/core/transport.d.ts +0 -18
- package/dist/Track/core/transport.js +0 -165
- package/lib/Track/core/auth.d.ts +0 -16
- package/lib/Track/core/auth.js +0 -67
- package/lib/Track/core/constants.d.ts +0 -17
- package/lib/Track/core/constants.js +0 -65
- package/lib/Track/core/envelope.d.ts +0 -9
- package/lib/Track/core/envelope.js +0 -61
- package/lib/Track/core/index.d.ts +0 -22
- package/lib/Track/core/index.js +0 -51
- package/lib/Track/core/instance.d.ts +0 -108
- package/lib/Track/core/instance.js +0 -266
- package/lib/Track/core/lifecycle.d.ts +0 -18
- package/lib/Track/core/lifecycle.js +0 -74
- package/lib/Track/core/profile.d.ts +0 -5
- package/lib/Track/core/profile.js +0 -47
- package/lib/Track/core/queue.d.ts +0 -13
- package/lib/Track/core/replay.d.ts +0 -17
- package/lib/Track/core/replay.js +0 -131
- package/lib/Track/core/router.d.ts +0 -6
- package/lib/Track/core/system.d.ts +0 -14
- package/lib/Track/core/system.js +0 -53
- package/lib/Track/core/transport.d.ts +0 -18
- package/lib/Track/core/transport.js +0 -128
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/Track/core/transport.ts
|
|
20
|
-
var transport_exports = {};
|
|
21
|
-
__export(transport_exports, {
|
|
22
|
-
beaconSend: () => beaconSend,
|
|
23
|
-
reportApiLog: () => reportApiLog,
|
|
24
|
-
reportAppVersion: () => reportAppVersion,
|
|
25
|
-
reportBatch: () => reportBatch,
|
|
26
|
-
reportError: () => reportError
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(transport_exports);
|
|
29
|
-
var import_package = require("../../../package.json");
|
|
30
|
-
var import_constants = require("./constants");
|
|
31
|
-
function resolveDomain(config) {
|
|
32
|
-
const env = config && config.env || "test";
|
|
33
|
-
switch (env) {
|
|
34
|
-
case "dev":
|
|
35
|
-
return import_constants.DEV_DOMAIN;
|
|
36
|
-
case "prod":
|
|
37
|
-
return import_constants.PROD_DOMAIN;
|
|
38
|
-
case "test":
|
|
39
|
-
default:
|
|
40
|
-
return import_constants.TEST_DOMAIN;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async function fetchWrapper(url, options) {
|
|
44
|
-
return new Promise((resolve, reject) => {
|
|
45
|
-
fetch(url, options).then((response) => {
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
`Network response was not ok: ${response.statusText}`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
return response.json();
|
|
52
|
-
}).then((data) => resolve(data)).catch((error) => reject(error));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function beaconSend(url, payload) {
|
|
56
|
-
try {
|
|
57
|
-
if (!Array.isArray(payload) && (typeof payload !== "object" || payload === null)) {
|
|
58
|
-
throw new Error("Payload must be an object or array");
|
|
59
|
-
}
|
|
60
|
-
const body = new Blob([JSON.stringify(payload)], {
|
|
61
|
-
type: "application/json"
|
|
62
|
-
});
|
|
63
|
-
navigator.sendBeacon(url, body);
|
|
64
|
-
} catch (err) {
|
|
65
|
-
console.warn("[track:debug] beacon failed", err, url, payload);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function reportAppVersion(config) {
|
|
69
|
-
const { appId } = config;
|
|
70
|
-
const domain = resolveDomain(config);
|
|
71
|
-
const storageKey = `__Track__${appId}`;
|
|
72
|
-
try {
|
|
73
|
-
const cached = localStorage.getItem(storageKey);
|
|
74
|
-
if (cached) {
|
|
75
|
-
try {
|
|
76
|
-
const { v } = JSON.parse(cached);
|
|
77
|
-
if (v === import_package.version) {
|
|
78
|
-
console.debug("[track:debug] skip version report (same)", import_package.version);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
localStorage.setItem(
|
|
85
|
-
storageKey,
|
|
86
|
-
JSON.stringify({ v: import_package.version, t: (/* @__PURE__ */ new Date()).toLocaleString() })
|
|
87
|
-
);
|
|
88
|
-
} catch {
|
|
89
|
-
}
|
|
90
|
-
beaconSend(`${domain}${import_constants.APP_VERSION_ENDPOINT}`, { appId, version: import_package.version });
|
|
91
|
-
}
|
|
92
|
-
function reportBatch(config, batch) {
|
|
93
|
-
if (!batch.length)
|
|
94
|
-
return;
|
|
95
|
-
const domain = resolveDomain(config);
|
|
96
|
-
beaconSend(`${domain}${import_constants.TRACK_ENDPOINT}`, batch);
|
|
97
|
-
}
|
|
98
|
-
function reportApiLog(config, apiLog, envelope) {
|
|
99
|
-
const domain = resolveDomain(config);
|
|
100
|
-
beaconSend(`${domain}${import_constants.TRACK_ENDPOINT}`, [envelope]);
|
|
101
|
-
}
|
|
102
|
-
async function reportError(config, envelope, replayPayload) {
|
|
103
|
-
const domain = resolveDomain(config);
|
|
104
|
-
const { data: id } = await fetchWrapper(`${domain}${import_constants.ERROR_TRACK_ENDPOINT}`, {
|
|
105
|
-
method: "POST",
|
|
106
|
-
headers: {
|
|
107
|
-
"Content-Type": "application/json"
|
|
108
|
-
},
|
|
109
|
-
body: JSON.stringify(envelope)
|
|
110
|
-
});
|
|
111
|
-
if (id && replayPayload) {
|
|
112
|
-
fetchWrapper(`${domain}${import_constants.ERROR_REPLAY_ENDPOINT}${id}`, {
|
|
113
|
-
method: "POST",
|
|
114
|
-
headers: {
|
|
115
|
-
"Content-Type": "text/plain"
|
|
116
|
-
},
|
|
117
|
-
body: JSON.stringify(replayPayload)
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
-
0 && (module.exports = {
|
|
123
|
-
beaconSend,
|
|
124
|
-
reportApiLog,
|
|
125
|
-
reportAppVersion,
|
|
126
|
-
reportBatch,
|
|
127
|
-
reportError
|
|
128
|
-
});
|