Skip to content

Commit 323fdc1

Browse files
committed
Squashed commit of the following:
commit d9ed6147cb5a1b34408342193896d9153a90898c Author: Maneesh Tewani <[email protected]> Date: Thu May 9 10:09:49 2024 -0700 Fixed issue where transport is undefined
1 parent 42eb5e5 commit 323fdc1

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

packages/data-connect/src/api/DataConnect.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const FIREBASE_DATA_CONNECT_EMULATOR_HOST_VAR =
6060
'FIREBASE_DATA_CONNECT_EMULATOR_HOST';
6161

6262
/**
63-
*
64-
* @param fullHost
63+
*
64+
* @param fullHost
6565
* @returns TransportOptions
6666
* @internal
6767
*/
@@ -131,10 +131,6 @@ export class DataConnect {
131131
this.app.options,
132132
this.authProvider
133133
);
134-
this.authTokenProvider.addTokenChangeListener(token => {
135-
logDebug(`New Token Available: ${token}`);
136-
this._transport.onTokenChanged(token);
137-
});
138134
}
139135

140136
this.initialized = true;

packages/data-connect/src/logger.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17-
import { Logger, LogLevel, LogLevelString } from "@firebase/logger";
18-
import { SDK_VERSION } from "./core/version";
17+
import { Logger, LogLevel, LogLevelString } from '@firebase/logger';
18+
import { SDK_VERSION } from './core/version';
1919

2020
const logger = new Logger('@firebase/data-connect');
2121
export function setLogLevel(logLevel: LogLevelString) {
2222
logger.setLogLevel(logLevel);
2323
}
2424
export function logDebug(msg: string): void {
25-
// if (logger.logLevel <= LogLevel.DEBUG) {
26-
logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`);
27-
// }
25+
logger.debug(`DataConnect (${SDK_VERSION}): ${msg}`);
2826
}
2927

3028
export function logError(msg: string): void {
31-
// if (logger.logLevel <= LogLevel.ERROR) {
32-
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`);
33-
// }
29+
logger.error(`DataConnect (${SDK_VERSION}): ${msg}`);
3430
}

packages/data-connect/src/network/fetch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ export function dcFetch<T, U>(
6363
.then(res => {
6464
if (res.errors && res.errors.length) {
6565
const stringified = JSON.stringify(res.errors);
66-
logError(
67-
'DataConnect error while performing request: ' + stringified
68-
);
66+
logError('DataConnect error while performing request: ' + stringified);
6967
throw new DataConnectError(Code.OTHER, stringified);
7068
}
7169
return res as { data: T; errors: Error[] };

packages/data-connect/src/network/transport/rest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { DataConnectTransport } from '.';
1919
import { DataConnectOptions, TransportOptions } from '../../api/DataConnect';
2020
import { DataConnectError, Code } from '../../core/error';
2121
import { AuthTokenProvider } from '../../core/FirebaseAuthProvider';
22+
import { logDebug } from '../../logger';
2223
import { addToken, urlBuilder } from '../../util/url';
2324
import { dcFetch } from '../fetch';
2425

@@ -62,6 +63,10 @@ export class RESTTransport implements DataConnectTransport {
6263
);
6364
}
6465
this.connectorName = connector;
66+
this.authProvider?.addTokenChangeListener(token => {
67+
logDebug(`New Token Available: ${token}`);
68+
this.accessToken = token;
69+
});
6570
}
6671
get endpointUrl(): string {
6772
return urlBuilder(

0 commit comments

Comments
 (0)