add fake id so there's always a segment instance created on Vue (#2214)
This commit is contained in:
parent
7d5e425d89
commit
1a5483221a
@ -7,16 +7,21 @@ import { isDoNotTrackEnabled } from '@/utils/doNotTrack';
|
|||||||
const Analytics = {
|
const Analytics = {
|
||||||
install(Vue, options) {
|
install(Vue, options) {
|
||||||
const isDoNotTrack = isDoNotTrackEnabled();
|
const isDoNotTrack = isDoNotTrackEnabled();
|
||||||
|
const hasSegmentID = options.id && options.id.length > 0;
|
||||||
|
|
||||||
if (isDoNotTrack && options.router != undefined) {
|
if (!hasSegmentID) {
|
||||||
|
options.id = "fake id";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((isDoNotTrack || !hasSegmentID) && options.router != undefined) {
|
||||||
delete options.router;
|
delete options.router;
|
||||||
}
|
}
|
||||||
|
|
||||||
VueSegmentAnalytics.install(Vue, options);
|
VueSegmentAnalytics.install(Vue, options);
|
||||||
|
|
||||||
/* tslint:disable-next-line */
|
/* tslint:disable-next-line */
|
||||||
if (isDoNotTrack) {
|
if (isDoNotTrack || !hasSegmentID) {
|
||||||
Vue.$segment.methods.forEach(method => {
|
Vue.$segment.forEach(method => {
|
||||||
Vue.$segment[method] = () => undefined;
|
Vue.$segment[method] = () => undefined;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user