@datarangers/sdk-javascript 0.0.6 → 0.1.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/core/es/index.min.js +1 -0
- package/core/lib/index.min.js +1 -0
- package/es/index-base.min.js +6430 -1
- package/es/index.min.js +9936 -1
- package/es/plugin/ab.js +928 -1
- package/es/plugin/autotrack.js +1897 -1
- package/es/plugin/duration.js +117 -1
- package/es/plugin/route.js +363 -1
- package/es/plugin/stay.js +547 -1
- package/es/plugin/store.js +151 -1
- package/lib/index-base.min.js +6435 -1
- package/lib/index.min.js +9941 -1
- package/lib/plugin/ab.js +930 -1
- package/lib/plugin/autotrack.js +1899 -1
- package/lib/plugin/duration.js +119 -1
- package/lib/plugin/route.js +365 -1
- package/lib/plugin/stay.js +549 -1
- package/lib/plugin/store.js +153 -1
- package/package.json +2 -2
package/es/plugin/duration.js
CHANGED
|
@@ -1 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
2
|
+
var TrackDuration =
|
|
3
|
+
/** @class */
|
|
4
|
+
function () {
|
|
5
|
+
function TrackDuration() {}
|
|
6
|
+
|
|
7
|
+
TrackDuration.prototype.apply = function (collector, config) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
|
|
10
|
+
this.collector = collector;
|
|
11
|
+
this.config = config;
|
|
12
|
+
var Types = collector.Types;
|
|
13
|
+
collector.on(Types.TrackDurationStart, function (eventName) {
|
|
14
|
+
_this.trackStart(eventName);
|
|
15
|
+
});
|
|
16
|
+
collector.on(Types.TrackDurationEnd, function (info) {
|
|
17
|
+
_this.trackEnd(info);
|
|
18
|
+
});
|
|
19
|
+
collector.on(Types.TrackDurationPause, function (eventName) {
|
|
20
|
+
_this.trackPause(eventName);
|
|
21
|
+
});
|
|
22
|
+
collector.on(Types.TrackDurationResume, function (eventName) {
|
|
23
|
+
_this.trackResume(eventName);
|
|
24
|
+
});
|
|
25
|
+
this.Types = Types;
|
|
26
|
+
this.TrackMap = new Map();
|
|
27
|
+
this.ready(Types.TrackDuration);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
TrackDuration.prototype.ready = function (name) {
|
|
31
|
+
var _this = this;
|
|
32
|
+
|
|
33
|
+
this.collector.set(name);
|
|
34
|
+
|
|
35
|
+
if (this.collector.hook._hooksCache.hasOwnProperty(name)) {
|
|
36
|
+
var emits = this.collector.hook._hooksCache[name];
|
|
37
|
+
if (!Object.keys(emits).length) return;
|
|
38
|
+
|
|
39
|
+
var _loop_1 = function _loop_1(key) {
|
|
40
|
+
if (emits[key].length) {
|
|
41
|
+
emits[key].forEach(function (item) {
|
|
42
|
+
_this.collector.hook.emit(key, item);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
for (var key in emits) {
|
|
48
|
+
_loop_1(key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
TrackDuration.prototype.trackStart = function (eventName) {
|
|
54
|
+
this.TrackMap.set(eventName, {
|
|
55
|
+
startTime: Date.now(),
|
|
56
|
+
isPause: false,
|
|
57
|
+
pauseTime: 0,
|
|
58
|
+
resumeTime: 0
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
TrackDuration.prototype.trackEnd = function (info) {
|
|
63
|
+
var eventName = info.eventName,
|
|
64
|
+
params = info.params;
|
|
65
|
+
if (!this.TrackMap.has(eventName)) return;
|
|
66
|
+
var trackData = this.TrackMap.get(eventName);
|
|
67
|
+
var event_duration = 0;
|
|
68
|
+
|
|
69
|
+
if (trackData.isPause) {
|
|
70
|
+
// 暂停后,未恢复,直接结束
|
|
71
|
+
event_duration = trackData.pauseTime - trackData.startTime;
|
|
72
|
+
} else {
|
|
73
|
+
// 处于未暂停状态,可能是恢复了,可能是从未暂停过
|
|
74
|
+
if (trackData.resumeTime) {
|
|
75
|
+
// 暂停后,恢复了
|
|
76
|
+
event_duration = trackData.pauseTime - trackData.startTime + (Date.now() - trackData.resumeTime);
|
|
77
|
+
} else {
|
|
78
|
+
// 未暂停过
|
|
79
|
+
event_duration = Date.now() - trackData.startTime;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var eventParmas = Object.assign(params, {
|
|
84
|
+
event_duration: event_duration
|
|
85
|
+
});
|
|
86
|
+
this.collector.event(eventName, eventParmas);
|
|
87
|
+
this.cleanTrack(eventName);
|
|
88
|
+
}; // 事件暂停计时
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
TrackDuration.prototype.trackPause = function (eventName) {
|
|
92
|
+
if (!this.TrackMap.has(eventName)) return;
|
|
93
|
+
var trackData = this.TrackMap.get(eventName);
|
|
94
|
+
if (trackData.isPause) return;
|
|
95
|
+
trackData.isPause = true;
|
|
96
|
+
trackData.pauseTime = Date.now();
|
|
97
|
+
this.TrackMap.set(eventName, trackData);
|
|
98
|
+
}; // 事件恢复计时
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
TrackDuration.prototype.trackResume = function (eventName) {
|
|
102
|
+
if (!this.TrackMap.has(eventName)) return;
|
|
103
|
+
var trackData = this.TrackMap.get(eventName);
|
|
104
|
+
if (!trackData.isPause) return;
|
|
105
|
+
trackData.isPause = false;
|
|
106
|
+
trackData.resumeTime = Date.now();
|
|
107
|
+
this.TrackMap.set(eventName, trackData);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
TrackDuration.prototype.cleanTrack = function (eventName) {
|
|
111
|
+
this.TrackMap["delete"](eventName);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
return TrackDuration;
|
|
115
|
+
}();
|
|
116
|
+
|
|
117
|
+
export { TrackDuration as default };
|
package/es/plugin/route.js
CHANGED
|
@@ -1 +1,363 @@
|
|
|
1
|
-
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
function __read(o, n) {
|
|
17
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
|
+
if (!m) return o;
|
|
19
|
+
var i = m.call(o), r, ar = [], e;
|
|
20
|
+
try {
|
|
21
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
+
}
|
|
23
|
+
catch (error) { e = { error: error }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e) throw e.error; }
|
|
29
|
+
}
|
|
30
|
+
return ar;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @deprecated */
|
|
34
|
+
function __spread() {
|
|
35
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
36
|
+
ar = ar.concat(__read(arguments[i]));
|
|
37
|
+
return ar;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
41
|
+
var Types;
|
|
42
|
+
|
|
43
|
+
(function (Types) {
|
|
44
|
+
Types["Init"] = "init";
|
|
45
|
+
Types["Config"] = "config";
|
|
46
|
+
Types["Start"] = "start";
|
|
47
|
+
Types["Ready"] = "ready";
|
|
48
|
+
Types["TokenComplete"] = "token-complete";
|
|
49
|
+
Types["TokenStorage"] = "token-storage";
|
|
50
|
+
Types["TokenFetch"] = "token-fetch";
|
|
51
|
+
Types["TokenError"] = "token-error";
|
|
52
|
+
Types["ConfigUuid"] = "config-uuid";
|
|
53
|
+
Types["ConfigWebId"] = "config-webid";
|
|
54
|
+
Types["ConfigDomain"] = "config-domain";
|
|
55
|
+
Types["CustomWebId"] = "custom-webid";
|
|
56
|
+
Types["AnonymousId"] = "anonymous-id";
|
|
57
|
+
Types["TokenChange"] = "token-change";
|
|
58
|
+
Types["TokenReset"] = "token-reset";
|
|
59
|
+
Types["ConfigTransform"] = "config-transform";
|
|
60
|
+
Types["EnvTransform"] = "env-transform";
|
|
61
|
+
Types["SessionReset"] = "session-reset";
|
|
62
|
+
Types["SessionResetTime"] = "session-reset-time";
|
|
63
|
+
Types["Event"] = "event";
|
|
64
|
+
Types["Events"] = "events";
|
|
65
|
+
Types["EventNow"] = "event-now";
|
|
66
|
+
Types["CleanEvents"] = "clean-events";
|
|
67
|
+
Types["BeconEvent"] = "becon-event";
|
|
68
|
+
Types["SubmitBefore"] = "submit-before";
|
|
69
|
+
Types["SubmitScuess"] = "submit-scuess";
|
|
70
|
+
Types["SubmitAfter"] = "submit-after";
|
|
71
|
+
Types["SubmitError"] = "submit-error";
|
|
72
|
+
Types["SubmitVerifyH"] = "submit-verify-h5";
|
|
73
|
+
Types["Stay"] = "stay";
|
|
74
|
+
Types["ResetStay"] = "reset-stay";
|
|
75
|
+
Types["StayReady"] = "stay-ready";
|
|
76
|
+
Types["SetStay"] = "set-stay";
|
|
77
|
+
Types["RouteChange"] = "route-change";
|
|
78
|
+
Types["RouteReady"] = "route-ready";
|
|
79
|
+
Types["Ab"] = "ab";
|
|
80
|
+
Types["AbVar"] = "ab-var";
|
|
81
|
+
Types["AbAllVars"] = "ab-all-vars";
|
|
82
|
+
Types["AbConfig"] = "ab-config";
|
|
83
|
+
Types["AbExternalVersion"] = "ab-external-version";
|
|
84
|
+
Types["AbVersionChangeOn"] = "ab-version-change-on";
|
|
85
|
+
Types["AbVersionChangeOff"] = "ab-version-change-off";
|
|
86
|
+
Types["AbOpenLayer"] = "ab-open-layer";
|
|
87
|
+
Types["AbCloseLayer"] = "ab-close-layer";
|
|
88
|
+
Types["AbReady"] = "ab-ready";
|
|
89
|
+
Types["AbComplete"] = "ab-complete";
|
|
90
|
+
Types["AbTimeout"] = "ab-timeout";
|
|
91
|
+
Types["Profile"] = "profile";
|
|
92
|
+
Types["ProfileSet"] = "profile-set";
|
|
93
|
+
Types["ProfileSetOnce"] = "profile-set-once";
|
|
94
|
+
Types["ProfileUnset"] = "profile-unset";
|
|
95
|
+
Types["ProfileIncrement"] = "profile-increment";
|
|
96
|
+
Types["ProfileAppend"] = "profile-append";
|
|
97
|
+
Types["ProfileClear"] = "profile-clear";
|
|
98
|
+
Types["TrackDuration"] = "track-duration";
|
|
99
|
+
Types["TrackDurationStart"] = "track-duration-start";
|
|
100
|
+
Types["TrackDurationEnd"] = "track-duration-end";
|
|
101
|
+
Types["TrackDurationPause"] = "track-duration-pause";
|
|
102
|
+
Types["TrackDurationResume"] = "tracl-duration-resume";
|
|
103
|
+
Types["Autotrack"] = "autotrack";
|
|
104
|
+
Types["AutotrackReady"] = "autotrack-ready";
|
|
105
|
+
Types["CepReady"] = "cep-ready";
|
|
106
|
+
Types["TracerReady"] = "tracer-ready";
|
|
107
|
+
})(Types || (Types = {}));
|
|
108
|
+
|
|
109
|
+
var DebuggerMesssge;
|
|
110
|
+
|
|
111
|
+
(function (DebuggerMesssge) {
|
|
112
|
+
DebuggerMesssge["DEBUGGER_MESSAGE"] = "debugger-message";
|
|
113
|
+
DebuggerMesssge["DEBUGGER_MESSAGE_SDK"] = "debugger-message-sdk";
|
|
114
|
+
DebuggerMesssge["DEBUGGER_MESSAGE_FETCH"] = "debugger-message-fetch";
|
|
115
|
+
DebuggerMesssge["DEBUGGER_MESSAGE_FETCH_RESULT"] = "debugger-message-fetch-result";
|
|
116
|
+
DebuggerMesssge["DEBUGGER_MESSAGE_EVENT"] = "debugger-message-event";
|
|
117
|
+
DebuggerMesssge["DEVTOOL_WEB_READY"] = "devtool-web-ready";
|
|
118
|
+
})(DebuggerMesssge || (DebuggerMesssge = {}));
|
|
119
|
+
|
|
120
|
+
var RuotePage =
|
|
121
|
+
/** @class */
|
|
122
|
+
function () {
|
|
123
|
+
function RuotePage() {
|
|
124
|
+
this.autotrack = false;
|
|
125
|
+
this.spa = false;
|
|
126
|
+
this.cache = {};
|
|
127
|
+
this.allowHash = false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
RuotePage.prototype.apply = function (collect, config) {
|
|
131
|
+
if (!config.spa && !config.autotrack) return;
|
|
132
|
+
var Types = collect.Types;
|
|
133
|
+
this.collect = collect;
|
|
134
|
+
this.config = config;
|
|
135
|
+
this.appid = config.app_id;
|
|
136
|
+
this.allowHash = config.allow_hash;
|
|
137
|
+
this.fncArray = new Map();
|
|
138
|
+
this.setKey();
|
|
139
|
+
this.setLocation();
|
|
140
|
+
this.hack();
|
|
141
|
+
this.init();
|
|
142
|
+
this.listener();
|
|
143
|
+
collect.emit(Types.RouteReady);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
RuotePage.prototype.setKey = function () {
|
|
147
|
+
var storage = this.collect.adapters.storage;
|
|
148
|
+
this.storage = new storage(false);
|
|
149
|
+
this.cache_key = "__tea_cache_refer_" + this.appid;
|
|
150
|
+
this.cache = {
|
|
151
|
+
refer_key: '',
|
|
152
|
+
refer_title: document.title || location.pathname,
|
|
153
|
+
refer_manual_key: '',
|
|
154
|
+
routeChange: false
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (this.config.autotrack && typeof this.config.autotrack === 'object' && this.config.autotrack.page_manual_key) {
|
|
158
|
+
this.cache.refer_manual_key = this.config.autotrack.page_manual_key;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.storage.setItem(this.cache_key, this.cache);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
RuotePage.prototype.hack = function () {
|
|
165
|
+
var _this = this;
|
|
166
|
+
|
|
167
|
+
var oldPushState = window.history.pushState;
|
|
168
|
+
|
|
169
|
+
history.pushState = function (state) {
|
|
170
|
+
var args = [];
|
|
171
|
+
|
|
172
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
173
|
+
args[_i - 1] = arguments[_i];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (typeof history['onpushstate'] === 'function') {
|
|
177
|
+
history['onpushstate']({
|
|
178
|
+
state: state
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var ret = oldPushState.call.apply(oldPushState, __spread([history, state], args));
|
|
183
|
+
if (_this.lastLocation === location.href) return;
|
|
184
|
+
|
|
185
|
+
var config = _this.getPopStateChangeEventData();
|
|
186
|
+
|
|
187
|
+
_this.setReferCache(_this.lastLocation);
|
|
188
|
+
|
|
189
|
+
_this.lastLocation = location.href;
|
|
190
|
+
|
|
191
|
+
_this.sendPv(config, 'pushState');
|
|
192
|
+
|
|
193
|
+
return ret;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
var oldReplaceState = history.replaceState;
|
|
197
|
+
|
|
198
|
+
history.replaceState = function (state) {
|
|
199
|
+
var args = [];
|
|
200
|
+
|
|
201
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
202
|
+
args[_i - 1] = arguments[_i];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (typeof history['onreplacestate'] === 'function') {
|
|
206
|
+
history['onreplacestate']({
|
|
207
|
+
state: state
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var ret = oldReplaceState.call.apply(oldReplaceState, __spread([history, state], args));
|
|
212
|
+
if (_this.lastLocation === location.href) return;
|
|
213
|
+
|
|
214
|
+
var config = _this.getPopStateChangeEventData();
|
|
215
|
+
|
|
216
|
+
_this.setReferCache(_this.lastLocation);
|
|
217
|
+
|
|
218
|
+
_this.lastLocation = location.href;
|
|
219
|
+
|
|
220
|
+
_this.sendPv(config);
|
|
221
|
+
|
|
222
|
+
return ret;
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
RuotePage.prototype.setLocation = function () {
|
|
227
|
+
if (typeof window !== 'undefined') {
|
|
228
|
+
this.lastLocation = window.location.href;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
RuotePage.prototype.getLocation = function () {
|
|
233
|
+
return this.lastLocation;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
RuotePage.prototype.init = function () {
|
|
237
|
+
var config = this.getPopStateChangeEventData();
|
|
238
|
+
this.collect.emit('route-change', {
|
|
239
|
+
config: config,
|
|
240
|
+
init: true
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
RuotePage.prototype.listener = function () {
|
|
245
|
+
var _this = this;
|
|
246
|
+
|
|
247
|
+
var timeoutId = null;
|
|
248
|
+
var time = 10;
|
|
249
|
+
window.addEventListener('hashchange', function (e) {
|
|
250
|
+
if (_this.lastLocation === window.location.href) return;
|
|
251
|
+
clearTimeout(timeoutId);
|
|
252
|
+
|
|
253
|
+
if (_this.allowHash) {
|
|
254
|
+
// 如果允许hashTag,就执行回调函数
|
|
255
|
+
_this.setReferCache(_this.lastLocation);
|
|
256
|
+
|
|
257
|
+
_this.lastLocation = window.location.href;
|
|
258
|
+
|
|
259
|
+
var config = _this.getPopStateChangeEventData();
|
|
260
|
+
|
|
261
|
+
_this.sendPv(config);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
window.addEventListener('popstate', function (e) {
|
|
265
|
+
if (_this.lastLocation === window.location.href) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
timeoutId = setTimeout(function () {
|
|
270
|
+
_this.setReferCache(_this.lastLocation);
|
|
271
|
+
|
|
272
|
+
_this.lastLocation = window.location.href;
|
|
273
|
+
|
|
274
|
+
var config = _this.getPopStateChangeEventData();
|
|
275
|
+
|
|
276
|
+
_this.sendPv(config);
|
|
277
|
+
}, time);
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
RuotePage.prototype.getPopStateChangeEventData = function () {
|
|
282
|
+
var config = this.pageConfig();
|
|
283
|
+
config['is_back'] = 0;
|
|
284
|
+
return config;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
RuotePage.prototype.pageConfig = function () {
|
|
288
|
+
try {
|
|
289
|
+
var cache_local = this.storage.getItem(this.cache_key) || {};
|
|
290
|
+
var is_first_time = false;
|
|
291
|
+
var firstStatus = this.storage.getItem("__tea_cache_first_" + this.appid);
|
|
292
|
+
|
|
293
|
+
if (firstStatus && firstStatus == 1) {
|
|
294
|
+
is_first_time = false;
|
|
295
|
+
} else {
|
|
296
|
+
is_first_time = true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
is_html: 1,
|
|
301
|
+
url: location.href,
|
|
302
|
+
referrer: this.handleRefer(),
|
|
303
|
+
page_key: location.href,
|
|
304
|
+
refer_page_key: this.handleRefer(),
|
|
305
|
+
page_title: document.title || location.pathname,
|
|
306
|
+
page_manual_key: this.config.autotrack && this.config.autotrack.page_manual_key || '',
|
|
307
|
+
refer_page_manual_key: cache_local && cache_local.refer_manual_key || '',
|
|
308
|
+
refer_page_title: cache_local && cache_local.refer_title || '',
|
|
309
|
+
page_path: location.pathname,
|
|
310
|
+
page_host: location.host,
|
|
311
|
+
is_first_time: "" + is_first_time
|
|
312
|
+
};
|
|
313
|
+
} catch (e) {
|
|
314
|
+
this.collect.emit(DebuggerMesssge.DEBUGGER_MESSAGE, {
|
|
315
|
+
type: DebuggerMesssge.DEBUGGER_MESSAGE_SDK,
|
|
316
|
+
info: '发生了异常',
|
|
317
|
+
level: 'error',
|
|
318
|
+
time: Date.now(),
|
|
319
|
+
data: e.message
|
|
320
|
+
});
|
|
321
|
+
return {};
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
RuotePage.prototype.sendPv = function (config, name) {
|
|
326
|
+
this.collect.emit('route-change', {
|
|
327
|
+
config: config,
|
|
328
|
+
init: false
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
RuotePage.prototype.handleRefer = function () {
|
|
333
|
+
var refer = '';
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
var cache_local = this.storage.getItem() || {};
|
|
337
|
+
|
|
338
|
+
if (cache_local.routeChange) {
|
|
339
|
+
// 已经发生路由变化
|
|
340
|
+
refer = cache_local.refer_key;
|
|
341
|
+
} else {
|
|
342
|
+
// 首页,用浏览器的refer
|
|
343
|
+
refer = this.collect.configManager.get('referrer');
|
|
344
|
+
}
|
|
345
|
+
} catch (e) {
|
|
346
|
+
refer = document.referrer;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return refer;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
RuotePage.prototype.setReferCache = function (url) {
|
|
353
|
+
var cache_local = this.storage.getItem(this.cache_key) || {};
|
|
354
|
+
cache_local.refer_key = url; // 不再是第一次进入页面
|
|
355
|
+
|
|
356
|
+
cache_local.routeChange = true;
|
|
357
|
+
this.storage.setItem(this.cache_key, cache_local);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
return RuotePage;
|
|
361
|
+
}();
|
|
362
|
+
|
|
363
|
+
export { RuotePage as default };
|