Skip to content

Commit e8f65b6

Browse files
committed
wip
1 parent 5498a81 commit e8f65b6

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

packages/signals/signals/src/core/signals/signals.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ export class Signals implements ISignals {
3838
private globalSettings: SignalGlobalSettings
3939
constructor(settingsConfig: SignalsSettingsConfig = {}) {
4040
this.globalSettings = new SignalGlobalSettings(settingsConfig)
41-
this.buffer = getSignalBuffer(this.globalSettings.signalBuffer)
42-
this.signalEmitter = this.getSignalEmitter(settingsConfig.middleware)
4341
if (settingsConfig.debug) {
4442
this.debug()
4543
}
44+
this.buffer = getSignalBuffer(this.globalSettings.signalBuffer)
45+
this.signalEmitter = this.getSignalEmitter(settingsConfig.middleware)
4646

4747
// We register the generators (along with the signal emitter) so they start collecting signals before the plugin is started.
4848
// Otherwise, we would wait until analytics is loaded, which would skip things like page network URL changes.

packages/signals/signals/src/plugin/signals-plugin.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,9 @@ export class SignalsPlugin implements Plugin, SignalsAugmentedFunctionality {
2929
public signals: Signals
3030
constructor(settings: SignalsPluginSettingsConfig = {}) {
3131
assertBrowserEnv()
32-
// assign to window for debugging purposes
33-
Object.assign(window, { SegmentSignalsPlugin: this })
34-
35-
if (settings.enableDebugLogging) {
36-
logger.enableLogging('debug')
37-
}
3832

39-
logger.debug(`SignalsPlugin v${version} initializing`, {
40-
settings,
41-
})
33+
// assign to window.SegmentSignalsPlugin for debugging purposes (e.g window.SegmentSignalsPlugin.debug())
34+
Object.assign(window, { SegmentSignalsPlugin: this })
4235

4336
this.signals = new Signals({
4437
debug: settings.debug,
@@ -60,6 +53,10 @@ export class SignalsPlugin implements Plugin, SignalsAugmentedFunctionality {
6053
signalStorageType: settings.signalStorageType,
6154
middleware: settings.middleware,
6255
})
56+
57+
logger.debug(`SignalsPlugin v${version} initializing`, {
58+
settings,
59+
})
6360
}
6461

6562
isLoaded() {
@@ -92,7 +89,8 @@ export class SignalsPlugin implements Plugin, SignalsAugmentedFunctionality {
9289
/**
9390
* Enable redaction and disable ingestion of signals. Also, logs signals to the console.
9491
*/
95-
debug(...args: Parameters<typeof this.signals['debug']>): void {
92+
debug(...args: Parameters<typeof this.signals['debug']>): this {
9693
this.signals.debug(...args)
94+
return this
9795
}
9896
}

packages/signals/signals/src/types/settings.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,12 @@ export interface SignalsPluginSettingsConfig {
1313
processSignal?: string | ProcessSignal
1414

1515
/**
16-
* Enable debug mode. Same as ?debug=true in the URL or SignalsPlugin.debug(true)
17-
* This sets the log level to 'info', disables redaction, and enables signals ingestion
16+
* Enable debug mode. Same as ?segment_signals_debug=true in the URL
17+
* This sets the log level to 'info', disables redaction, and enables signals ingestion (sending signals to segment)
1818
* @default false
1919
*/
2020
debug?: boolean
2121

22-
/**
23-
* Add console debug logging
24-
* @default false
25-
*/
26-
enableDebugLogging?: boolean
27-
2822
/**
2923
* Disable redaction of signals
3024
* @default false

0 commit comments

Comments
 (0)