diff --git a/pom.xml b/pom.xml
index dd304bf..b00a498 100644
--- a/pom.xml
+++ b/pom.xml
@@ -196,5 +196,11 @@
okhttp
4.10.0
-
+
+
+ org.apache.maven
+ maven-model
+ 3.9.6
+
+
diff --git a/src/main/java/co/novu/common/base/NovuConfig.java b/src/main/java/co/novu/common/base/NovuConfig.java
index c3a2ce4..3897fad 100644
--- a/src/main/java/co/novu/common/base/NovuConfig.java
+++ b/src/main/java/co/novu/common/base/NovuConfig.java
@@ -1,5 +1,10 @@
package co.novu.common.base;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+
+import java.io.FileReader;
+
import lombok.Getter;
import lombok.Setter;
@@ -7,10 +12,23 @@
@Setter
public class NovuConfig {
+ private String apiKey;
+ private String baseUrl = "https://api.novu.co/v1/";
+ private String sdkName;
+ private String sdkVersion;
public NovuConfig(String apiKey) {
this.apiKey = apiKey;
+ loadContextFromPom();
}
- private String apiKey;
- private String baseUrl = "https://api.novu.co/v1/";
+ private void loadContextFromPom(){
+ try {
+ MavenXpp3Reader reader = new MavenXpp3Reader();
+ Model model = reader.read(new FileReader("pom.xml"));
+ this.sdkName = model.getArtifactId();
+ this.sdkVersion = model.getVersion();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/co/novu/common/rest/RestHandler.java b/src/main/java/co/novu/common/rest/RestHandler.java
index 49c8796..c42ad4c 100644
--- a/src/main/java/co/novu/common/rest/RestHandler.java
+++ b/src/main/java/co/novu/common/rest/RestHandler.java
@@ -30,6 +30,7 @@ public Retrofit buildRetrofit() {
Request request = chain.request()
.newBuilder()
.addHeader("Authorization", "ApiKey " + novuConfig.getApiKey())
+ .addHeader("User-Agent", "novu/" + novuConfig.getSdkName() + "@" + novuConfig.getSdkVersion())
.build();
return chain.proceed(request);
}).addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC));