Skip to content

Conversation

@aram356
Copy link
Collaborator

@aram356 aram356 commented Feb 5, 2026

Summary

  • Adds GamIntegrationConfig with enabled, bidders, and force_render options
  • Implements IntegrationHeadInjector to inject GAM config script into <head>
  • Registers GAM integration in the integration builder system
  • Adds unit tests for config script generation

Configuration

[integrations.gam]
enabled = true
bidders = ["mocktioneer"]  # Only intercept these bidders, empty = all
force_render = false       # Force render even if GAM has a line item

Or via environment variables:

TRUSTED_SERVER__INTEGRATIONS__GAM__ENABLED=true
TRUSTED_SERVER__INTEGRATIONS__GAM__BIDDERS="mocktioneer,appnexus"

The injected script sets window.tsGamConfig which is picked up by the client-side GAM interceptor on initialization.

Test plan

  • Verify cargo check passes
  • Verify cargo test -p trusted-server-common passes
  • Enable GAM integration in config and verify <script>window.tsGamConfig=...</script> appears in HTML head
  • Verify config values (bidders, forceRender) are correctly serialized

Dependencies

Closes #248
Related to #179

- Add `Proxy.certificate_check` setting (defaults to true for secure production)
- Add `compute_host_header()` to properly format Host header with non-standard ports
- Extend `ensure_origin_backend()` with certificate_check parameter
- Include cert setting in backend name to avoid reusing backends with different settings
- Add comprehensive tests for port preservation in proxy signing and HTML rewriting
- Update all call sites to pass certificate_check=true (secure default)

This fixes an issue where backends behind reverse proxies would generate URLs
without the port when the Host header didn't include it.
- Add `IntegrationHeadInjector` trait allowing integrations to inject HTML into <head>
- Add `with_head_injector()` builder method to IntegrationRegistrationBuilder
- Add `head_inserts()` method to IntegrationRegistry to collect all injector snippets
- Update html_processor to inject integration head inserts after TSJS bundle

This enables integrations like GAM to inject configuration scripts into the
document head without modifying the main TSJS bundle.
- Add `GamIntegrationConfig` with enabled, bidders, and force_render options
- Implement `IntegrationHeadInjector` to inject GAM config script into <head>
- Register GAM integration in the integration builder system
- Add unit tests for config script generation

Configuration example:
```toml
[integrations.gam]
enabled = true
bidders = ["mocktioneer"]  # Only intercept these bidders, empty = all
force_render = false       # Force render even if GAM has a line item
```

The injected script sets `window.tsGamConfig` which is picked up by the
client-side GAM interceptor on initialization.
@aram356 aram356 self-assigned this Feb 5, 2026
@aram356 aram356 marked this pull request as draft February 5, 2026 18:05
@aram356 aram356 added enhancement New feature or request and removed enhancement New feature or request labels Feb 5, 2026
Base automatically changed from feature/integration-head-injector to main February 10, 2026 03:34
@aram356 aram356 linked an issue Feb 10, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GAM interceptor integration - backend

1 participant