@segment/analytics-react-native-plugin-onetrust
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@segment/analytics-react-native-plugin-onetrust

Plugin for adding support for OneTrust CMP to your React Native application.

⚠️ version 1.2.0 and below are out of date and upgrading will require a re-implementation of the plugin configuration.

⚠️ The SDK version used must match the version of the JSON published from your OneTrust instance. This Provider was built using 202405.1.0. This is not a "plugin" as defined by the SDK's plugin-timeline architecture. Instead, it must be used with the ConsentPlugin included in the core SDK. This is deliberate as it is impossible to support every possible version of the OneTrust SDK. Therefore, the OneTrustConsentProvider should serve as a reference/example for users on a different version.

Installation

You will need to install the @segment/analytics-react-native-plugin-onetrust package as a dependency in your project:

Using NPM:

npm install --save @segment/analytics-react-native-plugin-onetrust react-native-onetrust-cmp

Using Yarn:

yarn add @segment/analytics-react-native-plugin-onetrust react-native-onetrust-cmp

Usage

Follow the instructions for adding plugins on the main Analytics client:

After you create your segment client there are a few steps you must follow to complete your One Trust integration.

  1. Initialize the OneTrust SDK:
import OTPublishersNativeSDK from 'react-native-onetrust-cmp';

...

OTPublishersNativeSDK.startSDK(
  'storageLocation',
  'domainIdentifier',
  'languageCode',
  {countryCode: 'us', regionCode:'ca'},
  true,
)
  .then((responseObject) => {
    console.info('Download status is ' + responseObject.status);
    // get full JSON object from responseObject.responseString
  })
  .catch((error) => {
    console.error(`OneTrust download failed with error ${error}`);
  });
  1. Create a new OneTrustConsentProvider and pass the OneTrust SDK to it:
import { createClient, ConsentPlugin } from '@segment/analytics-react-native';
import OTPublishersNativeSDK from 'react-native-onetrust-cmp';
import { OTCategoryConsentProvider } from '@segment/analytics-react-native-plugin-onetrust'

...

 const oneTrustProvider = new OneTrustConsentProvider(OTPublishersNativeSDK)
  1. Initialize a new ConsentPlugin and pass the OneTrustConsentProvider to it:
import OTPublishersNativeSDK from 'react-native-onetrust-cmp';
import { OneTrustConsentProvider  } from '@segment/analytics-react-native-plugin-onetrust'

...

const oneTrustProvider = new OneTrustConsentProvider(OTPublisherNativeSDK)
const oneTrustPlugin = new ConsentPlugin(oneTrustProvider);
  1. Add oneTrustPlugin as a plugin, order doesn't matter, this plugin will apply to all device mode destinations you add before and after this plugin is added.

  2. Call oneTrustPlugin.start() to start event flow.

Full example below:

import { createClient, ConsentPlugin} from '@segment/analytics-react-native';
import { OneTrustConsentProvider } from '@segment/analytics-react-native-plugin-onetrust';
import OTPublishersNativeSDK from 'react-native-onetrust-cmp';

OTPublishersNativeSDK.startSDK(
  'storageLocation',
  'domainIdentifier',
  'languageCode',
  {countryCode: 'us', regionCode:'ca'},
  true,
)
  .then((responseObject) => {
    console.info('Download status is ' + responseObject.status);
    // get full JSON object from responseObject.responseString
  })
  .catch((error) => {
    console.error(`OneTrust download failed with error ${error}`);
  });

const segment = createClient({
  writeKey: 'SEGMENT_KEY',
});


const oneTrustProvider = new OneTrustConsentProvider(OTPublisherNativeSDK)
const oneTrustPlugin = new ConsentPlugin(oneTrustProvider);

segment.add({ plugin: oneTrustPlugin });

// NOTE: You might want to wait until CMP is ready before you call start()
// so that events are held until the CMP is ready to provide the current consent status.
onetrustPlugin.start()


// device mode destinations
segment.add({ plugin: new BrazePlugin() });

Support

Please use Github issues, Pull Requests, or feel free to reach out to our support team.

Integrating with Segment

Interested in integrating your service with us? Check out our Partners page for more details.

License

MIT License

Copyright (c) 2021 Segment

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Package Sidebar

Install

npm i @segment/analytics-react-native-plugin-onetrust

Weekly Downloads

66

Version

1.2.1

License

MIT

Unpacked Size

21.7 kB

Total Files

18

Last publish

