@planningcenter/chat-react-native 3.37.0-rc.1 → 3.37.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,26 @@
1
+ export type ReportErrorScope = 'screen' | 'message' | 'http';
2
+ export type ReportErrorContext = {
3
+ componentStack?: string;
4
+ scope?: ReportErrorScope;
5
+ screenName?: string;
6
+ tags?: Record<string, string>;
7
+ extra?: Record<string, unknown>;
8
+ };
1
9
  interface LogAdapterConfig {
2
10
  enabled: boolean;
3
11
  error: (message: string, ...args: any[]) => void;
4
12
  info: (message: string, ...args: any[]) => void;
13
+ reportError: (error: Error, context?: ReportErrorContext) => void;
5
14
  }
6
15
  export declare class LogAdapter {
7
16
  enabled: boolean;
8
17
  onError?: LogAdapterConfig['error'];
9
18
  onInfo?: LogAdapterConfig['info'];
19
+ onReportError?: LogAdapterConfig['reportError'];
10
20
  constructor(config?: Partial<LogAdapterConfig>);
11
21
  error(message: string, ...args: any[]): void;
12
22
  info(message: string, ...args: any[]): void;
23
+ reportError(error: Error, context?: ReportErrorContext): void;
13
24
  }
14
25
  export {};
15
26
  //# sourceMappingURL=log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/utils/native_adapters/log.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;IAChD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAChD;AAED,qBAAa,UAAU;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;IACnC,MAAM,CAAC,EAAE,gBAAgB,CAAC,MAA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AE,OAAO,CAAC,gBAAgB,CAAM;IAOlD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMrC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAMpC,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,kBAAkB;CAQvD"}
