Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/2.1.0 #208

Merged
merged 8 commits into from
Feb 26, 2024
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
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -52,7 +52,7 @@ jobs:
TURBO_CACHE_DIR: .turbo/android
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down Expand Up @@ -106,7 +106,12 @@ jobs:
TURBO_CACHE_DIR: .turbo/ios
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.15.2

- name: Setup
uses: ./.github/actions/setup
Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
name: Deploy

on:
workflow_run:
workflows: [Build]
types: [completed]
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'

jobs:

version_check:
if: ${{ github.event.workflow_run.conclusion == 'success' }} && startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
outputs:
v_tracker: ${{ steps.version.outputs.RN_TRACKER_VERSION}}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup
uses: ./.github/actions/setup
uses: actions/checkout@v4

- name: Get tag and tracker versions
id: version
Expand Down Expand Up @@ -58,11 +54,14 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Run unit tests
run: yarn test

- name: Build dist files
run: |
yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/e2e-ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: setup-cocoapods
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: 1.15.2

- name: Setup
uses: ./.github/actions/setup

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 2.1.0 (2024-02-21)
--------------------------
Upgrade to mobile trackers version 6 and add screen engagement tracking (close #90)
Fix SelfDescribing extension type (close #204)
Update JavaScript tracker core version to 3.21.0
Fix running deploy action only on new tags
Update cocoapods version
Lock yarn version to 1.22.19
Update copyright headers

Version 2.0.0 (2023-09-29)
--------------------------
Upgrade project structure and update native trackers to version 5 (#199)
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ If your pull request is fairly chunky, there might be a non-trivial delay betwee
### Contributor license agreement

We require outside contributors to sign a Contributor license agreement (or CLA) before we can merge their pull requests.
You can find more information on the topic in [the dedicated wiki page](https://github.com/snowplow/snowplow/wiki/CLA).
You can find more information on the topic in [the dedicated wiki page](https://docs.snowplow.io/docs/contributing/contributor-license-agreement/).
The @snowplowcla bot will guide you through the process.

## Getting in touch
Expand All @@ -77,4 +77,4 @@ The @snowplowcla bot will guide you through the process.

Please do not log an issue if you are asking for support, all of our community support requests go through our Discourse forum: https://discourse.snowplowanalytics.com/.

Posting your problem there ensures more people will see it and you should get support faster than creating a new issue on GitHub. Please do create a new issue on GitHub if you think you've found a bug though!
Posting your problem there ensures more people will see it and you should get support faster than creating a new issue on GitHub. Please do create a new issue on GitHub if you think you've found a bug though!
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (c) 2020-2023 Snowplow Analytics Ltd, 2019 DataCamp.
Copyright (c) 2020-present Snowplow Analytics Ltd, 2019 DataCamp.
All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Feedback and contributions are welcome - if you have identified a bug, please lo

## Copyright and license

The Snowplow React Native Tracker is copyright 2020-2023 Snowplow Analytics Ltd, 2019 DataCamp.
The Snowplow React Native Tracker is copyright 2020-present Snowplow Analytics Ltd, 2019 DataCamp.

Licensed under the **[Apache License, Version 2.0][license]** (the "License");
you may not use this software except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.snowplowanalytics:snowplow-android-tracker:5.4.4"
implementation "com.snowplowanalytics:snowplow-android-tracker:6.0.+"
implementation "com.squareup.okhttp3:okhttp:4.10.0"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val sdj: SelfDescribingJson = EventUtil.createSelfDescribingJson(argmap)
val event = SelfDescribing(sdj)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -197,7 +197,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: Structured = EventUtil.createStructuredEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -217,7 +217,47 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: ScreenView = EventUtil.createScreenViewEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
promise.reject("ERROR", t.message)
}
}

@ReactMethod
fun trackScrollChangedEvent(
details: ReadableMap,
promise: Promise
) {
try {
val namespace = details.getString("tracker")
val argmap = details.getMap("eventData")!!
val contexts = details.getArray("contexts")!!
val trackerController = getTracker(namespace)
val event: ScrollChanged = EventUtil.createScrollChangedEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
promise.reject("ERROR", t.message)
}
}

@ReactMethod
fun trackListItemViewEvent(
details: ReadableMap,
promise: Promise
) {
try {
val namespace = details.getString("tracker")
val argmap = details.getMap("eventData")!!
val contexts = details.getArray("contexts")!!
val trackerController = getTracker(namespace)
val event: ListItemView = EventUtil.createListItemViewEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -237,7 +277,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: PageView = EventUtil.createPageViewEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -257,7 +297,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: Timing = EventUtil.createTimingEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -277,7 +317,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: ConsentGranted = EventUtil.createConsentGrantedEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -297,7 +337,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: ConsentWithdrawn = EventUtil.createConsentWithdrawnEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -317,7 +357,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: EcommerceTransaction = EventUtil.createEcommerceTransactionEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -337,7 +377,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: DeepLinkReceived = EventUtil.createDeepLinkReceivedEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand All @@ -357,7 +397,7 @@ class ReactNativeTrackerModule(val reactContext: ReactApplicationContext) :
val trackerController = getTracker(namespace)
val event: MessageNotification = EventUtil.createMessageNotificationEvent(argmap)
val evCtxts: List<SelfDescribingJson> = EventUtil.createContexts(contexts)
event.customContexts.addAll(evCtxts)
event.entities.addAll(evCtxts)
trackerController.track(event)
promise.resolve(true)
} catch (t: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ object ConfigUtil {
if (trackerConfig.hasKey("screenViewAutotracking")) {
trackerConfiguration.screenViewAutotracking(trackerConfig.getBoolean("screenViewAutotracking"))
}
if (trackerConfig.hasKey("screenEngagementAutotracking")) {
trackerConfiguration.screenEngagementAutotracking(trackerConfig.getBoolean("screenEngagementAutotracking"))
}
if (trackerConfig.hasKey("lifecycleAutotracking")) {
trackerConfiguration.lifecycleAutotracking(trackerConfig.getBoolean("lifecycleAutotracking"))
}
Expand Down Expand Up @@ -252,8 +255,8 @@ object ConfigUtil {
private fun mkBufferOption(bufferOpt: String): BufferOption? {
return when (bufferOpt) {
"single" -> BufferOption.Single
"default" -> BufferOption.DefaultGroup
"large" -> BufferOption.HeavyGroup
"small" -> BufferOption.SmallGroup
"large" -> BufferOption.LargeGroup
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,26 @@ object EventUtil {
return event
}

fun createScrollChangedEvent(argmap: ReadableMap): ScrollChanged {
val event = ScrollChanged(
yOffset = if (argmap.hasKey("yOffset")) { argmap.getDouble("yOffset").toInt() } else { null },
xOffset = if (argmap.hasKey("xOffset")) { argmap.getDouble("xOffset").toInt() } else { null },
viewHeight = if (argmap.hasKey("viewHeight")) { argmap.getDouble("viewHeight").toInt() } else { null },
viewWidth = if (argmap.hasKey("viewWidth")) { argmap.getDouble("viewWidth").toInt() } else { null },
contentHeight = if (argmap.hasKey("contentHeight")) { argmap.getDouble("contentHeight").toInt() } else { null },
contentWidth = if (argmap.hasKey("contentWidth")) { argmap.getDouble("contentWidth").toInt() } else { null },
)
return event
}

fun createListItemViewEvent(argmap: ReadableMap): ListItemView {
val event = ListItemView(
index = argmap.getDouble("index").toInt(),
itemsCount = if (argmap.hasKey("itemsCount")) { argmap.getDouble("itemsCount").toInt() } else { null },
)
return event
}

fun createPageViewEvent(argmap: ReadableMap): PageView {
val event = PageView(argmap.getString("pageUrl")!!)
argmap.getString("pageTitle")?.let { event.pageTitle(it) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.snowplow.reactnativetracker.util

object TrackerVersion {
const val RN_TRACKER_VERSION = "rn-2.0.0"
const val RN_TRACKER_VERSION = "rn-2.1.0"
}
2 changes: 1 addition & 1 deletion example/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.12'
gem 'cocoapods', '1.15.2'
13 changes: 0 additions & 13 deletions example/e2e/emitEvents.e2e.detox.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
/*
* Copyright (c) 2020-2023 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/

const commands = require('./helpers/microCommands.js');

describe('Example', () => {
Expand Down
Loading
Loading