Skip to content

Commit b722506

Browse files
authored
fix: fix unset user property (#20)
1 parent 9923bba commit b722506

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

packages/browser/src/integration/amplitude.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ import {
44
ExperimentAnalyticsProvider,
55
} from '../types/provider';
66
import { ExperimentUser } from '../types/user';
7-
import { safeGlobal } from '../util/global';
8-
9-
declare global {
10-
// eslint-disable-next-line no-var, @typescript-eslint/no-explicit-any
11-
var amplitude: any;
12-
}
137

148
type AmplitudeIdentify = {
159
set(property: string, value: unknown): void;
@@ -20,6 +14,12 @@ type AmplitudeInstance = {
2014
options?: AmplitudeOptions;
2115
_ua?: AmplitudeUAParser;
2216
logEvent(eventName: string, properties: Record<string, string>): void;
17+
_logEvent(
18+
eventType: string,
19+
eventProperties: Record<string, unknown>,
20+
apiProperties: Record<string, unknown>,
21+
userProperties: Record<string, unknown>,
22+
);
2323
setUserProperties(userProperties: Record<string, unknown>): void;
2424
identify(identify: AmplitudeIdentify): void;
2525
};
@@ -102,8 +102,8 @@ export class AmplitudeAnalyticsProvider implements ExperimentAnalyticsProvider {
102102

103103
unsetUserProperty(event: ExperimentAnalyticsEvent): void {
104104
// if the variant does not have a value, unset the user property
105-
this.amplitudeInstance.identify(
106-
new safeGlobal.amplitude.Identify().unset(event.userProperty),
107-
);
105+
this.amplitudeInstance._logEvent('$identify', null, null, {
106+
$unset: { [event.userProperty]: '-' },
107+
});
108108
}
109109
}

0 commit comments

Comments
 (0)