|
1 | | -import { Scope } from '@sentry/hub'; |
| 1 | +import { Scope } from '@sentry/core'; |
2 | 2 | import { Attachment, Breadcrumb, User } from '@sentry/types'; |
3 | 3 |
|
4 | 4 | import { NATIVE } from './wrapper'; |
5 | 5 |
|
6 | 6 | /** |
7 | 7 | * Extends the scope methods to set scope on the Native SDKs |
8 | 8 | */ |
9 | | -export class NativescriptScope extends Scope { |
10 | | - /** |
11 | | - * @inheritDoc |
12 | | - */ |
13 | | - public setUser(user: User | null): this { |
14 | | - NATIVE.setUser(user); |
15 | | - return super.setUser(user); |
16 | | - } |
17 | 9 |
|
18 | | - /** |
19 | | - * @inheritDoc |
20 | | - */ |
21 | | - public setTag(key: string, value: string): this { |
22 | | - NATIVE.setTag(key, value); |
23 | | - return super.setTag(key, value); |
24 | | - } |
| 10 | +const methods = ['addBreadcrumb', 'addAttachment']; |
25 | 11 |
|
26 | | - /** |
27 | | - * @inheritDoc |
28 | | - */ |
29 | | - public setTags(tags: { [key: string]: string }): this { |
30 | | - // As native only has setTag, we just loop through each tag key. |
31 | | - Object.keys(tags).forEach((key) => { |
32 | | - NATIVE.setTag(key, tags[key]); |
33 | | - }); |
34 | | - return super.setTags(tags); |
35 | | - } |
| 12 | +// methods.forEach(m=>{ |
| 13 | +// const originalMethod =Scope.prototype[m] as Function; |
| 14 | +// Scope.prototype[m] = function(...args) { |
| 15 | +// NATIVE[m](...args); |
| 16 | +// return originalMethod.call(this, ...args); |
| 17 | +// }; |
| 18 | +// }); |
36 | 19 |
|
37 | | - /** |
38 | | - * @inheritDoc |
39 | | - */ |
40 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
41 | | - public setExtras(extras: { [key: string]: any }): this { |
42 | | - Object.keys(extras).forEach((key) => { |
43 | | - NATIVE.setExtra(key, extras[key]); |
44 | | - }); |
45 | | - return super.setExtras(extras); |
46 | | - } |
| 20 | +// export class NativescriptScope extends Scope { |
| 21 | +// /** |
| 22 | +// * @inheritDoc |
| 23 | +// */ |
| 24 | +// public setUser(user: User | null): this { |
| 25 | +// NATIVE.setUser(user); |
| 26 | +// return super.setUser(user); |
| 27 | +// } |
47 | 28 |
|
48 | | - /** |
49 | | - * @inheritDoc |
50 | | - */ |
51 | | - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any |
52 | | - public setExtra(key: string, extra: any): this { |
53 | | - NATIVE.setExtra(key, extra); |
54 | | - return super.setExtra(key, extra); |
55 | | - } |
| 29 | +// /** |
| 30 | +// * @inheritDoc |
| 31 | +// */ |
| 32 | +// public setTag(key: string, value: string): this { |
| 33 | +// NATIVE.setTag(key, value); |
| 34 | +// return super.setTag(key, value); |
| 35 | +// } |
56 | 36 |
|
57 | | - /** |
58 | | - * @inheritDoc |
59 | | - */ |
60 | | - public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this { |
61 | | - NATIVE.addBreadcrumb(breadcrumb); |
62 | | - return super.addBreadcrumb(breadcrumb, maxBreadcrumbs); |
63 | | - } |
| 37 | +// /** |
| 38 | +// * @inheritDoc |
| 39 | +// */ |
| 40 | +// public setTags(tags: { [key: string]: string }): this { |
| 41 | +// // As native only has setTag, we just loop through each tag key. |
| 42 | +// Object.keys(tags).forEach((key) => { |
| 43 | +// NATIVE.setTag(key, tags[key]); |
| 44 | +// }); |
| 45 | +// return super.setTags(tags); |
| 46 | +// } |
64 | 47 |
|
65 | | - /** |
66 | | - * @inheritDoc |
67 | | - */ |
68 | | - public clearBreadcrumbs(): this { |
69 | | - NATIVE.clearBreadcrumbs(); |
70 | | - return super.clearBreadcrumbs(); |
71 | | - } |
| 48 | +// /** |
| 49 | +// * @inheritDoc |
| 50 | +// */ |
| 51 | +// // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 52 | +// public setExtras(extras: { [key: string]: any }): this { |
| 53 | +// Object.keys(extras).forEach((key) => { |
| 54 | +// NATIVE.setExtra(key, extras[key]); |
| 55 | +// }); |
| 56 | +// return super.setExtras(extras); |
| 57 | +// } |
72 | 58 |
|
73 | | - /** |
74 | | - * @inheritDoc |
75 | | - */ |
76 | | - // eslint-disable-next-line @typescript-eslint/no-explicit-any |
77 | | - public setContext(key: string, context: { [key: string]: any } | null): this { |
78 | | - NATIVE.setContext(key, context); |
79 | | - return super.setContext(key, context); |
80 | | - } |
| 59 | +// /** |
| 60 | +// * @inheritDoc |
| 61 | +// */ |
| 62 | +// // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types,@typescript-eslint/no-explicit-any |
| 63 | +// public setExtra(key: string, extra: any): this { |
| 64 | +// NATIVE.setExtra(key, extra); |
| 65 | +// return super.setExtra(key, extra); |
| 66 | +// } |
81 | 67 |
|
82 | | - /** |
83 | | - * @inheritDoc |
84 | | - */ |
85 | | - public addAttachment(attachment: Attachment): this { |
86 | | - return super.addAttachment(attachment); |
87 | | - } |
| 68 | +// /** |
| 69 | +// * @inheritDoc |
| 70 | +// */ |
| 71 | +// public addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): this { |
| 72 | +// NATIVE.addBreadcrumb(breadcrumb); |
| 73 | +// return super.addBreadcrumb(breadcrumb, maxBreadcrumbs); |
| 74 | +// } |
88 | 75 |
|
89 | | - /** |
90 | | - * @inheritDoc |
91 | | - */ |
92 | | - public clearAttachments(): this { |
93 | | - return super.clearAttachments(); |
94 | | - } |
95 | | -} |
| 76 | +// /** |
| 77 | +// * @inheritDoc |
| 78 | +// */ |
| 79 | +// public clearBreadcrumbs(): this { |
| 80 | +// NATIVE.clearBreadcrumbs(); |
| 81 | +// return super.clearBreadcrumbs(); |
| 82 | +// } |
| 83 | + |
| 84 | +// /** |
| 85 | +// * @inheritDoc |
| 86 | +// */ |
| 87 | +// // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 88 | +// public setContext(key: string, context: { [key: string]: any } | null): this { |
| 89 | +// NATIVE.setContext(key, context); |
| 90 | +// return this; |
| 91 | +// // return super.setContext(key, context); |
| 92 | +// } |
| 93 | + |
| 94 | +// /** |
| 95 | +// * @inheritDoc |
| 96 | +// */ |
| 97 | +// public addAttachment(attachment: Attachment): this { |
| 98 | +// console.log('test addAttachment', attachment); |
| 99 | +// NATIVE.addAttachment(attachment); |
| 100 | +// return super.addAttachment(attachment); |
| 101 | +// } |
| 102 | + |
| 103 | +// /** |
| 104 | +// * @inheritDoc |
| 105 | +// */ |
| 106 | +// public clearAttachments(): this { |
| 107 | +// return super.clearAttachments(); |
| 108 | +// } |
| 109 | +// } |
0 commit comments