@dereekb/dbx-analytics 13.2.1 → 13.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -378,6 +378,11 @@ class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceList
378
378
  console.log('SegmentAnalyticsListenerService: Segment is disabled from sending events to the server.');
379
379
  }
380
380
  }
381
+ /**
382
+ * Subscribes to the Segment API service and analytics event stream, forwarding events to the Segment SDK.
383
+ *
384
+ * Events are only sent when the Segment configuration is marked as active.
385
+ */
381
386
  _initializeServiceSubscription() {
382
387
  return combineLatest([this._segmentApi.service$, this.analyticsEvents$]).subscribe(([segment, streamEvent]) => {
383
388
  if (this._segmentApi.config.logging) {
@@ -388,6 +393,12 @@ class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceList
388
393
  }
389
394
  });
390
395
  }
396
+ /**
397
+ * Routes an analytics stream event to the appropriate Segment API method based on event type.
398
+ *
399
+ * @param api - The Segment analytics SDK instance
400
+ * @param streamEvent - The analytics event to process
401
+ */
391
402
  handleStreamEvent(api, streamEvent) {
392
403
  switch (streamEvent.type) {
393
404
  case DbxAnalyticsStreamEventType.NewUserEvent:
@@ -411,9 +422,22 @@ class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceList
411
422
  break;
412
423
  }
413
424
  }
425
+ /**
426
+ * Handles a new user registration event by identifying the user in Segment.
427
+ *
428
+ * @param api - The Segment analytics SDK instance
429
+ * @param streamEvent - The event containing the new user data
430
+ */
414
431
  updateWithNewUserEvent(api, streamEvent) {
415
432
  this.changeUser(api, streamEvent.user);
416
433
  }
