lee_web_track_sdk 0.0.10 → 0.0.11
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/README.md +18 -15
- package/dist/index.cjs +1529 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +100 -14
- package/dist/index.d.ts +100 -14
- package/dist/index.js +814 -479
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/esm/index.js +0 -1066
- package/dist/esm/index.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1529 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function _array_like_to_array(arr, len) {
|
|
3
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
4
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5
|
+
return arr2;
|
|
6
|
+
}
|
|
7
|
+
function _array_without_holes(arr) {
|
|
8
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
|
+
}
|
|
10
|
+
function _assert_this_initialized(self) {
|
|
11
|
+
if (self === void 0) {
|
|
12
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
}
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _call_super(_this, derived, args) {
|
|
46
|
+
derived = _get_prototype_of(derived);
|
|
47
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
48
|
+
}
|
|
49
|
+
function _class_call_check(instance, Constructor) {
|
|
50
|
+
if (!(instance instanceof Constructor)) {
|
|
51
|
+
throw new TypeError("Cannot call a class as a function");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function _construct(Parent, args, Class) {
|
|
55
|
+
if (_is_native_reflect_construct()) {
|
|
56
|
+
_construct = Reflect.construct;
|
|
57
|
+
} else {
|
|
58
|
+
_construct = function construct(Parent, args, Class) {
|
|
59
|
+
var a = [
|
|
60
|
+
null
|
|
61
|
+
];
|
|
62
|
+
a.push.apply(a, args);
|
|
63
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
64
|
+
var instance = new Constructor();
|
|
65
|
+
if (Class) _set_prototype_of(instance, Class.prototype);
|
|
66
|
+
return instance;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return _construct.apply(null, arguments);
|
|
70
|
+
}
|
|
71
|
+
function _defineProperties(target, props) {
|
|
72
|
+
for(var i = 0; i < props.length; i++){
|
|
73
|
+
var descriptor = props[i];
|
|
74
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
75
|
+
descriptor.configurable = true;
|
|
76
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
77
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
81
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
82
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
83
|
+
return Constructor;
|
|
84
|
+
}
|
|
85
|
+
function _define_property(obj, key, value) {
|
|
86
|
+
if (key in obj) {
|
|
87
|
+
Object.defineProperty(obj, key, {
|
|
88
|
+
value: value,
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
obj[key] = value;
|
|
95
|
+
}
|
|
96
|
+
return obj;
|
|
97
|
+
}
|
|
98
|
+
function _get_prototype_of(o) {
|
|
99
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
100
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
101
|
+
};
|
|
102
|
+
return _get_prototype_of(o);
|
|
103
|
+
}
|
|
104
|
+
function _inherits(subClass, superClass) {
|
|
105
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
106
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
107
|
+
}
|
|
108
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
109
|
+
constructor: {
|
|
110
|
+
value: subClass,
|
|
111
|
+
writable: true,
|
|
112
|
+
configurable: true
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
116
|
+
}
|
|
117
|
+
function _is_native_function(fn) {
|
|
118
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
119
|
+
}
|
|
120
|
+
function _iterable_to_array(iter) {
|
|
121
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
122
|
+
}
|
|
123
|
+
function _non_iterable_spread() {
|
|
124
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
125
|
+
}
|
|
126
|
+
function _object_spread(target) {
|
|
127
|
+
for(var i = 1; i < arguments.length; i++){
|
|
128
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
129
|
+
var ownKeys = Object.keys(source);
|
|
130
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
131
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
132
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
ownKeys.forEach(function(key) {
|
|
136
|
+
_define_property(target, key, source[key]);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return target;
|
|
140
|
+
}
|
|
141
|
+
function _possible_constructor_return(self, call) {
|
|
142
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
143
|
+
return call;
|
|
144
|
+
}
|
|
145
|
+
return _assert_this_initialized(self);
|
|
146
|
+
}
|
|
147
|
+
function _set_prototype_of(o, p) {
|
|
148
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
149
|
+
o.__proto__ = p;
|
|
150
|
+
return o;
|
|
151
|
+
};
|
|
152
|
+
return _set_prototype_of(o, p);
|
|
153
|
+
}
|
|
154
|
+
function _to_consumable_array(arr) {
|
|
155
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
156
|
+
}
|
|
157
|
+
function _type_of(obj) {
|
|
158
|
+
"@swc/helpers - typeof";
|
|
159
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
160
|
+
}
|
|
161
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
162
|
+
if (!o) return;
|
|
163
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
164
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
165
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
166
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
167
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
168
|
+
}
|
|
169
|
+
function _wrap_native_super(Class) {
|
|
170
|
+
var _cache = typeof Map === "function" ? new Map() : undefined;
|
|
171
|
+
_wrap_native_super = function wrapNativeSuper(Class) {
|
|
172
|
+
if (Class === null || !_is_native_function(Class)) return Class;
|
|
173
|
+
if (typeof Class !== "function") {
|
|
174
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
175
|
+
}
|
|
176
|
+
if (typeof _cache !== "undefined") {
|
|
177
|
+
if (_cache.has(Class)) return _cache.get(Class);
|
|
178
|
+
_cache.set(Class, Wrapper);
|
|
179
|
+
}
|
|
180
|
+
function Wrapper() {
|
|
181
|
+
return _construct(Class, arguments, _get_prototype_of(this).constructor);
|
|
182
|
+
}
|
|
183
|
+
Wrapper.prototype = Object.create(Class.prototype, {
|
|
184
|
+
constructor: {
|
|
185
|
+
value: Wrapper,
|
|
186
|
+
enumerable: false,
|
|
187
|
+
writable: true,
|
|
188
|
+
configurable: true
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return _set_prototype_of(Wrapper, Class);
|
|
192
|
+
};
|
|
193
|
+
return _wrap_native_super(Class);
|
|
194
|
+
}
|
|
195
|
+
function _is_native_reflect_construct() {
|
|
196
|
+
try {
|
|
197
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
198
|
+
} catch (_) {}
|
|
199
|
+
return (_is_native_reflect_construct = function() {
|
|
200
|
+
return !!result;
|
|
201
|
+
})();
|
|
202
|
+
}
|
|
203
|
+
function _ts_generator(thisArg, body) {
|
|
204
|
+
var f, y, t, _ = {
|
|
205
|
+
label: 0,
|
|
206
|
+
sent: function() {
|
|
207
|
+
if (t[0] & 1) throw t[1];
|
|
208
|
+
return t[1];
|
|
209
|
+
},
|
|
210
|
+
trys: [],
|
|
211
|
+
ops: []
|
|
212
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
213
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
214
|
+
return this;
|
|
215
|
+
}), g;
|
|
216
|
+
function verb(n) {
|
|
217
|
+
return function(v) {
|
|
218
|
+
return step([
|
|
219
|
+
n,
|
|
220
|
+
v
|
|
221
|
+
]);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function step(op) {
|
|
225
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
226
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
227
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
228
|
+
if (y = 0, t) op = [
|
|
229
|
+
op[0] & 2,
|
|
230
|
+
t.value
|
|
231
|
+
];
|
|
232
|
+
switch(op[0]){
|
|
233
|
+
case 0:
|
|
234
|
+
case 1:
|
|
235
|
+
t = op;
|
|
236
|
+
break;
|
|
237
|
+
case 4:
|
|
238
|
+
_.label++;
|
|
239
|
+
return {
|
|
240
|
+
value: op[1],
|
|
241
|
+
done: false
|
|
242
|
+
};
|
|
243
|
+
case 5:
|
|
244
|
+
_.label++;
|
|
245
|
+
y = op[1];
|
|
246
|
+
op = [
|
|
247
|
+
0
|
|
248
|
+
];
|
|
249
|
+
continue;
|
|
250
|
+
case 7:
|
|
251
|
+
op = _.ops.pop();
|
|
252
|
+
_.trys.pop();
|
|
253
|
+
continue;
|
|
254
|
+
default:
|
|
255
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
256
|
+
_ = 0;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
260
|
+
_.label = op[1];
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
264
|
+
_.label = t[1];
|
|
265
|
+
t = op;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
if (t && _.label < t[2]) {
|
|
269
|
+
_.label = t[2];
|
|
270
|
+
_.ops.push(op);
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
if (t[2]) _.ops.pop();
|
|
274
|
+
_.trys.pop();
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
op = body.call(thisArg, _);
|
|
278
|
+
} catch (e) {
|
|
279
|
+
op = [
|
|
280
|
+
6,
|
|
281
|
+
e
|
|
282
|
+
];
|
|
283
|
+
y = 0;
|
|
284
|
+
} finally{
|
|
285
|
+
f = t = 0;
|
|
286
|
+
}
|
|
287
|
+
if (op[0] & 5) throw op[1];
|
|
288
|
+
return {
|
|
289
|
+
value: op[0] ? op[1] : void 0,
|
|
290
|
+
done: true
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
var __create = Object.create;
|
|
295
|
+
var __defProp = Object.defineProperty;
|
|
296
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
297
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
298
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
299
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
300
|
+
var __export = function(target, all) {
|
|
301
|
+
for(var name in all)__defProp(target, name, {
|
|
302
|
+
get: all[name],
|
|
303
|
+
enumerable: true
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
var __copyProps = function(to, from, except, desc) {
|
|
307
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
308
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
309
|
+
try {
|
|
310
|
+
var _loop = function() {
|
|
311
|
+
var key = _step.value;
|
|
312
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
313
|
+
get: function() {
|
|
314
|
+
return from[key];
|
|
315
|
+
},
|
|
316
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
320
|
+
} catch (err) {
|
|
321
|
+
_didIteratorError = true;
|
|
322
|
+
_iteratorError = err;
|
|
323
|
+
} finally{
|
|
324
|
+
try {
|
|
325
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
326
|
+
_iterator.return();
|
|
327
|
+
}
|
|
328
|
+
} finally{
|
|
329
|
+
if (_didIteratorError) {
|
|
330
|
+
throw _iteratorError;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return to;
|
|
336
|
+
};
|
|
337
|
+
var __toESM = function(mod, isNodeMode, target) {
|
|
338
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
339
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
340
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
341
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
342
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
343
|
+
value: mod,
|
|
344
|
+
enumerable: true
|
|
345
|
+
}) : target, mod);
|
|
346
|
+
};
|
|
347
|
+
var __toCommonJS = function(mod) {
|
|
348
|
+
return __copyProps(__defProp({}, "__esModule", {
|
|
349
|
+
value: true
|
|
350
|
+
}), mod);
|
|
351
|
+
};
|
|
352
|
+
// src/index.ts
|
|
353
|
+
var index_exports = {};
|
|
354
|
+
__export(index_exports, {
|
|
355
|
+
default: function() {
|
|
356
|
+
return index_default;
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
module.exports = __toCommonJS(index_exports);
|
|
360
|
+
// src/config/index.ts
|
|
361
|
+
var defaultConfig = {
|
|
362
|
+
project_name: "",
|
|
363
|
+
report_url: "",
|
|
364
|
+
app_version: "",
|
|
365
|
+
adapter: "web",
|
|
366
|
+
maxCacheSize: 15,
|
|
367
|
+
maxCacheTime: 3e5,
|
|
368
|
+
maxTimeout: 1e4,
|
|
369
|
+
plugins: [
|
|
370
|
+
{
|
|
371
|
+
type: "track",
|
|
372
|
+
options: {
|
|
373
|
+
autoPv: true,
|
|
374
|
+
frameType: "js",
|
|
375
|
+
router: null
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
]
|
|
379
|
+
};
|
|
380
|
+
// src/adapter/web/cache.ts
|
|
381
|
+
var localForage = __toESM(require("localforage"), 1);
|
|
382
|
+
// src/core/cache.ts
|
|
383
|
+
var Cache = function Cache(options) {
|
|
384
|
+
_class_call_check(this, Cache);
|
|
385
|
+
if (options) {
|
|
386
|
+
this.options = options;
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
function initCache(CacheClass, options) {
|
|
390
|
+
return new CacheClass(options);
|
|
391
|
+
}
|
|
392
|
+
// src/core/report.ts
|
|
393
|
+
var Report = function Report(options) {
|
|
394
|
+
_class_call_check(this, Report);
|
|
395
|
+
this.options = options;
|
|
396
|
+
};
|
|
397
|
+
function initReport(ReportClass, options) {
|
|
398
|
+
if (!options.url) {
|
|
399
|
+
throw new Error("\u8BF7\u4F20\u5165\u4E0A\u62A5\u5730\u5740url");
|
|
400
|
+
}
|
|
401
|
+
return new ReportClass(options);
|
|
402
|
+
}
|
|
403
|
+
// src/core/init.ts
|
|
404
|
+
var coreInit = function(param) {
|
|
405
|
+
var config = param.config, adapter = param.adapter, instance2 = param.instance;
|
|
406
|
+
instance2.$cache = initCache(adapter.cache);
|
|
407
|
+
instance2.$report = initReport(adapter.report, {
|
|
408
|
+
url: config.report_url,
|
|
409
|
+
timeout: config.maxTimeout
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
// src/static/constant.ts
|
|
413
|
+
var EVENT_TYPES = [
|
|
414
|
+
"page_view",
|
|
415
|
+
"user_view",
|
|
416
|
+
"page_destroy",
|
|
417
|
+
"click_event",
|
|
418
|
+
"module_click",
|
|
419
|
+
"module_view",
|
|
420
|
+
"login_event",
|
|
421
|
+
"order_event",
|
|
422
|
+
"custom_event",
|
|
423
|
+
"log_event"
|
|
424
|
+
];
|
|
425
|
+
var CAN_AGGREGATION_TYPES = [
|
|
426
|
+
"page_view",
|
|
427
|
+
"user_view"
|
|
428
|
+
];
|
|
429
|
+
var EVENT_KEYS = [
|
|
430
|
+
"project_name",
|
|
431
|
+
"event_type",
|
|
432
|
+
"event_name",
|
|
433
|
+
"event_time",
|
|
434
|
+
"user_id",
|
|
435
|
+
"app_version",
|
|
436
|
+
"user_timezone",
|
|
437
|
+
"device_type",
|
|
438
|
+
"user_agent",
|
|
439
|
+
"screen_resolution",
|
|
440
|
+
"custom_data",
|
|
441
|
+
"is_aggregation"
|
|
442
|
+
];
|
|
443
|
+
var CACHE_DATA_NAME = "fr-track-cache-data";
|
|
444
|
+
var CACHE_ERR_DATA_NAME = "fr-track-cache-err-data";
|
|
445
|
+
// src/utils/utils.ts
|
|
446
|
+
var logWarn = function(message, title) {
|
|
447
|
+
var logTitle = title ? "[Fr-track warning ".concat(title, "]") : "[Fr-track warning]";
|
|
448
|
+
console.warn("".concat(logTitle, ":"), message);
|
|
449
|
+
};
|
|
450
|
+
var logError = function(message, title) {
|
|
451
|
+
var logTitle = title ? "[Fr-track error ".concat(title, "]") : "[Fr-track error]";
|
|
452
|
+
console.error("".concat(logTitle, ":"), message);
|
|
453
|
+
};
|
|
454
|
+
var getVariableType = function(variable) {
|
|
455
|
+
var typeString = Object.prototype.toString.call(variable);
|
|
456
|
+
return typeString.slice(8, -1).toLowerCase();
|
|
457
|
+
};
|
|
458
|
+
var generateFallbackUUID = function() {
|
|
459
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
460
|
+
var r = Math.random() * 16 | 0;
|
|
461
|
+
var v = c === "x" ? r : r & 3 | 8;
|
|
462
|
+
return v.toString(16);
|
|
463
|
+
});
|
|
464
|
+
};
|
|
465
|
+
var generateUserId = function() {
|
|
466
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
467
|
+
return crypto.randomUUID();
|
|
468
|
+
}
|
|
469
|
+
return generateFallbackUUID();
|
|
470
|
+
};
|
|
471
|
+
var overrideHistoryMethods = function(type) {
|
|
472
|
+
var originalMethod = history[type];
|
|
473
|
+
return function overrideHistoryMethods() {
|
|
474
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
475
|
+
args[_key] = arguments[_key];
|
|
476
|
+
}
|
|
477
|
+
var res = originalMethod.apply(this, args);
|
|
478
|
+
var e = new Event(type);
|
|
479
|
+
window.dispatchEvent(e);
|
|
480
|
+
return res;
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
var getUserTimeZone = function() {
|
|
484
|
+
try {
|
|
485
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
486
|
+
} catch (error) {
|
|
487
|
+
logWarn(error, "\u65E0\u6CD5\u83B7\u53D6\u65F6\u533A\u540D\u79F0\uFF0C\u4F7F\u7528\u504F\u79FB\u91CF\u63A8\u7B97:");
|
|
488
|
+
var offset = /* @__PURE__ */ new Date().getTimezoneOffset();
|
|
489
|
+
if (offset >= 0) {
|
|
490
|
+
return "西".concat(offset / 60, "区");
|
|
491
|
+
} else {
|
|
492
|
+
return "东".concat(-offset / 60, "区");
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
// src/utils/validator.ts
|
|
497
|
+
function validateEventType(eventType) {
|
|
498
|
+
return typeof eventType === "string" && EVENT_TYPES.includes(eventType);
|
|
499
|
+
}
|
|
500
|
+
function validateEventKey(params) {
|
|
501
|
+
var type = getVariableType(params);
|
|
502
|
+
if (!params || type !== "object") {
|
|
503
|
+
logWarn("Event params must be an object");
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
var keys = Object.keys(params);
|
|
507
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
508
|
+
try {
|
|
509
|
+
for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
510
|
+
var key = _step.value;
|
|
511
|
+
if (!EVENT_KEYS.includes(key)) {
|
|
512
|
+
logWarn("Invalid event key: ".concat(key));
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
} catch (err) {
|
|
517
|
+
_didIteratorError = true;
|
|
518
|
+
_iteratorError = err;
|
|
519
|
+
} finally{
|
|
520
|
+
try {
|
|
521
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
522
|
+
_iterator.return();
|
|
523
|
+
}
|
|
524
|
+
} finally{
|
|
525
|
+
if (_didIteratorError) {
|
|
526
|
+
throw _iteratorError;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
// src/core/clean.ts
|
|
533
|
+
var cleanTrackData = function(rawData) {
|
|
534
|
+
try {
|
|
535
|
+
var tempIds = /* @__PURE__ */ new Set();
|
|
536
|
+
var resultData = rawData.filter(function(rawItem) {
|
|
537
|
+
var eventKeyResult = validateEventKey(rawItem);
|
|
538
|
+
if (!eventKeyResult) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
var eventTypeResult = validateEventType(rawItem.event_type);
|
|
542
|
+
if (!eventTypeResult) {
|
|
543
|
+
logWarn("\u4E8B\u4EF6\u7C7B\u578B\u4E0D\u5408\u6CD5");
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
var eventTime = rawItem.event_time;
|
|
547
|
+
var minDateTime = /* @__PURE__ */ new Date("2025-12-01").getTime();
|
|
548
|
+
if (!eventTime || typeof eventTime !== "number" || eventTime < minDateTime) {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
var id = "".concat(rawItem.event_type, "-").concat(rawItem.event_name, "-").concat(rawItem.event_time);
|
|
552
|
+
if (tempIds.has(id)) {
|
|
553
|
+
return false;
|
|
554
|
+
} else {
|
|
555
|
+
tempIds.add(id);
|
|
556
|
+
}
|
|
557
|
+
return true;
|
|
558
|
+
});
|
|
559
|
+
return {
|
|
560
|
+
type: "success",
|
|
561
|
+
data: resultData
|
|
562
|
+
};
|
|
563
|
+
} catch (error) {
|
|
564
|
+
logError(error, "\u6E05\u6D17\u5931\u8D25");
|
|
565
|
+
var errReason = error.message || "Unknown error";
|
|
566
|
+
return {
|
|
567
|
+
type: "fail",
|
|
568
|
+
errReason: errReason,
|
|
569
|
+
data: rawData
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
// src/core/aggregation.ts
|
|
574
|
+
var aggregationData = function(rawData) {
|
|
575
|
+
try {
|
|
576
|
+
var _loop = function(i) {
|
|
577
|
+
var item = rawData[i];
|
|
578
|
+
if (!item) return "continue";
|
|
579
|
+
if (CAN_AGGREGATION_TYPES.includes(item.event_type) || item.is_aggregation) {
|
|
580
|
+
delete item.is_aggregation;
|
|
581
|
+
var currentDate = new Date(item.event_time).setHours(0, 0, 0, 0);
|
|
582
|
+
var resultItem = resultData.find(function(r) {
|
|
583
|
+
return r.event_time === currentDate && r.event_type === item.event_type && r.event_name === item.event_name;
|
|
584
|
+
});
|
|
585
|
+
if (!resultItem) {
|
|
586
|
+
item.event_time = currentDate;
|
|
587
|
+
resultData.push(item);
|
|
588
|
+
} else {
|
|
589
|
+
if (item.event_type === "user_view") {
|
|
590
|
+
resultItem.user_id = item.user_id;
|
|
591
|
+
}
|
|
592
|
+
var customData = resultItem.custom_data;
|
|
593
|
+
if (customData && customData.count) {
|
|
594
|
+
customData.count += 1;
|
|
595
|
+
resultItem.custom_data = customData;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
} else {
|
|
599
|
+
delete item.is_aggregation;
|
|
600
|
+
resultData.push(item);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
var resultData = [];
|
|
604
|
+
for(var i = 0; i < rawData.length; i++)_loop(i);
|
|
605
|
+
return resultData;
|
|
606
|
+
} catch (error) {
|
|
607
|
+
logError(error, "\u805A\u5408\u5931\u8D25");
|
|
608
|
+
return rawData;
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
// src/adapter/web/cache.ts
|
|
612
|
+
var WebCache = /*#__PURE__*/ function(Cache) {
|
|
613
|
+
_inherits(WebCache, Cache);
|
|
614
|
+
function WebCache(options) {
|
|
615
|
+
_class_call_check(this, WebCache);
|
|
616
|
+
return _call_super(this, WebCache, [
|
|
617
|
+
options
|
|
618
|
+
]);
|
|
619
|
+
}
|
|
620
|
+
_create_class(WebCache, [
|
|
621
|
+
{
|
|
622
|
+
key: "get",
|
|
623
|
+
value: function get(name) {
|
|
624
|
+
return _async_to_generator(function() {
|
|
625
|
+
var res;
|
|
626
|
+
return _ts_generator(this, function(_state) {
|
|
627
|
+
switch(_state.label){
|
|
628
|
+
case 0:
|
|
629
|
+
return [
|
|
630
|
+
4,
|
|
631
|
+
localForage.getItem(name)
|
|
632
|
+
];
|
|
633
|
+
case 1:
|
|
634
|
+
res = _state.sent();
|
|
635
|
+
return [
|
|
636
|
+
2,
|
|
637
|
+
res || []
|
|
638
|
+
];
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
})();
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
key: "set",
|
|
646
|
+
value: function set(name, data) {
|
|
647
|
+
return _async_to_generator(function() {
|
|
648
|
+
var currentData, cacheData, _currentData;
|
|
649
|
+
return _ts_generator(this, function(_state) {
|
|
650
|
+
switch(_state.label){
|
|
651
|
+
case 0:
|
|
652
|
+
return [
|
|
653
|
+
4,
|
|
654
|
+
this.get(name)
|
|
655
|
+
];
|
|
656
|
+
case 1:
|
|
657
|
+
currentData = _state.sent();
|
|
658
|
+
cacheData = Array.isArray(data) ? data : [
|
|
659
|
+
data
|
|
660
|
+
];
|
|
661
|
+
if (!currentData.length) return [
|
|
662
|
+
3,
|
|
663
|
+
3
|
|
664
|
+
];
|
|
665
|
+
(_currentData = currentData).push.apply(_currentData, _to_consumable_array(cacheData));
|
|
666
|
+
return [
|
|
667
|
+
4,
|
|
668
|
+
localForage.setItem(name, currentData)
|
|
669
|
+
];
|
|
670
|
+
case 2:
|
|
671
|
+
_state.sent();
|
|
672
|
+
return [
|
|
673
|
+
3,
|
|
674
|
+
5
|
|
675
|
+
];
|
|
676
|
+
case 3:
|
|
677
|
+
return [
|
|
678
|
+
4,
|
|
679
|
+
localForage.setItem(name, cacheData)
|
|
680
|
+
];
|
|
681
|
+
case 4:
|
|
682
|
+
_state.sent();
|
|
683
|
+
_state.label = 5;
|
|
684
|
+
case 5:
|
|
685
|
+
return [
|
|
686
|
+
2
|
|
687
|
+
];
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
}).call(this);
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
key: "remove",
|
|
695
|
+
value: function remove(name) {
|
|
696
|
+
return _async_to_generator(function() {
|
|
697
|
+
return _ts_generator(this, function(_state) {
|
|
698
|
+
switch(_state.label){
|
|
699
|
+
case 0:
|
|
700
|
+
return [
|
|
701
|
+
4,
|
|
702
|
+
localForage.removeItem(name)
|
|
703
|
+
];
|
|
704
|
+
case 1:
|
|
705
|
+
_state.sent();
|
|
706
|
+
return [
|
|
707
|
+
2
|
|
708
|
+
];
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
})();
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
key: "clear",
|
|
716
|
+
value: function clear() {
|
|
717
|
+
return _async_to_generator(function() {
|
|
718
|
+
return _ts_generator(this, function(_state) {
|
|
719
|
+
switch(_state.label){
|
|
720
|
+
case 0:
|
|
721
|
+
return [
|
|
722
|
+
4,
|
|
723
|
+
localForage.clear()
|
|
724
|
+
];
|
|
725
|
+
case 1:
|
|
726
|
+
_state.sent();
|
|
727
|
+
return [
|
|
728
|
+
2
|
|
729
|
+
];
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
})();
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
]);
|
|
736
|
+
return WebCache;
|
|
737
|
+
}(_wrap_native_super(Cache));
|
|
738
|
+
var cache_default = WebCache;
|
|
739
|
+
// src/adapter/web/report.ts
|
|
740
|
+
var WebReport = /*#__PURE__*/ function(Report) {
|
|
741
|
+
_inherits(WebReport, Report);
|
|
742
|
+
function WebReport(options) {
|
|
743
|
+
_class_call_check(this, WebReport);
|
|
744
|
+
return _call_super(this, WebReport, [
|
|
745
|
+
options
|
|
746
|
+
]);
|
|
747
|
+
}
|
|
748
|
+
_create_class(WebReport, [
|
|
749
|
+
{
|
|
750
|
+
key: "retry",
|
|
751
|
+
value: function retry(failedData, callback) {
|
|
752
|
+
return _async_to_generator(function() {
|
|
753
|
+
var _this, retryCount, retryFun;
|
|
754
|
+
return _ts_generator(this, function(_state) {
|
|
755
|
+
_this = this;
|
|
756
|
+
retryCount = 1;
|
|
757
|
+
if (!(failedData === null || failedData === void 0 ? void 0 : failedData.length)) return [
|
|
758
|
+
2
|
|
759
|
+
];
|
|
760
|
+
if (retryCount >= 3) {
|
|
761
|
+
if (!callback) return [
|
|
762
|
+
2
|
|
763
|
+
];
|
|
764
|
+
callback();
|
|
765
|
+
return [
|
|
766
|
+
2
|
|
767
|
+
];
|
|
768
|
+
}
|
|
769
|
+
retryFun = function() {
|
|
770
|
+
return _async_to_generator(function() {
|
|
771
|
+
return _ts_generator(this, function(_state) {
|
|
772
|
+
switch(_state.label){
|
|
773
|
+
case 0:
|
|
774
|
+
return [
|
|
775
|
+
4,
|
|
776
|
+
this.send(failedData).catch(function() {
|
|
777
|
+
setTimeout(function() {
|
|
778
|
+
retryCount++;
|
|
779
|
+
retryFun();
|
|
780
|
+
}, 3e3);
|
|
781
|
+
})
|
|
782
|
+
];
|
|
783
|
+
case 1:
|
|
784
|
+
_state.sent();
|
|
785
|
+
return [
|
|
786
|
+
2
|
|
787
|
+
];
|
|
788
|
+
}
|
|
789
|
+
});
|
|
790
|
+
}).call(_this);
|
|
791
|
+
};
|
|
792
|
+
retryFun();
|
|
793
|
+
return [
|
|
794
|
+
2
|
|
795
|
+
];
|
|
796
|
+
});
|
|
797
|
+
}).call(this);
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
key: "send",
|
|
802
|
+
value: function send(data) {
|
|
803
|
+
return _async_to_generator(function() {
|
|
804
|
+
var _this_options, url, timeout;
|
|
805
|
+
return _ts_generator(this, function(_state) {
|
|
806
|
+
_this_options = this.options, url = _this_options.url, timeout = _this_options.timeout;
|
|
807
|
+
return [
|
|
808
|
+
2,
|
|
809
|
+
new Promise(function(resolve, reject) {
|
|
810
|
+
var xhr = new XMLHttpRequest();
|
|
811
|
+
xhr.open("POST", url, true);
|
|
812
|
+
xhr.timeout = timeout;
|
|
813
|
+
xhr.setRequestHeader("Content-Type", "application/json");
|
|
814
|
+
xhr.onload = function() {
|
|
815
|
+
resolve(xhr.response);
|
|
816
|
+
if (xhr.status === 0) {
|
|
817
|
+
resolve(xhr.response);
|
|
818
|
+
} else {
|
|
819
|
+
reject();
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
xhr.onerror = function() {
|
|
823
|
+
reject();
|
|
824
|
+
};
|
|
825
|
+
xhr.send(JSON.stringify(data));
|
|
826
|
+
})
|
|
827
|
+
];
|
|
828
|
+
});
|
|
829
|
+
}).call(this);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
]);
|
|
833
|
+
return WebReport;
|
|
834
|
+
}(Report);
|
|
835
|
+
var report_default = WebReport;
|
|
836
|
+
// src/adapter/index.ts
|
|
837
|
+
var getEnv = function() {
|
|
838
|
+
var isMiniProgram = wx && typeof wx.getSystemInfoSync === "function";
|
|
839
|
+
return isMiniProgram ? "miniProgram" : "web";
|
|
840
|
+
};
|
|
841
|
+
var getAdapter = function(configEnv) {
|
|
842
|
+
var env = configEnv || getEnv();
|
|
843
|
+
if (env === "miniProgram") {}
|
|
844
|
+
return {
|
|
845
|
+
env: "web",
|
|
846
|
+
cache: cache_default,
|
|
847
|
+
report: report_default
|
|
848
|
+
};
|
|
849
|
+
};
|
|
850
|
+
// src/utils/uuid.ts
|
|
851
|
+
var getUserId = function() {
|
|
852
|
+
var track_uuid = localStorage.getItem("track_uuid");
|
|
853
|
+
if (track_uuid) {
|
|
854
|
+
return track_uuid;
|
|
855
|
+
}
|
|
856
|
+
var uuid = generateUserId();
|
|
857
|
+
localStorage.setItem("track_uuid", uuid);
|
|
858
|
+
return uuid;
|
|
859
|
+
};
|
|
860
|
+
// src/utils/browser.ts
|
|
861
|
+
var import_bowser = __toESM(require("bowser"), 1);
|
|
862
|
+
var getBrowserAndDeviceInfo = function() {
|
|
863
|
+
var defRes = {
|
|
864
|
+
browserName: "unknown",
|
|
865
|
+
browserVersion: "unknown",
|
|
866
|
+
osName: "unknown",
|
|
867
|
+
osVersion: "unknown",
|
|
868
|
+
platformName: "unknown"
|
|
869
|
+
};
|
|
870
|
+
try {
|
|
871
|
+
var ua = window.navigator.userAgent;
|
|
872
|
+
if (!ua) return defRes;
|
|
873
|
+
var info = import_bowser.default.parse(ua);
|
|
874
|
+
var browser = info.browser, os = info.os, platform = info.platform;
|
|
875
|
+
return {
|
|
876
|
+
browserName: browser.name || "unknown",
|
|
877
|
+
browserVersion: browser.version || "unknown",
|
|
878
|
+
osName: os.name || "unknown",
|
|
879
|
+
osVersion: os.version || "unknown",
|
|
880
|
+
platformName: platform.type || "unknown"
|
|
881
|
+
};
|
|
882
|
+
} catch (error) {
|
|
883
|
+
logWarn(error);
|
|
884
|
+
return defRes;
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
var getDeviceResolution = function() {
|
|
888
|
+
if (!window) return "unknown";
|
|
889
|
+
var screen = window.screen;
|
|
890
|
+
return "".concat(screen.width, "x").concat(screen.height);
|
|
891
|
+
};
|
|
892
|
+
// src/plugin/track/trackClass.ts
|
|
893
|
+
var FrTrack = /*#__PURE__*/ function() {
|
|
894
|
+
function FrTrack(instance2, pluginOptions) {
|
|
895
|
+
var _this = this;
|
|
896
|
+
_class_call_check(this, FrTrack);
|
|
897
|
+
this.userId = getUserId();
|
|
898
|
+
this.timer = null;
|
|
899
|
+
this.uvTimer = null;
|
|
900
|
+
this.browserInfo = null;
|
|
901
|
+
this.taskQueue = [];
|
|
902
|
+
this.isProcessing = false;
|
|
903
|
+
this.reportPrevData = function() {
|
|
904
|
+
_this.reportCacheData();
|
|
905
|
+
_this.reportErrCacheData();
|
|
906
|
+
};
|
|
907
|
+
if (!instance2) {
|
|
908
|
+
throw new Error("\u8BF7\u4F20\u5165SDk\u5B9E\u4F8B");
|
|
909
|
+
}
|
|
910
|
+
this.cacheFn = instance2.$cache;
|
|
911
|
+
this.reportFn = instance2.$report;
|
|
912
|
+
this.instanceConfig = instance2.config;
|
|
913
|
+
this.pluginOptions = pluginOptions;
|
|
914
|
+
}
|
|
915
|
+
_create_class(FrTrack, [
|
|
916
|
+
{
|
|
917
|
+
key: "processQueue",
|
|
918
|
+
value: /* 执行异步队列任务 */ function processQueue() {
|
|
919
|
+
return _async_to_generator(function() {
|
|
920
|
+
var currentTask, err;
|
|
921
|
+
return _ts_generator(this, function(_state) {
|
|
922
|
+
switch(_state.label){
|
|
923
|
+
case 0:
|
|
924
|
+
if (this.isProcessing || this.taskQueue.length === 0) return [
|
|
925
|
+
2
|
|
926
|
+
];
|
|
927
|
+
this.isProcessing = true;
|
|
928
|
+
currentTask = this.taskQueue.shift();
|
|
929
|
+
_state.label = 1;
|
|
930
|
+
case 1:
|
|
931
|
+
_state.trys.push([
|
|
932
|
+
1,
|
|
933
|
+
3,
|
|
934
|
+
4,
|
|
935
|
+
5
|
|
936
|
+
]);
|
|
937
|
+
return [
|
|
938
|
+
4,
|
|
939
|
+
currentTask.fn()
|
|
940
|
+
];
|
|
941
|
+
case 2:
|
|
942
|
+
_state.sent();
|
|
943
|
+
console.log("✅ 任务执行成功:".concat(currentTask.desc));
|
|
944
|
+
return [
|
|
945
|
+
3,
|
|
946
|
+
5
|
|
947
|
+
];
|
|
948
|
+
case 3:
|
|
949
|
+
err = _state.sent();
|
|
950
|
+
logError(err, "❌ 任务执行失败:".concat(currentTask.desc));
|
|
951
|
+
return [
|
|
952
|
+
3,
|
|
953
|
+
5
|
|
954
|
+
];
|
|
955
|
+
case 4:
|
|
956
|
+
this.isProcessing = false;
|
|
957
|
+
this.processQueue();
|
|
958
|
+
return [
|
|
959
|
+
7
|
|
960
|
+
];
|
|
961
|
+
case 5:
|
|
962
|
+
return [
|
|
963
|
+
2
|
|
964
|
+
];
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
}).call(this);
|
|
968
|
+
}
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
/* 异步队列添加任务 */ key: "addTask",
|
|
972
|
+
value: function addTask(task) {
|
|
973
|
+
var taskWithDesc = _object_spread({
|
|
974
|
+
desc: "".concat(task.type, " 任务")
|
|
975
|
+
}, task);
|
|
976
|
+
this.taskQueue.push(taskWithDesc);
|
|
977
|
+
this.processQueue();
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
key: "reportCacheData",
|
|
982
|
+
value: /* 上报缓存数据 */ function reportCacheData() {
|
|
983
|
+
return _async_to_generator(function() {
|
|
984
|
+
var _this;
|
|
985
|
+
return _ts_generator(this, function(_state) {
|
|
986
|
+
_this = this;
|
|
987
|
+
this.addTask({
|
|
988
|
+
type: "report_send",
|
|
989
|
+
fn: function() {
|
|
990
|
+
return _async_to_generator(function() {
|
|
991
|
+
var cacheData, cleanInfo, result;
|
|
992
|
+
return _ts_generator(this, function(_state) {
|
|
993
|
+
switch(_state.label){
|
|
994
|
+
case 0:
|
|
995
|
+
if (!this.cacheFn || !this.reportFn) return [
|
|
996
|
+
2
|
|
997
|
+
];
|
|
998
|
+
return [
|
|
999
|
+
4,
|
|
1000
|
+
this.cacheFn.get(CACHE_DATA_NAME)
|
|
1001
|
+
];
|
|
1002
|
+
case 1:
|
|
1003
|
+
cacheData = _state.sent();
|
|
1004
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length)) return [
|
|
1005
|
+
2
|
|
1006
|
+
];
|
|
1007
|
+
cleanInfo = cleanTrackData(cacheData);
|
|
1008
|
+
if (cleanInfo.type !== "success") {
|
|
1009
|
+
logWarn(cleanInfo.errReason);
|
|
1010
|
+
} else {
|
|
1011
|
+
result = aggregationData(cleanInfo.data);
|
|
1012
|
+
if (result && result.length) {
|
|
1013
|
+
this.reportFn.send(result).catch(function(err) {
|
|
1014
|
+
logError(err, "\u4E0A\u62A5\u5931\u8D25\u6570\u636E\u5F02\u5E38");
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return [
|
|
1019
|
+
4,
|
|
1020
|
+
this.cacheFn.remove(CACHE_DATA_NAME)
|
|
1021
|
+
];
|
|
1022
|
+
case 2:
|
|
1023
|
+
_state.sent();
|
|
1024
|
+
return [
|
|
1025
|
+
2
|
|
1026
|
+
];
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
}).call(_this);
|
|
1030
|
+
}
|
|
1031
|
+
});
|
|
1032
|
+
return [
|
|
1033
|
+
2
|
|
1034
|
+
];
|
|
1035
|
+
});
|
|
1036
|
+
}).call(this);
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
key: "reportErrCacheData",
|
|
1041
|
+
value: /* 上报缓存的失败数据 */ function reportErrCacheData() {
|
|
1042
|
+
return _async_to_generator(function() {
|
|
1043
|
+
var _this;
|
|
1044
|
+
return _ts_generator(this, function(_state) {
|
|
1045
|
+
_this = this;
|
|
1046
|
+
this.addTask({
|
|
1047
|
+
type: "report_send",
|
|
1048
|
+
fn: function() {
|
|
1049
|
+
return _async_to_generator(function() {
|
|
1050
|
+
var cacheData;
|
|
1051
|
+
return _ts_generator(this, function(_state) {
|
|
1052
|
+
switch(_state.label){
|
|
1053
|
+
case 0:
|
|
1054
|
+
if (!this.cacheFn || !this.reportFn) return [
|
|
1055
|
+
2
|
|
1056
|
+
];
|
|
1057
|
+
return [
|
|
1058
|
+
4,
|
|
1059
|
+
this.cacheFn.get(CACHE_ERR_DATA_NAME)
|
|
1060
|
+
];
|
|
1061
|
+
case 1:
|
|
1062
|
+
cacheData = _state.sent();
|
|
1063
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.length)) return [
|
|
1064
|
+
2
|
|
1065
|
+
];
|
|
1066
|
+
this.reportFn.send(cacheData).catch(function(err) {
|
|
1067
|
+
logError(err, "\u4E0A\u62A5\u5931\u8D25\u6570\u636E\u5F02\u5E38");
|
|
1068
|
+
});
|
|
1069
|
+
return [
|
|
1070
|
+
4,
|
|
1071
|
+
this.cacheFn.remove(CACHE_ERR_DATA_NAME)
|
|
1072
|
+
];
|
|
1073
|
+
case 2:
|
|
1074
|
+
_state.sent();
|
|
1075
|
+
return [
|
|
1076
|
+
2
|
|
1077
|
+
];
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
}).call(_this);
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
return [
|
|
1084
|
+
2
|
|
1085
|
+
];
|
|
1086
|
+
});
|
|
1087
|
+
}).call(this);
|
|
1088
|
+
}
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
/* 定时循环上报 */ key: "loopReport",
|
|
1092
|
+
value: function loopReport() {
|
|
1093
|
+
var _this = this;
|
|
1094
|
+
if (this.timer) {
|
|
1095
|
+
clearInterval(this.timer);
|
|
1096
|
+
this.timer = null;
|
|
1097
|
+
}
|
|
1098
|
+
this.timer = setInterval(function() {
|
|
1099
|
+
_this.reportCacheData();
|
|
1100
|
+
}, this.instanceConfig.maxCacheTime);
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
/* 浏览器关闭时触发 */ key: "onBrowserClose",
|
|
1105
|
+
value: function onBrowserClose() {
|
|
1106
|
+
var _this = this;
|
|
1107
|
+
window.addEventListener("beforeunload", function() {
|
|
1108
|
+
if (_this.timer) {
|
|
1109
|
+
clearInterval(_this.timer);
|
|
1110
|
+
_this.timer = null;
|
|
1111
|
+
}
|
|
1112
|
+
if (_this.uvTimer) {
|
|
1113
|
+
clearInterval(_this.uvTimer);
|
|
1114
|
+
_this.uvTimer = null;
|
|
1115
|
+
}
|
|
1116
|
+
_this.reportCacheData();
|
|
1117
|
+
});
|
|
1118
|
+
window.addEventListener("visibilitychange", function() {
|
|
1119
|
+
if (document.visibilityState !== "visible") {
|
|
1120
|
+
if (_this.timer) {
|
|
1121
|
+
clearInterval(_this.timer);
|
|
1122
|
+
_this.timer = null;
|
|
1123
|
+
}
|
|
1124
|
+
_this.reportCacheData();
|
|
1125
|
+
} else {
|
|
1126
|
+
_this.loopReport();
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
key: "nativePv",
|
|
1133
|
+
value: function nativePv() {
|
|
1134
|
+
var _this = this;
|
|
1135
|
+
var methodsList = [
|
|
1136
|
+
"hashchange",
|
|
1137
|
+
"popstate",
|
|
1138
|
+
"pushState",
|
|
1139
|
+
"replaceState"
|
|
1140
|
+
];
|
|
1141
|
+
methodsList.forEach(function(method) {
|
|
1142
|
+
window.addEventListener(method, function() {
|
|
1143
|
+
var href = window.location.href || "";
|
|
1144
|
+
var params = {
|
|
1145
|
+
event_name: href,
|
|
1146
|
+
custom_data: {
|
|
1147
|
+
page_url: href,
|
|
1148
|
+
page_name: "unknown",
|
|
1149
|
+
count: 1
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
_this.singleTrack("page_view", params);
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
key: "vuePv",
|
|
1159
|
+
value: function vuePv() {
|
|
1160
|
+
var _this = this;
|
|
1161
|
+
if (!this.pluginOptions.router) {
|
|
1162
|
+
throw new Error("\u8BF7\u4F20\u5165\u8DEF\u7531\u5B9E\u4F8B");
|
|
1163
|
+
}
|
|
1164
|
+
var router = this.pluginOptions.router;
|
|
1165
|
+
router.afterEach(function(to) {
|
|
1166
|
+
var params = {
|
|
1167
|
+
event_name: to.path,
|
|
1168
|
+
custom_data: {
|
|
1169
|
+
page_url: to.fullPath || "--",
|
|
1170
|
+
page_name: to.name || "--",
|
|
1171
|
+
count: 1
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
_this.singleTrack("page_view", params);
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
key: "toSetCacheData",
|
|
1180
|
+
value: function toSetCacheData(params) {
|
|
1181
|
+
return _async_to_generator(function() {
|
|
1182
|
+
var _this;
|
|
1183
|
+
return _ts_generator(this, function(_state) {
|
|
1184
|
+
_this = this;
|
|
1185
|
+
this.addTask({
|
|
1186
|
+
type: "cache_set",
|
|
1187
|
+
fn: function() {
|
|
1188
|
+
return _async_to_generator(function() {
|
|
1189
|
+
var maxCacheSize, res;
|
|
1190
|
+
return _ts_generator(this, function(_state) {
|
|
1191
|
+
switch(_state.label){
|
|
1192
|
+
case 0:
|
|
1193
|
+
if (!this.cacheFn) return [
|
|
1194
|
+
2
|
|
1195
|
+
];
|
|
1196
|
+
return [
|
|
1197
|
+
4,
|
|
1198
|
+
this.cacheFn.set(CACHE_DATA_NAME, params)
|
|
1199
|
+
];
|
|
1200
|
+
case 1:
|
|
1201
|
+
_state.sent();
|
|
1202
|
+
maxCacheSize = this.instanceConfig.maxCacheSize;
|
|
1203
|
+
return [
|
|
1204
|
+
4,
|
|
1205
|
+
this.cacheFn.get(CACHE_DATA_NAME)
|
|
1206
|
+
];
|
|
1207
|
+
case 2:
|
|
1208
|
+
res = _state.sent();
|
|
1209
|
+
if ((res === null || res === void 0 ? void 0 : res.length) >= maxCacheSize) {
|
|
1210
|
+
this.reportCacheData();
|
|
1211
|
+
}
|
|
1212
|
+
return [
|
|
1213
|
+
2
|
|
1214
|
+
];
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
}).call(_this);
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
return [
|
|
1221
|
+
2
|
|
1222
|
+
];
|
|
1223
|
+
});
|
|
1224
|
+
}).call(this);
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1227
|
+
{
|
|
1228
|
+
key: "track",
|
|
1229
|
+
value: function track(params) {
|
|
1230
|
+
return _async_to_generator(function() {
|
|
1231
|
+
var _this_instanceConfig, project_name, app_version, _this_browserInfo, osName, osVersion, browserName, browserVersion, platformName, trackParams;
|
|
1232
|
+
return _ts_generator(this, function(_state) {
|
|
1233
|
+
_this_instanceConfig = this.instanceConfig, project_name = _this_instanceConfig.project_name, app_version = _this_instanceConfig.app_version;
|
|
1234
|
+
_this_browserInfo = this.browserInfo, osName = _this_browserInfo.osName, osVersion = _this_browserInfo.osVersion, browserName = _this_browserInfo.browserName, browserVersion = _this_browserInfo.browserVersion, platformName = _this_browserInfo.platformName;
|
|
1235
|
+
trackParams = Object.assign({
|
|
1236
|
+
project_name: project_name,
|
|
1237
|
+
app_version: app_version,
|
|
1238
|
+
user_id: this.userId,
|
|
1239
|
+
device_type: platformName,
|
|
1240
|
+
user_agent: "os: ".concat(osName, "--v").concat(osVersion, ", browser: ").concat(browserName, "--v").concat(browserVersion),
|
|
1241
|
+
screen_resolution: getDeviceResolution(),
|
|
1242
|
+
user_timezone: getUserTimeZone(),
|
|
1243
|
+
event_time: Date.now(),
|
|
1244
|
+
custom_data: null
|
|
1245
|
+
}, params);
|
|
1246
|
+
this.toSetCacheData(trackParams);
|
|
1247
|
+
return [
|
|
1248
|
+
2
|
|
1249
|
+
];
|
|
1250
|
+
});
|
|
1251
|
+
}).call(this);
|
|
1252
|
+
}
|
|
1253
|
+
},
|
|
1254
|
+
{
|
|
1255
|
+
key: "singleTrack",
|
|
1256
|
+
value: function singleTrack(eventType, params) {
|
|
1257
|
+
var baseParams = {
|
|
1258
|
+
event_type: eventType
|
|
1259
|
+
};
|
|
1260
|
+
var trackParams = Object.assign(baseParams, params);
|
|
1261
|
+
this.track(trackParams);
|
|
1262
|
+
}
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
/**
|
|
1266
|
+
* @method 自定义用户id
|
|
1267
|
+
*/ key: "setUser",
|
|
1268
|
+
value: function setUser(id) {
|
|
1269
|
+
this.userId = id;
|
|
1270
|
+
this.frUserView();
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
/**
|
|
1275
|
+
* @method 模块view
|
|
1276
|
+
*/ key: "frModuleView",
|
|
1277
|
+
value: function frModuleView(event_name, custom_data) {
|
|
1278
|
+
var params = {
|
|
1279
|
+
event_name: event_name,
|
|
1280
|
+
custom_data: custom_data
|
|
1281
|
+
};
|
|
1282
|
+
this.singleTrack("module_view", params);
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
{
|
|
1286
|
+
/**
|
|
1287
|
+
* @method 模块click
|
|
1288
|
+
*/ key: "frModuleClick",
|
|
1289
|
+
value: function frModuleClick(event_name, custom_data) {
|
|
1290
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1291
|
+
var params = {
|
|
1292
|
+
event_name: event_name,
|
|
1293
|
+
custom_data: custom_data,
|
|
1294
|
+
is_aggregation: is_aggregation
|
|
1295
|
+
};
|
|
1296
|
+
this.singleTrack("module_click", params);
|
|
1297
|
+
}
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
/**
|
|
1301
|
+
* @method 登录事件
|
|
1302
|
+
*/ key: "frLoginEvent",
|
|
1303
|
+
value: function frLoginEvent(event_name, custom_data) {
|
|
1304
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1305
|
+
var params = {
|
|
1306
|
+
event_name: event_name,
|
|
1307
|
+
custom_data: custom_data,
|
|
1308
|
+
is_aggregation: is_aggregation
|
|
1309
|
+
};
|
|
1310
|
+
this.singleTrack("login_event", params);
|
|
1311
|
+
}
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
/**
|
|
1315
|
+
* @method 生单事件
|
|
1316
|
+
*/ key: "frOrderEvent",
|
|
1317
|
+
value: function frOrderEvent(event_name, custom_data) {
|
|
1318
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1319
|
+
var params = {
|
|
1320
|
+
event_name: event_name,
|
|
1321
|
+
custom_data: custom_data,
|
|
1322
|
+
is_aggregation: is_aggregation
|
|
1323
|
+
};
|
|
1324
|
+
this.singleTrack("order_event", params);
|
|
1325
|
+
}
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
/**
|
|
1329
|
+
* @method 自定义事件
|
|
1330
|
+
*/ key: "frCustomEvent",
|
|
1331
|
+
value: function frCustomEvent(event_name, custom_data) {
|
|
1332
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1333
|
+
var params = {
|
|
1334
|
+
event_name: event_name,
|
|
1335
|
+
custom_data: custom_data,
|
|
1336
|
+
is_aggregation: is_aggregation
|
|
1337
|
+
};
|
|
1338
|
+
this.singleTrack("custom_event", params);
|
|
1339
|
+
}
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
/**
|
|
1343
|
+
* @method 日志事件
|
|
1344
|
+
*/ key: "frLogEvent",
|
|
1345
|
+
value: function frLogEvent(event_name, custom_data) {
|
|
1346
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1347
|
+
var params = {
|
|
1348
|
+
event_name: event_name,
|
|
1349
|
+
custom_data: custom_data,
|
|
1350
|
+
is_aggregation: is_aggregation
|
|
1351
|
+
};
|
|
1352
|
+
this.singleTrack("log_event", params);
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
/**
|
|
1357
|
+
* @method 点击事件
|
|
1358
|
+
*/ key: "frClickEvent",
|
|
1359
|
+
value: function frClickEvent(event_name, custom_data) {
|
|
1360
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1361
|
+
var params = {
|
|
1362
|
+
event_name: event_name,
|
|
1363
|
+
custom_data: custom_data,
|
|
1364
|
+
is_aggregation: is_aggregation
|
|
1365
|
+
};
|
|
1366
|
+
this.singleTrack("click_event", params);
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
/**
|
|
1371
|
+
* @method 自动收集pv事件
|
|
1372
|
+
*/ key: "frAutoPageView",
|
|
1373
|
+
value: function frAutoPageView() {
|
|
1374
|
+
if (this.pluginOptions.frameType === "js") {
|
|
1375
|
+
window.history.pushState = overrideHistoryMethods("pushState");
|
|
1376
|
+
window.history.replaceState = overrideHistoryMethods("replaceState");
|
|
1377
|
+
this.nativePv();
|
|
1378
|
+
} else if (this.pluginOptions.frameType === "vue") {
|
|
1379
|
+
this.vuePv();
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
/**
|
|
1385
|
+
* @method pv事件
|
|
1386
|
+
*/ key: "frPageView",
|
|
1387
|
+
value: function frPageView(event_name, custom_data) {
|
|
1388
|
+
var params = {
|
|
1389
|
+
event_name: event_name,
|
|
1390
|
+
custom_data: custom_data
|
|
1391
|
+
};
|
|
1392
|
+
this.singleTrack("page_view", params);
|
|
1393
|
+
}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
/**
|
|
1397
|
+
* @method uv事件
|
|
1398
|
+
*/ key: "frUserView",
|
|
1399
|
+
value: function frUserView() {
|
|
1400
|
+
var _this = this;
|
|
1401
|
+
var currentDate = /* @__PURE__ */ new Date().setHours(0, 0, 0, 0);
|
|
1402
|
+
var interval = 60 * 60 * 1e3;
|
|
1403
|
+
var params = {
|
|
1404
|
+
event_name: "user_view"
|
|
1405
|
+
};
|
|
1406
|
+
this.singleTrack("user_view", params);
|
|
1407
|
+
if (this.uvTimer) {
|
|
1408
|
+
clearInterval(this.uvTimer);
|
|
1409
|
+
this.uvTimer = null;
|
|
1410
|
+
}
|
|
1411
|
+
this.uvTimer = setInterval(function() {
|
|
1412
|
+
var now = /* @__PURE__ */ new Date().setHours(0, 0, 0, 0);
|
|
1413
|
+
if (now > currentDate + 24 * interval) {
|
|
1414
|
+
_this.singleTrack("user_view", params);
|
|
1415
|
+
}
|
|
1416
|
+
}, interval);
|
|
1417
|
+
}
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
/**
|
|
1421
|
+
* @method 页面销毁事件
|
|
1422
|
+
*/ key: "frPageDestroy",
|
|
1423
|
+
value: function frPageDestroy(event_name, custom_data) {
|
|
1424
|
+
var is_aggregation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
1425
|
+
var params = {
|
|
1426
|
+
event_name: event_name,
|
|
1427
|
+
custom_data: custom_data,
|
|
1428
|
+
is_aggregation: is_aggregation
|
|
1429
|
+
};
|
|
1430
|
+
this.singleTrack("page_destroy", params);
|
|
1431
|
+
}
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
/**
|
|
1435
|
+
* @method 手动立即上报缓存的数据
|
|
1436
|
+
*/ key: "frReport",
|
|
1437
|
+
value: function frReport() {
|
|
1438
|
+
this.reportCacheData();
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
key: "init",
|
|
1443
|
+
value: function init() {
|
|
1444
|
+
this.browserInfo = getBrowserAndDeviceInfo();
|
|
1445
|
+
this.reportPrevData();
|
|
1446
|
+
this.loopReport();
|
|
1447
|
+
this.onBrowserClose();
|
|
1448
|
+
this.frUserView();
|
|
1449
|
+
if (this.pluginOptions.autoPv) {
|
|
1450
|
+
this.frAutoPageView();
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
]);
|
|
1455
|
+
return FrTrack;
|
|
1456
|
+
}();
|
|
1457
|
+
var trackClass_default = FrTrack;
|
|
1458
|
+
// src/plugin/track/index.ts
|
|
1459
|
+
var trackPlugin = {
|
|
1460
|
+
name: "track",
|
|
1461
|
+
defaultEnable: true,
|
|
1462
|
+
install: function(sdkInstance, pluginOptions) {
|
|
1463
|
+
try {
|
|
1464
|
+
if (!(sdkInstance === null || sdkInstance === void 0 ? void 0 : sdkInstance.$cache) || !(sdkInstance === null || sdkInstance === void 0 ? void 0 : sdkInstance.$report)) return;
|
|
1465
|
+
var defaultOptions = {
|
|
1466
|
+
frameType: "js",
|
|
1467
|
+
router: void 0,
|
|
1468
|
+
autoPv: true
|
|
1469
|
+
};
|
|
1470
|
+
if (pluginOptions) {
|
|
1471
|
+
Object.assign(defaultOptions, pluginOptions);
|
|
1472
|
+
}
|
|
1473
|
+
if (sdkInstance.$track) return;
|
|
1474
|
+
var frTrack = new trackClass_default(sdkInstance, defaultOptions);
|
|
1475
|
+
sdkInstance.$track = frTrack;
|
|
1476
|
+
frTrack.init();
|
|
1477
|
+
} catch (err) {
|
|
1478
|
+
logError(err, "trackPlugin\u521D\u59CB\u5316\u5931\u8D25");
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
// src/index.ts
|
|
1483
|
+
var instance = null;
|
|
1484
|
+
var FrWebSDK = /*#__PURE__*/ function() {
|
|
1485
|
+
function FrWebSDK() {
|
|
1486
|
+
_class_call_check(this, FrWebSDK);
|
|
1487
|
+
this.isInit = false;
|
|
1488
|
+
this.config = defaultConfig;
|
|
1489
|
+
this.adapter = null;
|
|
1490
|
+
}
|
|
1491
|
+
_create_class(FrWebSDK, [
|
|
1492
|
+
{
|
|
1493
|
+
key: "init",
|
|
1494
|
+
value: function init(userConfig) {
|
|
1495
|
+
var _this = this;
|
|
1496
|
+
if (this.isInit) {
|
|
1497
|
+
logWarn("SDK\u5DF2\u521D\u59CB\u5316");
|
|
1498
|
+
return this;
|
|
1499
|
+
}
|
|
1500
|
+
this.config = _object_spread({}, defaultConfig, userConfig);
|
|
1501
|
+
this.adapter = getAdapter(this.config.adapter);
|
|
1502
|
+
coreInit({
|
|
1503
|
+
config: this.config,
|
|
1504
|
+
adapter: this.adapter,
|
|
1505
|
+
instance: this
|
|
1506
|
+
});
|
|
1507
|
+
if (this.config.plugins) {
|
|
1508
|
+
this.config.plugins.forEach(function(plugin) {
|
|
1509
|
+
if (plugin.type === "track") {
|
|
1510
|
+
trackPlugin.install(_this, plugin.options);
|
|
1511
|
+
}
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
this.isInit = true;
|
|
1515
|
+
return this;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
]);
|
|
1519
|
+
return FrWebSDK;
|
|
1520
|
+
}();
|
|
1521
|
+
function getInstance() {
|
|
1522
|
+
if (!instance) {
|
|
1523
|
+
instance = new FrWebSDK();
|
|
1524
|
+
}
|
|
1525
|
+
return instance;
|
|
1526
|
+
}
|
|
1527
|
+
var webSdk = getInstance();
|
|
1528
|
+
var index_default = webSdk;
|
|
1529
|
+
//# sourceMappingURL=index.cjs.map
|