Collaborators

  • harksingh
  • fhalim-segment
  • cfree
  • ldelossantos
  • hjoonpm
  • celine-segment
  • pmcanseco-segment
  • masira
  • amillet89
  • cholt002
  • av-segment
  • aghotikar
  • vikrant-segment
  • larryatsegment
  • scruwys1
  • kyliepedersen
  • jinapark
  • cdignam-segment
  • segmentio
  • jrupasinghe
  • lateefat
  • rajulvadera
  • yash-twilio
  • sowjanyasegment
  • ebru.odok
  • ryanligon
  • lpediredla
  • brookstaylorjr
  • nithan-twilio
  • dean-huynh
  • wdbetts
  • n2parko
  • jayakrishnannair
  • rhall-twilio
  • karimkeshwani
  • tyson_segment
  • jgabe13
  • bgamwell
  • poojasegment
  • maryam.sharif
  • wally.tg
  • salolivares
  • erikdw
  • chenxiangzhang
  • justeen
  • mericsson
  • prayansh-segmentt
  • jeremylarkin
  • bsneed
  • danieljackins
  • segment-seth
  • sayan-das-in
  • james9446
  • priscilla.giatti
  • nlsun
  • drew-thompson
  • segment-jsingh
  • mcoulibali
  • andrius-segment
  • valerieernst
  • nithin-benny
  • ainatancinco
  • skondamuri
  • clintz.seg
  • replatero
  • slenin-twilio
  • csayuso
  • seanhan-segment
  • nevermore2022
  • gilomer
  • marcelopv
  • eric.rogner
  • kdharaiya
  • jon.anderson-at-segment.com
  • stacy.song
  • rexatsegment
  • nickaguilar
  • bradenbecker
  • reneewang
  • dan.lasky
  • sam.tapia
  • lnamba
  • vikramkumar19
  • mpriyad25
  • jeremy.parker
  • smidges
  • nageshgolem
  • sudojatin
  • pmaid
  • sethsegment
  • jair.aviles
  • manali-bhosale
  • elmoselyee
  • chtoombs
  • peterdemartini
  • vincen7tran
  • mayur-pitale
  • lfdelossantos
  • emmy.byrne
  • felttrip
  • sa-jsooter
  • lluque-twilio
  • kevinburkesegment
  • afsha-nazim-seg
  • song4you
  • david.anusontarangkul.segment
  • jyim008
  • michaelghseg
  • acharles14
  • aishikawaki
  • twjosiah
  • tanya.gupta.segment
  • sindhusegment
  • prabhnoor1997
  • chihchun-twilio
  • pmiller-twilio
  • vbatanov
  • simpixelated
  • mcullenmeyer
  • neeharikakondipati
  • eric-hyde
  • arunlalam-segment
  • mschaszberger
  • shuvrajit9904
  • abhinavsureka
  • varadarajan-tw
  • immanoj
  • blangtwilio
  • jsh-wu
  • jahood-twilio
  • sethnutetwilio
  • rrivera-segment
  • segment-admin
  • bgillan
  • tcgilbert
  • mckern_segment
  • maneesh.dharma29
  • joetessy
  • gkochar123
  • dominicbarnes
  • mugelstad
  • jalexy12
  • lerahulram
  • pmunin
  • whaider_twilio
  • ariel.silvestri
  • shraddha-twilio
  • michelr
  • brandon.scott-segment
  • jfehrman.segment
  • prayansh-twilio
  • dangmai-segment
  • aaronklish
  • brianhumphreystwilio
  • rmukundan
  • ashwitha.bg
  • ryanrouleau-segment
  • funlu
  • tdibacco
  • fauzy.yy
  • nlubchenco
  • arubiochavez
  • phillip.thomas
  • jkusa_segment
  • rollcode
  • meg1000
  • nainy.agrawal
  • seg-rustybailey
  • jbandi-twilio
  • saisagarkappaganthula
  • forgetfulfellow
  • dbaik-twilio-segment
  • pooja.patil
  • joe.ayoub.segment
  • hmohanram_seg
  • brian.aguirre
  • enyi.asonye
  • farhan0581
  • tbrennanj
  • parag.panda
  • cherylj-segment
  • harsh.vardhan
  • sshaikh_segment
  • xinghao.huang
  • shupadhyay
  • john.lee1100
  • kx-segment
  • segment_fan
  • dazu70
  • sai-patanjali
  • emilyjia
  • y.yu
  • ea_segment
  • yli119
  • pooyaj
  • sungju.jin
  • conniechen
  • bharath.boregowda
  • igracheva-twilio
  • benattwilio
  • marinhero
  • ankit.gupta.unthinkable
  • dobrin.ganev
  • alfrimpong
  • brandonheyer-segment
  • alecjacobs-segment
  • cjo2
  • yashnit-segment
  • dltnbrks-segment
  • achandrashekaran
  • himanshuph
  • pragupta
  • tw-dgarcia
  • alayvora
  • aparna.singhal
  • ynguyen
  • timmyzsearcy
  • lweimersegment
  • anton-vylushchak
  • azhaotwilio
  • rokatyal
  • kjoerres
  • msaraf
  • vikakumar
  • aditi.raveesh
  • chenchensegmentcom
  • sanket.mishra
  • odoren_segment
  • jxin_twilio
  • rcheedhalla
  • jbasiglio-segment
  • viveksainaneesegment
  • priyanshis
  • preetyp
  • akash.gautam07
  • nanotimm
  • yshkpr
  • srivig21
  • ssuneja
  • bala.singareddy
  • moyara2
  • arjunbhandage
  • akodankiry
  • rodhilton_twilio
  • cdelaomartinez
  • gbatra
  • spencerattick
  • segmentsean
  • sundareswar.jayakumar
  • vaibhavnanda
  • bannapple
  • srishti-nema
  • ar7dev
  • gsolis_segment
  • itsarijitray
  • bhavanki-segment
  • nikumarsegment
  • nanette.ranes
  • amigandhi
  • guthriesegment
  • miguelpdiaz8
  • mansari
  • sandhya16
  • hema-bahirwani-segment
  • bnakkina
  • praveenugiri
  • ighorela
  • nemery-segment
  • wlumsegment
  • nat-grid
  • needcaffeine
  • kbhargavaram-sg
  • irfan.ali.segment
  • harsh-joshi99
  • ed-twilion-npm
  • aubreysine
  • light-bringer-blr
  • sethgrid_segment
  • jibrang
  • seg-leonelsanches
  • smccoy-twilio
  • devthale
  • andwivedi
  • poojapatilseg
  • gaprabhu
  • apacker
  • monusegment
  • ehydesegment
  • psandquist
  • dcp-twilio
  • agerbas-segment
  • amitsinglaatseg
  • joy-twilio
  • sprajapati89