Windows SDK Integration Guide: .NET

  • Updated

 

 

Overview 

General 

Step 1: Updating your Terms of Service 

Step 2: Integrate Bright SDK in your application 

Prerequisites

Step 2.1: Add SDK files to your solution

Build-time dependencies

Run-time dependencies

Step 2.2: Add SDK initialization to your code

Step 2.3: Add opt-in/out settings option

Step 2.4: Update your application installer

Install

Uninstall

Update

Step 2.5: Add SDK service status notifications and recovery (optional)

Step 2.6: Customizing the consent screen

Step 3: Submit your integration 

Testing 

How to update SDK in your project 

Code Example 

API documentation 

brd_config.json:

.NET

 

Overview

You can integrate Bright SDK in 2 ways:

 

  1. Using a full SDK implemented into your app.
  2. Using Bright’s “Wrapper installer” which installs a standalone Bright SDK application. This is easier but usually gives lower conversion rates and revenue.

 

This guide is about the full implementation (#1). For #2, contact us for details.

General

This guide is for developers who want to monetize Windows applications with Bright SDK.

Integrating the Bright SDK into an application is the first step toward earning revenue. Once you've integrated the SDK, you will start seeing revenue in Bright SDK Dashboard in 24 hours.

This document will walk you through the steps needed to be taken in order to properly integrate Bright SDK into your application.

 

Step 1: Updating your Terms of Service

Bright Data works tirelessly to make sure users are fully aware of what it means to become a peer in Bright Data’s network. Please follow the terms of service additions that need to be done below.

 

  • Add the following text to your Terms of Service Web page (such as: TOS, EULA, or Privacy Policy):

In return for some of the premium features of ‘[name of Partner Solution]’, you may choose to be a peer on the Bright Data network. By doing so you agree to have read and

accepted the Terms of Service of the Bright SDK EULA: https://bright-sdk.com/eula and Bright Data’s Privacy Policy https://bright-sdk.com/privacy-policy.

You may opt out of the Bright Data network by clicking [add clear description for how to opt-out].



 

  • Add the following text to your Frequently Asked Questions Web page:

You will get <value: ads free version/free feature> in exchange for safely using some of your device’s resources, and only in a manner that will not substantially affect the device's operation (you can see exactly how on https://bright-sdk.com/users#learn-more-about-bright-sdk-web-indexing). You may turn this off from the settings menu. Please see our TOS [Link to TOS] and the SDK Privacy Policy at https://bright-sdk.com/privacy-policy for further information.



Please note: the text above must be added in full to your ToS, including the links. In case you wish to add any addition text that is related to Bright SDK, please share with us as part of the app review process.


 

Step 2: Integrate Bright SDK in your application

Prerequisites

Make sure you have the assigned APPID for this specific app from your SDK manager. It uniquely identifies your application and associates the peers, provided by your application, with you in the Bright Data network.

Step 2.1: Add SDK files to your solution

Download the latest Bright SDK from Bright SDK Dashboard or by clicking the link provided in the latest release email.

 

Once you unzip the SDK, the following contents are of interest:

 

File Description
net_updater32.exe Bright Data windows service installer, uninstaller and entry point
lum_sdk.dll .NET API, targeting .NET Framework 4.5 (AnyCPU)
brd_config.json consent configuration and customization
lum_sdk.xml .NET API documentation for Visual Studio

 

IMPORTANT:   lum_sdk.dll, net_updater32.exe and brd_config.json files have to be located next to each other when running the application.

Build-time dependencies

  1. Copy the following files to any location inside your repository
  • lum_sdk.dll
  • lum_sdk.xml
  1. Add them to your source control
  2. Add reference from your main project to lum_sdk.dll 
  • (Copy Local = true)

 

Note:  lum_sdk.xml is for Visual Studio to display documentation of the API and has to be located next to the referenced lum_sdk.dll. It is not needed at runtime.

Run-time dependencies

  1. Copy the following files to the root of your main project
    • net_updater32.exe
    • brd_config.json
  2. Add them to your source control
  3. Add them to your project as Content
    • Set them to be copied to the output folder

Step 2.2: Add SDK initialization to your code

  1. Instantiate BrightData.Api
  2. Initialize it during your application’s startup initialization
    • Set required fields now and you can customize the consent screen later.
Note:

Use brd_config.json and/or set them programmatically.

See API Documentation

  1. Write your handler code for the user choice changed event
    • for example, enable/disable ads or premium features
  2. Close the SDK when your application is exiting

 

Note:  Init will show consent screen to the user only if the user hasn’t seen the consent screen before (didn’t agree or disagree). You can disable consent on Init completely with Setting.SkipConsent=true and manually show it later with Api.ShowConsent()

 

See Code Example at the end of the guide and use cs_winform_anycpu and cs_wpf_anycpu from samples directory for reference.

Step 2.3: Add opt-in/out settings option

 

⚠️ Read and implement this section carefully. The user must always be able to opt-out of Bright SDK after giving their initial consent. 

 

Your app will usually first show the consent screen to the user on first run (or after a short “trial” period), the user will make a choice and SDK will act according to that choice.

 

Regardless of the user’s choice you must add an option for the user to opt-in/out of using SDK at any time. The user must always be able to opt-out of Bright SDK after giving their initial consent. 

 

This means that you must add an opt-out option in your app - this is usually placed in the settings menu



 

  1. Add a switch with the label “Web Indexing”. The switch should clearly reflect the current status (is the user opted-in or not?).
  2. Below “Web Indexing” add your own text to emphasize the value users get when opting in.
  3. Include a way to give more information to the user (“Learn more”). The hyperlink should open a browser window with the following URL: https://bright-sdk.com/users#learn-more-about-bright-sdk-web-indexing.
  4. In general, you are free to choose the UX (radio button, switch, etc) but the opt-out option must be clearly labeled so users can freely opt-out.
  5. FYI: You are free to add a pop up / confirmation dialog box to discourage the user from opting out (for example: “if you disable Web Indexing, you will start seeing ads. Do you want to see ads?”). You are responsible for the text and design for this implementation and it will be reviewed before publishing.

 

See the examples below, illustrating both opted-in and opted-out scenarios:

6 off.png 6 on.png
4 off.png 4 on.png

 

Some ideas for value text:

 

When opted-out When opted-in
Enable to see fewer ads When enabled you see fewer ads
Enable to get 100 extra coins When enabled you get 100 extra coins
Enable to enjoy premium features When enabled you enjoy premium features
Enable to get 2 free cars When enabled you get 2 free cars
Enable to unlock more levels When enabled you unlock more levels

 

  • Refrain from using the technical term “opt in” / “opt out”. We always prefer speaking value to users.

 

Add a checkbox/toggle button to your app menu/settings window, following these guidelines:

  • Should be checked if BrightData.Api.ConsentChoice  is true
  • Unchecking it should call BrightData.Api.OptOut()
  • Checking it should call BrightData.Api.ShowConsent()

 

See Code Example at the end of the guide.

 

FYI: You are free to add a pop up / confirmation dialog box to discourage the user from opting out (for example: “if you disable Web Indexing, you will start seeing ads. Do you want to see ads?”), as well as a confirmation message that shows after opting out (for example: “You have successfully disabled Web Indexing. !you may enable it again anytime from settings menu”)

 

You are responsible for the text and design for this implementation and it will be reviewed before publishing. Please refrain from using the technical term “opt in” / “opt out” here as well. 

 

⚠️ Important! Bright Data will verify the UX and functionality of the opt-out functionality. Please make sure it is implemented prior to submitting the app for review.

 

Examples for common mistakes with opt-out settings screens:

 

Web Indexing Switch

Example Comments



 
  • The label should be Web Indexing, and not Bright/Bright SDK.
  • Missing text to emphasize the value users get when opting in.
  • The switch should clearly reflect the current status (is the user opted-in or not?).
  • Missing text to emphasize the value users get when opting in.

 

Opt-Out Messages (Optional but highly recommended)

 

Example Comments
  • Correct messaging, correct default choice
  • Dialog box to validate the user’s choice, reminding them how to opt back in.




 

Step 2.4: Update your application installer

Install

  1. Add the following text to your installation wizard under “License agreement” part:

{App name} installs Bright Data components (no execution).

You will be able to view the component details in full before you accept this offer, as well as being able to turn Bright Data on and off directly from the 'App Settings'. Read more about Bright Data's EULA here

 

  1. Add step to deploy lum_sdk.dll, net_updater32.exe and brd_config.json to your install directory
  2. Add step to execute Bright Data service installer during your app installation (recommended, optional)
Note: Your installer must be running with admin privileges in order for net_updater to be able to install
  • Process to start: net_updater32.exe --install-ui APPID.
    It will show the consent screen and if agreed, install the service
Note:  Run net_updater32.exe -h in a command prompt to see available --dlg- parameters, or simply set them in brd_config.json
  • Wait for the process to finish before proceeding

Uninstall

Add the following to your application’s uninstall script:

  1. Make sure no process uses lum_sdk.dll (terminate your application)
  2. Uninstall Bright Data service and remove all Bright SDK files by executing net_updater32.exe --uninstall APPID
  3. Wait for uninstall to finish before proceeding

Update

Add the following to your application’s update script:

  1. Stop your application (which is using lum_sdk.dll)
  2. Stop Bright Data service luminati_net_updater_APPID where APPID is your assigned APPID with `.` (dot) replaced with ‘_’ (underscore) (e.g.. win_abc.myapp.com -> luminati_net_updater_win_abc_myapp_com)
  3. Deploy new net_updater32.exe, lum_sdk.dll and brd_config.json
  4. You should
  • Either install new net_updater: net_updater32.exe --install-ui APPID
Notes: 

It will show consent to the user which they can accept or decline

Requires admin privileges to run the installer

Use brd_config.json so that you don't have to pass consent customization parameters

 

  • Or restart service if it exists
Notes: 

Does not require admin privileges

Does not show consent

Step 2.5: Add SDK service status notifications and recovery (optional)

Notifications

You can register your app for notifications about the status of the SDK service, this will allow you to know if the SDK is in a valid usable state, you can also prevent the user from receiving the benefit until they restore the SDK service status to working condition.

Add delegate for the BrightData.Api.ServiceStatusChanged event, the handler for the event is an EventHandler that receives the BrightData.Api.ServiceStatusChangedEventArgs as event data.

See ServiceStatus enum for more information on the different status.

Note: The callback function can be called from a different thread than the one used to register the callback

 

Recovery

If the ServiceStatus is in the NotInstalled, Installed or NotRunning status you can use the FixServiceStatus api to trigger automatic recovery, you can also have this api trigger on user action (e.g. "Click here to fix Bright Data SDK and regain benefit")

 

Step 2.6: Customizing the consent screen

Subject to Bright SDK approval, you can create and use your own consent screen with Bright SDK. Please follow the following guidelines.

 

  1. Your screen must include the mandatory text below (marked in red), as well as links to our terms and privacy policies.
  2. If you wish to translate your screen into other languages, please find the most common ones here. If there is a language you miss here, contact your partnership manager and ask for it. Make sure you only use these translations precisely, without additions or omissions.

This is what it looks like on the default Bright SDK screen: 

Win screen.jpg

Mandatory text: “To [Benefit to user], please allow Web Indexing by Bright Data to use your device's free resources and IP address to download public web data from the Internet. Bright Data values your trust and takes every measure possible to protect your privacy and personal data. Bright Data understands the security matters at stake in sharing your IP address and monitors all of its network traffic to ensure your safety. Bright Data will only use your IP address for approved business-related use cases and never for unauthorized cases. None of your personal information is accessed or collected except your IP address."

 

"Learn more about web indexing by Bright Data
Learn more about Bright Data’s Privacy Policy
Bright Data runs in the background even after closing the application.
Updates will be automatically downloaded by your device from time to time and will be subject to the EULA (End User Level Agreement)"

 

- The link to "Bright Data” leads to "https://brightdata.com/"

- The link to "learn more" leads to "https://bright-sdk.com/users#learn-more-about-bright-sdk-web-indexing"

- The link to "Privacy Policy” leads to "https://bright-sdk.com/privacy-policy"

- The link to "End User License Agreement" leads to "https://bright-sdk.com/eula"

- Clicking on "will only use" -> opens a popup with the following info:

"Your IP address WILL be used for cases such as:

Support academic research
Help brands track sites selling fake products
Collect public web data like product prices and reviews
Aggregate travel information like flights and hotel prices "

 

PC_benefit_light_popup_used (2).png

 - Clicking on "never" ->opens a popup with the following info:

"Your IP address will NEVER be misused:

Never to steal, encrypt, or delete sensitive data
Never to alter or hijack core computing functions
Never to monitor users' computer activity
Never to access illegal sites (dark web, porn, etc.)
Never to perform DDOS attacks "

PC_benefit_light_popup_never (1).png

 

Integration code

- You should pass `SkipConsent = true` in SDK's initialization method to prevent showing the default consent screen.

- The opt-in button (e.g. "I Agree”) should call `ExternalOptIn()` method.

- The opt-out button (e.g. "I Disagree”) should call `OptOut()` method.

 

In case you show your custom consent dialog you also should call the `NotifyShowConsent()` method.

See below some examples of a possible custom consent screens:

1920x1080_PC_Vers_1.png1920x1080_PC_Vers_2.png

Please contact Bright SDK before implementing in order to get pre-approved.

Step 3: Submit your integration

  • Important: Bright SDK compliance team will verify the UX and functionality of the SDK integration, including consent screen, opt-out, value added to user, etc. Please do some internal QA prior to submitting the app for review.
  • When you are ready to submit the app, the first step is running a self-check, which takes a few minutes and can save you precious time by identifying implementation issues. Details here.
  • Submit the app for review by uploading the package (zip/exe format) through the Bright SDK Dashboard :click the relevant appID and “Submit for Review” button.
  • As part of the submission process you will go through our checklist questions, to help you validate your app compliance to some of our main guidelines. Paying attention to this checklist, as well as to our quality standards will lead to faster approval.
  • We also welcome you to watch our guided tour video prior to submission. It highlights critical elements to pay attention to, ensuring a faster review process and transparent communication with your users.
  • Please note that we will review each app up to 3 times. 3 review rejections, or failure to meet our minimum quality standards may lead to a final rejection of your app.




 

 

Testing

You may set BrightData.Api.Settings.TestMode = true while developing. This way BrightData service will not be installed when you accept the consent screen, making it easier to develop.

 

While testing, you can remove Bright Data service by opting out through your application settings.Then removing the luminati folder (or simply deleting your entire output folder) will reset your previous consent choice and the consent screen will be displayed next time you run the application.

Or you can execute net_updater32.exe --uninstall APPID in your output folder, which will delete all SDK files as well.

How to update SDK in your project

Download the latest SDK from our website and follow these simple steps:

  • replace net_updater(32|64).exe, lum_sdk(32|64).dll and lum_sdk.dll with a newer version
  • clean and rebuild your project

Code Example

public partial class ExampleAppMainForm : Form

{

  private BrightData.Api _brightSdk = new BrightData.Api();

w

      BrightData.Api.ConsentChoiceChangedEventArgs e)

  {

    if (choice == true)

    {

      // user agreed to Bright Data consent

      // you can disable ads here, for example

    }

    else

    {

      // user disagreed to the consent or opted out

      // you can enable ads here, for example

    }

  }

  private void BrightSdk_ServiceStatusChanged(object sender,

      BrightData.Api.ServiceStatusChangedEventArgs e)

  {

    if (!_brightSdk.ConsentChoice)

      return;

    if (e.Status==BrightData.Api.ServiceStatus.NotInstalled)

    {

      // optional: notify user about SDK service not installed and offer to recover

      // optional: automatically try and recover (might cause bad UX)

      if (userWantsToRecover || autoRecoverIsEnabled)

        _brightSdk.FixServiceStatus();

    }

    else if (e.Status==BrightData.Api.ServiceStatus.Installed ||

      e.Status==BrightData.Api.ServiceStatus.NotRunning)

    {

      // optional: notify user about SDK service not running and offer to recover

      // optional: automatically try and recover (might cause bad UX)

      if (userWantsToRecover || autoRecoverIsEnabled)

        _brightSdk.FixServiceStatus();

    }

  }

  protected override void OnFormClosing(FormClosingEventArgs e) {

      _brightSdk.Close();

      base.OnFormClosing(e);

  }

  private void SettingsToolStripMenuItem_Click(object sender, EventArgs e)

  {

    new SettingsForm(_brightSdk).ShowDialog();

  }

}

 

public partial class SettingsForm : Form

{

  private readonly BrightData.Api _brightSdk;

 

  public SettingsForm(BrightData.Api brightSdk)

  {

    InitializeComponent();

    _brightSdk = brightSdk;

    _brightSdk.ConsentChoiceChanged += BrightSdk_ConsentChoiceChanged;

   

    _chkBrightData.AutoCheck = false;

    _chkBrightData.Checked = _brightSdk.ConsentChoice ?? false;

    _chkBrightData.Click += ChkBrightData_Click;

  }

 

  protected override void OnClosing(CancelEventArgs e)

  {

    // make sure to avoid event handler leak

    _brightSdk.ConsentChoiceChanged -= BrightSdk_ConsentChoiceChanged;

    base.OnClosing(e);

  }

 

  private void ChkBrightData_Click(object sender, EventArgs e)

  {

    if (_brightSdk.ConsentChoice == true)

      _brightSdk.OptOut();

    else

      _brightSdk.ShowConsent();

  }

 

  private void BrightSdk_ConsentChoiceChanged(object sender,

    BrightData.Api.ConsentChoiceChangedEventArgs e)

  {

    _chkBrightData.Checked = e.Choice ?? false;

  }

}

 

API documentation

 

Note: 

What you set in brd_config.json is shared by both lum_sdk.dll and net_updater32.exe

You can use the config file in tandem with the programmatic API, the latter takes precedence. 

 

brd_config.json:

  • app_id - (required) your APPID
  • app_name - (required) friendly name of your app that will appear on the consent screen.
  • logo_link - (required) URL to your app's logo that will appear on the consent screen.
  • benefit - (optional) description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen.
  • agree_btn - (optional) text of the consent screen's agree button.
  • disagree_btn - (optional) text of the consent screen's disagree button.
  • opt_out_txt - (optional) text of the consent screen's opt-out instructions.

.NET

  • void BrightData.Api.Init(Settings settings) - initializes Bright SDK. Should be called during app initialization. All other methods will be accessible afterwards. By default, consent screen will be shown if the user hasn’t made a choice yet, but can be skipped with Settings.SkipConsent = true
  • void BrightData.Api.ShowConsent() - displays consent screen. (Clears user choice and removes Brightdata service if installed.) Can be used when a user tries to close an ad or clicks the checkbox to activate Bright SDK.
  • void BrightData.Api.OptOut() - disables Bright SDK and removes Brightdata service. ConsentChoice will change to false.
  • void BrightData.Api.Close() - closes Bright SDK. Should be called when the application exits if the SDK cannot automatically detect the application exit and keeps running, keeping the app process running.
  • bool? BrightData.Api.ConsentChoice { get; } - returns the user's consent choice. true if the user agreed, false if disagreed and null if no choice has been made.
  • event BrightData.Api.ConsentChoiceChanged - Occurs when the user's consent choice has changed. For example when they accepted the consent or they disabled Bright SDK through your application settings.
  • event BrightData.Api.ConsentDialogShown - Occurs when the consent dialog is shown.
  • event BrightData.Api.ConsentDialogClosed - Occurs when the consent dialog is closed
  • string BrightData.Api.GetUuid() - returns the peer's unique identifier. Useful for debugging.


 

  • class BrightData.Api.Settings:
    • string AppId - your APPID. Required if not provided in brd_config.json file.
    • string AppName - friendly name of your app that will appear on the consent screen. Required if not provided in brd_config.json file.
    • string AppLogo - URL to your app's logo that will appear on the consent screen. Required if not provided in brd_config.json file.
    • bool SkipConsent - if true, Init method will not show consent screen. The consent screen can be shown later with the ShowConsent method. Default false.
    • string Benefit - description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen.
    • string TextColor - color of the consent text. Format: hex argb, "#AABBCCDD". Optional.
    • string AppNameColor - color of the application name text. Format: hex argb, "#AABBCCDD". Optional.
    • string BrightDataLogoColor - color of the BrightData logo background. Format: hex argb, "#AABBCCDD". Optional.
    • string BackgroundColor - background color of the consent screen. Format: hex argb, "#AABBCCDD". Optional.
    • string ButtonColor - button color of the consent screen. Format: hex argb, "#AABBCCDD". Optional.
    • string AgreeBtn - text of the consent screen's agree button
    • string DisagreeBtn - text of the consent screen's disagree button
    • string Language - Language code for consent screen language. Default value: “en-US”. Supported: en-US, de-De, es-Es, fr-FR, it-IT, pt-PT, ru-RU, zh-CN
    • string Campaign - optional parameter for the further breakdown of the existing app ID to monitor the statistics separately
    • string OptOutText - text of the consent opt-out instructions

net_updater(32|64).exe command line arguments

  • -h - print command descriptions
  • --install-ui appid - install service with provided appid after showing dialog and getting user permission
  • --check-peer appid - validate peer
  • --uninstall appid - remove service with provided appid (must match appid used during install)
  • --start-service appid - starts Bright Data service
  • --stop-service appid - stops Bright Data service
  • --dlg-language culture - language code for consent screen language. Default value: “en-US”. Supported: en-US, de-De, es-Es, fr-FR, it-IT, pt-PT, ru-RU, zh-CN
  • --dlg-app-name name - friendly name of your app that will appear on the consent screen
  • --dlg-logo-link logo - URL to your app's logo that will appear on the consent screen
  • --dlg-benefit benefit - description of the benefits a user gets if he/she consents to enable Bright SDK. Consent screen will have different wordings if set. The value will be the first part of the first sentence on the consent screen
  • --campaign campaign_id - optional parameter for the further breakdown of the existing app ID to monitor the statistics separately