add option to disable profiles
This commit is contained in:
@@ -13,10 +13,11 @@ export interface NewMixanOptions {
|
|||||||
sessionTimeout?: number;
|
sessionTimeout?: number;
|
||||||
session?: boolean;
|
session?: boolean;
|
||||||
verbose?: boolean;
|
verbose?: boolean;
|
||||||
|
profile?: boolean;
|
||||||
|
trackIp?: boolean;
|
||||||
setItem: (key: string, profileId: string) => void;
|
setItem: (key: string, profileId: string) => void;
|
||||||
getItem: (key: string) => string | null;
|
getItem: (key: string) => string | null;
|
||||||
removeItem: (key: string) => void;
|
removeItem: (key: string) => void;
|
||||||
trackIp?: boolean;
|
|
||||||
}
|
}
|
||||||
export type MixanOptions = Required<NewMixanOptions>;
|
export type MixanOptions = Required<NewMixanOptions>;
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ export class Mixan {
|
|||||||
batchInterval: 10000,
|
batchInterval: 10000,
|
||||||
maxBatchSize: 10,
|
maxBatchSize: 10,
|
||||||
trackIp: false,
|
trackIp: false,
|
||||||
|
profile: true,
|
||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -222,6 +224,9 @@ export class Mixan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async setAnonymousUser(retryCount = 0) {
|
private async setAnonymousUser(retryCount = 0) {
|
||||||
|
if (!this.options.profile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const profileId = this.options.getItem('@mixan:profileId');
|
const profileId = this.options.getItem('@mixan:profileId');
|
||||||
if (profileId) {
|
if (profileId) {
|
||||||
this.profileId = profileId;
|
this.profileId = profileId;
|
||||||
@@ -252,6 +257,9 @@ export class Mixan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setUser(profile: ProfilePayload) {
|
async setUser(profile: ProfilePayload) {
|
||||||
|
if (!this.options.profile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.profileId) {
|
if (!this.profileId) {
|
||||||
return this.logger('Mixan: Set user failed, no profileId');
|
return this.logger('Mixan: Set user failed, no profileId');
|
||||||
}
|
}
|
||||||
@@ -265,6 +273,9 @@ export class Mixan {
|
|||||||
name: string,
|
name: string,
|
||||||
value: string | number | boolean | Record<string, unknown> | unknown[]
|
value: string | number | boolean | Record<string, unknown> | unknown[]
|
||||||
) {
|
) {
|
||||||
|
if (!this.options.profile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.profileId) {
|
if (!this.profileId) {
|
||||||
return this.logger('Mixan: Set user property, no profileId');
|
return this.logger('Mixan: Set user property, no profileId');
|
||||||
}
|
}
|
||||||
@@ -290,6 +301,9 @@ export class Mixan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async increment(name: string, value = 1) {
|
async increment(name: string, value = 1) {
|
||||||
|
if (!this.options.profile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.profileId) {
|
if (!this.profileId) {
|
||||||
this.logger('Mixan: Increment failed, no profileId');
|
this.logger('Mixan: Increment failed, no profileId');
|
||||||
return;
|
return;
|
||||||
@@ -309,6 +323,9 @@ export class Mixan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async decrement(name: string, value = 1) {
|
async decrement(name: string, value = 1) {
|
||||||
|
if (!this.options.profile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!this.profileId) {
|
if (!this.profileId) {
|
||||||
this.logger('Mixan: Decrement failed, no profileId');
|
this.logger('Mixan: Decrement failed, no profileId');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user