Skip to content

Commit

Permalink
Release/2.1.2 (#92)
Browse files Browse the repository at this point in the history
* Release/2.1.2

* Clean up package.json

* Support to retrieve Session Id (#93)

Co-authored-by: Karen Tamayo <karentamayo@Karens-MacBook-Pro.local>

Co-authored-by: Karen Tamayo <karentamayo@Karens-MacBook-Pro.local>
  • Loading branch information
tamayok and Karen Tamayo authored Aug 9, 2021
1 parent 489e10b commit 1d5c06e
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 354 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Use of this software is subject to the terms and conditions of the license agree


---
Copyright (C) 2012-2018, Tealium Inc.
Copyright (C) 2012-2021, Tealium Inc.
13 changes: 12 additions & 1 deletion example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class App extends Component < {} > {
});
}

trackEvent() {
trackEvent() {
let event = new TealiumEvent('Test Event', {'event_name': 'test'});
Tealium.track(event);
}
Expand Down Expand Up @@ -156,6 +156,13 @@ export default class App extends Component < {} > {
});
}

getSessionId() {
Tealium.getSessionId(value => {
console.log("Session id: " + value)
Alert.alert("Session Id: ", value, [{ text: "OK", style: "cancel" }])
});
}

terminate() {
Tealium.terminateInstance();
}
Expand Down Expand Up @@ -226,6 +233,10 @@ export default class App extends Component < {} > {
<Text style={styles.textStyle}>GET VISITOR ID</Text>
</TouchableOpacity>
<View style={styles.space} />
<TouchableOpacity style={styles.buttonContainer} onPress={this.getSessionId}>
<Text style={styles.textStyle}>GET SESSION ID</Text>
</TouchableOpacity>
<View style={styles.space} />
<TouchableOpacity style={styles.buttonContainer} onPress={this.terminate}>
<Text style={styles.textStyle}>DISABLE TEALIUM</Text>
</TouchableOpacity>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

672 changes: 328 additions & 344 deletions example/yarn.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions npm-package/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'kotlin-android'

version = "2.1.1"
version = "2.1.2"
android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
Expand Down Expand Up @@ -99,12 +99,12 @@ dependencies {
implementation 'com.facebook.react:react-native:+' // From node_modules

//Tealium
implementation 'com.tealium:kotlin-core:1.2.5'
implementation 'com.tealium:kotlin-collect-dispatcher:1.0.4'
implementation 'com.tealium:kotlin-tagmanagement-dispatcher:1.0.5'
implementation 'com.tealium:kotlin-core:1.2.6'
implementation 'com.tealium:kotlin-collect-dispatcher:1.0.5'
implementation 'com.tealium:kotlin-tagmanagement-dispatcher:1.0.6'
implementation 'com.tealium:kotlin-remotecommand-dispatcher:1.0.4'
implementation 'com.tealium:kotlin-lifecycle:1.0.4'
implementation 'com.tealium:kotlin-visitor-service:1.0.4'
implementation 'com.tealium:kotlin-lifecycle:1.0.5'
implementation 'com.tealium:kotlin-visitor-service:1.0.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${project.ext.kotlinVersion}"

testImplementation 'com.facebook.react:react-native:+'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const val EVENT_EMITTERS_CONSENT_EXPIRED = "TealiumReactNative.ConsentExpiredEve
const val KEY_CONFIG_ACCOUNT: String = "account"
const val KEY_CONFIG_PROFILE: String = "profile"
const val KEY_CONFIG_ENV: String = "environment"
const val KEY_CONFIG_CUSTOM_VISITOR_ID = "customVisitorId"
const val KEY_CONFIG_DATA_SOURCE: String = "dataSource"
const val KEY_CONFIG_COLLECTORS: String = "collectors"
const val KEY_CONFIG_MODULES: String = "modules"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ fun ReadableMap.toTealiumConfig(application: Application): TealiumConfig? {
dataSourceId = it
}

// Existing visitor id
safeGetString(KEY_CONFIG_CUSTOM_VISITOR_ID)?.let {
existingVisitorId = it
}

// Collect Settings
safeGetString(KEY_COLLECT_OVERRIDE_URL)?.let {
overrideCollectUrl = it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,9 @@ class TealiumReact(private val reactContext: ReactApplicationContext) : ReactCon
fun getVisitorId(callback: Callback) {
callback.invoke(tealium?.visitorId ?: "")
}

@ReactMethod
fun getSessionId(callback: Callback){
callback(tealium?.session?.id.toString())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ExtensionsTests {

// Optional params
readableMap.putString(KEY_CONFIG_ENV, "dev")
readableMap.putString(KEY_CONFIG_CUSTOM_VISITOR_ID, "testVisitorId")
readableMap.putString(KEY_CONFIG_DATA_SOURCE, "dataSource")
readableMap.putString(KEY_COLLECT_OVERRIDE_DOMAIN, "domain")
readableMap.putString(KEY_COLLECT_OVERRIDE_URL, "url.domain")
Expand All @@ -115,6 +116,7 @@ class ExtensionsTests {
assertEquals("test-profile", config?.profileName)
assertEquals(Environment.DEV, config?.environment)

assertEquals("testVisitorId", config?.existingVisitorId)
assertEquals("dataSource", config?.dataSourceId)
assertEquals("domain", config?.overrideCollectDomain)
assertEquals("url.domain", config?.overrideCollectUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,17 @@ class TealiumReactTests {
}
}

@Test
fun getSessionId_CallsCallback() {
every { mockTealium.session.id } returns 12345

tealiumReact.getSessionId(mockCallback)

verify {
mockCallback.invoke("12345")
}
}

private class TestRemoteCommandFactory(
override val name: String = "factory_command"
) : RemoteCommandFactory {
Expand Down
5 changes: 5 additions & 0 deletions npm-package/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ declare module 'tealium-react-native' {
*/
public static getVisitorId(callback: (response: string) => void): void;

/**
* Retrieves the Tealium Session ID
*/
public static getSessionId(callback: (response: string) => void): void;

/**
* Initializes the Tealium SDK
* @param config Config options to change SDK behavior
Expand Down
6 changes: 5 additions & 1 deletion npm-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Tealium {
});
}
TealiumWrapper.initialize(config, callback || (response => {}));
TealiumWrapper.addToDataLayer({'plugin_name': 'Tealium-ReactNative', 'plugin_version': '2.1.1'}, Expiry.forever);
TealiumWrapper.addToDataLayer({'plugin_name': 'Tealium-ReactNative', 'plugin_version': '2.1.2'}, Expiry.forever);
if (config["dispatchers"].includes(Dispatchers.RemoteCommands)) {
this.setRemoteCommandListener();
}
Expand Down Expand Up @@ -71,6 +71,10 @@ export default class Tealium {
TealiumWrapper.getVisitorId(callback);
}

static getSessionId(callback) {
TealiumWrapper.getSessionId(callback);
}

static setVisitorServiceListener(callback) {
const visitor = this.emitter.addListener(EventListenerNames.visitor, profile => {
callback(profile);
Expand Down
2 changes: 2 additions & 0 deletions npm-package/ios/TealiumReactNative.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ @interface RCT_EXTERN_MODULE(TealiumWrapper, NSObject)

RCT_EXTERN_METHOD(getVisitorId:(RCTResponseSenderBlock)callback)

RCT_EXTERN_METHOD(getSessionId:(RCTResponseSenderBlock)callback)

@end

@interface RCT_EXTERN_MODULE(TealiumReactNative, RCTEventEmitter)
Expand Down
7 changes: 7 additions & 0 deletions npm-package/ios/TealiumReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class TealiumReactNative: RCTEventEmitter {
}
}

@objc
public static var sessionId: String? {
get {
tealium?.dataLayer.sessionId
}
}

override init() {
super.init()
EventEmitter.shared.registerEventEmitter(eventEmitter: self)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>TealiumReactNative.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
7 changes: 7 additions & 0 deletions npm-package/ios/TealiumWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,11 @@ class TealiumWrapper: NSObject {
callback([visitorId])
}

@objc(getSessionId:)
public func getSessionId(_ callback: RCTResponseSenderBlock) {
guard let sessionId = TealiumReactNative.sessionId else {
return
}
callback([sessionId])
}
}
2 changes: 1 addition & 1 deletion npm-package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tealium-react-native",
"title": "Tealium React Native",
"version": "2.1.1",
"version": "2.1.2",
"description": "A native module for using Tealium's Kotlin and Swift libraries.",
"main": "index.js",
"types": "*.ts",
Expand Down

0 comments on commit 1d5c06e

Please sign in to comment.