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 = {
|
||||
install(Vue, options) {
|
||||
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;
|
||||
}
|
||||
|
||||
VueSegmentAnalytics.install(Vue, options);
|
||||
|
||||
/* tslint:disable-next-line */
|
||||
if (isDoNotTrack) {
|
||||
Vue.$segment.methods.forEach(method => {
|
||||
if (isDoNotTrack || !hasSegmentID) {
|
||||
Vue.$segment.forEach(method => {
|
||||
Vue.$segment[method] = () => undefined;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user