Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ AudienceStream™ allows you to create a unified view of your customers, correla
* If you have **account specific questions** please contact your Tealium account manager

## Change Log

- 1.3.2 Persistent Data Deletion
- `deletePersistentData` method added to the `DataManager` class
- 1.3.1 Persistent Data
- Updated track method to use a copy of Persistent Data to stop event data unexpectedly being stored.
- 1.3.0 Remove visitor_id and switch to event endpoint
Expand Down Expand Up @@ -74,4 +77,4 @@ Use of this software is subject to the terms and conditions of the license agree


---
Copyright (C) 2012-2021, Tealium Inc.
Copyright (C) 2012-2024, Tealium Inc.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.tealium</groupId>
<artifactId>java</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<name>TealiumJava</name>

<packaging>jar</packaging>
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/tealium/DataManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tealium;

import java.security.SecureRandom;
import java.util.List;
import java.util.Random;

/**
Expand Down Expand Up @@ -74,6 +75,19 @@ public void addPersistentData(Udo data) throws UdoSerializationException {
this.persistentData.writeData(persistent);
}

/**
* Convenience to remove specific keys from the persistent data map
*
* @param keys The list of keys to be removed.
*/
public void deletePersistentData(List<String> keys) throws UdoSerializationException {
Udo persistent = getPersistentData();
for (String key : keys) {
persistent.remove(key);
}
this.persistentData.writeData(persistent);
}

/**
* Convenience to reset session ID
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tealium/LibraryContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Jason Koo, Chad Hartman, Karen Tamayo, Merritt Tidwell, Chris Anderberg
*/
class LibraryContext {
public static final String version = "1.3.1";
public static final String version = "1.3.2";

private final String account;
private final String profile;
Expand Down
43 changes: 36 additions & 7 deletions src/test/java/com/tealium/DataManagerTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* Jason Koo, Chad Hartman, Karen Tamayo, Merritt Tidwell, Chris Anderberg
*/
public class DataManagerTests {

@Test
public void testInit() throws Exception {
TestLibraryContext testCtx = TestLibraryContext.newInstance();
Expand Down Expand Up @@ -49,6 +48,23 @@ public void testGetPersistentData() throws Exception {

LibraryContext ctx = TestLibraryContext.newInstance();

Udo map = new Udo();
String key = "testKey";
String value = "testValue";
map.put(key, value);

DataManager data = new DataManager(ctx, TestUtils.dummyPersistentUdo(map));
Udo savedData = data.getPersistentData();

assertTrue(savedData.containsKey(key));
assertTrue(savedData.containsValue(value));
}

@Test
public void testAddPersistentDataAddsDataToPersistentUdo() throws Exception {

LibraryContext ctx = TestLibraryContext.newInstance();

DataManager data = new DataManager(ctx, TestUtils.dummyPersistentUdo());
Udo map = new Udo();

Expand All @@ -60,17 +76,30 @@ public void testGetPersistentData() throws Exception {
// Write to disk first
data.addPersistentData(map);

Class<? extends DataManager> myclass = data.getClass();
Method method = myclass.getDeclaredMethod("getPersistentData");
method.setAccessible(true);

@SuppressWarnings("unchecked")
Udo savedData = (Udo) method.invoke(data);
Udo savedData = data.getPersistentData();

assertTrue(savedData.containsKey(key));
assertTrue(savedData.containsValue(value));
}

@Test
public void testDeletePersistentDataRemovesDataFromPersistentUdo() throws Exception {

LibraryContext ctx = TestLibraryContext.newInstance();

Udo map = new Udo();
String key = "testKey";
String value = "testValue";
map.put(key, value);

DataManager data = new DataManager(ctx, TestUtils.dummyPersistentUdo(map));
data.deletePersistentData(Collections.singletonList("testKey"));
Udo savedData = data.getPersistentData();

assertFalse(savedData.containsKey(key));
assertFalse(savedData.containsValue(value));
}

/*
* Test that new data doesn't contain visitor id or vid
* Test that new data contains expected variables
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/com/tealium/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ public Boolean exists() {
}

public static PersistentUdo dummyPersistentUdo() {
return dummyPersistentUdo(null);
}

public static PersistentUdo dummyPersistentUdo(final Udo initialUdo) {
return new PersistentUdo(null) {
private Udo udo;
private Udo udo = initialUdo;

@Override
public Udo readOrCreateUdo(Udo defaultData) {
Expand Down