mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +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;
|
set?(metadata: IDataObject): void;
|
||||||
};
|
};
|
||||||
debug?(): void;
|
debug?(): void;
|
||||||
|
get_session_id?(): string | null;
|
||||||
};
|
};
|
||||||
analytics?: {
|
analytics?: {
|
||||||
identify(userId: string): void;
|
identify(userId: string): void;
|
||||||
|
|||||||
@@ -203,5 +203,29 @@ describe('telemetry', () => {
|
|||||||
{ context: { ip: '0.0.0.0' } },
|
{ 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) {
|
track(event: string, properties?: ITelemetryTrackProperties) {
|
||||||
if (!this.rudderStack) return;
|
if (!this.rudderStack) return;
|
||||||
|
|
||||||
|
const posthogSessionId = window.posthog?.get_session_id?.();
|
||||||
|
|
||||||
const updatedProperties = {
|
const updatedProperties = {
|
||||||
...properties,
|
...properties,
|
||||||
version_cli: useRootStore().versionCli,
|
version_cli: useRootStore().versionCli,
|
||||||
|
posthog_session_id: posthogSessionId,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rudderStack.track(event, updatedProperties, {
|
this.rudderStack.track(event, updatedProperties, {
|
||||||
|
|||||||
Reference in New Issue
Block a user