Add Disabled anonymity, improve tests
This commit is contained in:
parent
c34afdb4bd
commit
95f4275807
2 changed files with 45 additions and 10 deletions
|
@ -12,6 +12,7 @@ interface IEvent {
|
|||
}
|
||||
|
||||
export enum Anonymity {
|
||||
Disabled,
|
||||
Anonymous,
|
||||
Pseudonymous
|
||||
}
|
||||
|
@ -181,12 +182,12 @@ export class PosthogAnalytics {
|
|||
}
|
||||
|
||||
private async capture(eventName: string, properties: posthog.Properties) {
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
if (!this.initialised) {
|
||||
throw Error("Tried to track event before PoshogAnalytics.init has completed");
|
||||
}
|
||||
if (!this.enabled) {
|
||||
return;
|
||||
}
|
||||
const { origin, hash, pathname } = window.location;
|
||||
properties['$redacted_current_url'] = await getRedactedCurrentLocation(
|
||||
origin, hash, pathname, this.anonymity);
|
||||
|
@ -197,7 +198,7 @@ export class PosthogAnalytics {
|
|||
eventName: E["eventName"],
|
||||
properties: E["properties"],
|
||||
) {
|
||||
if (this.anonymity == Anonymity.Anonymous) return;
|
||||
if (this.anonymity == Anonymity.Anonymous || this.anonymity == Anonymity.Disabled) return;
|
||||
await this.capture(eventName, properties);
|
||||
}
|
||||
|
||||
|
@ -205,6 +206,7 @@ export class PosthogAnalytics {
|
|||
eventName: E["eventName"],
|
||||
properties: E["properties"],
|
||||
) {
|
||||
if (this.anonymity == Anonymity.Disabled) return;
|
||||
await this.capture(eventName, properties);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue