Skip to content

Commit

Permalink
chore: added set.email to posthog events
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Villa committed Jan 18, 2024
1 parent a01fcd5 commit 8bd70f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ describe("AnalyticsService", () => {
appProviderService = {
teamService: {
signedInUserState: {
getValue: jasmine.createSpy().and.returnValue({ accessToken: "mocked-access-token" }),
getValue: jasmine.createSpy().and.returnValue({ accessToken: "mocked-access-token", email: "[email protected]" }),
},
getKeychainCurrentWorkspace: () => "remoteWorkspace",
},
} as any;
const service2 = new AnalyticsService(appProviderService);
const spy2 = spyOn((service2 as any).myPosthog, "capture").and.stub();
await service2.captureEvent("event", { dummy: "test" });
expect(spy2).toHaveBeenCalledWith("event", { ["leapp_agent"]: "Desktop App", environment: "development", dummy: "test" });
expect(spy2).toHaveBeenCalledWith("event", {
["leapp_agent"]: "Desktop App",
environment: "development",
$set: { email: "[email protected]" },
dummy: "test",
});
});

it("captureEvent() - if anonymous user do not log the event", async () => {
Expand Down
9 changes: 8 additions & 1 deletion packages/desktop-app/src/app/services/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export class AnalyticsService {
try {
this.myPosthog.capture(
eventName,
Object.assign({ ["leapp_agent"]: "Desktop App", environment: environment.production ? "production" : "development" }, properties)
Object.assign(
{
["leapp_agent"]: "Desktop App",
environment: environment.production ? "production" : "development",
$set: { email: signedInUser.email },
},
properties
)
);
} catch (err: any) {
console.log("PostHog error: " + err.toString());
Expand Down

0 comments on commit 8bd70f0

Please sign in to comment.