Skip to content

Commit

Permalink
Override collect url (#52)
Browse files Browse the repository at this point in the history
* Added override collect dispatch url to init method

* Updated sample app version

* Update podfile.lock

* Changed order of params in init custom

* TypeScript updates (#53)

* ts allow nulls

* readme + changelog updates

Co-authored-by: Christina <[email protected]>
Co-authored-by: jameskeith <[email protected]>
  • Loading branch information
3 people authored Apr 28, 2020
1 parent b3d6e85 commit ed4c36f
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 39 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

- 1.0.10
- Added Collect Dispatch URL to the `initializeCustom` method
- Enabled `null` in TypeScript definition for parameters that accept it
- Fixed TypeScript definition for Remote Command methods
- 1.0.9
- Bug fix
- Removed duplicate default keywords from Typescript definitions file
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
## Tealium React Native

This repository contains the necessary assets for exposing Tealium's native [Android](https://community.tealiumiq.com/t5/Tealium-for-Android/tkb-p/android-documentation) and [iOS](https://community.tealiumiq.com/t5/Tealium-for-iOS/tkb-p/ios-documentation) mobile libraries to the JavaScript code in your React Native project. This includes code for exposing the native APIs for both platforms through React Native's bridging system, and a basic helper class in JavaScript to create a single cross platform API.
This repository contains the necessary assets for exposing Tealium's native [Android](https://docs.tealium.com/platforms/android-java/) and [iOS](https://docs.tealium.com/platforms/ios-objective-c/) mobile libraries to the JavaScript code in your React Native project. This includes code for exposing the native APIs for both platforms through React Native's bridging system, and a basic helper class in JavaScript to create a single cross platform API.

Because including the respective libraries for Android and iOS means working with platform specific code, you will need access to your native build environments. For example you will need to "[eject](https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md)" if you're using [Create React Native App](https://github.com/react-community/create-react-native-app) and haven't done so already. Including the mobile libraries works no differently than in any other Android or iOS project. Therefore any non React Native specific documentation in the [Tealium Learning Community](https://community.tealiumiq.com/) regarding the mobile libraries is still relevant, and at times you may be directed to it from our React Native documentation. For this reason the mobile libraries themselves aren't distributed in this repository, and are meant to be acquired through the usual methods described for [Android](https://community.tealiumiq.com/t5/Tealium-for-Android/Adding-Tealium-to-Your-Android-App/ta-p/16846) and [iOS](https://community.tealiumiq.com/t5/Tealium-for-iOS/Adding-Tealium-to-Your-iOS-App/ta-p/16327).

You can also find a sample application demonstrating how everything is put together and how the API gets called in JavaScript, with instructions in the Tealium Learning Community.
You can also find a sample application demonstrating how everything is put together and how the API gets called in JavaScript.

## Documentation
For full documentation, please see the Tealium Learning Community:
For full documentation, please see the Tealium Developer Docs website:

[Tealium React Native Documentation on TLC](https://community.tealiumiq.com/t5/Mobile-Libraries/Tealium-for-React-Native/ta-p/22449)
[Tealium React Native Documentation](https://docs.tealium.com/platforms/react-native/install/)

## License

Expand Down
2 changes: 1 addition & 1 deletion TealiumSampleApp/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export default class App extends React.Component {
Tealium.initializeCustom(
'tealiummobile', 'react-native', 'qa',
'your-ios-datasource', 'your-android-datasource', 'instance-2',
true, null, null, true, true
true, null, null, true, false, 'https://your.custom.endpoint/here'
);
}

Expand Down
6 changes: 3 additions & 3 deletions TealiumSampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ PODS:
- React-cxxreact (= 0.61.3)
- React-jsi (= 0.61.3)
- ReactCommon/jscallinvoker (= 0.61.3)
- tealium-react-native (1.0.7):
- tealium-react-native (1.0.10):
- React
- TealiumIOS (= 5.6.6)
- TealiumIOSLifecycle (= 5.6.6)
Expand Down Expand Up @@ -342,11 +342,11 @@ SPEC CHECKSUMS:
React-RCTText: b8f895b94aa0e7778fef28d13f3d71eed4a10c3d
React-RCTVibration: 262588c97551b0b1c675468cda857466ba5af18f
ReactCommon: c2c63d9290b422ca6ad5b3663073a015dd892ae9
tealium-react-native: b9f45e5242eaffb754085da8ef6764df85b08290
tealium-react-native: 04e565c1db7174dba64ae3fa53e0268e142ce9ee
TealiumIOS: 6fa0157ef4ea13ff56b576e17d90085dc2fe9c4d
TealiumIOSLifecycle: f26daa58f08ea3a76b96363b966698c5c79af6ed
Yoga: 02036f6383c0008edb7ef0773a0e6beb6ce82bd1

PODFILE CHECKSUM: 063bda2eba9e64c447cb71e6f95741b86dd5b2c6

COCOAPODS: 1.8.4
COCOAPODS: 1.9.1
2 changes: 1 addition & 1 deletion TealiumSampleApp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6111,7 +6111,7 @@ tar@^4:
yallist "^3.0.3"

tealium-react-native@../npm-package:
version "1.0.8"
version "1.0.10"

[email protected]:
version "0.8.3"
Expand Down
6 changes: 5 additions & 1 deletion android/TealiumModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void initializeCustom(String account,
String overridePublishSettingsUrl,
String overrideTagManagementUrl,
boolean enableCollectUrl,
boolean enableConsentManager) {
boolean enableConsentManager,
String overrideCollectDispatchUrl) {

if (account == null || profile == null || environment == null) {
throw new IllegalArgumentException("Account, profile, and environment parameters must be provided and non-null");
Expand All @@ -156,6 +157,9 @@ public void initializeCustom(String account,
if (overrideTagManagementUrl != null) {
config.setOverrideTagManagementUrl(overrideTagManagementUrl);
}
if (overrideCollectDispatchUrl != null) {
config.setOverrideCollectDispatchUrl(overrideCollectDispatchUrl);
}
if (!enableCollectUrl) {
config.setVdataCollectEndpointEnabled(true);
}
Expand Down
8 changes: 6 additions & 2 deletions ios/TealiumModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ @implementation TealiumModule
overrideTagManagementURL:(NSString *)overrideTagManagementURL
collectURL:(BOOL)enableCollectURL
enableConsentManager:(BOOL)enableConsentManager
overrideCollectDispatchURL:(NSString *)overrideCollectDispatchURL
) {
// Set your account, profile, and environment
TEALConfiguration *configuration = [TEALConfiguration configurationWithAccount:account
Expand All @@ -99,6 +100,9 @@ @implementation TealiumModule
if (overrideTagManagementURL) {
configuration.overrideTagManagementURL = overrideTagManagementURL;
}
if (overrideCollectDispatchURL) {
configuration.overrideCollectDispatchURL = overrideCollectDispatchURL;
}
if (!enableCollectURL) {
configuration.collectURL = TEALCollectURLVdata;
}
Expand Down Expand Up @@ -274,10 +278,10 @@ @implementation TealiumModule
}

RCT_EXPORT_METHOD(isConsentLoggingEnabled:(RCTResponseSenderBlock)callback) {
[self isConsentLoggingEnabledForInstance:tealiumInternalInstanceName callback:callback];
[self isConsentLoggingEnabledForInstanceName:tealiumInternalInstanceName callback:callback];
}

RCT_EXPORT_METHOD(isConsentLoggingEnabledForInstance:(NSString *)instanceName callback:(RCTResponseSenderBlock)callback) {
RCT_EXPORT_METHOD(isConsentLoggingEnabledForInstanceName:(NSString *)instanceName callback:(RCTResponseSenderBlock)callback) {
Tealium *tealium = [Tealium instanceForKey:instanceName];
[[tealium consentManager] isConsentLoggingEnabled];
}
Expand Down
13 changes: 2 additions & 11 deletions npm-package/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# tealium-react-native

This package provides a native module for React Native apps giving access to Tealium's native libraries for Android and iOS, exposed through a common JavaScript api. More information can be found in the [Tealium Learning Community document](https://community.tealiumiq.com/t5/Mobile-Libraries/Tealium-for-React-Native/ta-p/22449).
This package provides a native module for React Native apps giving access to Tealium's native libraries for Android and iOS, exposed through a common JavaScript API. More information can be found in the [Tealium Developer Docs](https://docs.tealium.com/platforms/react-native/).

## Installation

In the root of your React Native project, run the following:

```console
npm install tealium-react-native
react-native link
```

The first command will download the `tealium-react-native` package and install it to your project.

The second command will link the native dependencies within the module to your main React Native app so that it can build against the module.
For installation instructions, please refer to the installation guide found on the Tealium Developer Docs website [here](https://docs.tealium.com/platforms/react-native/install/)
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ public void initializeCustom(String account,
String overridePublishSettingsUrl,
String overrideTagManagementUrl,
boolean enableCollectUrl,
boolean enableConsentManager) {
boolean enableConsentManager,
String overrideCollectDispatchUrl) {

if (account == null || profile == null || environment == null) {
throw new IllegalArgumentException("Account, profile, and environment parameters must be provided and non-null");
Expand All @@ -156,6 +157,9 @@ public void initializeCustom(String account,
if (overrideTagManagementUrl != null) {
config.setOverrideTagManagementUrl(overrideTagManagementUrl);
}
if (overrideCollectDispatchUrl != null) {
config.setOverrideCollectDispatchUrl(overrideCollectDispatchUrl);
}
if (!enableCollectUrl) {
config.setVdataCollectEndpointEnabled(true);
}
Expand Down
26 changes: 16 additions & 10 deletions npm-package/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ declare module 'tealium-react-native' {
account: string,
profile = string,
environment: string,
iosDataSource?: string,
androidDataSource?: string,
iosDataSource?: string | null,
androidDataSource?: string | null,
): void;

/**
Expand All @@ -38,8 +38,8 @@ declare module 'tealium-react-native' {
account: string,
profile = string,
environment: string,
iosDataSource?: string,
androidDataSource?: string,
iosDataSource?: string | null,
androidDataSource?: string | null,
): void;

/**
Expand All @@ -55,19 +55,21 @@ declare module 'tealium-react-native' {
* @param overrideTagManagementUrl String representing the tag management URL if overriding, otherwise null (default: null)
* @param enableCollectEndpoint True sends data to the Collect endpoint (default: true)
* @param enableConsentManager True enables Consent Management
* @param overrideCollectDispatchURL String representing the HTTP endpoint to send all event data (default: null)
*/
static initializeCustom(
account: string,
profile = string,
environment: string,
iosDataSource?: string,
androidDataSource?: string,
iosDataSource?: string | null,
androidDataSource?: string | null,
instance: string,
enableLifeCycle = boolean,
overridePublishSettingsUrl: string,
overrideTagManagementUrl: string,
overridePublishSettingsUrl: string | null,
overrideTagManagementUrl: string | null,
enableCollectEndpoint = boolean,
enableConsentManager = boolean,
overrideCollectDispatchURL: string | null
): void;

/**
Expand Down Expand Up @@ -344,27 +346,31 @@ declare module 'tealium-react-native' {

/**
* Adds a remote command to the remote command manager.
* Don't forget to subscribe to the `RemoteCommandEvent` emitter.
*
* @param commandID Name of the Remote Command (if using TiQ, this is whatever is in the tag config)
* @param description A description of the remote command
* @param callback Callback to execute with the Remote Command payload
*/
static addRemoteCommand(
commandID: string,
description: string,
callback: (payload: object) => void
): void;

/**
* Adds a remote command to the remote command manager.
* Don't forget to subscribe to the `RemoteCommandEvent` emitter.
*
* This method should be used if you have multiple instances of Tealium in your app.
* @param instanceName Name of the Tealium instance
* @param commandID Name of the Remote Command (if using TiQ, this is whatever is in the tag config)
* @param description A description of the remote command
* @param callback Callback to execute with the Remote Command payload
*/
static addRemoteCommandForInstanceName(
instanceName: string,
commandID: string,
description: string,
callback: (payload: object) => void
): void;


Expand Down
6 changes: 4 additions & 2 deletions npm-package/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export default class Tealium {
overridePublishSettingsURL,
overrideTagManagementURL,
collectURL,
enableConsentManager
enableConsentManager,
overrideCollectDispatchURL
) {
TealiumModule.initializeCustom(
account,
Expand All @@ -72,7 +73,8 @@ export default class Tealium {
overridePublishSettingsURL,
overrideTagManagementURL,
collectURL,
enableConsentManager
enableConsentManager,
overrideCollectDispatchURL
);
this.addRemoteCommandListener('RemoteCommandEvent');
}
Expand Down
4 changes: 4 additions & 0 deletions npm-package/ios/TealiumModule/TealiumModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ @implementation TealiumModule
overrideTagManagementURL:(NSString *)overrideTagManagementURL
collectURL:(BOOL)enableCollectURL
enableConsentManager:(BOOL)enableConsentManager
overrideCollectDispatchURL:(NSString *)overrideCollectDispatchURL
) {
// Set your account, profile, and environment
TEALConfiguration *configuration = [TEALConfiguration configurationWithAccount:account
Expand All @@ -99,6 +100,9 @@ @implementation TealiumModule
if (overrideTagManagementURL) {
configuration.overrideTagManagementURL = overrideTagManagementURL;
}
if (overrideCollectDispatchURL) {
configuration.overrideCollectDispatchURL = overrideCollectDispatchURL;
}
if (!enableCollectURL) {
configuration.collectURL = TEALCollectURLVdata;
}
Expand Down
2 changes: 1 addition & 1 deletion npm-package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tealium-react-native",
"version": "1.0.9",
"version": "1.0.10",
"description": "A native module for using Tealium's Android and iOS libraries from a React Native app.",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit ed4c36f

Please sign in to comment.