434
+ /**
435
+ * Sends a track event to Segment with the event name, value, and additional data properties.
436
+ *
437
+ * @param api - The Segment analytics SDK instance
438
+ * @param streamEvent - The analytics event containing name, value, and data
439
+ * @param name - Optional override for the event name
440
+ */
417
441
  updateWithEvent(api, streamEvent, name) {
418
442
  const event = streamEvent.event;
419
443
  const eventName = name || event?.name;
@@ -1 +1 @@
1
- {"version":3,"file":"dereekb-dbx-analytics.mjs","sources":["../../../../packages/dbx-analytics/src/lib/analytics/analytics.stream.ts","../../../../packages/dbx-analytics/src/lib/analytics/analytics.service.ts","../../../../packages/dbx-analytics/src/lib/action/analytics.action.directive.ts","../../../../packages/dbx-analytics/src/lib/action/analytics.module.ts","../../../../packages/dbx-analytics/src/lib/analytics/analytics.providers.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.service.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.listener.service.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.providers.ts","../../../../packages/dbx-analytics/src/dereekb-dbx-analytics.ts"],"sourcesContent":["import { type Maybe } from '@dereekb/util';\nimport { type DbxAnalyticsUser, type DbxUserAnalyticsEvent, type DbxAnalyticsUserId } from './analytics';\n\nexport enum DbxAnalyticsStreamEventType {\n PageView,\n /**\n * Emitted any time the user value changes.\n *\n * Can emit when the user goes from defined to undefined.\n */\n UserChange,\n /**\n * Emitted any time the user id changes.\n */\n UserIdChange,\n\n // User Events\n NewUserEvent,\n UserLoginEvent,\n UserLogoutEvent,\n UserPropertiesEvent,\n\n // Events\n Event\n}\n\nexport interface DbxAnalyticsStreamEvent {\n readonly type: DbxAnalyticsStreamEventType;\n readonly user?: Maybe<DbxAnalyticsUser>;\n readonly event?: DbxUserAnalyticsEvent;\n readonly userId?: DbxAnalyticsUserId;\n}\n","import { type Observable, Subject, BehaviorSubject, of, type Subscription, first, shareReplay, switchMap, distinctUntilChanged } from 'rxjs';\nimport { Injectable, inject } from '@angular/core';\nimport { SubscriptionObject, filterMaybe } from '@dereekb/rxjs';\nimport { type DbxAnalyticsEvent, type DbxAnalyticsEventData, type DbxAnalyticsEventName, type DbxAnalyticsUser, type NewUserAnalyticsEventData, type DbxUserAnalyticsEvent } from './analytics';\nimport { type DbxAnalyticsStreamEvent, DbxAnalyticsStreamEventType } from './analytics.stream';\nimport { type Maybe, type Destroyable, safeCompareEquality } from '@dereekb/util';\n\nexport abstract class DbxAnalyticsEventEmitterService {\n abstract sendNewUserEvent(user: DbxAnalyticsUser, data: NewUserAnalyticsEventData): void;\n abstract sendUserLoginEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void;\n abstract sendUserLogoutEvent(data?: DbxAnalyticsEventData): void;\n abstract sendUserPropertiesEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void;\n abstract sendEventData(name: DbxAnalyticsEventName, data?: DbxAnalyticsEventData): void;\n abstract sendEvent(event: DbxAnalyticsEvent): void;\n abstract sendPageView(page?: string): void;\n}\n\nexport abstract class DbxAnalyticsEventStreamService {\n abstract readonly events$: Observable<DbxAnalyticsStreamEvent>;\n}\n\nexport abstract class DbxAnalyticsUserSource {\n abstract readonly analyticsUser$: Observable<Maybe<DbxAnalyticsUser>>;\n}\n\nexport abstract class DbxAnalyticsServiceListener {\n public abstract listenToService(service: DbxAnalyticsService): void;\n}\n\n/**\n * Abstract AnalyticsServiceListener implementation.\n */\nexport abstract class AbstractDbxAnalyticsServiceListener implements DbxAnalyticsServiceListener, Destroyable {\n private _sub = new SubscriptionObject();\n protected _analytics = new BehaviorSubject<Maybe<DbxAnalyticsService>>(undefined);\n\n readonly analytics$ = this._analytics.pipe(filterMaybe(), shareReplay(1));\n readonly analyticsEvents$ = this.analytics$.pipe(\n switchMap((x) => x.events$),\n shareReplay(1)\n );\n\n // MARK: AnalyticsServiceListener\n listenToService(service: DbxAnalyticsService): void {\n this._analytics.next(service);\n const sub = this._initializeServiceSubscription();\n\n if (sub !== false) {\n this._sub.subscription = sub;\n }\n }\n\n protected abstract _initializeServiceSubscription(): Subscription | false;\n\n // MARK: Destroy\n destroy(): void {\n this._analytics.complete();\n this._sub.destroy();\n }\n}\n\nexport abstract class DbxAnalyticsServiceConfiguration {\n readonly listeners: DbxAnalyticsServiceListener[] = [];\n readonly isProduction?: boolean;\n readonly logEvents?: boolean;\n readonly userSource?: DbxAnalyticsUserSource;\n}\n\nexport interface DbxAnalyticsStreamEventAnalyticsEventWrapper extends DbxAnalyticsStreamEvent {\n readonly event: DbxUserAnalyticsEvent;\n readonly type: DbxAnalyticsStreamEventType;\n readonly user: Maybe<DbxAnalyticsUser>;\n readonly userId: string | undefined;\n}\n\nexport function dbxAnalyticsStreamEventAnalyticsEventWrapper(event: DbxUserAnalyticsEvent, type: DbxAnalyticsStreamEventType = DbxAnalyticsStreamEventType.Event) {\n const { user } = event;\n const userId = user ? user.user : undefined;\n\n return {\n event,\n type,\n user,\n userId\n };\n}\n\n/**\n * Primary analytics service that emits analytics events that components can listen to.\n */\n@Injectable()\nexport class DbxAnalyticsService implements DbxAnalyticsEventStreamService, DbxAnalyticsEventEmitterService, Destroyable {\n private readonly _config = inject(DbxAnalyticsServiceConfiguration);\n\n // TODO: Make these configurable.\n static readonly USER_REGISTRATION_EVENT_NAME = 'User Registered';\n static readonly USER_LOGIN_EVENT_NAME = 'User Login';\n static readonly USER_LOGOUT_EVENT_NAME = 'User Logout';\n static readonly USER_PROPERTIES_EVENT_NAME = 'User Properties';\n\n private _subject = new Subject<DbxAnalyticsStreamEvent>();\n readonly events$ = this._subject.asObservable();\n\n private _userSource = new BehaviorSubject<Maybe<DbxAnalyticsUserSource>>(undefined);\n\n readonly user$ = this._userSource.pipe(\n switchMap((x) => (x ? x.analyticsUser$ : of(undefined))),\n shareReplay(1)\n );\n\n private _userSourceSub = new SubscriptionObject();\n private _userIdEventSub = new SubscriptionObject();\n private _loggerSub = new SubscriptionObject();\n\n constructor() {\n this._init();\n let userSource: Maybe<DbxAnalyticsUserSource> = inject(DbxAnalyticsUserSource, { optional: true });\n userSource = userSource || this._config.userSource;\n\n if (userSource) {\n this.setUserSource(userSource);\n }\n }\n\n // MARK: Source\n /**\n * Sets the user directly, overridding the UserSource.\n */\n public setUser(user: Maybe<DbxAnalyticsUser>): void {\n let source: Maybe<DbxAnalyticsUserSource>;\n\n if (user) {\n source = { analyticsUser$: of(user) };\n }\n\n this._userSource.next(source);\n\n if (this._userSource.value) {\n console.warn('DbxAnalyticsService has a userSource that is set. Source is now overridden by setUser() value.');\n }\n }\n\n public setUserSource(source: DbxAnalyticsUserSource): void {\n this._userSource.next(source);\n }\n\n // MARK: AnalyticsEventEmitterService\n /**\n * Sends an event.\n */\n public sendNewUserEvent(user: DbxAnalyticsUser, data: NewUserAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_REGISTRATION_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.NewUserEvent,\n user\n );\n }\n\n public sendUserLoginEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_LOGIN_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserLoginEvent,\n user\n );\n }\n\n public sendUserLogoutEvent(data?: DbxAnalyticsEventData, clearUser = true): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_LOGOUT_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserLogoutEvent\n );\n\n if (clearUser) {\n this.setUser(undefined);\n }\n }\n\n public sendUserPropertiesEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_PROPERTIES_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserPropertiesEvent,\n user\n );\n }\n\n public sendEventData(name: DbxAnalyticsEventName, data?: DbxAnalyticsEventData): void {\n return this.sendEvent({\n name,\n data\n });\n }\n\n public sendEventType(eventType: DbxAnalyticsEventName): void {\n this.sendNextEvent(\n {\n name: eventType\n },\n DbxAnalyticsStreamEventType.Event\n );\n }\n\n public sendEvent(event: DbxAnalyticsEvent): void {\n this.sendNextEvent(event, DbxAnalyticsStreamEventType.Event);\n }\n\n public sendPageView(page?: string): void {\n this.sendNextEvent(\n {\n name: page\n },\n DbxAnalyticsStreamEventType.PageView\n );\n }\n\n /**\n * Sends the next event.\n *\n * @param event\n * @param type\n * @param userOverride Uses this user if set as null or an override value. If undefined the current analytics user is used.\n */\n protected sendNextEvent(event: DbxAnalyticsEvent = {}, type: DbxAnalyticsStreamEventType, userOverride?: Maybe<DbxAnalyticsUser>): void {\n this.user$.pipe(first()).subscribe((analyticsUser) => {\n const user: Maybe<DbxAnalyticsUser> = userOverride !== undefined ? userOverride : analyticsUser;\n const analyticsEvent: DbxUserAnalyticsEvent = { ...event, user };\n this.nextEvent(analyticsEvent, type);\n });\n }\n\n protected nextEvent(event: DbxUserAnalyticsEvent, type: DbxAnalyticsStreamEventType): void {\n const wrapper = dbxAnalyticsStreamEventAnalyticsEventWrapper(event, type);\n this._subject.next(wrapper);\n }\n\n // MARK: Internal\n private _init(): void {\n if (this._config.isProduction) {\n // Initialize listeners.\n this._config.listeners.forEach((listener) => {\n listener.listenToService(this);\n });\n } else {\n console.warn('AnalyticsService: Analytics not in production mode. All analytics events are ignored.');\n }\n\n if (this._config.logEvents || !this._config.isProduction) {\n console.log('AnalyticsService: Log analytics events enabled.');\n\n // Create a new subscription\n this._loggerSub.subscription = this._subject.subscribe((x) => {\n console.log(`AnalyticsService: Analytics Event - ${DbxAnalyticsStreamEventType[x.type]} | User: ${x.userId} | Data: ${JSON.stringify(x.event)}.`);\n });\n }\n\n this._userSourceSub.subscription = this.user$.subscribe((user) => {\n this.sendNextEvent({}, DbxAnalyticsStreamEventType.UserChange, user ?? null);\n });\n\n this._userIdEventSub.subscription = this.user$.pipe(distinctUntilChanged((a, b) => safeCompareEquality(a, b, (x, y) => x.user === y.user))).subscribe((user) => {\n this.sendNextEvent({}, DbxAnalyticsStreamEventType.UserIdChange, user ?? null);\n });\n }\n\n destroy() {\n this._subject.complete();\n this._userSource.complete();\n this._userSourceSub.destroy();\n this._userIdEventSub.destroy();\n this._loggerSub.destroy();\n }\n}\n","import { filterMaybe } from '@dereekb/rxjs';\nimport { switchMap, tap, shareReplay, merge, type Observable, of } from 'rxjs';\nimport { Directive, inject, input } from '@angular/core';\nimport { DbxActionContextStoreSourceInstance, cleanSubscriptionWithLockSet } from '@dereekb/dbx-core';\nimport { DbxAnalyticsService } from '../analytics/analytics.service';\nimport { type Maybe, type ReadableError } from '@dereekb/util';\nimport { toObservable } from '@angular/core/rxjs-interop';\n\n/**\n * DbxActionAnalyticsDirective config\n */\nexport interface DbxActionAnalyticsConfig<T = unknown, O = unknown> {\n readonly onTriggered?: (service: DbxAnalyticsService) => void;\n readonly onReady?: (service: DbxAnalyticsService, value: T) => void;\n readonly onSuccess?: (service: DbxAnalyticsService, result: Maybe<O>, value: T) => void;\n readonly onError?: (service: DbxAnalyticsService, error: Maybe<ReadableError>) => void;\n}\n\n/**\n * Used to listen to an ActionContext and send analytical events based on action events.\n */\n@Directive({\n selector: '[dbxActionAnalytics]',\n standalone: true\n})\nexport class DbxActionAnalyticsDirective<T, O> {\n readonly source = inject(DbxActionContextStoreSourceInstance<T, O>, { host: true });\n readonly analyticsService = inject(DbxAnalyticsService);\n\n readonly config = input<Maybe<DbxActionAnalyticsConfig<T, O>>>(undefined, { alias: 'dbxActionAnalytics' });\n readonly config$ = toObservable(this.config).pipe(filterMaybe(), shareReplay(1));\n\n constructor() {\n cleanSubscriptionWithLockSet({\n lockSet: this.source.lockSet,\n sub: this.config$\n .pipe(\n switchMap(({ onTriggered, onReady, onSuccess, onError }) => {\n const triggerObs: Observable<unknown>[] = [];\n\n if (onTriggered) {\n triggerObs.push(this.source.triggered$.pipe(tap(() => onTriggered(this.analyticsService))));\n }\n\n if (onReady) {\n triggerObs.push(this.source.valueReady$.pipe(tap((value) => onReady(this.analyticsService, value))));\n }\n\n if (onSuccess) {\n triggerObs.push(this.source.successPair$.pipe(tap(({ result, value }) => onSuccess(this.analyticsService, result, value))));\n }\n\n if (onError) {\n triggerObs.push(\n this.source.error$.pipe(\n filterMaybe(),\n tap((error) => onError(this.analyticsService, error))\n )\n );\n }\n\n if (triggerObs.length) {\n return merge(...triggerObs);\n } else {\n return of();\n }\n })\n )\n .subscribe()\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { DbxActionAnalyticsDirective } from './analytics.action.directive';\n\n/**\n * @deprecated The exported DbxActionAnalyticsDirective is now a standalone component. Import that instead.\n */\n@NgModule({\n imports: [DbxActionAnalyticsDirective],\n exports: [DbxActionAnalyticsDirective]\n})\nexport class DbxAnalyticsActionModule {}\n","import { type EnvironmentProviders, Injector, type Provider, makeEnvironmentProviders } from '@angular/core';\nimport { DbxAnalyticsServiceConfiguration, DbxAnalyticsService } from './analytics.service';\n\nexport type DbxAnalyticsServiceConfigurationFactory = (injector: Injector) => DbxAnalyticsServiceConfiguration;\n\n/**\n * Configuration for provideDbxAnalyticsService()\n */\nexport interface ProvideDbxAnalyticsConfig {\n readonly dbxAnalyticsServiceConfigurationFactory: DbxAnalyticsServiceConfigurationFactory;\n}\n\n/**\n * Creates a EnvironmentProviders that provides a DbxAnalyticsService.\n *\n * @param config Configuration\n * @returns EnvironmentProviders\n */\nexport function provideDbxAnalyticsService(config: ProvideDbxAnalyticsConfig): EnvironmentProviders {\n const { dbxAnalyticsServiceConfigurationFactory } = config;\n\n const providers: Provider[] = [\n // configuration\n {\n provide: DbxAnalyticsServiceConfiguration,\n useFactory: dbxAnalyticsServiceConfigurationFactory,\n deps: [Injector]\n },\n // service\n DbxAnalyticsService\n ];\n\n return makeEnvironmentProviders(providers);\n}\n","import { Injectable, InjectionToken, inject } from '@angular/core';\nimport { AbstractAsyncWindowLoadedService } from '@dereekb/browser';\nimport { poll } from '@dereekb/util';\n\nexport const PRELOAD_SEGMENT_TOKEN = new InjectionToken<string>('DbxAnalyticsSegmentApiServicePreload');\n\nexport class DbxAnalyticsSegmentApiServiceConfig {\n writeKey: string;\n logging = true;\n active = true;\n constructor(writeKey: string) {\n this.writeKey = writeKey;\n }\n}\n\n/**\n * When the Segment library finishes loading, it is invoked.\n */\ntype SegmentAnalyticsInvoked = SegmentAnalytics.AnalyticsJS & { invoked?: boolean };\n\n/**\n * Segment API Service used for waiting/retrieving the segment API from window when initialized.\n *\n * This requires some setup in index.html.\n */\n@Injectable()\nexport class DbxAnalyticsSegmentApiService extends AbstractAsyncWindowLoadedService<SegmentAnalytics.AnalyticsJS> {\n private readonly _config = inject(DbxAnalyticsSegmentApiServiceConfig);\n\n static readonly SEGMENT_API_WINDOW_KEY = 'analytics';\n static readonly SEGMENT_READY_KEY = 'SegmentReady';\n\n constructor() {\n const preload = inject(PRELOAD_SEGMENT_TOKEN, { optional: true });\n super(DbxAnalyticsSegmentApiService.SEGMENT_API_WINDOW_KEY, undefined, 'Segment', preload);\n }\n\n get config(): DbxAnalyticsSegmentApiServiceConfig {\n return this._config;\n }\n\n protected override _prepareCompleteLoadingService(): Promise<void> {\n return poll({\n // poll until analytics.invoked is true.\n check: () => Boolean((window.analytics as SegmentAnalyticsInvoked).invoked),\n timesToGiveup: 100\n });\n }\n\n protected override _initService(service: SegmentAnalytics.AnalyticsJS): Promise<SegmentAnalytics.AnalyticsJS> {\n return new Promise((resolve, reject) => {\n try {\n service.load(this._config.writeKey); // Initialize Segment\n\n // Wait for the service to ready itself.\n service.ready(() => {\n // Segment changes itself or rather the target, and the previous initial target is ignored after.\n const segment: SegmentAnalytics.AnalyticsJS = window[DbxAnalyticsSegmentApiService.SEGMENT_API_WINDOW_KEY];\n resolve(segment);\n });\n } catch (e) {\n console.log('Failed to init segment: ' + e);\n reject(e);\n }\n });\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { type Maybe } from '@dereekb/util';\nimport { combineLatest } from 'rxjs';\nimport { AbstractDbxAnalyticsServiceListener, type DbxAnalyticsStreamEvent, DbxAnalyticsStreamEventType, type DbxAnalyticsUser } from '../../analytics';\nimport { DbxAnalyticsSegmentApiService } from './segment.service';\n\n/**\n * DbxAnalyticsServiceListener adapter for Segment.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceListener {\n private readonly _segmentApi = inject(DbxAnalyticsSegmentApiService);\n\n constructor() {\n super();\n\n if (this._segmentApi.config.logging) {\n console.log('SegmentAnalyticsListenerService: Segment is logging events.');\n }\n\n if (!this._segmentApi.config.active) {\n console.log('SegmentAnalyticsListenerService: Segment is disabled from sending events to the server.');\n }\n }\n\n protected _initializeServiceSubscription() {\n return combineLatest([this._segmentApi.service$, this.analyticsEvents$]).subscribe(([segment, streamEvent]: [SegmentAnalytics.AnalyticsJS, DbxAnalyticsStreamEvent]) => {\n if (this._segmentApi.config.logging) {\n console.log('Segment Listener Logging Event: ', streamEvent);\n }\n\n if (this._segmentApi.config.active) {\n this.handleStreamEvent(segment, streamEvent);\n }\n });\n }\n\n protected handleStreamEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void {\n switch (streamEvent.type) {\n case DbxAnalyticsStreamEventType.NewUserEvent:\n this.updateWithNewUserEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.UserLoginEvent:\n this.changeUser(api, streamEvent.user);\n this.updateWithEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.Event:\n this.updateWithEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.UserLogoutEvent:\n this.changeUser(api, undefined);\n break;\n case DbxAnalyticsStreamEventType.PageView:\n api.page();\n break;\n case DbxAnalyticsStreamEventType.UserChange:\n this.changeUser(api, streamEvent.user);\n break;\n }\n }\n\n protected updateWithNewUserEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void {\n this.changeUser(api, streamEvent.user);\n }\n\n protected updateWithEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent, name?: string): void {\n const event = streamEvent.event;\n const eventName = name || event?.name;\n\n if (eventName) {\n const value = event?.value;\n const data = event?.data;\n\n api.track(\n eventName,\n {\n ...(value != null\n ? {\n value\n }\n : undefined),\n ...data\n },\n {},\n () => {\n if (this._segmentApi.config.logging) {\n console.log('Segment track success.');\n }\n }\n );\n }\n }\n\n private changeUser(api: SegmentAnalytics.AnalyticsJS, user: Maybe<DbxAnalyticsUser>): void {\n if (user?.user) {\n api.identify(\n user.user,\n {\n ...user.properties\n },\n {},\n () => {\n if (this._segmentApi.config.logging) {\n console.log('Segment identify success.');\n }\n }\n );\n } else {\n api.reset();\n }\n }\n}\n","import { type EnvironmentProviders, Injector, makeEnvironmentProviders, type Provider } from '@angular/core';\nimport { DbxAnalyticsSegmentApiService, DbxAnalyticsSegmentApiServiceConfig, PRELOAD_SEGMENT_TOKEN } from './segment.service';\n\nexport type DbxAnalyticsSegmentApiServiceConfigFactory = (injector: Injector) => DbxAnalyticsSegmentApiServiceConfig;\n\n/**\n * Configuration for provideDbxAnalyticsSegmentApiService()\n */\nexport interface ProvideDbxAnalyticsSegmentModuleConfig {\n readonly preloadSegmentToken?: boolean;\n readonly dbxAnalyticsSegmentApiServiceConfigFactory: DbxAnalyticsSegmentApiServiceConfigFactory;\n}\n\n/**\n * Creates a EnvironmentProviders that provides a DbxAnalyticsSegmentApiService.\n *\n * @param config Configuration\n * @returns EnvironmentProviders\n */\nexport function provideDbxAnalyticsSegmentApiService(config: ProvideDbxAnalyticsSegmentModuleConfig): EnvironmentProviders {\n const { preloadSegmentToken, dbxAnalyticsSegmentApiServiceConfigFactory } = config;\n\n const providers: Provider[] = [\n // configuration\n {\n provide: DbxAnalyticsSegmentApiServiceConfig,\n useFactory: dbxAnalyticsSegmentApiServiceConfigFactory,\n deps: [Injector]\n },\n // service\n DbxAnalyticsSegmentApiService\n ];\n\n if (preloadSegmentToken) {\n providers.push({\n provide: PRELOAD_SEGMENT_TOKEN,\n useValue: preloadSegmentToken\n });\n }\n\n return makeEnvironmentProviders(providers);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;IAGY;AAAZ,CAAA,UAAY,2BAA2B,EAAA;AACrC,IAAA,2BAAA,CAAA,2BAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAA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A,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kCAAkC,cAFjC,MAAM,EAAA,CAAA;;2FAEP,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAH9C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACED;;;;;AAKG;AACG,SAAU,oCAAoC,CAAC,MAA8C,EAAA;AACjG,IAAA,MAAM,EAAE,mBAAmB,EAAE,0CAA0C,EAAE,GAAG,MAAM;AAElF,IAAA,MAAM,SAAS,GAAe;;AAE5B,QAAA;AACE,YAAA,OAAO,EAAE,mCAAmC;AAC5C,YAAA,UAAU,EAAE,0CAA0C;YACtD,IAAI,EAAE,CAAC,QAAQ;AAChB,SAAA;;QAED;KACD;IAED,IAAI,mBAAmB,EAAE;QACvB,SAAS,CAAC,IAAI,CAAC;AACb,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE;AACX,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,wBAAwB,CAAC,SAAS,CAAC;AAC5C;;ACzCA;;AAEG;;;;"}
1
+ {"version":3,"file":"dereekb-dbx-analytics.mjs","sources":["../../../../packages/dbx-analytics/src/lib/analytics/analytics.stream.ts","../../../../packages/dbx-analytics/src/lib/analytics/analytics.service.ts","../../../../packages/dbx-analytics/src/lib/action/analytics.action.directive.ts","../../../../packages/dbx-analytics/src/lib/action/analytics.module.ts","../../../../packages/dbx-analytics/src/lib/analytics/analytics.providers.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.service.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.listener.service.ts","../../../../packages/dbx-analytics/src/lib/providers/segment/segment.providers.ts","../../../../packages/dbx-analytics/src/dereekb-dbx-analytics.ts"],"sourcesContent":["import { type Maybe } from '@dereekb/util';\nimport { type DbxAnalyticsUser, type DbxUserAnalyticsEvent, type DbxAnalyticsUserId } from './analytics';\n\nexport enum DbxAnalyticsStreamEventType {\n PageView,\n /**\n * Emitted any time the user value changes.\n *\n * Can emit when the user goes from defined to undefined.\n */\n UserChange,\n /**\n * Emitted any time the user id changes.\n */\n UserIdChange,\n\n // User Events\n NewUserEvent,\n UserLoginEvent,\n UserLogoutEvent,\n UserPropertiesEvent,\n\n // Events\n Event\n}\n\nexport interface DbxAnalyticsStreamEvent {\n readonly type: DbxAnalyticsStreamEventType;\n readonly user?: Maybe<DbxAnalyticsUser>;\n readonly event?: DbxUserAnalyticsEvent;\n readonly userId?: DbxAnalyticsUserId;\n}\n","import { type Observable, Subject, BehaviorSubject, of, type Subscription, first, shareReplay, switchMap, distinctUntilChanged } from 'rxjs';\nimport { Injectable, inject } from '@angular/core';\nimport { SubscriptionObject, filterMaybe } from '@dereekb/rxjs';\nimport { type DbxAnalyticsEvent, type DbxAnalyticsEventData, type DbxAnalyticsEventName, type DbxAnalyticsUser, type NewUserAnalyticsEventData, type DbxUserAnalyticsEvent } from './analytics';\nimport { type DbxAnalyticsStreamEvent, DbxAnalyticsStreamEventType } from './analytics.stream';\nimport { type Maybe, type Destroyable, safeCompareEquality } from '@dereekb/util';\n\nexport abstract class DbxAnalyticsEventEmitterService {\n abstract sendNewUserEvent(user: DbxAnalyticsUser, data: NewUserAnalyticsEventData): void;\n abstract sendUserLoginEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void;\n abstract sendUserLogoutEvent(data?: DbxAnalyticsEventData): void;\n abstract sendUserPropertiesEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void;\n abstract sendEventData(name: DbxAnalyticsEventName, data?: DbxAnalyticsEventData): void;\n abstract sendEvent(event: DbxAnalyticsEvent): void;\n abstract sendPageView(page?: string): void;\n}\n\nexport abstract class DbxAnalyticsEventStreamService {\n abstract readonly events$: Observable<DbxAnalyticsStreamEvent>;\n}\n\nexport abstract class DbxAnalyticsUserSource {\n abstract readonly analyticsUser$: Observable<Maybe<DbxAnalyticsUser>>;\n}\n\nexport abstract class DbxAnalyticsServiceListener {\n public abstract listenToService(service: DbxAnalyticsService): void;\n}\n\n/**\n * Abstract AnalyticsServiceListener implementation.\n */\nexport abstract class AbstractDbxAnalyticsServiceListener implements DbxAnalyticsServiceListener, Destroyable {\n private _sub = new SubscriptionObject();\n protected _analytics = new BehaviorSubject<Maybe<DbxAnalyticsService>>(undefined);\n\n readonly analytics$ = this._analytics.pipe(filterMaybe(), shareReplay(1));\n readonly analyticsEvents$ = this.analytics$.pipe(\n switchMap((x) => x.events$),\n shareReplay(1)\n );\n\n // MARK: AnalyticsServiceListener\n listenToService(service: DbxAnalyticsService): void {\n this._analytics.next(service);\n const sub = this._initializeServiceSubscription();\n\n if (sub !== false) {\n this._sub.subscription = sub;\n }\n }\n\n protected abstract _initializeServiceSubscription(): Subscription | false;\n\n // MARK: Destroy\n destroy(): void {\n this._analytics.complete();\n this._sub.destroy();\n }\n}\n\nexport abstract class DbxAnalyticsServiceConfiguration {\n readonly listeners: DbxAnalyticsServiceListener[] = [];\n readonly isProduction?: boolean;\n readonly logEvents?: boolean;\n readonly userSource?: DbxAnalyticsUserSource;\n}\n\nexport interface DbxAnalyticsStreamEventAnalyticsEventWrapper extends DbxAnalyticsStreamEvent {\n readonly event: DbxUserAnalyticsEvent;\n readonly type: DbxAnalyticsStreamEventType;\n readonly user: Maybe<DbxAnalyticsUser>;\n readonly userId: string | undefined;\n}\n\nexport function dbxAnalyticsStreamEventAnalyticsEventWrapper(event: DbxUserAnalyticsEvent, type: DbxAnalyticsStreamEventType = DbxAnalyticsStreamEventType.Event) {\n const { user } = event;\n const userId = user ? user.user : undefined;\n\n return {\n event,\n type,\n user,\n userId\n };\n}\n\n/**\n * Primary analytics service that emits analytics events that components can listen to.\n */\n@Injectable()\nexport class DbxAnalyticsService implements DbxAnalyticsEventStreamService, DbxAnalyticsEventEmitterService, Destroyable {\n private readonly _config = inject(DbxAnalyticsServiceConfiguration);\n\n // TODO: Make these configurable.\n static readonly USER_REGISTRATION_EVENT_NAME = 'User Registered';\n static readonly USER_LOGIN_EVENT_NAME = 'User Login';\n static readonly USER_LOGOUT_EVENT_NAME = 'User Logout';\n static readonly USER_PROPERTIES_EVENT_NAME = 'User Properties';\n\n private _subject = new Subject<DbxAnalyticsStreamEvent>();\n readonly events$ = this._subject.asObservable();\n\n private _userSource = new BehaviorSubject<Maybe<DbxAnalyticsUserSource>>(undefined);\n\n readonly user$ = this._userSource.pipe(\n switchMap((x) => (x ? x.analyticsUser$ : of(undefined))),\n shareReplay(1)\n );\n\n private _userSourceSub = new SubscriptionObject();\n private _userIdEventSub = new SubscriptionObject();\n private _loggerSub = new SubscriptionObject();\n\n constructor() {\n this._init();\n let userSource: Maybe<DbxAnalyticsUserSource> = inject(DbxAnalyticsUserSource, { optional: true });\n userSource = userSource || this._config.userSource;\n\n if (userSource) {\n this.setUserSource(userSource);\n }\n }\n\n // MARK: Source\n /**\n * Sets the user directly, overridding the UserSource.\n */\n public setUser(user: Maybe<DbxAnalyticsUser>): void {\n let source: Maybe<DbxAnalyticsUserSource>;\n\n if (user) {\n source = { analyticsUser$: of(user) };\n }\n\n this._userSource.next(source);\n\n if (this._userSource.value) {\n console.warn('DbxAnalyticsService has a userSource that is set. Source is now overridden by setUser() value.');\n }\n }\n\n public setUserSource(source: DbxAnalyticsUserSource): void {\n this._userSource.next(source);\n }\n\n // MARK: AnalyticsEventEmitterService\n /**\n * Sends an event.\n */\n public sendNewUserEvent(user: DbxAnalyticsUser, data: NewUserAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_REGISTRATION_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.NewUserEvent,\n user\n );\n }\n\n public sendUserLoginEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_LOGIN_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserLoginEvent,\n user\n );\n }\n\n public sendUserLogoutEvent(data?: DbxAnalyticsEventData, clearUser = true): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_LOGOUT_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserLogoutEvent\n );\n\n if (clearUser) {\n this.setUser(undefined);\n }\n }\n\n public sendUserPropertiesEvent(user: DbxAnalyticsUser, data?: DbxAnalyticsEventData): void {\n this.sendNextEvent(\n {\n name: DbxAnalyticsService.USER_PROPERTIES_EVENT_NAME,\n data\n },\n DbxAnalyticsStreamEventType.UserPropertiesEvent,\n user\n );\n }\n\n public sendEventData(name: DbxAnalyticsEventName, data?: DbxAnalyticsEventData): void {\n return this.sendEvent({\n name,\n data\n });\n }\n\n public sendEventType(eventType: DbxAnalyticsEventName): void {\n this.sendNextEvent(\n {\n name: eventType\n },\n DbxAnalyticsStreamEventType.Event\n );\n }\n\n public sendEvent(event: DbxAnalyticsEvent): void {\n this.sendNextEvent(event, DbxAnalyticsStreamEventType.Event);\n }\n\n public sendPageView(page?: string): void {\n this.sendNextEvent(\n {\n name: page\n },\n DbxAnalyticsStreamEventType.PageView\n );\n }\n\n /**\n * Sends the next event.\n *\n * @param event\n * @param type\n * @param userOverride Uses this user if set as null or an override value. If undefined the current analytics user is used.\n */\n protected sendNextEvent(event: DbxAnalyticsEvent = {}, type: DbxAnalyticsStreamEventType, userOverride?: Maybe<DbxAnalyticsUser>): void {\n this.user$.pipe(first()).subscribe((analyticsUser) => {\n const user: Maybe<DbxAnalyticsUser> = userOverride !== undefined ? userOverride : analyticsUser;\n const analyticsEvent: DbxUserAnalyticsEvent = { ...event, user };\n this.nextEvent(analyticsEvent, type);\n });\n }\n\n protected nextEvent(event: DbxUserAnalyticsEvent, type: DbxAnalyticsStreamEventType): void {\n const wrapper = dbxAnalyticsStreamEventAnalyticsEventWrapper(event, type);\n this._subject.next(wrapper);\n }\n\n // MARK: Internal\n private _init(): void {\n if (this._config.isProduction) {\n // Initialize listeners.\n this._config.listeners.forEach((listener) => {\n listener.listenToService(this);\n });\n } else {\n console.warn('AnalyticsService: Analytics not in production mode. All analytics events are ignored.');\n }\n\n if (this._config.logEvents || !this._config.isProduction) {\n console.log('AnalyticsService: Log analytics events enabled.');\n\n // Create a new subscription\n this._loggerSub.subscription = this._subject.subscribe((x) => {\n console.log(`AnalyticsService: Analytics Event - ${DbxAnalyticsStreamEventType[x.type]} | User: ${x.userId} | Data: ${JSON.stringify(x.event)}.`);\n });\n }\n\n this._userSourceSub.subscription = this.user$.subscribe((user) => {\n this.sendNextEvent({}, DbxAnalyticsStreamEventType.UserChange, user ?? null);\n });\n\n this._userIdEventSub.subscription = this.user$.pipe(distinctUntilChanged((a, b) => safeCompareEquality(a, b, (x, y) => x.user === y.user))).subscribe((user) => {\n this.sendNextEvent({}, DbxAnalyticsStreamEventType.UserIdChange, user ?? null);\n });\n }\n\n destroy() {\n this._subject.complete();\n this._userSource.complete();\n this._userSourceSub.destroy();\n this._userIdEventSub.destroy();\n this._loggerSub.destroy();\n }\n}\n","import { filterMaybe } from '@dereekb/rxjs';\nimport { switchMap, tap, shareReplay, merge, type Observable, of } from 'rxjs';\nimport { Directive, inject, input } from '@angular/core';\nimport { DbxActionContextStoreSourceInstance, cleanSubscriptionWithLockSet } from '@dereekb/dbx-core';\nimport { DbxAnalyticsService } from '../analytics/analytics.service';\nimport { type Maybe, type ReadableError } from '@dereekb/util';\nimport { toObservable } from '@angular/core/rxjs-interop';\n\n/**\n * DbxActionAnalyticsDirective config\n */\nexport interface DbxActionAnalyticsConfig<T = unknown, O = unknown> {\n readonly onTriggered?: (service: DbxAnalyticsService) => void;\n readonly onReady?: (service: DbxAnalyticsService, value: T) => void;\n readonly onSuccess?: (service: DbxAnalyticsService, result: Maybe<O>, value: T) => void;\n readonly onError?: (service: DbxAnalyticsService, error: Maybe<ReadableError>) => void;\n}\n\n/**\n * Used to listen to an ActionContext and send analytical events based on action events.\n */\n@Directive({\n selector: '[dbxActionAnalytics]',\n standalone: true\n})\nexport class DbxActionAnalyticsDirective<T, O> {\n readonly source = inject(DbxActionContextStoreSourceInstance<T, O>, { host: true });\n readonly analyticsService = inject(DbxAnalyticsService);\n\n readonly config = input<Maybe<DbxActionAnalyticsConfig<T, O>>>(undefined, { alias: 'dbxActionAnalytics' });\n readonly config$ = toObservable(this.config).pipe(filterMaybe(), shareReplay(1));\n\n constructor() {\n cleanSubscriptionWithLockSet({\n lockSet: this.source.lockSet,\n sub: this.config$\n .pipe(\n switchMap(({ onTriggered, onReady, onSuccess, onError }) => {\n const triggerObs: Observable<unknown>[] = [];\n\n if (onTriggered) {\n triggerObs.push(this.source.triggered$.pipe(tap(() => onTriggered(this.analyticsService))));\n }\n\n if (onReady) {\n triggerObs.push(this.source.valueReady$.pipe(tap((value) => onReady(this.analyticsService, value))));\n }\n\n if (onSuccess) {\n triggerObs.push(this.source.successPair$.pipe(tap(({ result, value }) => onSuccess(this.analyticsService, result, value))));\n }\n\n if (onError) {\n triggerObs.push(\n this.source.error$.pipe(\n filterMaybe(),\n tap((error) => onError(this.analyticsService, error))\n )\n );\n }\n\n if (triggerObs.length) {\n return merge(...triggerObs);\n } else {\n return of();\n }\n })\n )\n .subscribe()\n });\n }\n}\n","import { NgModule } from '@angular/core';\nimport { DbxActionAnalyticsDirective } from './analytics.action.directive';\n\n/**\n * @deprecated The exported DbxActionAnalyticsDirective is now a standalone component. Import that instead.\n */\n@NgModule({\n imports: [DbxActionAnalyticsDirective],\n exports: [DbxActionAnalyticsDirective]\n})\nexport class DbxAnalyticsActionModule {}\n","import { type EnvironmentProviders, Injector, type Provider, makeEnvironmentProviders } from '@angular/core';\nimport { DbxAnalyticsServiceConfiguration, DbxAnalyticsService } from './analytics.service';\n\n/**\n * Factory function that creates a {@link DbxAnalyticsServiceConfiguration} using the Angular injector.\n *\n * Used by {@link provideDbxAnalyticsService} to defer configuration resolution to runtime.\n */\nexport type DbxAnalyticsServiceConfigurationFactory = (injector: Injector) => DbxAnalyticsServiceConfiguration;\n\n/**\n * Configuration for provideDbxAnalyticsService()\n */\nexport interface ProvideDbxAnalyticsConfig {\n readonly dbxAnalyticsServiceConfigurationFactory: DbxAnalyticsServiceConfigurationFactory;\n}\n\n/**\n * Creates a EnvironmentProviders that provides a DbxAnalyticsService.\n *\n * @param config Configuration\n * @returns EnvironmentProviders\n */\nexport function provideDbxAnalyticsService(config: ProvideDbxAnalyticsConfig): EnvironmentProviders {\n const { dbxAnalyticsServiceConfigurationFactory } = config;\n\n const providers: Provider[] = [\n // configuration\n {\n provide: DbxAnalyticsServiceConfiguration,\n useFactory: dbxAnalyticsServiceConfigurationFactory,\n deps: [Injector]\n },\n // service\n DbxAnalyticsService\n ];\n\n return makeEnvironmentProviders(providers);\n}\n","import { Injectable, InjectionToken, inject } from '@angular/core';\nimport { AbstractAsyncWindowLoadedService } from '@dereekb/browser';\nimport { poll } from '@dereekb/util';\n\nexport const PRELOAD_SEGMENT_TOKEN = new InjectionToken<string>('DbxAnalyticsSegmentApiServicePreload');\n\nexport class DbxAnalyticsSegmentApiServiceConfig {\n writeKey: string;\n logging = true;\n active = true;\n constructor(writeKey: string) {\n this.writeKey = writeKey;\n }\n}\n\n/**\n * When the Segment library finishes loading, it is invoked.\n */\ntype SegmentAnalyticsInvoked = SegmentAnalytics.AnalyticsJS & { invoked?: boolean };\n\n/**\n * Segment API Service used for waiting/retrieving the segment API from window when initialized.\n *\n * This requires some setup in index.html.\n */\n@Injectable()\nexport class DbxAnalyticsSegmentApiService extends AbstractAsyncWindowLoadedService<SegmentAnalytics.AnalyticsJS> {\n private readonly _config = inject(DbxAnalyticsSegmentApiServiceConfig);\n\n static readonly SEGMENT_API_WINDOW_KEY = 'analytics';\n static readonly SEGMENT_READY_KEY = 'SegmentReady';\n\n constructor() {\n const preload = inject(PRELOAD_SEGMENT_TOKEN, { optional: true });\n super(DbxAnalyticsSegmentApiService.SEGMENT_API_WINDOW_KEY, undefined, 'Segment', preload);\n }\n\n get config(): DbxAnalyticsSegmentApiServiceConfig {\n return this._config;\n }\n\n protected override _prepareCompleteLoadingService(): Promise<void> {\n return poll({\n // poll until analytics.invoked is true.\n check: () => Boolean((window.analytics as SegmentAnalyticsInvoked).invoked),\n timesToGiveup: 100\n });\n }\n\n protected override _initService(service: SegmentAnalytics.AnalyticsJS): Promise<SegmentAnalytics.AnalyticsJS> {\n return new Promise((resolve, reject) => {\n try {\n service.load(this._config.writeKey); // Initialize Segment\n\n // Wait for the service to ready itself.\n service.ready(() => {\n // Segment changes itself or rather the target, and the previous initial target is ignored after.\n const segment: SegmentAnalytics.AnalyticsJS = window[DbxAnalyticsSegmentApiService.SEGMENT_API_WINDOW_KEY];\n resolve(segment);\n });\n } catch (e) {\n console.log('Failed to init segment: ' + e);\n reject(e);\n }\n });\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { type Maybe } from '@dereekb/util';\nimport { combineLatest } from 'rxjs';\nimport { AbstractDbxAnalyticsServiceListener, type DbxAnalyticsStreamEvent, DbxAnalyticsStreamEventType, type DbxAnalyticsUser } from '../../analytics';\nimport { DbxAnalyticsSegmentApiService } from './segment.service';\n\n/**\n * DbxAnalyticsServiceListener adapter for Segment.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceListener {\n private readonly _segmentApi = inject(DbxAnalyticsSegmentApiService);\n\n constructor() {\n super();\n\n if (this._segmentApi.config.logging) {\n console.log('SegmentAnalyticsListenerService: Segment is logging events.');\n }\n\n if (!this._segmentApi.config.active) {\n console.log('SegmentAnalyticsListenerService: Segment is disabled from sending events to the server.');\n }\n }\n\n /**\n * Subscribes to the Segment API service and analytics event stream, forwarding events to the Segment SDK.\n *\n * Events are only sent when the Segment configuration is marked as active.\n */\n protected _initializeServiceSubscription() {\n return combineLatest([this._segmentApi.service$, this.analyticsEvents$]).subscribe(([segment, streamEvent]: [SegmentAnalytics.AnalyticsJS, DbxAnalyticsStreamEvent]) => {\n if (this._segmentApi.config.logging) {\n console.log('Segment Listener Logging Event: ', streamEvent);\n }\n\n if (this._segmentApi.config.active) {\n this.handleStreamEvent(segment, streamEvent);\n }\n });\n }\n\n /**\n * Routes an analytics stream event to the appropriate Segment API method based on event type.\n *\n * @param api - The Segment analytics SDK instance\n * @param streamEvent - The analytics event to process\n */\n protected handleStreamEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void {\n switch (streamEvent.type) {\n case DbxAnalyticsStreamEventType.NewUserEvent:\n this.updateWithNewUserEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.UserLoginEvent:\n this.changeUser(api, streamEvent.user);\n this.updateWithEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.Event:\n this.updateWithEvent(api, streamEvent);\n break;\n case DbxAnalyticsStreamEventType.UserLogoutEvent:\n this.changeUser(api, undefined);\n break;\n case DbxAnalyticsStreamEventType.PageView:\n api.page();\n break;\n case DbxAnalyticsStreamEventType.UserChange:\n this.changeUser(api, streamEvent.user);\n break;\n }\n }\n\n /**\n * Handles a new user registration event by identifying the user in Segment.\n *\n * @param api - The Segment analytics SDK instance\n * @param streamEvent - The event containing the new user data\n */\n protected updateWithNewUserEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void {\n this.changeUser(api, streamEvent.user);\n }\n\n /**\n * Sends a track event to Segment with the event name, value, and additional data properties.\n *\n * @param api - The Segment analytics SDK instance\n * @param streamEvent - The analytics event containing name, value, and data\n * @param name - Optional override for the event name\n */\n protected updateWithEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent, name?: string): void {\n const event = streamEvent.event;\n const eventName = name || event?.name;\n\n if (eventName) {\n const value = event?.value;\n const data = event?.data;\n\n api.track(\n eventName,\n {\n ...(value != null\n ? {\n value\n }\n : undefined),\n ...data\n },\n {},\n () => {\n if (this._segmentApi.config.logging) {\n console.log('Segment track success.');\n }\n }\n );\n }\n }\n\n private changeUser(api: SegmentAnalytics.AnalyticsJS, user: Maybe<DbxAnalyticsUser>): void {\n if (user?.user) {\n api.identify(\n user.user,\n {\n ...user.properties\n },\n {},\n () => {\n if (this._segmentApi.config.logging) {\n console.log('Segment identify success.');\n }\n }\n );\n } else {\n api.reset();\n }\n }\n}\n","import { type EnvironmentProviders, Injector, makeEnvironmentProviders, type Provider } from '@angular/core';\nimport { DbxAnalyticsSegmentApiService, DbxAnalyticsSegmentApiServiceConfig, PRELOAD_SEGMENT_TOKEN } from './segment.service';\n\nexport type DbxAnalyticsSegmentApiServiceConfigFactory = (injector: Injector) => DbxAnalyticsSegmentApiServiceConfig;\n\n/**\n * Configuration for provideDbxAnalyticsSegmentApiService()\n */\nexport interface ProvideDbxAnalyticsSegmentModuleConfig {\n readonly preloadSegmentToken?: boolean;\n readonly dbxAnalyticsSegmentApiServiceConfigFactory: DbxAnalyticsSegmentApiServiceConfigFactory;\n}\n\n/**\n * Creates a EnvironmentProviders that provides a DbxAnalyticsSegmentApiService.\n *\n * @param config Configuration\n * @returns EnvironmentProviders\n */\nexport function provideDbxAnalyticsSegmentApiService(config: ProvideDbxAnalyticsSegmentModuleConfig): EnvironmentProviders {\n const { preloadSegmentToken, dbxAnalyticsSegmentApiServiceConfigFactory } = config;\n\n const providers: Provider[] = [\n // configuration\n {\n provide: DbxAnalyticsSegmentApiServiceConfig,\n useFactory: dbxAnalyticsSegmentApiServiceConfigFactory,\n deps: [Injector]\n },\n // service\n DbxAnalyticsSegmentApiService\n ];\n\n if (preloadSegmentToken) {\n providers.push({\n provide: PRELOAD_SEGMENT_TOKEN,\n useValue: preloadSegmentToken\n });\n }\n\n return makeEnvironmentProviders(providers);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;IAGY;AAAZ,CAAA,UAAY,2BAA2B,EAAA;AACrC,IAAA,2BAAA,CAAA,2BAAA,CAAA,UAAA,CAAA,GAAA,CAAA,CAAA,GAAA,UAAQ;AACR;;;;AAIG;AACH,IAAA,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AAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kCAAkC,cAFjC,MAAM,EAAA,CAAA;;2FAEP,kCAAkC,EAAA,UAAA,EAAA,CAAA;kBAH9C,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACED;;;;;AAKG;AACG,SAAU,oCAAoC,CAAC,MAA8C,EAAA;AACjG,IAAA,MAAM,EAAE,mBAAmB,EAAE,0CAA0C,EAAE,GAAG,MAAM;AAElF,IAAA,MAAM,SAAS,GAAe;;AAE5B,QAAA;AACE,YAAA,OAAO,EAAE,mCAAmC;AAC5C,YAAA,UAAU,EAAE,0CAA0C;YACtD,IAAI,EAAE,CAAC,QAAQ;AAChB,SAAA;;QAED;KACD;IAED,IAAI,mBAAmB,EAAE;QACvB,SAAS,CAAC,IAAI,CAAC;AACb,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE;AACX,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,wBAAwB,CAAC,SAAS,CAAC;AAC5C;;ACzCA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@dereekb/dbx-analytics",
3
- "version": "13.2.1",
3
+ "version": "13.3.0",
4
4
  "peerDependencies": {
5
- "@dereekb/rxjs": "13.2.1",
5
+ "@dereekb/rxjs": "13.3.0",
6
6
  "rxjs": "^7.8.0",
7
7
  "@angular/core": "^21.0.0",
8
- "@dereekb/dbx-core": "13.2.1",
9
- "@dereekb/util": "13.2.1",
10
- "@dereekb/browser": "13.2.1"
8
+ "@dereekb/dbx-core": "13.3.0",
9
+ "@dereekb/util": "13.3.0",
10
+ "@dereekb/browser": "13.3.0"
11
11
  },
12
12
  "dependencies": {
13
13
  "tslib": "^2.3.0"
@@ -183,6 +183,11 @@ declare class DbxAnalyticsActionModule {
183
183
  static ɵinj: i0.ɵɵInjectorDeclaration<DbxAnalyticsActionModule>;
184
184
  }
185
185
 
186
+ /**
187
+ * Factory function that creates a {@link DbxAnalyticsServiceConfiguration} using the Angular injector.
188
+ *
189
+ * Used by {@link provideDbxAnalyticsService} to defer configuration resolution to runtime.
190
+ */
186
191
  type DbxAnalyticsServiceConfigurationFactory = (injector: Injector) => DbxAnalyticsServiceConfiguration;
187
192
  /**
188
193
  * Configuration for provideDbxAnalyticsService()
@@ -204,9 +209,33 @@ declare function provideDbxAnalyticsService(config: ProvideDbxAnalyticsConfig):
204
209
  declare class DbxAnalyticsSegmentServiceListener extends AbstractDbxAnalyticsServiceListener {
205
210
  private readonly _segmentApi;
206
211
  constructor();
212
+ /**
213
+ * Subscribes to the Segment API service and analytics event stream, forwarding events to the Segment SDK.
214
+ *
215
+ * Events are only sent when the Segment configuration is marked as active.
216
+ */
207
217
  protected _initializeServiceSubscription(): rxjs.Subscription;
218
+ /**
219
+ * Routes an analytics stream event to the appropriate Segment API method based on event type.
220
+ *
221
+ * @param api - The Segment analytics SDK instance
222
+ * @param streamEvent - The analytics event to process
223
+ */
208
224
  protected handleStreamEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void;
225
+ /**
226
+ * Handles a new user registration event by identifying the user in Segment.
227
+ *
228
+ * @param api - The Segment analytics SDK instance
229
+ * @param streamEvent - The event containing the new user data
230
+ */
209
231
  protected updateWithNewUserEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent): void;
232
+ /**
233
+ * Sends a track event to Segment with the event name, value, and additional data properties.
234
+ *
235
+ * @param api - The Segment analytics SDK instance
236
+ * @param streamEvent - The analytics event containing name, value, and data
237
+ * @param name - Optional override for the event name
238
+ */
210
239
  protected updateWithEvent(api: SegmentAnalytics.AnalyticsJS, streamEvent: DbxAnalyticsStreamEvent, name?: string): void;
211
240
  private changeUser;
212
241
  static ɵfac: i0.ɵɵFactoryDeclaration<DbxAnalyticsSegmentServiceListener, never>;