1.1.16 • Published 2 years ago

ngx-vectranalytics-client v1.1.16

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Usage

To install and use the client in any existing projects, do the following steps:

  1. Install the Analytics Client via npm:
npm install ngx-vectranalytics-client
  1. Load the Analytics Module in your root app.module.ts file:
@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [

    VectranalyticsClientModule.forRoot({
      appName: 'Demo',
      version: '1.0',
      environment: 'Dev',
      deviceId: 'IMEI or IP',
      serviceUrl: 'https://xxx.xxxxx.xxx/api/analytics'
    })

  ],
  providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }
  1. Use the AnalyticsService service wherever needed, this will be made available via dependency injection:
constructor(private analytics: AnalyticsService) { }
  1. On logon, set the identity. There is an AnalyticsIdentityBase interface that can be extended with custom fields. As long as the userId is used:
export interface AuthModel extends AnalyticsIdentityBase {
  // userId: string <-- field in base interface
  customfield2: string
  customfield3: string
}

await this.analytics.setIdentity(this.auth)
  1. To log an action, use the code below. A session will be created if it does not already exist.
await this.analytics.logAction({
  module: {
    moduleName: 'Module Name',
    // sectionName: 'Section Name' <-- This is optional
  },
  actionName: 'Action Name'
})
  1. To start a session manually, use the code below. If there is an open session in the module / section, it will be ended automatically. It will also be linked to the current session if open.
await this.analytics.startSession({
  moduleName: 'Module Name',
  // sectionName: 'Section Name' <-- This is optional
})
  1. To end a session, use the code below. Any child sessions linked to the session will also be ended.
await this.analytics.endSession({
  moduleName: 'Module Name',
  // sectionName: 'Section Name' <-- This is optional
})
  1. The version can be set by using the setVersion method.
await this.analytics.setVersion('1.0')
  1. The device ID can be set by using the setDeviceId method.
await this.analytics.setDeviceId('IMEI or IP')

Notes:

  1. Logging an action will automatically create a session if it does not already exist.
  2. Only 1 session will be tracked per module / section combination. If a new session is created, any existing sessions in that module / section combination will be ended automatically.
  3. If a new session is started from an existing open session, they will be linked as a parent / child session. Closing parent sessions will automatically close child sessions.
1.1.12

2 years ago

1.1.11

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.10

2 years ago

1.1.1

2 years ago

1.0.2

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.1.7

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.0.7

2 years ago

1.1.5

2 years ago

1.0.6

2 years ago

1.1.4

2 years ago

1.0.5

2 years ago

1.1.3

2 years ago

1.0.4

2 years ago

1.1.2

2 years ago

1.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago