Skip to content

Commit b07ae8c

Browse files
committed
[Part of #176153] Analytics client
1 parent a936bf7 commit b07ae8c

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

packages/analytics/client/src/analytics_client/analytics_client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ export class AnalyticsClient implements IAnalyticsClient {
168168
this.optInConfig$.next(optInConfigInstance);
169169
};
170170

171-
// @ts-expect-error upgrade typescript v4.9.5
172-
public registerContextProvider = <Context>(contextProviderOpts: ContextProviderOpts<Context>) => {
171+
public registerContextProvider = <Context extends Partial<EventContext>>(
172+
contextProviderOpts: ContextProviderOpts<Context>
173+
) => {
173174
this.contextService.registerContextProvider(contextProviderOpts);
174175
};
175176

packages/analytics/client/src/analytics_client/context_service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export class ContextService {
2727
* Registers a context provider, and subscribes to any updates from it.
2828
* @param contextProviderOpts The options to register the context provider {@link ContextProviderOpts}
2929
*/
30-
public registerContextProvider<Context>({
30+
public registerContextProvider<Context extends Partial<EventContext>>({
3131
name,
3232
context$,
33-
schema, // @ts-expect-error upgrade typescript v4.9.5
33+
schema,
3434
}: ContextProviderOpts<Context>) {
3535
if (this.contextProvidersSubscriptions.has(name)) {
3636
throw new Error(`Context provider with name '${name}' already registered`);
@@ -58,9 +58,8 @@ export class ContextService {
5858
})
5959
)
6060
.subscribe((context) => {
61-
// We store each context linked to the context provider so they can increase and reduce
61+
// We store each context linked to the context provider, so they can increase and reduce
6262
// the number of fields they report without having left-overs in the global context.
63-
// @ts-expect-error upgrade typescript v4.9.5
6463
this.contextProvidersRegistry.set(name, context);
6564

6665
// For every context change, we rebuild the global context.

packages/analytics/client/src/analytics_client/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ export interface IAnalyticsClient {
205205
*
206206
* @track-adoption
207207
*/
208-
// @ts-expect-error upgrade typescript v4.9.5
209-
registerContextProvider: <Context>(contextProviderOpts: ContextProviderOpts<Context>) => void;
208+
registerContextProvider: <Context extends Partial<EventContext>>(
209+
contextProviderOpts: ContextProviderOpts<Context>
210+
) => void;
210211
/**
211212
* Removes the context provider and stop enriching the events from its context.
212213
* @param contextProviderName The name of the context provider to remove.

0 commit comments

Comments
 (0)