react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Duplicate entries is stored in database

Open Nishad013 opened this issue 1 year ago • 2 comments

Your Environment

npx react-native info info Fetching system and libraries information... System: OS: macOS 14.3.1 CPU: (8) arm64 Apple M2 Memory: 1.11 GB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node Yarn: 1.22.21 - ~/Documents/GitHub/alt-tomrex-app/node_modules/.bin/yarn npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm Watchman: 2024.01.22.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.15.0 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 23.2, iOS 17.2, macOS 14.2, tvOS 17.2, visionOS 1.0, watchOS 10.2 Android SDK: Not Found IDEs: Android Studio: 2023.1 AI-231.9392.1.2311.11330709 Xcode: 15.2/15C500b - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ^0.64.0 => 0.64.4 react-native-macos: Not Found

  • Plugin version: "^4.12.1"

  • Platform: iOS or Android : both devices (android and ios)

  • OS version: (android version 12)

  • Device manufacturer / model: realme 7 pro

  • React Native version (react-native -v): "^0.64.0"

  • Plugin config:

 const state = await BackgroundGeolocation.ready({
        url: API_URL + API_ENDPOINTS.SAVELOCATION,
        logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
        desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
        distanceFilter: 10,
        stopTimeout: 5,
        locationTemplate:
          '{"Latitude":<%= latitude %>,"Longitude":<%= longitude %>,"TimeStamp": "<%= timestamp %>","uuid":"<%= uuid %>","Age":"<%= age %>"}',
        locationAuthorizationRequest: 'Always',
        backgroundPermissionRationale: {
          title:
            "Allow {applicationName} to access this device's location even when closed or not in use.",
          message:
            'This app collects location data to enable recording your trips to work and calculate distance-travelled.',
          positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
          negativeAction: 'Cancel',
        },
        headers: {
          authorization: 'Bearer ' + getToken.data.Token,
          source: source,
        },
        params: {
          ClientId: respo_storage.data.ClientId,
        },
        batchSync: true ,
        autoSync: true,
        maxDaysToPersist: 14,
        stopOnTerminate: false,
        startOnBoot: true,
        enableHeadless: true,

      });

BackgroundGeolocation.onMotionChange(async (location) => {
        console.log('onMotionChange', location);

        const { type } = location.location.activity || {}
        BackgroundGeolocation.setConfig({
          distanceFilter: type === 'in_vehicle' ? 120 : 10,
        });

        this.setState({
          isMoving: location.isMoving,
        });
      }),

Expected Behavior

No entry should be entered twice in the database.

Actual Behavior

When I kill my application and travel the distance till 5-10 km, then in my database it's showing several entries in which the same lat long or timestamp is also the same. or it is only tracked sometimes. and also i'm not able to replicated it manually . I am still sending my UUID but the UUID of the same entries is different and the age is also different. what can i do to avoid entering the same data in my database .

Steps to Reproduce

unable to replicate manually

Context

i'm creating the app which track the location of device

Debug logs

[TOMREX Issues.xlsx](https://github.com/transistorsoft/react-native-background-geolocation/files/14309181/TOMREX.Issues. Screenshot 2024-01-19 at 3 45 01 PM xlsx) image_2024_02_12T05_00_03_566Z

actually im testing in release mode so i'm unable to get the logs, i tried the emailLog but it's not responding

im sharing the bd table in which you can filter for client id 11049 and date filter for 16 jan as you can see for client id 11049 on 16 jan it show multiple entries .

please give me any suggestion what can i do to avoid it. in the sheet no uuid is present because it's old but in new release we have sended the uuid in test release

Nishad013 avatar Feb 16 '24 09:02 Nishad013

I hope this message finds you well. I am reaching out regarding some critical issues we have encountered with the implementation of your library in our production environment. Our team has identified two main issues that require urgent attention:

  1. Duplicate Entries in Database:

We are experiencing a recurring problem where duplicate entries are being recorded in our database. Upon investigation, we found that while the UUID for each entry is unique, the latitude, longitude, and timestamp fields are consistently the same for these duplicate entries. This inconsistency is causing significant data integrity issues and requires immediate resolution.

  1. Data Recovery Anomaly:

On January 30th, we performed a truncation of all records in our database. However, to our surprise, all entries prior to January 19th were inexplicably restored. This unexpected behavior is concerning, as it undermines our data management processes.

To assist you in diagnosing and addressing these issues promptly, I have attached the relevant code snippets and records for your review.

Given the critical nature of these issues and their impact on our operations, I kindly request your prompt attention and assistance in resolving them. If additional information or clarification is needed from our end, please do not hesitate to reach out.

Thank you for your immediate attention to this matter

Nishad013 avatar Feb 16 '24 09:02 Nishad013

Plugin version: "^4.12.1"

The latest version is 4.14.6

I am still sending my UUID but the UUID of the same entries is different and the age is also different

If the uuid and age are different, then the locations are not technically "duplicate".

Recent versions of Android simply refuse to allow location-services to be turned on when the device is sitting stationary. In these situations, the "last known location" will be returned as last resort, and the location.age will be appended, showing how old that location was relative to the time is was received.

Data Recovery Anomaly: However, to our surprise, all entries prior to January 19th were inexplicably restored

How do you suspect the plugin has anything to do with that?

christocracy avatar Feb 16 '24 15:02 christocracy

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 17 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 01 '24 01:05 github-actions[bot]