Skip to content

Commit 1bcf83d

Browse files
authored
Expose setUserProperties from internal analytics instance (#9263)
1 parent cb3bdd8 commit 1bcf83d

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

.changeset/young-timers-jump.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@firebase/analytics-interop-types': patch
3+
'@firebase/analytics': patch
4+
---
5+
6+
Expose `setUserProperties` on internal Analytics instance.

packages/analytics-interop-types/index.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ export interface FirebaseAnalyticsInternal {
2929
eventParams?: { [key: string]: unknown },
3030
options?: AnalyticsCallOptions
3131
): void;
32+
setUserProperties: (
33+
properties: { [key: string]: unknown },
34+
options?: AnalyticsCallOptions
35+
) => void;
3236
}
3337

3438
export interface AnalyticsCallOptions {

packages/analytics/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import {
3333
InstanceFactoryOptions
3434
} from '@firebase/component';
3535
import { ERROR_FACTORY, AnalyticsError } from './errors';
36-
import { logEvent } from './api';
36+
import { logEvent, setUserProperties } from './api';
3737
import { name, version } from '../package.json';
38-
import { AnalyticsCallOptions } from './public-types';
38+
import { AnalyticsCallOptions, CustomParams } from './public-types';
3939
import '@firebase/installations';
4040

4141
declare global {
@@ -79,7 +79,11 @@ function registerAnalytics(): void {
7979
eventName: string,
8080
eventParams?: { [key: string]: unknown },
8181
options?: AnalyticsCallOptions
82-
) => logEvent(analytics, eventName, eventParams, options)
82+
) => logEvent(analytics, eventName, eventParams, options),
83+
setUserProperties: (
84+
properties: CustomParams,
85+
options?: AnalyticsCallOptions
86+
) => setUserProperties(analytics, properties, options)
8387
};
8488
} catch (e) {
8589
throw ERROR_FACTORY.create(AnalyticsError.INTEROP_COMPONENT_REG_FAILED, {

packages/messaging/src/testing/fakes/firebase-dependencies.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ export function getFakeInstallations(): _FirebaseInstallationsInternal {
6868

6969
export function getFakeAnalyticsProvider(): Provider<FirebaseAnalyticsInternalName> {
7070
const analytics: FirebaseAnalyticsInternal = {
71-
logEvent() {}
71+
logEvent() {},
72+
setUserProperties() {}
7273
};
7374

7475
return {

0 commit comments

Comments
 (0)