1. Home
  2. Docs
  3. Congether SDK and API
  4. Congether SDK
  5. Congether SDK for Angular 6+

Congether SDK for Angular 6+

Install Congether SDK for Angular 6+

The Congether SDK for Angular (Angular 6 and higher) is available as a NPM-Package here.

To install it, type following command in your terminal.

1
npm update @schnell.technology/congether-sdk-angular6

You also can find the source-code of the SDK on GitHub here. Feel free to optimize and contribute or create and share your own SDKs. For more informations on how to contribute or create SDKs for another Framework, read this docs.

Using the SDK

To start using the SDK, you have to import and register the CongetherSdkLibModule. 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import * as congether from '@schnell.technology/congether-sdk-angular6';
import { HttpModule } from '@angular/http';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    HttpModule,
    BrowserModule,
    congether.CongetherSdkLibModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

After this registration, you’re able to use the “CongetherAngularClient” as a simple Angular-service with dependency-injection.

CongetherAngularClient

The CongetherClient will initialize the application, requests the Congether Manifest for your individual installation and provide all module-based tasks.

Instantiate and initialize

1
2
3
4
5
6
import * as congether from '@schnell.technology/congether-sdk-angular6';
[...]
constructor(private congetherSvc : congether.CongetherAngularClient)
  {
    this.congetherSvc.initialize("appIdentifier","baseUrl","endpoint", "secret", "optionalDeviceIdentifier", "optionalVersion");
  }

AppIdentifier: The identifier of your application
BaseUrl: The URL, where your Congether-Service is hosted
Endpoint: Endpoint-Token
Secret: Endpoint-Secret
DeviceIdentifier (Optional): Identifier for the Device (e.g. a Serial-Number, etc.)
Version: Application Version (if null, the package-version of the package.json will be used).

Set the Privacy-Mode

By default, the privacy-mode is “pseudonymization”. 

Using Conductor

To get your Conductor Configuration-Set, which is composed individually for each installation. You can simply use the “Conductor”-Module in your CongetherAngularClient. This is the way on how to read a given parameter.

1
var value = await this.congetherSvc.conductor.getConfigurationValue("parameterKey", "defaultValue");

This will return the value of the “parameterKey” in your Configuration-Set as a string. If this parameter isn’t available or doesn’t exist, the defaultValue will be returned.

Using Tracer

To write log- or metric-events, Tracer is the module you want to use. For this case, you can use the “Tracer”-Module in your CongetherAngularClient.

This example shows you on how to create a simple log entry in Congether.

1
2
3
4
var logEntry = new EndpointLogEvent();
logEntry.identifier = "test";
logEntry.content = new VariantValue({stringValue: "Hello world!"});
await this.congetherSvc.tracer.log(logEntry);

The EndpointLogEvent contains several parameters.
Identifier: The identifier of your Tracer-Item
Content: A VariantValue, which can be contain a String, Number, Boolean or DateTime-Value
Details: A string with additional informations

The following example creates a metric entry in Congether.

1
2
var metricEvent = new EndpointMetricEvent({ identifier: "metric", value: 1.234 });
await this.congetherSvc.tracer.metric(metricEvent);

The EndpointMetricEvent contains following parameters.
Identifier: The identifier of your Tracer-Item
Value: The value of your metric

Demos and Examples

You can find the demos and examples at GitHub here.

Was this article helpful to you? Yes No

How can we help?