From 92bf575171a635e360e9c1ed3e99716664022ae7 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Wed, 10 Jun 2020 14:50:28 +0700 Subject: [PATCH 1/3] fix: Serialize the default user keys in setUser --- src/js/wrapper.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/wrapper.ts b/src/js/wrapper.ts index 16a3d9cbc1..208745368c 100644 --- a/src/js/wrapper.ts +++ b/src/js/wrapper.ts @@ -166,12 +166,12 @@ export const NATIVE = { let otherUserKeys = null; if (user) { const { id, ip_address, email, username, ...otherKeys } = user; - defaultUserKeys = { + defaultUserKeys = this._serializeObject({ email, id, ip_address, username, - }; + }); otherUserKeys = this._serializeObject(otherKeys); } From 4c6836111628348944873dcfb206d43787f0fee0 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Wed, 10 Jun 2020 15:22:05 +0700 Subject: [PATCH 2/3] test: Add setUser serialization test --- test/wrapper.test.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/wrapper.test.ts b/test/wrapper.test.ts index b912645581..ef67cd4b5f 100644 --- a/test/wrapper.test.ts +++ b/test/wrapper.test.ts @@ -21,6 +21,9 @@ jest.mock( nativeClientAvailable: true, nativeTransport: true, sendEvent: jest.fn(() => Promise.resolve()), + setUser: jest.fn(() => { + return; + }), startWithOptions: jest.fn((options) => Promise.resolve(options)) } }, @@ -177,6 +180,29 @@ describe("Tests Native Wrapper", () => { }); }); + describe("setUser", () => { + test("serializes all user object keys", async () => { + const RN = require("react-native"); + + NATIVE.setUser({ + email: "hello@sentry.io", + // @ts-ignore + id: 3.14159265359, + unique: 123, + }); + // tslint:disable-next-line: no-unsafe-any + expect(RN.NativeModules.RNSentry.setUser).toBeCalledWith( + { + email: "hello@sentry.io", + id: "3.14159265359", + }, + { + unique: "123", + } + ); + }); + }); + describe("isNativeClientAvailable", () => { test("checks if native client is available", () => { expect(NATIVE.isNativeClientAvailable()).toBe(true); From 0b18488f7cac3a7e2c5f1c3cf06fd5e60cd66a53 Mon Sep 17 00:00:00 2001 From: Jenn Mueng Date: Wed, 10 Jun 2020 16:35:03 +0700 Subject: [PATCH 3/3] meta: changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e19efb172c..280df46ba5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- fix: Serialize the default user keys in setUser #926 + ## 1.4.5 - fix: Fix Native Wrapper not checking enableNative setting #919