mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(editor): Send posthog session id to rudderstack (no-changelog) (#17867)
This commit is contained in:
@@ -111,6 +111,7 @@ declare global {
|
||||
set?(metadata: IDataObject): void;
|
||||
};
|
||||
debug?(): void;
|
||||
get_session_id?(): string | null;
|
||||
};
|
||||
analytics?: {
|
||||
identify(userId: string): void;
|
||||
|
||||
@@ -203,5 +203,29 @@ describe('telemetry', () => {
|
||||
{ context: { ip: '0.0.0.0' } },
|
||||
);
|
||||
});
|
||||
|
||||
it('should include the posthog session id in the parameters', () => {
|
||||
const trackFunction = vi.spyOn(window.rudderanalytics, 'track');
|
||||
vi.stubGlobal('posthog', {
|
||||
init: vi.fn(),
|
||||
get_session_id: vi.fn().mockReturnValue('test_session_id'),
|
||||
});
|
||||
|
||||
const event = 'testEvent';
|
||||
const properties = { test: '1' };
|
||||
|
||||
telemetry.track(event, properties);
|
||||
|
||||
expect(trackFunction).toHaveBeenCalledTimes(1);
|
||||
expect(trackFunction).toHaveBeenCalledWith(
|
||||
event,
|
||||
expect.objectContaining({
|
||||
posthog_session_id: 'test_session_id',
|
||||
}),
|
||||
expect.any(Object),
|
||||
);
|
||||
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -99,9 +99,12 @@ export class Telemetry {
|
||||
track(event: string, properties?: ITelemetryTrackProperties) {
|
||||
if (!this.rudderStack) return;
|
||||
|
||||
const posthogSessionId = window.posthog?.get_session_id?.();
|
||||
|
||||
const updatedProperties = {
|
||||
...properties,
|
||||
version_cli: useRootStore().versionCli,
|
||||
posthog_session_id: posthogSessionId,
|
||||
};
|
||||
|
||||
this.rudderStack.track(event, updatedProperties, {
|
||||
|
||||
Reference in New Issue
Block a user