@@ -2,10 +2,12 @@ export class LogAdapter {
2
2
  enabled;
3
3
  onError;
4
4
  onInfo;
5
+ onReportError;
5
6
  constructor(config = {}) {
6
7
  this.enabled = config.enabled ?? false;
7
8
  this.onError = config.error;
8
9
  this.onInfo = config.info;
10
+ this.onReportError = config.reportError;
9
11
  }
10
12
  error(message, ...args) {
11
13
  if (!this.enabled)
@@ -17,5 +19,12 @@ export class LogAdapter {
17
19
  return;
18
20
  this.onInfo?.(message, ...args);
19
21
  }
22
+ reportError(error, context) {
23
+ if (this.onReportError) {
24
+ this.onReportError(error, context);
25
+ return;
26
+ }
27
+ console.error(error, context);
28
+ }
20
29
  }
21
30
  //# sourceMappingURL=log.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/log.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,UAAU;IACrB,OAAO,CAAS;IAChB,OAAO,CAA4B;IACnC,MAAM,CAA2B;IAEjC,YAAY,SAAoC,EAAE;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEzB,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEzB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC;CACF","sourcesContent":["interface LogAdapterConfig {\n enabled: boolean\n error: (message: string, ...args: any[]) => void\n info: (message: string, ...args: any[]) => void\n}\n\nexport class LogAdapter {\n enabled: boolean\n onError?: LogAdapterConfig['error']\n onInfo?: LogAdapterConfig['info']\n\n constructor(config: Partial<LogAdapterConfig> = {}) {\n this.enabled = config.enabled ?? false\n this.onError = config.error\n this.onInfo = config.info\n }\n\n error(message: string, ...args: any[]) {\n if (!this.enabled) return\n\n this.onError?.(message, ...args)\n }\n\n info(message: string, ...args: any[]) {\n if (!this.enabled) return\n\n this.onInfo?.(message, ...args)\n }\n}\n"]}
1
+ {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/log.ts"],"names":[],"mappings":"AAiBA,MAAM,OAAO,UAAU;IACrB,OAAO,CAAS;IAChB,OAAO,CAA4B;IACnC,MAAM,CAA2B;IACjC,aAAa,CAAkC;IAE/C,YAAY,SAAoC,EAAE;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAA;QACzB,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,WAAW,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEzB,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEzB,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IACjC,CAAC;IAED,WAAW,CAAC,KAAY,EAAE,OAA4B;QACpD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YAClC,OAAM;QACR,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAC/B,CAAC;CACF","sourcesContent":["export type ReportErrorScope = 'screen' | 'message' | 'http'\n\nexport type ReportErrorContext = {\n componentStack?: string\n scope?: ReportErrorScope\n screenName?: string\n tags?: Record<string, string>\n extra?: Record<string, unknown>\n}\n\ninterface LogAdapterConfig {\n enabled: boolean\n error: (message: string, ...args: any[]) => void\n info: (message: string, ...args: any[]) => void\n reportError: (error: Error, context?: ReportErrorContext) => void\n}\n\nexport class LogAdapter {\n enabled: boolean\n onError?: LogAdapterConfig['error']\n onInfo?: LogAdapterConfig['info']\n onReportError?: LogAdapterConfig['reportError']\n\n constructor(config: Partial<LogAdapterConfig> = {}) {\n this.enabled = config.enabled ?? false\n this.onError = config.error\n this.onInfo = config.info\n this.onReportError = config.reportError\n }\n\n error(message: string, ...args: any[]) {\n if (!this.enabled) return\n\n this.onError?.(message, ...args)\n }\n\n info(message: string, ...args: any[]) {\n if (!this.enabled) return\n\n this.onInfo?.(message, ...args)\n }\n\n reportError(error: Error, context?: ReportErrorContext) {\n if (this.onReportError) {\n this.onReportError(error, context)\n return\n }\n\n console.error(error, context)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.37.0-rc.1",
3
+ "version": "3.37.0-rc.2",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "react-native": "./src/index.tsx",
@@ -72,5 +72,5 @@
72
72
  "react-native-url-polyfill": "^2.0.0",
73
73
  "typescript": "~5.9.2"
74
74
  },
75
- "gitHead": "7c6773155a5b589fe9a58a28921ddaac1d134e86"
75
+ "gitHead": "13e581dd9640a86feea850c6f0d1c34e7b0357cd"
76
76
  }
@@ -0,0 +1,62 @@
1
+ import { LogAdapter } from '../log'
2
+
3
+ describe('LogAdapter', () => {
4
+ describe('reportError', () => {
5
+ it('forwards the error and context to the host callback', () => {
6
+ const reportError = jest.fn()
7
+ const adapter = new LogAdapter({ reportError })
8
+ const error = new Error('boom')
9
+ const context = { scope: 'screen' as const, screenName: 'ConversationScreen' }
10
+
11
+ adapter.reportError(error, context)
12
+
13
+ expect(reportError).toHaveBeenCalledWith(error, context)
14
+ })
15
+
16
+ it('fires even when the adapter is disabled', () => {
17
+ const reportError = jest.fn()
18
+ const adapter = new LogAdapter({ enabled: false, reportError })
19
+
20
+ adapter.reportError(new Error('boom'))
21
+
22
+ expect(reportError).toHaveBeenCalledTimes(1)
23
+ })
24
+
25
+ it('falls back to console.error when no host callback is configured', () => {
26
+ const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
27
+ const adapter = new LogAdapter()
28
+ const error = new Error('boom')
29
+
30
+ adapter.reportError(error, { scope: 'http' })
31
+
32
+ expect(spy).toHaveBeenCalledWith(error, { scope: 'http' })
33
+ spy.mockRestore()
34
+ })
35
+ })
36
+
37
+ describe('info and error', () => {
38
+ it('drops info and error calls when disabled', () => {
39
+ const info = jest.fn()
40
+ const error = jest.fn()
41
+ const adapter = new LogAdapter({ enabled: false, info, error })
42
+
43
+ adapter.info('hi')
44
+ adapter.error('bye')
45
+
46
+ expect(info).not.toHaveBeenCalled()
47
+ expect(error).not.toHaveBeenCalled()
48
+ })
49
+
50
+ it('forwards info and error calls when enabled', () => {
51
+ const info = jest.fn()
52
+ const error = jest.fn()
53
+ const adapter = new LogAdapter({ enabled: true, info, error })
54
+
55
+ adapter.info('hi', { a: 1 })
56
+ adapter.error('bye', { b: 2 })
57
+
58
+ expect(info).toHaveBeenCalledWith('hi', { a: 1 })
59
+ expect(error).toHaveBeenCalledWith('bye', { b: 2 })
60
+ })
61
+ })
62
+ })
@@ -1,18 +1,31 @@
1
+ export type ReportErrorScope = 'screen' | 'message' | 'http'
2
+
3
+ export type ReportErrorContext = {
4
+ componentStack?: string
5
+ scope?: ReportErrorScope
6
+ screenName?: string
7
+ tags?: Record<string, string>
8
+ extra?: Record<string, unknown>
9
+ }
10
+
1
11
  interface LogAdapterConfig {
2
12
  enabled: boolean
3
13
  error: (message: string, ...args: any[]) => void
4
14
  info: (message: string, ...args: any[]) => void
15
+ reportError: (error: Error, context?: ReportErrorContext) => void
5
16
  }
6
17
 
7
18
  export class LogAdapter {
8
19
  enabled: boolean
9
20
  onError?: LogAdapterConfig['error']
10
21
  onInfo?: LogAdapterConfig['info']
22
+ onReportError?: LogAdapterConfig['reportError']
11
23
 
12
24
  constructor(config: Partial<LogAdapterConfig> = {}) {
13
25
  this.enabled = config.enabled ?? false
14
26
  this.onError = config.error
15
27
  this.onInfo = config.info
28
+ this.onReportError = config.reportError
16
29
  }
17
30
 
18
31
  error(message: string, ...args: any[]) {
@@ -26,4 +39,13 @@ export class LogAdapter {
26
39
 
27
40
  this.onInfo?.(message, ...args)
28
41
  }
42
+
43
+ reportError(error: Error, context?: ReportErrorContext) {
44
+ if (this.onReportError) {
45
+ this.onReportError(error, context)
46
+ return
47
+ }
48
+
49
+ console.error(error, context)
50
+ }
29
51
  }