diff --git a/src/main/java/com/dynatrace/openkit/protocol/Beacon.java b/src/main/java/com/dynatrace/openkit/protocol/Beacon.java index a6841acd..4aac999a 100644 --- a/src/main/java/com/dynatrace/openkit/protocol/Beacon.java +++ b/src/main/java/com/dynatrace/openkit/protocol/Beacon.java @@ -859,7 +859,7 @@ private void generateSendEventPayload(EventPayloadBuilder builder) { .addNonOverridableAttribute(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(configuration.getOpenKitConfiguration().getPercentEncodedApplicationID())) .addNonOverridableAttribute(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(deviceID))) .addNonOverridableAttribute(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(getSessionNumber()))) - .addNonOverridableAttribute("dt.rum.schema_version", JSONStringValue.fromString("1.0")) + .addNonOverridableAttribute("dt.rum.schema_version", JSONStringValue.fromString("1.1")) .addOverridableAttribute(EventPayloadAttributes.APP_VERSION, JSONStringValue.fromString(configuration.getOpenKitConfiguration().getApplicationVersion())) .addOverridableAttribute(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString(configuration.getOpenKitConfiguration().getOperatingSystem())) .addOverridableAttribute(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString(configuration.getOpenKitConfiguration().getManufacturer())) @@ -909,12 +909,6 @@ public void sendBizEvent(String type, Map attributes) { builder.addNonOverridableAttribute(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString(EVENT_KIND_BIZ)); - if (attributes != null && attributes.containsKey("event.name")) { - builder.addNonOverridableAttribute("event.name", attributes.get("event.name")); - } else { - builder.addNonOverridableAttribute("event.name", JSONStringValue.fromString(type)); - } - sendEventPayload(builder); } diff --git a/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java b/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java index 9ed1f6a3..a450b95e 100644 --- a/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java +++ b/src/test/java/com/dynatrace/openkit/protocol/BeaconTest.java @@ -1305,7 +1305,6 @@ public void sendValidBizEvent() { actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1313,7 +1312,7 @@ public void sendValidBizEvent() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(62)); // then @@ -1329,50 +1328,6 @@ public void sendValidBizEvent() { ); } - @Test - public void sendBizEventWithNameInAttributes(){ - // given - final Beacon target = createBeacon().build(); - String appVersion = "1111"; - when(mockOpenKitConfiguration.getApplicationVersion()).thenReturn(appVersion); - String eventType = "SomeType"; - - HashMap attributes = new HashMap<>(); - attributes.put("event.name", JSONStringValue.fromString("Test")); - - // when - target.sendBizEvent(eventType, attributes); - - HashMap actualAttributes = new HashMap<>(); - actualAttributes.put("event.type", JSONStringValue.fromString(eventType)); - - actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); - actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString("Test")); - actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); - actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); - actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); - actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); - actualAttributes.put(EventPayloadAttributes.APP_VERSION, JSONStringValue.fromString(appVersion)); - actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); - actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); - actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); - actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(45)); - - // then - String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); - String expectedEventData = - "et=98&" + // event type - "pl=" + encodedPayload // event payload - ; - verify(mockBeaconCache, times(1)).addEventData( - eq(new BeaconKey(SESSION_ID, SESSION_SEQ_NO)), // beacon key - eq(0L), // event timestamp - argThat(new EventPayloadMatcher(expectedEventData)) - ); - } - @Test public void sendBizEventWithEventProviderInAttributes(){ // given @@ -1392,7 +1347,6 @@ public void sendBizEventWithEventProviderInAttributes(){ actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString("Test")); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); @@ -1401,7 +1355,7 @@ public void sendBizEventWithEventProviderInAttributes(){ actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(49)); // then @@ -1438,7 +1392,6 @@ public void sendBizEventWithTypeAndDtTypeInAttributes(){ actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1446,7 +1399,7 @@ public void sendBizEventWithTypeAndDtTypeInAttributes(){ actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(45)); // then @@ -1487,7 +1440,6 @@ public void sendBizEventWithDtRumSchemaVersionInAttributes(){ actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1495,7 +1447,7 @@ public void sendBizEventWithDtRumSchemaVersionInAttributes(){ actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(56)); // then @@ -1535,7 +1487,6 @@ public void sendBizEventWithDtRumCustomAttributeSizeInAttributes(){ actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1543,7 +1494,7 @@ public void sendBizEventWithDtRumCustomAttributeSizeInAttributes(){ actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -1604,7 +1555,6 @@ public void sendBizEventWithEmptyPayload() { actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1612,7 +1562,7 @@ public void sendBizEventWithEmptyPayload() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(25)); // then @@ -1646,7 +1596,6 @@ public void sendBizEventWithNullPayload() { actualAttributes.put(EventPayloadAttributes.TIMESTAMP, JSONNumberValue.fromLong(0)); actualAttributes.put(EventPayloadAttributes.EVENT_KIND, JSONStringValue.fromString("BIZ_EVENT")); actualAttributes.put(EventPayloadAttributes.EVENT_PROVIDER, JSONStringValue.fromString(APP_ID)); - actualAttributes.put("event.name", JSONStringValue.fromString(eventType)); actualAttributes.put(EVENT_PAYLOAD_APPLICATION_ID, JSONStringValue.fromString(APP_ID)); actualAttributes.put(EVENT_PAYLOAD_INSTANCE_ID, JSONStringValue.fromString(String.valueOf(DEVICE_ID))); actualAttributes.put(EVENT_PAYLOAD_SESSION_ID, JSONStringValue.fromString(String.valueOf(SESSION_ID))); @@ -1654,7 +1603,7 @@ public void sendBizEventWithNullPayload() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); actualAttributes.put("dt.rum.custom_attributes_size", JSONNumberValue.fromLong(25)); // then @@ -1770,7 +1719,7 @@ public void sendValidEvent() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -1814,7 +1763,7 @@ public void sendEventWithDtType() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -1859,7 +1808,7 @@ public void sendEventWithEventProviderInAttributes() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -1901,7 +1850,7 @@ public void sendEventWithDtRumSchemaInAttributes() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -1973,7 +1922,7 @@ public void sendEventWithEmptyPayload() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS); @@ -2013,7 +1962,7 @@ public void sendEventWithNullPayload() { actualAttributes.put(EventPayloadAttributes.OS_NAME, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MANUFACTURER, JSONStringValue.fromString("")); actualAttributes.put(EventPayloadAttributes.DEVICE_MODEL_IDENTIFIER, JSONStringValue.fromString("")); - actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.0")); + actualAttributes.put("dt.rum.schema_version", JSONStringValue.fromString("1.1")); // then String encodedPayload = PercentEncoder.encode(JSONObjectValue.fromMap(actualAttributes).toString(), Beacon.CHARSET, Beacon.RESERVED_CHARACTERS);