File tree 3 files changed +9
-20
lines changed
experimental/packages/otlp-exporter-base/src
3 files changed +9
-20
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,7 @@ export abstract class OTLPExporterBase<
37
37
ServiceRequest ,
38
38
> {
39
39
public readonly url : string ;
40
- public readonly shutDownEvent : ShutdownEvent ;
41
- public readonly isShutdownEventDisabled : boolean ;
40
+ public readonly shutDownEvents : ShutdownEvent [ ] ;
42
41
public readonly hostname : string | undefined ;
43
42
public readonly timeoutMillis : number ;
44
43
protected _concurrencyLimit : number ;
@@ -50,10 +49,7 @@ export abstract class OTLPExporterBase<
50
49
*/
51
50
constructor ( config : T = { } as T ) {
52
51
this . url = this . getDefaultUrl ( config ) ;
53
- this . isShutdownEventDisabled = config . isShutdownEventDisabled ;
54
- if ( ! config . isShutdownEventDisabled ) {
55
- this . shutDownEvent = config . shutDownEvent ?? 'unload' ;
56
- }
52
+ this . shutDownEvents = config . shutDownEvents ?? [ 'unload' ] ;
57
53
if ( typeof config . hostname === 'string' ) {
58
54
this . hostname = config . hostname ;
59
55
}
Original file line number Diff line number Diff line change @@ -53,21 +53,15 @@ export abstract class OTLPExporterBrowserBase<
53
53
}
54
54
55
55
onInit ( ) : void {
56
- if ( this . shutDownEvent ) {
57
- _globalThis . addEventListener (
58
- this . shutDownEvent ?? 'unload' ,
59
- this . shutdown
60
- ) ;
61
- }
56
+ this . shutDownEvents ?. forEach ( browserEvent => {
57
+ _globalThis . addEventListener ( browserEvent , this . shutdown ) ;
58
+ } ) ;
62
59
}
63
60
64
61
onShutdown ( ) : void {
65
- if ( this . shutDownEvent ) {
66
- _globalThis . removeEventListener (
67
- this . shutDownEvent ?? 'unload' ,
68
- this . shutdown
69
- ) ;
70
- }
62
+ this . shutDownEvents ?. forEach ( browserEvent => {
63
+ _globalThis . removeEventListener ( browserEvent , this . shutdown ) ;
64
+ } ) ;
71
65
}
72
66
73
67
send (
Original file line number Diff line number Diff line change @@ -53,8 +53,7 @@ export type ShutdownEvent = 'unload' | 'onhide' | 'pagehide' | 'beforeunload';
53
53
* Collector Exporter base config
54
54
*/
55
55
export interface OTLPExporterConfigBase {
56
- isShutdownEventDisabled ?: boolean ;
57
- shutDownEvent ?: ShutdownEvent ;
56
+ shutDownEvents ?: ShutdownEvent [ ] ;
58
57
headers ?: Partial < Record < string , unknown > > ;
59
58
hostname ?: string ;
60
59
url ?: string ;
You can’t perform that action at this time.
0 commit comments